Author: adietish
Date: 2011-08-25 07:35:14 -0400 (Thu, 25 Aug 2011)
New Revision: 34308
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/JBossManagementServiceTest.java
Log:
[JBIDE-9586] make sure that service bundle is started
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/JBossManagementServiceTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/JBossManagementServiceTest.java 2011-08-25
11:34:01 UTC (rev 34307)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/internal/management/as7/tests/JBossManagementServiceTest.java 2011-08-25
11:35:14 UTC (rev 34308)
@@ -15,6 +15,7 @@
import java.net.UnknownHostException;
import org.jboss.ide.eclipse.as.core.server.v7.management.IJBoss7ManagerService;
+import org.jboss.ide.eclipse.as.internal.management.as7.AS7ManagementActivator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -42,35 +43,48 @@
@Test
public void serviceIsReachable() throws BundleException {
ensureDSIsRunning();
+ ensureServiceBundleIsRunning();
BundleContext context = Activator.getContext();
- ServiceReference<IJBoss7ManagerService> reference =
+ ServiceReference<IJBoss7ManagerService> reference =
context.getServiceReference(IJBoss7ManagerService.class);
assertNotNull(reference);
IJBoss7ManagerService service = context.getService(reference);
assertNotNull(service);
}
+ private void ensureServiceBundleIsRunning() throws BundleException {
+ BundleContext context = Activator.getContext();
+ assertNotNull("bundle of this test is not active", context);
+ Bundle bundle = getBundle(AS7ManagementActivator.PLUGIN_ID);
+ assertNotNull(AS7ManagementActivator.PLUGIN_ID + " not installed", bundle);
+ startBundle(bundle);
+ }
+
private void ensureDSIsRunning() throws BundleException {
BundleContext context = Activator.getContext();
assertNotNull("bundle of this test is not active", context);
- Bundle bundle = getDSBundle();
+ Bundle bundle = getBundle(DS_BUNDLEID);
assertNotNull(
DS_BUNDLEID + " not installed. You have to install the declarative services
daemon so that "
+ IJBoss7ManagerService.class + " service is registered"
, bundle);
+ startBundle(bundle);
+ }
+
+ private void startBundle(Bundle bundle) throws BundleException {
if (bundle.getState() != Bundle.ACTIVE) {
bundle.start();
}
}
- private Bundle getDSBundle() {
- Bundle dsBundle = null;
+ private Bundle getBundle(String id) {
+ Bundle bundleFound = null;
for (Bundle bundle : Activator.getContext().getBundles()) {
- if (DS_BUNDLEID.equals(bundle.getSymbolicName())) {
- dsBundle = bundle;
+ if (id.equals(bundle.getSymbolicName())) {
+ bundleFound = bundle;
break;
}
}
- return dsBundle;
+ return bundleFound;
}
}
Show replies by date