@Test public void findClassDoesNotTryToRedefineClassesTwice() throws Exception { assertStandardClassLoaderCannotFindClass(testClassName); final byte[] loadedClassContent = FileUtils.readFileToByteArray(testClassFile); InMemoryClassFile classFileObject = new InMemoryClassFile(testClassName) { @Override public byte[] getBytes() { return loadedClassContent; }; }; testObject.addClass(testClassName, classFileObject); testObject.findClass(testClassName); testObject.findClass(testClassName); }
@Test public void findClassTriesTheHashMapFirst() throws Exception { assertStandardClassLoaderCannotFindClass(testClassName); final byte[] loadedClassContent = FileUtils.readFileToByteArray(testClassFile); InMemoryClassFile classFileObject = new InMemoryClassFile(testClassName) { @Override public byte[] getBytes() { return loadedClassContent; }; }; testObject.addClass(testClassName, classFileObject); Class<?> clazz = testObject.findClass(testClassName); assertNotNull(clazz); }