*
* @throws Exception for any error
*/
public void testMethodLevelAnnotationsWithDeclaredMethodSignature() throws Exception
{
AnnotatedElementMetaDataLoader annotatedElementLoader = new AnnotatedElementMetaDataLoader(MethodBean.class);
// Create a DeclaredMethodSignature for the method with 1 annotation
Method methodWithOneAnnotation = MethodBean.class.getMethod("testAnnotation", new Class<?>[] {String.class});
DeclaredMethodSignature declaredMethodSignature = new DeclaredMethodSignature(methodWithOneAnnotation);
// create a retrieval out of it
MetaDataRetrieval retrieval = annotatedElementLoader.getComponentMetaDataRetrieval(declaredMethodSignature);
MetaData metadata = new MetaDataRetrievalToMetaDataBridge(retrieval);
// should be empty array since the bean has no annotations
Annotation[] annotations = metadata.getAnnotations();
assertTrue("Expected one annotation on " + methodWithOneAnnotation, annotations.length == 1);
// Now try the same on a method which has 2 annotations
Method methodWithTwoAnnotations = MethodBean.class.getMethod("testAnnotation12", new Class<?>[] {String.class, Class.class});
DeclaredMethodSignature anotherDeclaredMethodSignature = new DeclaredMethodSignature(methodWithTwoAnnotations);
// create a retrieval out of it
MetaDataRetrieval anotherRetrieval = annotatedElementLoader.getComponentMetaDataRetrieval(anotherDeclaredMethodSignature);
MetaData anotherMetadata = new MetaDataRetrievalToMetaDataBridge(anotherRetrieval);
// should be empty array since the bean has no annotations
Annotation[] annotationsOnMethodWithTwoAnnotations = anotherMetadata.getAnnotations();
assertTrue("Expected two annotations on " + anotherDeclaredMethodSignature, annotationsOnMethodWithTwoAnnotations.length == 2);
}