@Test public void testLoadXml() throws IOException { InputStream in = pluginLoader.getResourceAsStream("test1.xml"); assertNotNull("input stream is null", in); byte b[] = toBytes(in); String xml = new String(b); assertTrue("xml is wrong", xml.contains("<test1>")); }
@Test public void testLoadProperties_fromDir() throws IOException { InputStream in = pluginLoader.getResourceAsStream( "resources/plugin-classloader-test-inresourcesdir.properties"); assertNotNull("input stream is null", in); byte b[] = toBytes(in); String classBytes = new String(b); assertTrue("property is missing", classBytes.contains("name=")); }
@Test public void testLoadProperties_fromJar() throws IOException { InputStream in = pluginLoader.getResourceAsStream( "org/pentaho/test/platform/engine/services/test.properties"); assertNotNull("input stream is null", in); byte b[] = toBytes(in); String classBytes = new String(b); assertTrue("property is missing", classBytes.contains("test_setting=test")); }
@Test public void testFindClassResource() throws IOException { InputStream in = pluginLoader.getResourceAsStream( "org/pentaho/test/platform/engine/services/TestClassForClassloader.class"); assertNotNull("input stream is null", in); byte b[] = toBytes(in); String xml = new String(b); assertTrue("xml is wrong", xml.contains("TestClassForClassloader")); }
@Test public void testLoadClassAsResource() throws IOException, ClassNotFoundException { // test the byte array first InputStream in = pluginLoader.getResourceAsStream( "org/pentaho/test/platform/engine/services/TestClassForClassloader.class"); assertNotNull("Could not find class TestClassForClassloader in jar file", in); byte b[] = toBytes(in); String classBytes = new String(b); assertTrue( "method is missing", classBytes.contains("org/pentaho/test/platform/engine/services/TestClassForClassloader")); }
@Test public void testLoadBadResource() throws IOException { InputStream in = pluginLoader.getResourceAsStream("bogus.xml"); assertNull("input stream should be null", in); }