Skip to content

Commit cff5d59

Browse files
committed
Merge branch 'unitTesting' into develop
2 parents 09648ac + 4acbd26 commit cff5d59

File tree

9 files changed

+86
-15
lines changed

9 files changed

+86
-15
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ language: java
33
# blocklist
44
branches:
55
except:
6-
- develop
7-
- unitTesting
6+
- develop

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
JavaGame Alpha v1.8.2 [![Travis-CI Build Status](https://travis-ci.org/redomar/JavaGame.svg?branch=master)](https://travis-ci.org/redomar/JavaGame)
2-
=====================
3-
Acknowledgement: Inspired from [vanZeben](https://github.com/vanZeben)
1+
JavaGame [![GitHub release](https://img.shields.io/github/release/redomar/JavaGame.svg?style=flat-square&label=Alpha)](https://github.com/redomar/JavaGame/releases/latest) [![Travis-CI Build Status](https://img.shields.io/travis/redomar/JavaGame.svg?style=flat-square)](https://travis-ci.org/redomar/JavaGame) [![GitHub license](https://img.shields.io/badge/license-AGPLv3-red.svg?style=flat-square)](https://raw.githubusercontent.com/Redomar/JavaGame/master/LICENSE)
2+
==
43

54
#####What is JavaGame?
65
JavaGame is a game project that have been working on since May 2013. I have added many features to the game over the last year and I plan on adding even more features. This game is purely for my own sake to practice my skills in Java.
@@ -10,9 +9,9 @@ Well i'm still not sure what exactly i'm going to do with it, and I haven't thou
109

1110
#####Play the Game
1211
* For latest version get
13-
* [v1.8](https://github.com/redomar/JavaGame/releases/tag/v1.8)
12+
* [![GitHub release](https://img.shields.io/github/release/redomar/JavaGame.svg?style=flat-square&label=Alpha)](https://github.com/redomar/JavaGame/releases/latest)
1413
* For multiplayer enabled get
15-
* [v1.5.4](https://github.com/redomar/JavaGame/releases/tag/v1.5.4)
14+
* [![GitHub release](https://img.shields.io/badge/Alpha-v1.5.4-cc0000.svg)](https://github.com/redomar/JavaGame/releases/v1.5.4)
1615

1716
#####Your version naming is all wrong
1817
Yes, I recently noticed that there is a standard called Semantic Versioning that I should follow. Currently my project isn't organised as well as I hoped so starting from the Beta I will follow Semantic Versioning schema.
@@ -36,3 +35,5 @@ Watch this video [here](http://youtu.be/_3nCgac3KKM) or checkout the [GitHub Pag
3635
* Commit your changes (```git commit -m "Change Title"```)
3736
* Push to the branch (```git push origin my_branch```)
3837
* Open a [Pull Request](https://github.com/redomar/JavaGame/pull/new/master)
38+
39+
Inspired from [vanZeben](https://github.com/vanZeben).

build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ repositories{
44

55
apply plugin: 'java'
66

7-
sourceSets.main.java.srcDir 'src'
8-
sourceSets.main.resources.srcDirs 'res'
7+
sourceSets{
8+
main{
9+
java.srcDir 'src'
10+
resources.srcDir 'res'
11+
}
12+
test{
13+
java.srcDir 'test'
14+
}
15+
}
916

1017
dependencies{
1118
compile 'org.apache.commons:commons-lang3:3.4'

src/com/redomar/game/InputHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ private void toggleKey(int keyCode, boolean isPressed) {
124124

125125
private void quitGame() {
126126
Game.setClosing(true);
127+
print.removeLog();
127128
try {
128129
Thread.sleep(1000);
129130
} catch (InterruptedException e) {

src/com/redomar/game/entities/projectiles/Projectile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public Projectile(LevelHandler level, int x, int y, double dir) {
2020
super(level);
2121
xOrigin = x;
2222
yOrigin = y;
23-
angle = dir + (Math.random() * (dir + 0.2));
23+
angle = dir;
2424
this.x = x;
2525
this.y = y;
2626
}

src/com/redomar/game/script/PrintTypes.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ public enum PrintTypes {
55
LEVEL,
66
MUSIC,
77
ERROR,
8+
TEST,
89
NETWORK,
9-
SERVER;
10+
SERVER
1011
}

src/com/redomar/game/script/Printing.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.redomar.game.lib.Time;
44

5+
import java.io.File;
56
import java.util.Arrays;
67

78
public class Printing {
@@ -30,7 +31,7 @@ private void printOut(){
3031
msgTime = "[" + time.getTime() + "]";
3132
msgType = "[" + type.toString() + "]";
3233

33-
logFile = new PrintToLog(".log.txt");
34+
logFile = printToLogType(type);
3435
if (lineNumber == 0) {
3536

3637
String dashes = "";
@@ -56,6 +57,18 @@ private void printOut(){
5657
}
5758
}
5859

60+
private PrintToLog printToLogType(PrintTypes type){
61+
if (type == PrintTypes.TEST){
62+
return new PrintToLog(".PrintType-TEST.txt");
63+
} else {
64+
return new PrintToLog(".log.txt");
65+
}
66+
}
67+
68+
public void removeLog(){
69+
new File(".log.txt").delete()
70+
}
71+
5972
public String getMessage() {
6073
return message;
6174
}

test/com/redomar/game/script/PrintToLogTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.junit.Test;
44

5+
import static org.junit.Assert.assertFalse;
56
import static org.junit.Assert.assertTrue;
67

78
/**
@@ -11,7 +12,7 @@
1112
*/
1213
public class PrintToLogTest {
1314

14-
PrintToLog print;
15+
private PrintToLog print;
1516

1617
@Test(expected = NullPointerException.class)
1718
public void PrintToLogNullFile() {
@@ -20,9 +21,9 @@ public void PrintToLogNullFile() {
2021

2122
@Test
2223
public void PrintToLogDoesWork() {
23-
print = new PrintToLog(".Test.txt");
24+
print = new PrintToLog(".PrintToLogDoesWork.txt");
2425
assertTrue(print.getUrl().exists());
25-
print.getUrl().delete();
26+
assertTrue(print.getUrl().delete());
2627
}
2728

2829
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.redomar.game.script;
2+
3+
import org.junit.After;
4+
import org.junit.Before;
5+
import org.junit.Test;
6+
7+
import java.io.File;
8+
9+
import static org.junit.Assert.*;
10+
11+
/**
12+
* Created by Mohamed on 28/08/2016.
13+
* This file tests the com.redomar.game.script.Printing class
14+
*/
15+
public class PrintingTest {
16+
17+
private Printing printing;
18+
19+
@Before
20+
public void setUp() throws Exception {
21+
printing = new Printing();
22+
}
23+
24+
@Test
25+
public void printToFileWorks() throws Exception {
26+
printing.print("TESTING STRING", PrintTypes.TEST);
27+
File file = new File(".PrintType-TEST.txt");
28+
assertTrue(file.exists());
29+
assertTrue(file.delete());
30+
}
31+
32+
@Test
33+
public void getMessageIsNull() {
34+
assertNull(printing.getMessage());
35+
}
36+
37+
@Test
38+
public void getMessageIsNotNull() {
39+
printing.setMessage("Not Null");
40+
assertNotNull(printing.getMessage());
41+
}
42+
43+
@After
44+
public void cleanUp(){
45+
printing = null;
46+
}
47+
48+
}

0 commit comments

Comments
 (0)