@Test public void testModification() throws Exception { final PackageInfoModifier.Modification mod = modifier.modify("com.edugility.jaxb"); assertNotNull(mod); assertEquals(PackageInfoModifier.Modification.Kind.MODIFIED, mod.getKind()); validateTwoAnnotations(mod); }
private final void validateTwoAnnotations(final PackageInfoModifier.Modification mod) throws Exception { assertNotNull(mod); final byte[] newClass = mod.toByteArray(); assertNotNull(newClass); assertTrue(newClass.length > 0); final Class<?> c = new ClassDefiner().define(mod.getPackageName(), newClass); assertNotNull(c); final Annotation[] annotations = c.getAnnotations(); assertNotNull(annotations); assertTrue(annotations.length == 2); Annotation a = annotations[0]; assertNotNull(a); if (a instanceof Deprecated) { a = annotations[1]; assertNotNull(a); } assertTrue(a instanceof XmlJavaTypeAdapters); final XmlJavaTypeAdapters adaptersAnnotation = (XmlJavaTypeAdapters) a; final XmlJavaTypeAdapter[] adapters = adaptersAnnotation.value(); assertNotNull(adapters); assertEquals(1, adapters.length); final XmlJavaTypeAdapter adapter = adapters[0]; assertNotNull(adapter); assertEquals(Person.class, adapter.type()); assertEquals(AnyTypeAdapter.class, adapter.value()); }
@Test public void testGeneration() throws Exception { final PackageInfoModifier.Modification mod = this.modifier.modify("com.edugility.jaxb.generation"); assertNotNull(mod); assertEquals(PackageInfoModifier.Modification.Kind.GENERATED, mod.getKind()); validateOneAnnotation(mod); }
@Test public void testPackageInfoWithEmptyXmlJavaTypeAdaptersAnnotation() throws Exception { final PackageInfoModifier.Modification mod = modifier.modify("com.edugility.jaxb.emptyxmljavatypeadaptersannotation"); assertNotNull(mod); assertEquals(PackageInfoModifier.Modification.Kind.MODIFIED, mod.getKind()); validateOneAnnotation(mod); }