initProps.setProperty("openejb.deployments.classpath.include", "");
initProps.setProperty("openejb.deployments.classpath.filter.descriptors", "true");
OpenEJB.init(initProps, new ServerFederation());
ejbServer.init(new Properties());
ServiceDaemon serviceDaemon = new ServiceDaemon(ejbServer, 0, "localhost");
serviceDaemon.start();
int port = serviceDaemon.getPort();
Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
ConfigurationFactory config = new ConfigurationFactory();
EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean("Orange", Fruit.class));
ejbJar.addEnterpriseBean(new StatelessBean("Apple", Fruit.class));
ejbJar.addEnterpriseBean(new StatelessBean("Peach", Fruit.class));
ejbJar.addEnterpriseBean(new StatelessBean("Pear", Fruit.class));
ejbJar.addEnterpriseBean(new StatelessBean("Plum", Fruit.class));
ejbJar.addEnterpriseBean(new StatelessBean("ejb/Orange", Fruit.class));
ejbJar.addEnterpriseBean(new StatelessBean("ejb/Apple", Fruit.class));
ejbJar.addEnterpriseBean(new StatelessBean("ejb/Peach", Fruit.class));
ejbJar.addEnterpriseBean(new StatelessBean("ejb/Pear", Fruit.class));
ejbJar.addEnterpriseBean(new StatelessBean("ejb/Plum", Fruit.class));
assembler.createApplication(config.configureApplication(ejbJar));
try {
// good creds
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
props.put("java.naming.provider.url", "ejbd://127.0.0.1:" + port);
Context context = new InitialContext(props);
assertNameClassPair(context.list(""));
assertNameClassPair(context.list("ejb"));
assertBindings(context.listBindings(""));
assertBindings(context.listBindings("ejb"));
} finally {
serviceDaemon.stop();
OpenEJB.destroy();
}
}