use of tests.support.Support_TestWebServer in project robovm by robovm.
the class URLConnectionTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
server = new Support_TestWebServer();
port = server.initServer();
url = new URL("http://localhost:" + port + "/test1");
uc = url.openConnection();
url2 = new URL("http://localhost:" + port + "/test2");
uc2 = url2.openConnection();
fileURL = createTempHelloWorldFile();
fileURLCon = fileURL.openConnection();
jarURLCon = openJarURLConnection();
gifURLCon = openGifURLConnection();
}
use of tests.support.Support_TestWebServer in project robovm by robovm.
the class OldURLClassLoaderTest method test_findResourceLjava_lang_String.
@SideEffect("Support_TestWebServer requires isolation.")
public void test_findResourceLjava_lang_String() throws Exception {
File tmp = File.createTempFile("test", ".txt");
Support_TestWebServer server = new Support_TestWebServer();
try {
int port = server.initServer(tmp.getAbsolutePath(), "text/html");
URL[] urls = { new URL("http://localhost:" + port + "/") };
ucl = new URLClassLoader(urls);
URL res = ucl.findResource("test1");
assertNotNull("Failed to locate resource", res);
StringBuffer sb = getResContent(res);
assertEquals("Returned incorrect resource", new String(Support_TestWebData.test1), sb.toString());
} finally {
server.close();
}
}
use of tests.support.Support_TestWebServer in project robovm by robovm.
the class OldURLClassLoaderTest method test_findResource_String.
/**
* Regression for Harmony-2237
*/
@SideEffect("Support_TestWebServer requires isolation.")
public void test_findResource_String() throws Exception {
File tempFile1 = File.createTempFile("textFile", ".txt");
tempFile1.createNewFile();
tempFile1.deleteOnExit();
File tempFile2 = File.createTempFile("jarFile", ".jar");
tempFile2.delete();
tempFile2.deleteOnExit();
Support_TestWebServer server = new Support_TestWebServer();
try {
int port = server.initServer();
String tempPath1 = tempFile1.getParentFile().getAbsolutePath() + "/";
InputStream is = getClass().getResourceAsStream("/tests/resources/hyts_patch.jar");
Support_Resources.copyLocalFileto(tempFile2, is);
String tempPath2 = tempFile2.getAbsolutePath();
String tempPath3 = "http://localhost:" + port + "/";
URLClassLoader urlLoader = getURLClassLoader(tempPath1, tempPath2);
assertNull("Found inexistant resource", urlLoader.findResource("XXX"));
assertNotNull("Couldn't find resource from directory", urlLoader.findResource(tempFile1.getName()));
assertNotNull("Couldn't find resource from jar", urlLoader.findResource("Blah.txt"));
urlLoader = getURLClassLoader(tempPath1, tempPath2, tempPath3);
assertNotNull("Couldn't find resource from web", urlLoader.findResource("test1"));
assertNull("Found inexistant resource from web", urlLoader.findResource("test3"));
} finally {
server.close();
}
}
Aggregations