public class Test extends AbstractIntegrationTest {
private static final String PLATFORM_TRANSACTION_MANAGER_CLASS = "org.springframework.transaction.PlatformTransactionManager";
public void test() throws Exception {
ServiceTracker tracker = new ServiceTracker(bundleContext, TransactionManager.class.getName(), null);
tracker.open();
tracker.waitForService(5000L);
ServiceReference ref = tracker.getServiceReference();
assertNotNull(ref);
String[] objClass = (String[]) ref.getProperty(Constants.OBJECTCLASS);
assertNotNull(objClass);
boolean found = false;
for (String clazz : objClass) {
found |= PLATFORM_TRANSACTION_MANAGER_CLASS.equals(clazz);
}
assertFalse(found);
Bundle bundle = ref.getBundle();
bundle.stop();
installBundle("org.springframework", "spring-tx", null, "jar");
getOsgiService(PackageAdmin.class).refreshPackages(new Bundle[] { bundle });
System.err.println("Bundle refreshed");
Thread.sleep(500);
System.err.println("Starting bundle");
bundle.start();
tracker.waitForService(5000L);
ref = tracker.getServiceReference();
assertNotNull(ref);
objClass = (String[]) ref.getProperty(Constants.OBJECTCLASS);
assertNotNull(objClass);
found = false;
for (String clazz : objClass) {
found |= PLATFORM_TRANSACTION_MANAGER_CLASS.equals(clazz);
}
assertTrue(found);
tracker.close();
}