Skip to content

Instantly share code, notes, and snippets.

@fikovnik
Created November 20, 2015 12:56
Show Gist options
  • Save fikovnik/0f1d361328943fa62d95 to your computer and use it in GitHub Desktop.
Save fikovnik/0f1d361328943fa62d95 to your computer and use it in GitHub Desktop.
Tests eclipse link moxy annotation helper
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
package com.oracle.bacs.metadata.internal.binding;
import org.eclipse.persistence.jaxb.JAXBContextFactory;
import org.eclipse.persistence.jaxb.JAXBContextProperties;
import org.eclipse.persistence.jaxb.javamodel.reflection.AnnotationHelper;
import org.testng.annotations.Test;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.util.HashMap;
import java.util.Map;
public class AnnotationHelperTest {
public static class A {
private int a;
}
@Test
public void testWhenItGetsCalled() throws JAXBException {
Map<String, Object> properties = new HashMap<>();
properties.put(JAXBContextProperties.ANNOTATION_HELPER, new AnnotationHelper() {
@Override
public Annotation getAnnotation(final AnnotatedElement elem, final Class annotationClass) {
System.out.println("get " + elem + " " + annotationClass);
return super.getAnnotation(elem, annotationClass);
}
@Override
public Annotation[] getAnnotations(final AnnotatedElement elem) {
System.out.println("get all " + elem);
return super.getAnnotations(elem);
}
@Override
public boolean isAnnotationPresent(final AnnotatedElement elem, final Class annotationClass) {
System.out.println("is " + elem + " " + annotationClass);
return super.isAnnotationPresent(elem, annotationClass);
}
@Override
public Annotation[] getDeclaredAnnotations(final AnnotatedElement elem) {
System.out.println("get declared " + elem);
return super.getDeclaredAnnotations(elem);
}
});
JAXBContext ctx = JAXBContextFactory.createContext(new Class[] {A.class}, properties);
ctx.createMarshaller();
}
}
@fikovnik
Copy link
Author

is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface javax.xml.bind.annotation.XmlRegistry
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface javax.xml.bind.annotation.XmlTransient
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlElementNillable
is package com.oracle.bacs.metadata.internal.binding interface org.eclipse.persistence.oxm.annotations.XmlElementNillable
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlVirtualAccessMethods
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface javax.xml.bind.annotation.XmlInlineBinaryData
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlNamedObjectGraphs
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlNamedObjectGraph
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface javax.xml.bind.annotation.XmlRootElement
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface javax.xml.bind.annotation.XmlSeeAlso
is package com.oracle.bacs.metadata.internal.binding interface javax.xml.bind.annotation.XmlSchema
is package com.oracle.bacs.metadata.internal.binding interface javax.xml.bind.annotation.XmlAccessorType
is package com.oracle.bacs.metadata.internal.binding interface javax.xml.bind.annotation.XmlAccessorOrder
is package com.oracle.bacs.metadata.internal.binding interface com.sun.xml.internal.bind.XmlAccessorFactory
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface javax.xml.bind.annotation.XmlType
get declared class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface javax.xml.bind.annotation.XmlAccessorOrder
is package com.oracle.bacs.metadata.internal.binding interface javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters
is package com.oracle.bacs.metadata.internal.binding interface javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlCustomizer
is package com.oracle.bacs.metadata.internal.binding interface javax.xml.bind.annotation.XmlSchemaTypes
is package com.oracle.bacs.metadata.internal.binding interface javax.xml.bind.annotation.XmlSchemaType
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlClassExtractor
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlProperties
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlProperty
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlDiscriminatorNode
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlDiscriminatorValue
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface javax.xml.bind.annotation.XmlRegistry
is class com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A interface org.eclipse.persistence.oxm.annotations.XmlNameTransformer
is package com.oracle.bacs.metadata.internal.binding interface org.eclipse.persistence.oxm.annotations.XmlNameTransformer
get all private int com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A.a
is private int com.oracle.bacs.metadata.internal.binding.AnnotationHelperTest$A.a interface javax.xml.bind.annotation.XmlTransient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment