use of org.apache.openejb.server.ServerService in project tomee by apache.
the class FailoverTest method _testCleanShutdown.
public void _testCleanShutdown() throws Exception {
agent = new TestAgent();
try {
// Properties initProps = System.getProperties();
final Properties initProps = new Properties();
initProps.setProperty("openejb.deployments.classpath.include", "");
initProps.setProperty("openejb.deployments.classpath.filter.descriptors", "true");
OpenEJB.init(initProps, new ServerFederation());
} catch (Exception e) {
}
final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
final ConfigurationFactory config = new ConfigurationFactory();
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(Target.class));
assembler.createApplication(config.configureApplication(ejbJar));
SystemInstance.get().setComponent(DiscoveryAgent.class, agent);
final ServerService red = server(Host.RED);
final ServerService blue = server(Host.BLUE);
final ServerService green = server(Host.GREEN);
red.start();
blue.start();
green.start();
final TargetRemote target = getBean(red);
assertEquals(Host.RED, target.getHost());
red.stop();
assertEquals(Host.BLUE, target.getHost());
blue.stop();
assertEquals(Host.GREEN, target.getHost());
green.stop();
try {
target.getHost();
fail("EJBException should have been thrown");
} catch (EJBException e) {
// pass
}
red.start();
assertEquals(Host.RED, target.getHost());
}
use of org.apache.openejb.server.ServerService in project tomee by apache.
the class FailoverTest method server.
private ServerService server(final Host host) throws Exception {
ServerService server = new EjbServer();
server = new HostFilter(server, host);
server = new ServiceDaemon(server, 0, "localhost");
server = new AgentFilter(server, agent, host);
server.init(new Properties());
return server;
}
use of org.apache.openejb.server.ServerService in project tomee by apache.
the class FailoverTest method testCrash.
public void testCrash() throws Exception {
agent = new TestAgent();
try {
// Properties initProps = System.getProperties();
final Properties initProps = new Properties();
initProps.setProperty("openejb.deployments.classpath.include", "");
initProps.setProperty("openejb.deployments.classpath.filter.descriptors", "true");
OpenEJB.init(initProps, new ServerFederation());
} catch (Exception e) {
}
final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
final ConfigurationFactory config = new ConfigurationFactory();
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(Target.class));
assembler.createApplication(config.configureApplication(ejbJar));
SystemInstance.get().setComponent(DiscoveryAgent.class, agent);
final ServerService red = server(Host.RED);
final ServerService blue = server(Host.BLUE);
final ServerService green = server(Host.GREEN);
red.start();
blue.start();
green.start();
final TargetRemote target = getBean(red);
assertEquals(Host.GREEN, target.kill(Host.RED, Host.BLUE).host);
assertEquals(Host.GREEN, target.getHost());
red.stop();
blue.stop();
green.stop();
try {
target.getHost();
fail("EJBException should have been thrown");
} catch (EJBException e) {
// pass
}
red.start();
assertEquals(Host.RED, target.getHost());
red.stop();
OpenEJB.destroy();
}
Aggregations