use of com.ctrip.xpipe.lifecycle.CreatedComponentRedistry in project x-pipe by ctripcorp.
the class CreatedComponentRedistryTest method test.
@Test
public void test() throws Exception {
CreatedComponentRedistry registry = new CreatedComponentRedistry();
String name = registry.add(new Object());
logger.info("{}", name);
Lifecycle lifecycle = new NoOpLifecycleObject();
registry.add(lifecycle);
registry.initialize();
registry.start();
Assert.assertTrue(lifecycle.getLifecycleState().isStarted());
Lifecycle lifecycle2 = new NoOpLifecycleObject();
registry.add(lifecycle2);
Assert.assertTrue(lifecycle2.getLifecycleState().isStarted());
registry.remove(lifecycle2);
Assert.assertTrue(lifecycle2.getLifecycleState().isDisposed());
Assert.assertEquals(2, registry.allComponents().size());
}
use of com.ctrip.xpipe.lifecycle.CreatedComponentRedistry in project x-pipe by ctripcorp.
the class AbstractTest method beforeAbstractTest.
@Before
public void beforeAbstractTest() throws Exception {
ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
// clear interrupt
Thread.interrupted();
executors = Executors.newCachedThreadPool(XpipeThreadFactory.create(getTestName()));
scheduled = Executors.newScheduledThreadPool(OsUtils.getCpuCount(), XpipeThreadFactory.create(getTestName()));
orginProperties = (Properties) System.getProperties().clone();
doBeforeAbstractTest();
logger.info(remarkableMessage("[begin test][{}]"), name.getMethodName());
componentRegistry = new DefaultRegistry(new CreatedComponentRedistry(), getSpringRegistry());
startedComponentRegistry = new CreatedComponentRedistry();
startedComponentRegistry.initialize();
startedComponentRegistry.start();
Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
InputStream fins = getClass().getClassLoader().getResourceAsStream("xpipe-test.properties");
try {
properties.load(fins);
} finally {
if (fins != null) {
fins.close();
}
}
File file = new File(getTestFileDir());
if (file.exists() && deleteTestDirBeforeTest()) {
deleteTestDir();
}
if (!file.exists()) {
boolean testSucceed = file.mkdirs();
if (!testSucceed) {
throw new IllegalStateException("test dir make failed!" + file);
}
}
}
use of com.ctrip.xpipe.lifecycle.CreatedComponentRedistry in project x-pipe by ctripcorp.
the class AppTest method initComponentRegistry.
private void initComponentRegistry(ConfigurableApplicationContext context) throws Exception {
ComponentRegistry registry = new DefaultRegistry(new CreatedComponentRedistry(), new SpringComponentRegistry(context));
registry.initialize();
registry.start();
ComponentRegistryHolder.initializeRegistry(registry);
}
use of com.ctrip.xpipe.lifecycle.CreatedComponentRedistry in project x-pipe by ctripcorp.
the class KeeperContainerApplication method initComponentRegistry.
private static ComponentRegistry initComponentRegistry(ConfigurableApplicationContext context) throws Exception {
final ComponentRegistry registry = new DefaultRegistry(new CreatedComponentRedistry(), new SpringComponentRegistry(context));
registry.initialize();
registry.start();
ComponentRegistryHolder.initializeRegistry(registry);
return registry;
}
Aggregations