use of org.drools.compiler.compiler.io.memory.MemoryFolder in project drools by kiegroup.
the class MemoryKieModuleResourceProviderTest method testGetResourceAsStreamFolderWithOnlySubFolders.
@Test
public void testGetResourceAsStreamFolderWithOnlySubFolders() throws Exception {
MemoryFileSystem mfs = new MemoryFileSystem();
mfs.createFolder(new MemoryFolder(mfs, "src/main/java"));
mfs.createFolder(new MemoryFolder(mfs, "src/main/java/org"));
mfs.createFolder(new MemoryFolder(mfs, "src/main/java/com"));
MemoryKieModule mkm = new MemoryKieModule(releaseId, kieModuleModel, mfs);
ResourceProvider resourceProvider = mkm.createResourceProvider();
String folderContents = IOUtils.toString(resourceProvider.getResourceAsStream("src/main/java"));
Assertions.assertThat(folderContents).hasLineCount(2).contains("com", "org");
}
use of org.drools.compiler.compiler.io.memory.MemoryFolder in project drools by kiegroup.
the class MemoryKieModuleResourceProviderTest method testGetResourceForFolderWithFilesAndSubFolders.
@Test
public void testGetResourceForFolderWithFilesAndSubFolders() throws Exception {
MemoryFileSystem mfs = new MemoryFileSystem();
mfs.createFolder(new MemoryFolder(mfs, "src/main/java"));
mfs.createFolder(new MemoryFolder(mfs, "src/main/java/org"));
mfs.createFolder(new MemoryFolder(mfs, "src/main/java/com"));
mfs.setFileContents(new MemoryFile(mfs, "my-file1", mfs.getFolder("src/main/java")), new byte[10]);
mfs.setFileContents(new MemoryFile(mfs, "my-file2", mfs.getFolder("src/main/java")), new byte[10]);
MemoryKieModule mkm = new MemoryKieModule(releaseId, kieModuleModel, mfs);
ResourceProvider resourceProvider = mkm.createResourceProvider();
String folderContents = IOUtils.toString(resourceProvider.getResource("src/main/java").openStream());
Assertions.assertThat(folderContents).hasLineCount(4).contains("com", "org", "my-file1", "my-file2");
}
use of org.drools.compiler.compiler.io.memory.MemoryFolder in project drools by kiegroup.
the class MemoryKieModuleResourceProviderTest method testGetResourceForFolderWithOnlySubFolders.
@Test
public void testGetResourceForFolderWithOnlySubFolders() throws Exception {
MemoryFileSystem mfs = new MemoryFileSystem();
mfs.createFolder(new MemoryFolder(mfs, "src/main/java"));
mfs.createFolder(new MemoryFolder(mfs, "src/main/java/org"));
mfs.createFolder(new MemoryFolder(mfs, "src/main/java/com"));
MemoryKieModule mkm = new MemoryKieModule(releaseId, kieModuleModel, mfs);
ResourceProvider resourceProvider = mkm.createResourceProvider();
String folderContents = IOUtils.toString(resourceProvider.getResource("src/main/java").openStream());
Assertions.assertThat(folderContents).hasLineCount(2).contains("com", "org");
}
use of org.drools.compiler.compiler.io.memory.MemoryFolder in project drools by kiegroup.
the class MemoryKieModuleResourceProviderTest method testGetResourceForEmptyFolder.
@Test
public void testGetResourceForEmptyFolder() throws Exception {
MemoryFileSystem mfs = new MemoryFileSystem();
mfs.createFolder(new MemoryFolder(mfs, "src/main/java"));
MemoryKieModule mkm = new MemoryKieModule(releaseId, kieModuleModel, mfs);
ResourceProvider resourceProvider = mkm.createResourceProvider();
String folderContents = IOUtils.toString(resourceProvider.getResource("src/main/java").openStream());
Assertions.assertThat(folderContents).isEmpty();
}
use of org.drools.compiler.compiler.io.memory.MemoryFolder in project drools by kiegroup.
the class MemoryFolderTest method testGetParentWithLeadingAndTrailingSlash.
@Test
public void testGetParentWithLeadingAndTrailingSlash() {
MemoryFileSystem mfs = new MemoryFileSystem();
assertEquals("", new MemoryFolder(mfs, "/src").getParent().getPath().toPortableString());
assertEquals("", new MemoryFolder(mfs, "src/").getParent().getPath().toPortableString());
assertEquals("", new MemoryFolder(mfs, "/src/").getParent().getPath().toPortableString());
assertEquals("src", new MemoryFolder(mfs, "/src/main").getParent().getPath().toPortableString());
assertEquals("src", new MemoryFolder(mfs, "src/main/").getParent().getPath().toPortableString());
assertEquals("src", new MemoryFolder(mfs, "/src/main/").getParent().getPath().toPortableString());
assertEquals("src/main", new MemoryFolder(mfs, "/src/main/java").getParent().getPath().toPortableString());
assertEquals("src/main", new MemoryFolder(mfs, "src/main/java/").getParent().getPath().toPortableString());
assertEquals("src/main", new MemoryFolder(mfs, "/src/main/java/").getParent().getPath().toPortableString());
}
Aggregations