Skip to content

Commit

Permalink
Add test for multi-release.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Sep 24, 2024
1 parent 9c7dd7d commit 2603c3d
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,37 @@ public void testSimpleTransformationErrorIgnored() throws Exception {
verifyNoMoreInteractions(listener);
}

@Test
public void testSimpleTransformationMultiRelease() throws Exception {
Plugin.Engine.Listener listener = mock(Plugin.Engine.Listener.class);
Plugin plugin = eager
? new SimplePlugin()
: new PreprocessingPlugin(new SimplePlugin());
Plugin.Engine.Source source = new Plugin.Engine.Source.InMemory(Collections.singletonMap(
"META-INF/versions/11/" + Sample.class.getName().replace('.', '/') + Plugin.Engine.CLASS_FILE_EXTENSION,
ClassFileLocator.ForClassLoader.read(Sample.class)
));
Plugin.Engine.Target.InMemory target = new Plugin.Engine.Target.InMemory(ClassFileVersion.JAVA_V11);
Plugin.Engine.Summary summary = new Plugin.Engine.Default()
.with(listener)
.with(ClassFileVersion.JAVA_V11)
.with(ClassFileLocator.ForClassLoader.of(SimplePlugin.class.getClassLoader()))
.with(dispatcherFactory)
.apply(source, target, new Plugin.Factory.Simple(plugin));
ClassLoader classLoader = new ByteArrayClassLoader(ClassLoadingStrategy.BOOTSTRAP_LOADER, target.toTypeMap());
Class<?> type = classLoader.loadClass(Sample.class.getName());
assertThat(type.getDeclaredField(FOO).getType(), is((Object) Void.class));
assertThat(summary.getTransformed(), hasItems(TypeDescription.ForLoadedType.of(Sample.class)));
assertThat(summary.getFailed().size(), is(0));
assertThat(summary.getUnresolved().size(), is(0));
verify(listener).onManifest(Plugin.Engine.Source.Origin.NO_MANIFEST);
verify(listener).onDiscovery(Sample.class.getName());
verify(listener).onTransformation(TypeDescription.ForLoadedType.of(Sample.class), plugin);
verify(listener).onTransformation(TypeDescription.ForLoadedType.of(Sample.class), Collections.singletonList(plugin));
verify(listener).onComplete(TypeDescription.ForLoadedType.of(Sample.class));
verifyNoMoreInteractions(listener);
}

@Test
public void testLiveInitializer() throws Exception {
Plugin.Engine.Listener listener = mock(Plugin.Engine.Listener.class);
Expand Down

0 comments on commit 2603c3d

Please sign in to comment.