CachedComponentClassLoader extends ClassLoader { protected Class<?> findClass(String name) throws ClassNotFoundException { Class<?> clazz = findLoadedClass(name); if(clazz != null) return clazz; byte[] data = this.byteCode.get(name); if(data == null || data.length < 1) { return null; } return defineClass(name, data, 0, data.length); } CachedComponentClassLoader(final ClassLoader parentClassLoader); Class<?> loadClass(String name); InputStream getResourceAsStream(String name); void initialize(final String componentFolder); MicroPipelineComponent newInstance(final String id, final String name, final String version, final Properties properties); boolean isManagedComponent(final String name, final String version); String getManagedComponentKey(final String name, final String version); Map<String, ComponentDescriptor> getManagedComponents();  }
@Test public void testFindClass_withEmptyInput() throws Exception { CachedComponentClassLoader cl = new CachedComponentClassLoader(CachedComponentClassLoader.class.getClassLoader()); Assert.assertNull(cl.findClass("")); }
@Test public void testFindClass_withInvalidClassReference() throws Exception { CachedComponentClassLoader cl = new CachedComponentClassLoader(CachedComponentClassLoader.class.getClassLoader()); Assert.assertNull(cl.findClass("java.lang.Stringunknown")); }
@Test public void testFindClass_withStandardClassReference() throws Exception { CachedComponentClassLoader cl = new CachedComponentClassLoader(CachedComponentClassLoader.class.getClassLoader()); Assert.assertNull(cl.findClass("java.lang.String")); }