Skip to content

Commit ba0b333

Browse files
hansonrhansonr
authored andcommitted
adds test for httpstat.us/201
Testing httpstat 201 httpstat.us reports 201 httpstat.us reports 201 Created
1 parent a626ffe commit ba0b333

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

sources/net.sf.j2s.java.core/src/test/Test_HTTP.java

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public class Test_HTTP extends Test_ {
2424
static {
2525
/** @j2sNative
2626
J2S.addDirectDatabaseCall("www.compbio.dundee.ac.uk/slivka");
27+
28+
J2S.addDirectDatabaseCall("httpstat.us");
29+
2730
*/
2831

2932
}
@@ -33,20 +36,36 @@ public static void main(String[] args) {
3336
HttpClient client = HttpClientFactory.getClient(null);
3437
HttpRequest req = null;
3538

39+
System.out.println("Testing httpstat 201");
40+
41+
try {
42+
URL url = new URL("http://httpstat.us/201");
43+
HttpURLConnection c = (HttpURLConnection) url.openConnection();
44+
int code = c.getResponseCode();
45+
System.out.println("httpstat.us reports " + code);
46+
InputStream oi = url.openStream();
47+
String s = new String(oi.readAllBytes());
48+
System.out.println("httpstat.us reports " + s);
49+
} catch (IOException e) {
50+
System.out.println(e);
51+
}
52+
53+
54+
System.out.println("Testing unknown host");
55+
56+
try {
57+
URL url = new URL("https://www.compbiolivka/api/services");
58+
HttpURLConnection c = (HttpURLConnection) url.openConnection();
59+
int code = c.getResponseCode();
60+
InputStream oi = url.openStream();
61+
} catch (IOException e) {
62+
assert(e instanceof UnknownHostException);
63+
}
64+
65+
3666
System.out.println("Testing sync GET");
3767

3868
try {
39-
40-
try {
41-
URL url = new URL("https://www.compbiolivka/api/services");
42-
HttpURLConnection c = (HttpURLConnection) url.openConnection();
43-
int code = c.getResponseCode();
44-
InputStream oi = url.openStream();
45-
} catch (IOException e) {
46-
assert(e instanceof UnknownHostException);
47-
}
48-
49-
5069
req = javajs.http.SimpleHttpClient.createRequest(client, "get",
5170
"https://www.compbio.dundee.ac.uk/slivka/api/services");
5271
System.out.println(req.getUri());

0 commit comments

Comments
 (0)