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();
}
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));
}
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);
}
}
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);
}
}
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);
}
}
Aggregations