Skip to content

Commit d129e1a

Browse files
committed
add test units
1 parent f7ddcbe commit d129e1a

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# goj judger api for java
1+
# goj judger api for java
2+
3+
[![Build Status](https://travis-ci.org/gojudge/gojapi-java.svg)](https://travis-ci.org/gojudge/gojapi-java)
24

35
here is the goj judger api for java developer.
46

src/test/java/net/duguying/goj/JudgerHTTPTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import junit.framework.TestCase;
44

5+
import java.util.Map;
6+
57
/**
68
* Created by rex on 2015/1/26.
79
*/
@@ -13,5 +15,13 @@ protected void setUp() {
1315

1416
public void testJudgerHTTP(){
1517
this.h = new JudgerHTTP("oj.duguying.net", 1005, "123456789");
18+
19+
Map<String, Object> response = this.h.AddTask(12,"randomstring","C","int main(){return 0;}");
20+
boolean rst = (Boolean)response.get("result");
21+
assertTrue(rst);
22+
23+
Map<String, Object> response2 = this.h.GetStatus(12, "randomstring");
24+
int rst2 = (Integer)response2.get("id");
25+
assertEquals(12, rst2);
1626
}
1727
}

src/test/java/net/duguying/goj/JudgerTCPTest.java

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

33
import junit.framework.TestCase;
44
import java.io.IOException;
5+
import java.util.Map;
56

67
public class JudgerTCPTest extends TestCase {
78
private JudgerTCP j = null;
@@ -16,6 +17,28 @@ public void testJudgerTCP() {
1617
// assert connect success
1718
assertNotNull(this.j);
1819

20+
Map<String, Object> response = null;
21+
try {
22+
response = this.j.AddTask(12,"randomstring","C","int main(){return 0;}");
23+
} catch (IOException e) {
24+
e.printStackTrace();
25+
}
26+
boolean rst = (Boolean)response.get("result");
27+
28+
// assert add task
29+
assertTrue(rst);
30+
31+
Map<String, Object> response2 = null;
32+
try {
33+
response2 = this.j.GetStatus(12,"randomstring");
34+
} catch (IOException e) {
35+
e.printStackTrace();
36+
}
37+
int rst2 = (Integer)response2.get("id");
38+
39+
// assert get status
40+
assertEquals(12, rst2);
41+
1942
this.j = null;
2043
System.gc();
2144
}

0 commit comments

Comments
 (0)