Skip to content

Commit

Permalink
Extend test.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Sep 24, 2024
1 parent e06d8ea commit 9c7dd7d
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.bytebuddy.build;

import net.bytebuddy.ClassFileVersion;
import net.bytebuddy.description.type.TypeDescription;
import org.junit.Test;

Expand Down Expand Up @@ -67,4 +68,31 @@ public void testIgnoreFolderElement() throws Exception {
verify(element).getName();
verifyNoMoreInteractions(element);
}

@Test
public void testMultiVersion() throws Exception {
Plugin.Engine.Target.InMemory target = new Plugin.Engine.Target.InMemory(ClassFileVersion.JAVA_V11);
Plugin.Engine.Target.Sink sink = target.write(Plugin.Engine.Source.Origin.NO_MANIFEST);
sink.store(Collections.singletonMap(TypeDescription.ForLoadedType.of(Object.class), new byte[]{1, 2, 3}));
sink.store(11, Collections.singletonMap(TypeDescription.ForLoadedType.of(Object.class), new byte[]{4, 5, 6}));
sink.store(17, Collections.singletonMap(TypeDescription.ForLoadedType.of(Object.class), new byte[]{7, 8, 9}));
sink.close();
assertThat(target.getStorage().size(), is(1));
assertThat(target.getStorage().get(TypeDescription.ForLoadedType.of(Object.class).getInternalName() + ".class"), is(new byte[]{4, 5, 6}));
assertThat(target.toTypeMap().size(), is(1));
assertThat(target.toTypeMap().get(TypeDescription.ForLoadedType.of(Object.class).getName()), is(new byte[]{4, 5, 6}));
}

@Test
public void testNoMultiVersion() throws Exception {
Plugin.Engine.Target.InMemory target = new Plugin.Engine.Target.InMemory();
Plugin.Engine.Target.Sink sink = target.write(Plugin.Engine.Source.Origin.NO_MANIFEST);
sink.store(Collections.singletonMap(TypeDescription.ForLoadedType.of(Object.class), new byte[]{1, 2, 3}));
sink.store(11, Collections.singletonMap(TypeDescription.ForLoadedType.of(Object.class), new byte[]{4, 5, 6}));
sink.close();
assertThat(target.getStorage().size(), is(1));
assertThat(target.getStorage().get(TypeDescription.ForLoadedType.of(Object.class).getInternalName() + ".class"), is(new byte[]{1, 2, 3}));
assertThat(target.toTypeMap().size(), is(1));
assertThat(target.toTypeMap().get(TypeDescription.ForLoadedType.of(Object.class).getName()), is(new byte[]{1, 2, 3}));
}
}

0 comments on commit 9c7dd7d

Please sign in to comment.