Search in sources :

Example 1 with ServerConfiguration

use of com.canoo.dp.impl.server.config.ServerConfiguration in project dolphin-platform by canoo.

the class TestGarbageCollection method testDeactivatedGC.

@Test
public void testDeactivatedGC() {
    GarbageCollectionCallback gcConsumer = new GarbageCollectionCallback() {

        @Override
        public void onReject(Set<Instance> instances) {
            fail("GC should be deactivated!");
        }
    };
    Properties properties = new Properties();
    properties.setProperty("garbageCollectionActive", "false");
    RemotingConfiguration configuration = new RemotingConfiguration(new ServerConfiguration(properties));
    GarbageCollector garbageCollector = new GarbageCollector(configuration, gcConsumer);
    BeanWithLists parentBeanA = new BeanWithLists(garbageCollector);
    garbageCollector.onBeanCreated(parentBeanA, true);
    BeanWithProperties childBean = new BeanWithProperties(garbageCollector);
    garbageCollector.onBeanCreated(childBean, false);
    BeanWithProperties childBeanB = new BeanWithProperties(garbageCollector);
    garbageCollector.onBeanCreated(childBeanB, false);
    childBean.beanProperty().set(childBeanB);
    parentBeanA.getBeansList2().add(childBeanB);
    parentBeanA.getBeansList2().add(childBean);
    assertEquals(garbageCollector.getManagedInstancesCount(), 0);
    garbageCollector.gc();
    parentBeanA.getBeansList2().remove(childBean);
    assertEquals(garbageCollector.getManagedInstancesCount(), 0);
    garbageCollector.gc();
}
Also used : Set(java.util.Set) RemotingConfiguration(com.canoo.dp.impl.server.config.RemotingConfiguration) ServerConfiguration(com.canoo.dp.impl.server.config.ServerConfiguration) Properties(java.util.Properties) Test(org.testng.annotations.Test)

Example 2 with ServerConfiguration

use of com.canoo.dp.impl.server.config.ServerConfiguration in project dolphin-platform by canoo.

the class ClasspathScannerTest method testSimpleScan.

@Test
public void testSimpleScan() {
    // There can't be a class that is annotated with Inject
    final ServerConfiguration defaultPlatformConfiguration = ConfigurationFileLoader.loadConfiguration();
    final DefaultClasspathScanner scanner = new DefaultClasspathScanner(defaultPlatformConfiguration.getListProperty(ROOT_PACKAGE_FOR_CLASSPATH_SCAN));
    Set<Class<?>> classes = scanner.getTypesAnnotatedWith(Resources.class);
    assertNotNull(classes);
    assertEquals(classes.size(), 0);
    classes = scanner.getTypesAnnotatedWith(AnnotationForClasspathScanTest.class);
    assertNotNull(classes);
    assertEquals(classes.size(), 1);
    assertTrue(classes.contains(AnnotatedClassForClasspathScan.class));
}
Also used : DefaultClasspathScanner(com.canoo.dp.impl.server.scanner.DefaultClasspathScanner) ServerConfiguration(com.canoo.dp.impl.server.config.ServerConfiguration) DocumentAnnotatedClass(com.canoo.impl.server.classpathscan.documented.DocumentAnnotatedClass) AnnotationForClasspathScanTest(com.canoo.impl.server.util.AnnotationForClasspathScanTest) AnnotatedClassForClasspathScan(com.canoo.impl.server.util.AnnotatedClassForClasspathScan) Test(org.testng.annotations.Test) AnnotationForClasspathScanTest(com.canoo.impl.server.util.AnnotationForClasspathScanTest)

Example 3 with ServerConfiguration

use of com.canoo.dp.impl.server.config.ServerConfiguration in project dolphin-platform by canoo.

the class ConfigurationFileLoaderTest method testNullPropertyWillNotRemoveOldValue.

@Test
public void testNullPropertyWillNotRemoveOldValue() {
    try {
        // given:
        final ServerConfiguration configuration = ConfigurationFileLoader.loadConfiguration();
        // when:
        configuration.setProperty("test-key", "a");
        configuration.setProperty("test-key", null);
        // then:
        assertEquals(configuration.getProperty("test-key", null), "a");
        assertEquals(configuration.getProperty("test-key", "b"), "a");
        assertTrue(configuration.getPropertyKeys().contains("test-key"));
    } catch (Exception e) {
        fail("Error in test", e);
    }
}
Also used : ServerConfiguration(com.canoo.dp.impl.server.config.ServerConfiguration) Test(org.testng.annotations.Test)

Example 4 with ServerConfiguration

use of com.canoo.dp.impl.server.config.ServerConfiguration in project dolphin-platform by canoo.

the class ConfigurationFileLoaderTest method testConfigLoad.

@Test
public void testConfigLoad() {
    try {
        // given:
        final ServerConfiguration configuration = ConfigurationFileLoader.loadConfiguration();
        // then:
        assertEquals(configuration.getBooleanProperty(USE_CROSS_SITE_ORIGIN_FILTER), false);
        assertEquals(configuration.getProperty(ROOT_PACKAGE_FOR_CLASSPATH_SCAN), null);
    } catch (Exception e) {
        fail("Error in test", e);
    }
}
Also used : ServerConfiguration(com.canoo.dp.impl.server.config.ServerConfiguration) Test(org.testng.annotations.Test)

Example 5 with ServerConfiguration

use of com.canoo.dp.impl.server.config.ServerConfiguration in project dolphin-platform by canoo.

the class ConfigurationFileLoaderTest method testConfigurationProvider.

@Test
public void testConfigurationProvider() {
    try {
        // given:
        final ServerConfiguration configuration = ConfigurationFileLoader.loadConfiguration();
        // then:
        assertEquals(configuration.getProperty(TestConfigurationProvider.PROPERTY_1_NAME, null), TestConfigurationProvider.PROPERTY_1_VALUE);
        assertEquals(configuration.getProperty(TestConfigurationProvider.PROPERTY_2_NAME, null), TestConfigurationProvider.PROPERTY_2_VALUE);
        assertEquals(configuration.getProperty(TestConfigurationProvider.PROPERTY_3_NAME, null), TestConfigurationProvider.PROPERTY_3_VALUE);
        assertEquals(configuration.getProperty(AdditionalTestConfigurationProvider.PROPERTY_NAME, null), AdditionalTestConfigurationProvider.PROPERTY_VALUE);
    } catch (Exception e) {
        fail("Error in test", e);
    }
}
Also used : ServerConfiguration(com.canoo.dp.impl.server.config.ServerConfiguration) Test(org.testng.annotations.Test)

Aggregations

ServerConfiguration (com.canoo.dp.impl.server.config.ServerConfiguration)12 Test (org.testng.annotations.Test)10 PlatformBootstrap (com.canoo.dp.impl.server.bootstrap.PlatformBootstrap)2 CrossSiteOriginFilter (com.canoo.dp.impl.server.servlet.CrossSiteOriginFilter)2 RemotingConfiguration (com.canoo.dp.impl.server.config.RemotingConfiguration)1 DefaultClasspathScanner (com.canoo.dp.impl.server.scanner.DefaultClasspathScanner)1 DocumentAnnotatedClass (com.canoo.impl.server.classpathscan.documented.DocumentAnnotatedClass)1 AnnotatedClassForClasspathScan (com.canoo.impl.server.util.AnnotatedClassForClasspathScan)1 AnnotationForClasspathScanTest (com.canoo.impl.server.util.AnnotationForClasspathScanTest)1 Properties (java.util.Properties)1 Set (java.util.Set)1