PathBuilderTest.java from Kneobase at Krugle
Show PathBuilderTest.java syntax highlighted
/*
* Created on 13/12/2004
*
*/
package com.kneobase.driver.documentbuilder;
import junit.framework.TestCase;
import com.kneobase.driver.TreeCompositeContentAux;
import com.kneobase.driver.TreeContentSourceAux;
import com.kneobase.driver.TreeContentUnitAux;
/**
* @author Ernesto De Santis
*
*/
public class PathBuilderTest extends TestCase {
public void testPathLinux() {
try {
PathBuilder builder = new PathBuilder("path");
TreeContentSourceAux source = new TreeContentSourceAux();
source.setAbsolutePath("/dragon/colabs");
TreeCompositeContentAux composite = new TreeCompositeContentAux();
composite.setContentSource(source);
TreeContentUnitAux cu = new TreeContentUnitAux(composite);
cu.setPath("index-files/index-6.html");
String path = (String) builder.getValue(cu);
assertNotNull(path);
assertFalse("".equals(path));
assertEquals("index-files/index-6.html", path);
} catch (Exception e) {
fail();
}
}
public void testPathWin() {
try {
PathBuilder builder = new PathBuilder("path");
TreeContentSourceAux source = new TreeContentSourceAux();
source.setAbsolutePath("c:\\dragon\\colabs");
TreeCompositeContentAux composite = new TreeCompositeContentAux();
composite.setContentSource(source);
TreeContentUnitAux cu = new TreeContentUnitAux(composite);
cu.setSeparatorChar('\\');
cu.setPath("index-files\\index-6.html");
String path = (String) builder.getValue(cu);
assertNotNull(path);
assertFalse("".equals(path));
assertEquals("index-files\\index-6.html", path);
} catch (Exception e) {
fail();
}
}
public void testAbsPath() {
try {
PathBuilder builder = new PathBuilder("path");
builder.setUseAbsolutePath(true);
TreeContentSourceAux source = new TreeContentSourceAux();
source.setAbsolutePath("/dragon/colabs");
TreeCompositeContentAux composite = new TreeCompositeContentAux();
composite.setContentSource(source);
TreeContentUnitAux cu = new TreeContentUnitAux(composite);
cu.setAbsolutePath("/dragon/colabs/index-files/index-6.html");
String path = (String) builder.getValue(cu);
assertNotNull(path);
assertFalse("".equals(path));
assertEquals("/dragon/colabs/index-files/index-6.html", path);
} catch (Exception e) {
fail();
}
}
}
See more files for this project here