diff options
| author | reger <reger18@arcor.de> | 2015-05-12 01:09:10 +0200 |
|---|---|---|
| committer | reger <reger18@arcor.de> | 2015-05-12 01:09:10 +0200 |
| commit | c37dda8849cd2f4a8264bc218c14f7cc0683c840 (patch) | |
| tree | db9f92d50706fa947fceb3ebe30e63e1e1288f5a /test/net | |
| parent | f810915717579d490259d70610dc4118b7c6e6e9 (diff) | |
fix NPE on MultiProtocolURL on url with parameter value and '='
in getAttribute
- added test case for it
Diffstat (limited to 'test/net')
| -rw-r--r-- | test/net/yacy/cora/document/id/MultiProtocolURLTest.java | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/net/yacy/cora/document/id/MultiProtocolURLTest.java b/test/net/yacy/cora/document/id/MultiProtocolURLTest.java index 790aaf64d..ad4555c69 100644 --- a/test/net/yacy/cora/document/id/MultiProtocolURLTest.java +++ b/test/net/yacy/cora/document/id/MultiProtocolURLTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.*; import java.net.MalformedURLException; import java.util.LinkedHashMap; +import java.util.Map; import java.util.TreeSet; import org.junit.Test; @@ -158,7 +159,7 @@ public class MultiProtocolURLTest { for (String[] testString : testStrings) { // desired conversion result - System.out.print("orig uri: " + testString[0]); + System.out.print("toNormalform orig uri: " + testString[0]); String shouldBe = testString[1]; // conversion result String resultUrl = new MultiProtocolURL(testString[0]).toNormalform(true); @@ -167,6 +168,30 @@ public class MultiProtocolURLTest { System.out.println(" -> " + resultUrl); } } + + /** + * Test of getAttribute method, of class MultiProtocolURL. + */ + @Test + public void testGetAttribute() throws Exception { + // some test url/uri with problems in the past + String[][] testStrings = new String[][]{ + // teststring , expectedresult + new String[]{"http://yacy.net?&test", "test"} + }; + + for (String[] testString : testStrings) { + // desired conversion result + System.out.print("test getAttribute: " + testString[0]); + String shouldBe = testString[1]; + + MultiProtocolURL resultUrl = new MultiProtocolURL(testString[0]); + Map<String, String> attr = resultUrl.getAttributes(); + + assertEquals("", attr.get(shouldBe)); + System.out.println(" -> " + resultUrl.toNormalform(false)); + } + } } |
