Search in sources :

Example 6 with ContextConfiguration

use of org.springframework.test.context.ContextConfiguration in project spring-framework by spring-projects.

the class MetaAnnotationUtilsTests method findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes.

@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes() throws Exception {
    Class<?> startClass = MetaConfigWithOverriddenAttributesTestCase.class;
    Class<ContextConfiguration> annotationType = ContextConfiguration.class;
    UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class, ContextConfiguration.class, Order.class, Transactional.class);
    assertNotNull(descriptor);
    assertEquals(startClass, descriptor.getRootDeclaringClass());
    assertEquals(annotationType, descriptor.getAnnotationType());
    assertArrayEquals(new Class[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
    assertArrayEquals(new Class[] { MetaAnnotationUtilsTests.class }, descriptor.getAnnotationAttributes().getClassArray("classes"));
    assertNotNull(descriptor.getComposedAnnotation());
    assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
}
Also used : ContextConfiguration(org.springframework.test.context.ContextConfiguration) UntypedAnnotationDescriptor(org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor) Test(org.junit.Test)

Example 7 with ContextConfiguration

use of org.springframework.test.context.ContextConfiguration in project Activiti by Activiti.

the class SpringActivitiTestCase method initializeProcessEngine.

@Override
protected void initializeProcessEngine() {
    ContextConfiguration contextConfiguration = getClass().getAnnotation(ContextConfiguration.class);
    String[] value = contextConfiguration.value();
    boolean hasOneArg = value != null && value.length == 1;
    String key = hasOneArg ? value[0] : ProcessEngine.class.getName();
    ProcessEngine engine = this.cachedProcessEngines.containsKey(key) ? this.cachedProcessEngines.get(key) : this.applicationContext.getBean(ProcessEngine.class);
    this.cachedProcessEngines.put(key, engine);
    this.processEngine = engine;
}
Also used : ContextConfiguration(org.springframework.test.context.ContextConfiguration) ProcessEngine(org.activiti.engine.ProcessEngine)

Aggregations

ContextConfiguration (org.springframework.test.context.ContextConfiguration)7 Test (org.junit.Test)5 AnnotationAttributes (org.springframework.core.annotation.AnnotationAttributes)2 UntypedAnnotationDescriptor (org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ProcessEngine (org.activiti.engine.ProcessEngine)1 ContextConfigurationAttributes (org.springframework.test.context.ContextConfigurationAttributes)1 ContextHierarchy (org.springframework.test.context.ContextHierarchy)1 ContextLoader (org.springframework.test.context.ContextLoader)1