diff options
author | Elliott Hughes <enh@google.com> | 2012-07-24 14:02:00 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2012-07-24 15:23:57 -0700 |
commit | d3298cd1b4bc69183e96e3cf8fd247e1596b7e07 (patch) | |
tree | b7945310657e6f864f21022c1650fd0107470472 /support/src/test | |
parent | 3ff7a80532c9edbcca3331de2b9e87bbf16a0c96 (diff) | |
download | libcore-d3298cd1b4bc69183e96e3cf8fd247e1596b7e07.zip libcore-d3298cd1b4bc69183e96e3cf8fd247e1596b7e07.tar.gz libcore-d3298cd1b4bc69183e96e3cf8fd247e1596b7e07.tar.bz2 |
Fix URLConnectionTest#test_getAllowUserInteraction.
Also improve the documentation, make it possible to run these tests
individually outside of CTS with vogar, and remove a few more URLs of
external web servers.
We should clean up all tests to remove all reliance on external web servers.
Bug: http://code.google.com/p/android/issues/detail?id=35400
(cherry-picked from 3827b65b1937acfbf3abbc449f8ba0ffc60f3cf3.)
Conflicts:
luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
Change-Id: I4959fefa130290236533be72cce7c57b9ea1e296
Diffstat (limited to 'support/src/test')
-rw-r--r-- | support/src/test/java/tests/support/Support_Configuration.java | 10 | ||||
-rw-r--r-- | support/src/test/java/tests/support/resource/Support_Resources.java | 20 |
2 files changed, 17 insertions, 13 deletions
diff --git a/support/src/test/java/tests/support/Support_Configuration.java b/support/src/test/java/tests/support/Support_Configuration.java index fed0bc8..9cb617d 100644 --- a/support/src/test/java/tests/support/Support_Configuration.java +++ b/support/src/test/java/tests/support/Support_Configuration.java @@ -91,18 +91,8 @@ public class Support_Configuration { // than one addresses returned for this host name as needed by a test // END android-changed - public static String testURL = "harmony.apache.org"; - - public static String hTTPURLwExpiration = "http://phpwiki.sourceforge.net/phpwiki-1.2/"; - public static String hTTPURLwLastModified = "http://www.php.net/manual/en/function.explode.php"; - public static String hTTPURLyahoo = "http://news.yahoo.com/"; - - public static String hTTPURLgoogle = "http://www.google.com/ie"; - - public static String testContentEncoding = "http://www.amazon.com/"; - public static int SpecialInetTestAddressNumber = 4; /** diff --git a/support/src/test/java/tests/support/resource/Support_Resources.java b/support/src/test/java/tests/support/resource/Support_Resources.java index 80a53fb..ddcb881 100644 --- a/support/src/test/java/tests/support/resource/Support_Resources.java +++ b/support/src/test/java/tests/support/resource/Support_Resources.java @@ -18,6 +18,7 @@ package tests.support.resource; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; @@ -34,12 +35,25 @@ public class Support_Resources { public static final String RESOURCE_PACKAGE_NAME = "tests.resources"; public static InputStream getStream(String name) { + // If we have the resources packaged up in our jar file, get them that way. String path = RESOURCE_PACKAGE + name; InputStream result = Support_Resources.class.getResourceAsStream(path); - if (result == null) { - throw new IllegalArgumentException("No such resource: " + path); + if (result != null) { + return result; } - return result; + // Otherwise, if we're in an Android build tree, get the files directly. + String ANDROID_BUILD_TOP = System.getenv("ANDROID_BUILD_TOP"); + if (ANDROID_BUILD_TOP != null) { + File resource = new File(ANDROID_BUILD_TOP + "/libcore/support/src/test/java" + path); + if (resource.exists()) { + try { + return new FileInputStream(resource); + } catch (IOException ex) { + throw new IllegalArgumentException("Couldn't open: " + resource, ex); + } + } + } + throw new IllegalArgumentException("No such resource: " + path); } public static String getURL(String name) { |