@Test @SuppressWarnings("unchecked") public void testInjection() throws Exception { InjectionClassLoader classLoader = mock(InjectionClassLoader.class); TypeDescription typeDescription = mock(TypeDescription.class); byte[] binaryRepresentation = new byte[0]; when(typeDescription.getName()).thenReturn(FOO); when(classLoader.defineClasses(Collections.singletonMap(FOO, binaryRepresentation))) .thenReturn((Map) Collections.singletonMap(FOO, Object.class)); assertThat(InjectionClassLoader.Strategy.INSTANCE.load(classLoader, Collections.singletonMap(typeDescription, binaryRepresentation)), is(Collections.<TypeDescription, Class<?>>singletonMap(typeDescription, Object.class))); verify(classLoader).defineClasses(Collections.singletonMap(FOO, binaryRepresentation)); verifyNoMoreInteractions(classLoader); }
public Map<String, Class<?>> defineClasses(Map<String, byte[]> typeDefinitions) throws ClassNotFoundException { if (sealed) { throw new IllegalStateException("Cannot inject classes into a sealed class loader"); } return doDefineClasses(typeDefinitions); }
InjectionClassLoader extends ClassLoader { public Map<String, Class<?>> defineClasses(Map<String, byte[]> typeDefinitions) throws ClassNotFoundException { if (sealed) { throw new IllegalStateException("Cannot inject classes into a sealed class loader"); } return doDefineClasses(typeDefinitions); } }
InjectionClassLoader extends ClassLoader { public Map<String, Class<?>> defineClasses(Map<String, byte[]> typeDefinitions) throws ClassNotFoundException { if (sealed) { throw new IllegalStateException("Cannot inject classes into a sealed class loader"); } return doDefineClasses(typeDefinitions); } protected  InjectionClassLoader(ClassLoader parent, boolean sealed); }
InjectionClassLoader extends ClassLoader { public Map<String, Class<?>> defineClasses(Map<String, byte[]> typeDefinitions) throws ClassNotFoundException { if (sealed) { throw new IllegalStateException("Cannot inject classes into a sealed class loader"); } return doDefineClasses(typeDefinitions); } protected  InjectionClassLoader(ClassLoader parent, boolean sealed); boolean isSealed(); Class<?> defineClass(String name, byte[] binaryRepresentation); Map<String, Class<?>> defineClasses(Map<String, byte[]> typeDefinitions); }
InjectionClassLoader extends ClassLoader { public Map<String, Class<?>> defineClasses(Map<String, byte[]> typeDefinitions) throws ClassNotFoundException { if (sealed) { throw new IllegalStateException("Cannot inject classes into a sealed class loader"); } return doDefineClasses(typeDefinitions); } protected  InjectionClassLoader(ClassLoader parent, boolean sealed); boolean isSealed(); Class<?> defineClass(String name, byte[] binaryRepresentation); Map<String, Class<?>> defineClasses(Map<String, byte[]> typeDefinitions);  }