use of org.drools.compiler.compiler.io.FileSystem in project drools by kiegroup.
the class MemoryFileTest method testFilePath.
@Test
public void testFilePath() {
FileSystem fs = new MemoryFileSystem();
Folder mres = fs.getFolder("src/main/java/org/domain");
File f1 = mres.getFile("MyClass.java");
assertEquals("src/main/java/org/domain/MyClass.java", f1.getPath().toPortableString());
}
use of org.drools.compiler.compiler.io.FileSystem in project drools by kiegroup.
the class MemoryFileTest method testRelativeToParentFilePath.
@Test
public void testRelativeToParentFilePath() {
FileSystem fs = new MemoryFileSystem();
Folder mres = fs.getFolder("src/main/java/org/domain");
Folder f2 = fs.getFolder("src/main/java/org/domain/f1/f2/");
File f1 = mres.getFile("MyClass.java");
assertEquals("../../MyClass.java", f1.getPath().toRelativePortableString(f2.getPath()));
}
use of org.drools.compiler.compiler.io.FileSystem in project drools by kiegroup.
the class MemoryFileTest method testFileCreation.
@Test
public void testFileCreation() throws IOException {
FileSystem fs = new MemoryFileSystem();
Folder mres = fs.getFolder("src/main/java/org/domain");
File f1 = mres.getFile("MyClass.java");
f1.create(new ByteArrayInputStream("ABC".getBytes()));
mres.create();
f1 = mres.getFile("MyClass.java");
assertTrue(f1.exists());
f1.create(new ByteArrayInputStream("ABC".getBytes()));
f1 = mres.getFile("MyClass.java");
assertTrue(f1.exists());
assertEquals("ABC", StringUtils.toString(f1.getContents()));
f1.create(new ByteArrayInputStream("ABC".getBytes()));
f1.setContents(new ByteArrayInputStream("DEF".getBytes()));
assertEquals("DEF", StringUtils.toString(f1.getContents()));
}
use of org.drools.compiler.compiler.io.FileSystem in project drools by kiegroup.
the class MemoryFolderTest method testNestedRelativePath.
@Test
public void testNestedRelativePath() {
FileSystem fs = new MemoryFileSystem();
Folder f1 = fs.getFolder("src/main/java");
Folder f2 = fs.getFolder("src/main/java/org");
f1.create();
f2.create();
assertEquals("org", f2.getPath().toRelativePortableString(f1.getPath()));
fs = new MemoryFileSystem();
f1 = fs.getFolder("src/main/java");
f2 = fs.getFolder("src/main/java/org/drools/reteoo");
f1.create();
f2.create();
assertEquals("org/drools/reteoo", f2.getPath().toRelativePortableString(f1.getPath()));
}
use of org.drools.compiler.compiler.io.FileSystem in project drools by kiegroup.
the class MemoryFolderTest method testFolderGetParent.
@Test
public void testFolderGetParent() {
FileSystem fs = new MemoryFileSystem();
Folder mres = fs.getFolder("src/main/resources");
mres.create();
assertEquals("src/main", mres.getParent().getPath().asString());
assertEquals("src", mres.getParent().getParent().getPath().asString());
}
Aggregations