factory.setServiceClass(GreeterService.class);
factory.setAddress("http://localhost:9191/grrr");
factory.getServiceFactory().setDataBinding(new AegisDatabinding());
factory.setServiceBean(new TestGreeter());
Server server = null;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
server = factory.create();
System.out.println("Give the system a few seconds to breathe...");
Thread.sleep(3000);
Hashtable<String, Object> props = new Hashtable<String, Object>();
props.put("testName", "test1");
getBundleContext().registerService(Object.class.getName(), new Object(), props);
// Wait for the service tracker in the test bundle to register a service with the test result
ServiceReference ref = waitService(String.class.getName(), "(testResult=test1)");
Assert.assertEquals("HiOSGi", ref.getProperty("result"));
} finally {
server.stop();
Thread.currentThread().setContextClassLoader(cl);
}
}