You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.9 KiB
64 lines
1.9 KiB
16 years ago
|
package de.anomic.yacy;
|
||
18 years ago
|
|
||
|
import java.net.MalformedURLException;
|
||
|
|
||
|
import junit.framework.TestCase;
|
||
|
|
||
16 years ago
|
public class yacyURLTest extends TestCase {
|
||
18 years ago
|
|
||
|
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/"}
|
||
|
};
|
||
|
|
||
16 years ago
|
yacyURL urlObj = new yacyURL("http://yacy.net");
|
||
18 years ago
|
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);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
18 years ago
|
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
|
||
16 years ago
|
String resolvedURL = (new yacyURL(testStrings[i][0])).toString();
|
||
18 years ago
|
|
||
|
// test if equal
|
||
|
assertEquals(shouldBe,resolvedURL);
|
||
|
System.out.println(" -> " + resolvedURL);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
18 years ago
|
}
|