use of org.drools.wiring.api.ResourceProvider in project drools by kiegroup.
the class MemoryKieModuleResourceProviderTest method testGetResourceTrailingSlashIgnored.
@Test
public void testGetResourceTrailingSlashIgnored() throws Exception {
MemoryFileSystem mfs = new MemoryFileSystem();
mfs.setFileContents(new MemoryFile(mfs, "my-file1", mfs.getFolder("src/main/resources")), new byte[] { 65, 66 });
MemoryKieModule mkm = new MemoryKieModule(releaseId, kieModuleModel, mfs);
ResourceProvider resourceProvider = mkm.createResourceProvider();
String noTrailingSlashContents = IOUtils.toString(resourceProvider.getResourceAsStream("src/main/resources/my-file1"));
// "AB" == new byte[] {65, 66}
Assertions.assertThat(noTrailingSlashContents).hasLineCount(1).contains("AB");
String withTrailingSlashContents = IOUtils.toString(resourceProvider.getResourceAsStream("src/main/resources/my-file1/"));
// "AB" == new byte[] {65, 66}
Assertions.assertThat(withTrailingSlashContents).hasLineCount(1).contains("AB");
}
use of org.drools.wiring.api.ResourceProvider in project drools by kiegroup.
the class MemoryKieModuleResourceProviderTest method testGetResourceAsStreamForFile.
@Test
public void testGetResourceAsStreamForFile() throws Exception {
MemoryFileSystem mfs = new MemoryFileSystem();
mfs.setFileContents(new MemoryFile(mfs, "my-file1", mfs.getFolder("src/main/resources")), new byte[] { 65, 66 });
MemoryKieModule mkm = new MemoryKieModule(releaseId, kieModuleModel, mfs);
ResourceProvider resourceProvider = mkm.createResourceProvider();
String folderContents = IOUtils.toString(resourceProvider.getResourceAsStream("src/main/resources/my-file1"));
// "AB" == new byte[] {65, 66}
Assertions.assertThat(folderContents).hasLineCount(1).contains("AB");
}
Aggregations