1
1
package fi .helsinki .cs .tmc .functionaltests .utils ;
2
2
3
- import fi .helsinki .cs .tmc .model .ServerAccess ;
4
- import fi .helsinki .cs .tmc .testing .AdHocHttpServer ;
3
+ // import fi.helsinki.cs.tmc.model.ServerAccess;
4
+ // import fi.helsinki.cs.tmc.testing.AdHocHttpServer;
5
5
import java .io .UnsupportedEncodingException ;
6
6
import org .apache .http .entity .StringEntity ;
7
7
import java .io .IOException ;
22
22
import org .apache .http .protocol .HttpRequestHandler ;
23
23
import static org .junit .Assert .*;
24
24
25
- public class FakeTmcServer extends AdHocHttpServer {
25
+ public class FakeTmcServer /* extends AdHocHttpServer*/ {
26
26
27
- private int expectedApiVersion = ServerAccess .API_VERSION ;
27
+ // private int expectedApiVersion = ServerAccess.API_VERSION;
28
28
private String expectedUsername ;
29
29
private String expectedPassword ;
30
30
private String coursesJson = "{}" ;
@@ -33,7 +33,7 @@ public class FakeTmcServer extends AdHocHttpServer {
33
33
private HashMap <String , byte []> zipFiles = new HashMap <String , byte []>();
34
34
35
35
public FakeTmcServer () {
36
- setHandler (new Handler ());
36
+ // setHandler(new Handler());
37
37
}
38
38
39
39
public synchronized FakeTmcServer expectUser (String username , String password ) {
@@ -76,11 +76,11 @@ public void handle(HttpRequest req, HttpResponse resp, HttpContext hc) throws Ht
76
76
Map <String , String > params = parseQueryParameters (uri );
77
77
78
78
String path = uri .getPath ();
79
- debug ("Path: " + path );
79
+ // debug("Path: " + path);
80
80
81
81
if (path .startsWith ("/courses.json" )) {
82
82
authenticate (params );
83
- debug ("Responding with course list: " + coursesJson );
83
+ // debug("Responding with course list: " + coursesJson);
84
84
respondWithJson (resp , coursesJson );
85
85
} else if (courseRegex .matcher (path ).matches ()) {
86
86
Matcher m = courseRegex .matcher (path );
@@ -92,17 +92,17 @@ public void handle(HttpRequest req, HttpResponse resp, HttpContext hc) throws Ht
92
92
String response = courseDetails .get (id );
93
93
if (response != null ) {
94
94
authenticate (params );
95
- debug ("Responding with course details: " + response );
95
+ // debug("Responding with course details: " + response);
96
96
respondWithJson (resp , response );
97
97
} else {
98
- debug ("Unknown course path: " + path );
98
+ // debug("Unknown course path: " + path);
99
99
resp .setStatusCode (404 );
100
100
resp .setEntity (new StringEntity ("Not Found" ));
101
101
}
102
102
} else if (zipFiles .containsKey (path )) {
103
103
respondWithBinary (resp , zipFiles .get (path ), "application/zip" );
104
104
} else {
105
- debug ("Unknown path: " + path );
105
+ // debug("Unknown path: " + path);
106
106
resp .setStatusCode (404 );
107
107
resp .setEntity (new StringEntity ("Not Found" ));
108
108
}
@@ -119,7 +119,7 @@ private Map<String, String> parseQueryParameters(URI uri) {
119
119
}
120
120
121
121
private void authenticate (Map <String , String > params ) {
122
- assertEquals ("" + expectedApiVersion , params .get ("api_version" ));
122
+ // assertEquals("" + expectedApiVersion, params.get("api_version"));
123
123
if (expectedUsername != null ) {
124
124
assertEquals (expectedUsername , params .get ("api_username" ));
125
125
}
0 commit comments