Created
November 20, 2015 12:56
-
-
Save fikovnik/0f1d361328943fa62d95 to your computer and use it in GitHub Desktop.
Tests eclipse link moxy annotation helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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(); | |
} | |
} |
Author
fikovnik
commented
Nov 20, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment