yacy_search_server/test/de/anomic/yacy/yacyURLTest.java
f1ori 69dfd03985 reactivate unittests
* fix old tests
* add buildtarget "ant test"


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6228 6c8d7289-2bf4-0310-a012-ef5d649a1542
2009-07-17 20:58:21 +00:00

64 lines
1.9 KiB
Java

package de.anomic.yacy;
import java.net.MalformedURLException;
import junit.framework.TestCase;
public class yacyURLTest extends TestCase {
public void testResolveBackpath() throws MalformedURLException {
String[][] testStrings = new String[][] {
new String[]{"/..home","/..home"},
new String[]{"/test/..home/test.html","/test/..home/test.html"},
new String[]{"/../","/../"},
new String[]{"/..","/.."},
new String[]{"/test/..","/"},
new String[]{"/test/../","/"},
new String[]{"/test/test2/..","/test"},
new String[]{"/test/test2/../","/test/"},
new String[]{"/test/test2/../hallo","/test/hallo"},
new String[]{"/test/test2/../hallo/","/test/hallo/"},
new String[]{"/home/..test/../hallo/../","/home/"}
};
yacyURL urlObj = new yacyURL("http://yacy.net");
for (int i=0; i < testStrings.length; i++) {
// desired conversion result
System.out.print("testResolveBackpath: " + testStrings[i][0]);
String shouldBe = testStrings[i][1];
// conversion result
String resolvedURL = urlObj.resolveBackpath(testStrings[i][0]);
// test if equal
assertEquals(shouldBe,resolvedURL);
System.out.println(" -> " + resolvedURL);
}
}
public void testIdentPort() throws MalformedURLException {
String[][] testStrings = new String[][] {
new String[]{"http://www.yacy.net:","http://www.yacy.net/"},
new String[]{"http://www.yacy.net:-1","http://www.yacy.net/"},
new String[]{"http://www.yacy.net:/","http://www.yacy.net/"},
new String[]{"http://www.yacy.net: /","http://www.yacy.net/"}
};
for (int i=0; i < testStrings.length; i++) {
// desired conversion result
System.out.print("testIdentPort: " + testStrings[i][0]);
String shouldBe = testStrings[i][1];
// conversion result
String resolvedURL = (new yacyURL(testStrings[i][0])).toString();
// test if equal
assertEquals(shouldBe,resolvedURL);
System.out.println(" -> " + resolvedURL);
}
}
}