use of com.ctrip.xpipe.api.lifecycle.Lifecycle in project x-pipe by ctripcorp.
the class DefaultLifecycleControllerTest method testCanStart.
@Test
public void testCanStart() throws Exception {
Lifecycle lifecycle = new NoOpLifecycleObject();
try {
lifecycle.start();
Assert.fail();
} catch (Exception e) {
}
lifecycle.initialize();
lifecycle.start();
lifecycle.stop();
lifecycle.start();
lifecycle.stop();
lifecycle.dispose();
try {
lifecycle.start();
Assert.fail();
} catch (Exception e) {
}
}
use of com.ctrip.xpipe.api.lifecycle.Lifecycle in project x-pipe by ctripcorp.
the class DefaultLifecycleControllerTest method testCanDispose.
@Test
public void testCanDispose() throws Exception {
Lifecycle lifecycle = new NoOpLifecycleObject();
try {
lifecycle.dispose();
Assert.fail();
} catch (Exception e) {
}
lifecycle.initialize();
lifecycle.dispose();
lifecycle.initialize();
lifecycle.start();
try {
lifecycle.dispose();
Assert.fail();
} catch (Exception e) {
}
lifecycle.stop();
lifecycle.dispose();
try {
lifecycle.dispose();
Assert.fail();
} catch (Exception e) {
}
}
use of com.ctrip.xpipe.api.lifecycle.Lifecycle in project x-pipe by ctripcorp.
the class DefaultLifecycleControllerTest method testCanStop.
@Test
public void testCanStop() throws Exception {
Lifecycle lifecycle = new NoOpLifecycleObject();
try {
lifecycle.stop();
Assert.fail();
} catch (Exception e) {
}
lifecycle.initialize();
try {
lifecycle.stop();
Assert.fail();
} catch (Exception e) {
}
lifecycle.start();
lifecycle.stop();
lifecycle.dispose();
try {
lifecycle.stop();
Assert.fail();
} catch (Exception e) {
}
}
use of com.ctrip.xpipe.api.lifecycle.Lifecycle in project x-pipe by ctripcorp.
the class SpringComponentRegistry method lifecycleCallable.
@Override
public List<Lifecycle> lifecycleCallable() {
List<Lifecycle> result = new LinkedList<>();
Map<String, Lifecycle> beans = applicationContext.getBeansOfType(Lifecycle.class);
for (Entry<String, Lifecycle> entry : beans.entrySet()) {
@SuppressWarnings("unused") String name = entry.getKey();
Lifecycle bean = entry.getValue();
if (bean instanceof TopElement) {
result.add((Lifecycle) bean);
}
}
return sort(result);
}
use of com.ctrip.xpipe.api.lifecycle.Lifecycle in project x-pipe by ctripcorp.
the class SpringComponentRegistryTest method test.
@Test
public void test() throws Exception {
ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(TestFactory.class);
ComponentRegistry componentRegistry = new SpringComponentRegistry(applicationContext);
componentRegistry.initialize();
componentRegistry.start();
Map<String, Lifecycle> objects = componentRegistry.getComponents(Lifecycle.class);
for (Lifecycle lifecycle : objects.values()) {
if (lifecycle instanceof TopElement) {
Assert.assertTrue(lifecycle.getLifecycleState().isStarted());
} else {
Assert.assertTrue(lifecycle.getLifecycleState().isEmpty());
}
}
}
Aggregations