Search in sources :

Example 1 with TestBean

use of org.alfresco.repo.management.subsystems.test.TestBean in project alfresco-repository by Alfresco.

the class SubsystemsTest method testSubsystems.

/**
 * Test subsystems.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void testSubsystems() throws Exception {
    ApplicationContextFactory subsystem = (ApplicationContextFactory) applicationContext.getBean("testsubsystem");
    ConfigurableApplicationContext childContext = (ConfigurableApplicationContext) subsystem.getApplicationContext();
    assertTrue("Subsystem not started", childContext.isActive());
    TestService testService = (TestService) childContext.getBean("testService");
    // Make sure subsystem defaults work
    assertEquals("Subsystem Default1", testService.getSimpleProp1());
    // Make sure global property overrides work
    assertEquals(true, testService.getSimpleProp2().booleanValue());
    // Make sure extension classpath property overrides work
    assertEquals("Instance Override3", testService.getSimpleProp3());
    // Make sure extension classpath Spring overrides work
    assertEquals("An extra bean I changed", childContext.getBean("anotherBean"));
    // Make sure composite properties and their defaults work
    TestBean[] testBeans = testService.getTestBeans();
    assertNotNull("Composite property not set", testBeans);
    assertEquals(3, testBeans.length);
    assertEquals("inst1", testBeans[0].getId());
    assertEquals(false, testBeans[0].isBoolProperty());
    assertEquals(123456789123456789L, testBeans[0].getLongProperty());
    assertEquals("Global Default", testBeans[0].getAnotherStringProperty());
    assertEquals("inst2", testBeans[1].getId());
    assertEquals(true, testBeans[1].isBoolProperty());
    assertEquals(123456789123456789L, testBeans[1].getLongProperty());
    assertEquals("Global Default", testBeans[1].getAnotherStringProperty());
    assertEquals("inst3", testBeans[2].getId());
    assertEquals(false, testBeans[2].isBoolProperty());
    assertEquals(123456789123456789L, testBeans[2].getLongProperty());
    assertEquals("Global Instance Default", testBeans[2].getAnotherStringProperty());
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ChildApplicationContextFactory(org.alfresco.repo.management.subsystems.ChildApplicationContextFactory) ApplicationContextFactory(org.alfresco.repo.management.subsystems.ApplicationContextFactory) TestService(org.alfresco.repo.management.subsystems.test.TestService) TestBean(org.alfresco.repo.management.subsystems.test.TestBean) BaseSpringTest(org.alfresco.util.BaseSpringTest) Test(org.junit.Test)

Aggregations

ApplicationContextFactory (org.alfresco.repo.management.subsystems.ApplicationContextFactory)1 ChildApplicationContextFactory (org.alfresco.repo.management.subsystems.ChildApplicationContextFactory)1 TestBean (org.alfresco.repo.management.subsystems.test.TestBean)1 TestService (org.alfresco.repo.management.subsystems.test.TestService)1 BaseSpringTest (org.alfresco.util.BaseSpringTest)1 Test (org.junit.Test)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1