Skip to content

Commit

Permalink
add test units
Browse files Browse the repository at this point in the history
  • Loading branch information
duguying committed Feb 14, 2015
1 parent f7ddcbe commit d129e1a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# goj judger api for java
# goj judger api for java

[![Build Status](https://travis-ci.org/gojudge/gojapi-java.svg)](https://travis-ci.org/gojudge/gojapi-java)

here is the goj judger api for java developer.

Expand Down
10 changes: 10 additions & 0 deletions src/test/java/net/duguying/goj/JudgerHTTPTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import junit.framework.TestCase;

import java.util.Map;

/**
* Created by rex on 2015/1/26.
*/
Expand All @@ -13,5 +15,13 @@ protected void setUp() {

public void testJudgerHTTP(){
this.h = new JudgerHTTP("oj.duguying.net", 1005, "123456789");

Map<String, Object> response = this.h.AddTask(12,"randomstring","C","int main(){return 0;}");
boolean rst = (Boolean)response.get("result");
assertTrue(rst);

Map<String, Object> response2 = this.h.GetStatus(12, "randomstring");
int rst2 = (Integer)response2.get("id");
assertEquals(12, rst2);
}
}
23 changes: 23 additions & 0 deletions src/test/java/net/duguying/goj/JudgerTCPTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import junit.framework.TestCase;
import java.io.IOException;
import java.util.Map;

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

Map<String, Object> response = null;
try {
response = this.j.AddTask(12,"randomstring","C","int main(){return 0;}");
} catch (IOException e) {
e.printStackTrace();
}
boolean rst = (Boolean)response.get("result");

// assert add task
assertTrue(rst);

Map<String, Object> response2 = null;
try {
response2 = this.j.GetStatus(12,"randomstring");
} catch (IOException e) {
e.printStackTrace();
}
int rst2 = (Integer)response2.get("id");

// assert get status
assertEquals(12, rst2);

this.j = null;
System.gc();
}
Expand Down

0 comments on commit d129e1a

Please sign in to comment.