private void getMergedAnnotationAttributesWithHalfConventionBasedAndHalfAliasedComposedAnnotation( Class<?> clazz) { String[] expected = asArray("explicitDeclaration"); String name = ContextConfig.class.getName(); String simpleName = clazz.getSimpleName(); AnnotationAttributes attributes = getMergedAnnotationAttributes(clazz, name); assertNotNull("Should find @ContextConfig on " + simpleName, attributes); assertArrayEquals( "locations for class [" + clazz.getSimpleName() + "]", expected, attributes.getStringArray("locations")); assertArrayEquals( "value for class [" + clazz.getSimpleName() + "]", expected, attributes.getStringArray("value")); // Verify contracts between utility methods: assertTrue(isAnnotated(clazz, name)); }
private void assertGetMergedAnnotation(Class<?> element, String... expected) { String name = ContextConfig.class.getName(); ContextConfig contextConfig = getMergedAnnotation(element, ContextConfig.class); assertNotNull("Should find @ContextConfig on " + element.getSimpleName(), contextConfig); assertArrayEquals("locations", expected, contextConfig.locations()); assertArrayEquals("value", expected, contextConfig.value()); assertArrayEquals("classes", new Class<?>[0], contextConfig.classes()); // Verify contracts between utility methods: assertTrue(isAnnotated(element, name)); }
@Test public void getMergedAnnotationAttributesWithAliasedValueComposedAnnotation() { Class<?> element = AliasedValueComposedContextConfigClass.class; String name = ContextConfig.class.getName(); AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); assertNotNull("Should find @ContextConfig on " + element.getSimpleName(), attributes); assertArrayEquals("locations", asArray("test.xml"), attributes.getStringArray("locations")); assertArrayEquals("value", asArray("test.xml"), attributes.getStringArray("value")); // Verify contracts between utility methods: assertTrue(isAnnotated(element, name)); }
@Test public void getMergedAnnotationWithImplicitAliasesInMetaAnnotationOnComposedAnnotation() { Class<?> element = ComposedImplicitAliasesContextConfigClass.class; String name = ImplicitAliasesContextConfig.class.getName(); ImplicitAliasesContextConfig config = getMergedAnnotation(element, ImplicitAliasesContextConfig.class); String[] expected = asArray("A.xml", "B.xml"); assertNotNull( "Should find @ImplicitAliasesContextConfig on " + element.getSimpleName(), config); assertArrayEquals("groovyScripts", expected, config.groovyScripts()); assertArrayEquals("xmlFiles", expected, config.xmlFiles()); assertArrayEquals("locations", expected, config.locations()); assertArrayEquals("value", expected, config.value()); // Verify contracts between utility methods: assertTrue(isAnnotated(element, name)); }