This is the mail archive of the mauve-patches@sources.redhat.com mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

URLTest addition


Please find attached a patch for URLTest.java that adds a test for URLs constructed with a context.
If resource URLs are created with erroneous '..' or '.' segments in their paths it increases the likelihood of resolution failure.


The tests pass on JDK1.5 and fail on classpath.
echo gnu.testlet.java.net.URL.URLTest | java gnu.testlet.SimpleTestHarness
0 of 171 tests failed

echo gnu.testlet.java.net.URL.URLTest | mono ikvm.exe gnu.testlet.SimpleTestHarness
FAIL: gnu.testlet.java.net.URL.URLTest: Error in test_Basics - 35 exception should not be thrown here (number 1)
---snip---
FAIL: gnu.testlet.java.net.URL.URLTest: contextResolution (number 5)
FAIL: gnu.testlet.java.net.URL.URLTest: contextResolution (number 6)
3 of 168 tests failed


Only gnu.testlet.java.net.URL.URLTest: contextResolution errors pertain to this patch.
I wasn't sure about the name of the test; feel free to rename it.


Regards,
Bryn

Index: gnu/testlet/java/net/URL/URLTest.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/net/URL/URLTest.java,v
retrieving revision 1.13
diff -u -r1.13 URLTest.java
--- gnu/testlet/java/net/URL/URLTest.java	11 Jan 2005 18:18:50 -0000	1.13
+++ gnu/testlet/java/net/URL/URLTest.java	12 Jan 2005 17:21:56 -0000
@@ -578,6 +578,50 @@
 	      }
 	}
 
+    public void test_contextResolution() {
+	harness.checkPoint("contextResolution");
+	try {
+	    String[][] testData = new String[][] {
+		{"file://www.example.com/foo/bar.txt",
+		 "../test.txt",
+		 "file://www.example.com/test.txt"
+		},
+		{"file://www.example.com/foo/bar.txt",
+		 "./test.txt",
+		 "file://www.example.com/foo/test.txt"
+		},
+		{"http://www.example.com/foo/bar.txt";,
+		 "../test.txt",
+		 "http://www.example.com/test.txt";
+		},
+		{"http://www.example.com/foo/bar.txt";,
+		 "./test.txt",
+		 "http://www.example.com/foo/test.txt";
+		},
+		{"jar:file://www.example.com/test.jar!/foo/bar.txt",
+		 "../test.txt",
+		 "jar:file://www.example.com/test.jar!/test.txt"
+		},
+		{"jar:file://www.example.com/test.jar!/foo/bar.txt",
+		 "./test.txt",
+		 "jar:file://www.example.com/test.jar!/foo/test.txt"
+		},
+	    };
+	    
+	    for (int count = 0; count < testData.length; count++) {
+		URL base = new URL(testData[count][0]);
+		String relative = testData[count][1];
+		URL resolved = new URL(base, relative);
+		harness.check(resolved.toString(), testData[count][2]);
+	    }
+	}
+	catch (Exception e) {
+	    harness.debug(e);
+	    harness.fail("Should not have thrown exception");
+	}
+    }
+
+
 	public void testall()
 	{
 		harness.debug("Running: test_Basics");
@@ -598,6 +642,8 @@
                 test_cr601b();
 		harness.debug("Running: authority");
 		test_authority();
+		harness.debug("Running: test_contextResolution");
+		test_contextResolution();
 	}
 
   public void test (TestHarness the_harness)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]