Author: adietish
Date: 2011-04-23 09:58:56 -0400 (Sat, 23 Apr 2011)
New Revision: 30805
Added:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementServiceIntegrationTest.java
Removed:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java
Modified:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagementUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/META-INF/jboss-management-service.xml
Log:
[JBIDE-8784] added service availability test, added server version property &
constant
Modified: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/META-INF/MANIFEST.MF 2011-04-23
11:55:49 UTC (rev 30804)
+++ trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/META-INF/MANIFEST.MF 2011-04-23
13:58:56 UTC (rev 30805)
@@ -11,3 +11,5 @@
org.hamcrest;bundle-version="[1.1.0,2.0.0)"
Bundle-ClassPath: .,
wars/
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.jboss.ide.eclipse.as.management.as7.tests.Activator
Deleted:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java
===================================================================
---
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java 2011-04-23
11:55:49 UTC (rev 30804)
+++
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java 2011-04-23
13:58:56 UTC (rev 30805)
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.ide.eclipse.as.management.as7.tests;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.UnknownHostException;
-import java.util.concurrent.ExecutionException;
-
-import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7DeploymentState;
-import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ManangementException;
-import org.jboss.ide.eclipse.as.management.as7.deployment.AS7Manager;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- *
- * @author André Dietisheim
- */
-public class JBossManagementIntegrationTest {
-
- private AS7Manager manager;
-
- @Before
- public void setUp() throws UnknownHostException {
- this.manager = new AS7Manager(AS7ManagerTestUtils.HOST,
AS7ManagerTestUtils.MGMT_PORT);
- }
-
- @After
- public void tearDown() {
- manager.dispose();
- }
-
- @Ignore
- @Test
- public void canDeploy() throws Exception {
- File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
- try {
- AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
-
- String response = AS7ManagerTestUtils.waitForRespose(
- "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
- assertTrue(response != null
- && response.indexOf("minimalistic") >= 0);
- } finally {
- AS7ManagerTestUtils.quietlyUndeploy(warFile, manager);
- }
- }
-
- @Ignore
- @Test
- public void deployedWarIsResponding() throws Exception {
- File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
- try {
- AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
-
- String response = AS7ManagerTestUtils.waitForRespose(
- "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
- assertTrue(response != null
- && response.indexOf("minimalistic") >= 0);
-
- } finally {
- AS7ManagerTestUtils.quietlyUndeploy(warFile, manager);
- }
- }
-
- @Ignore
- @Test(expected = JBoss7ManangementException.class)
- public void cannotDeployWarTwice() throws Exception {
- File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
- try {
- AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
- AS7ManagerTestUtils.waitUntilFinished(manager.deploy(warFile));
- } finally {
- AS7ManagerTestUtils.quietlyUndeploy(warFile, manager);
- }
- }
-
- @Ignore
- @Test(expected = JBoss7ManangementException.class)
- public void cannotUndeployNondeployed() throws JBoss7ManangementException,
InterruptedException, ExecutionException {
- AS7ManagerTestUtils.waitUntilFinished(manager.undeploy("inexistant"));
- }
-
- @Ignore
- @Test
- public void canReplaceWar() throws Exception {
- File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
- File warFile2 =
AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.GWT_HELLOWORLD_WAR);
- String name = warFile.getName();
- try {
- AS7ManagerTestUtils.waitUntilFinished(manager.deploy(name, warFile));
- AS7ManagerTestUtils.waitUntilFinished(manager.replace(name, warFile2));
- String response = AS7ManagerTestUtils.waitForRespose(
- "minimalistic", AS7ManagerTestUtils.HOST, AS7ManagerTestUtils.WEB_PORT);
- assertTrue(response != null
- && response.indexOf("GWT") >= 0);
- } finally {
- AS7ManagerTestUtils.quietlyUndeploy(name, manager);
- }
- }
-
- @Test
- public void getEnabledStateIfDeploymentIsDeployed() throws URISyntaxException,
IOException, JBoss7ManangementException {
- String deploymentName = "testDeployment";
- File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
- try {
- AS7ManagerTestUtils.waitUntilFinished(manager.deploy(deploymentName, warFile));
- JBoss7DeploymentState state = manager.getDeploymentState(deploymentName);
- assertNotNull(state);
- assertThat(state, equalTo(JBoss7DeploymentState.STARTED));
- } finally {
- AS7ManagerTestUtils.quietlyUndeploy(deploymentName, manager);
- }
- }
-
- @Test
- public void getDisabledStateIfDeploymentIsOnlyAdded() throws URISyntaxException,
IOException, JBoss7ManangementException {
- String deploymentName = "testDeployment";
- File warFile = AS7ManagerTestUtils.getWarFile(AS7ManagerTestUtils.MINIMALISTIC_WAR);
- try {
- AS7ManagerTestUtils.waitUntilFinished(manager.add(deploymentName, warFile));
- JBoss7DeploymentState state = manager.getDeploymentState(deploymentName);
- assertNotNull(state);
- assertThat(state, equalTo(JBoss7DeploymentState.STOPPED));
- } finally {
- AS7ManagerTestUtils.quietlyRemove(deploymentName, manager);
- }
- }
-
- @Test(expected = JBoss7ManangementException.class)
- public void getErrorIfDeploymentIsNotDeployed() throws URISyntaxException, IOException,
JBoss7ManangementException {
- String deploymentName = "testDeployment";
- try {
- manager.getDeploymentState(deploymentName);
- } finally {
- AS7ManagerTestUtils.quietlyUndeploy(deploymentName, manager);
- }
- }
-}
Copied:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementServiceIntegrationTest.java
(from rev 30803,
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java)
===================================================================
---
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementServiceIntegrationTest.java
(rev 0)
+++
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementServiceIntegrationTest.java 2011-04-23
13:58:56 UTC (rev 30805)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.management.as7.tests;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.net.UnknownHostException;
+
+import org.jboss.ide.eclipse.as.core.server.internal.v7.IJBoss7ManagementService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ *
+ * @author André Dietisheim
+ */
+public class JBossManagementServiceIntegrationTest {
+
+ private static final String DS_BUNDLEID = "org.eclipse.equinox.ds";
+
+ @Before
+ public void setUp() throws UnknownHostException {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void serviceIsReachable() throws BundleException {
+ ensureDSIsRunning();
+ BundleContext context = Activator.getContext();
+ ServiceReference<IJBoss7ManagementService> reference =
+ context.getServiceReference(IJBoss7ManagementService.class);
+ assertNotNull(reference);
+ IJBoss7ManagementService service = context.getService(reference);
+ assertNotNull(service);
+ }
+
+ private void ensureDSIsRunning() throws BundleException {
+ BundleContext context = Activator.getContext();
+ assertNotNull("bundle of this test is not active", context);
+ Bundle bundle = getDSBundle();
+ assertNotNull(
+ DS_BUNDLEID + " not installed. You have to install the declarative services
daemon so that "
+ + IJBoss7ManagementService.class + " service is registered"
+ , bundle);
+ if (bundle.getState() != Bundle.ACTIVE) {
+ bundle.start();
+ }
+ }
+
+ private Bundle getDSBundle() {
+ Bundle dsBundle = null;
+ for (Bundle bundle : Activator.getContext().getBundles()) {
+ if (DS_BUNDLEID.equals(bundle.getSymbolicName())) {
+ dsBundle = bundle;
+ break;
+ }
+ }
+ return dsBundle;
+ }
+}
Property changes on:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementServiceIntegrationTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagementUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagementUtil.java 2011-04-23
11:55:49 UTC (rev 30804)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagementUtil.java 2011-04-23
13:58:56 UTC (rev 30805)
@@ -7,47 +7,50 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal.v7;
+import java.util.Collection;
+import java.util.Iterator;
+
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
public class JBoss7ManagementUtil {
+ public static final String SERVER_VERSION_PROPERTY = "as.version";
//$NON-NLS-1$
+
public static final String SERVICE_VERSION_70 =
"org.jboss.ide.eclipse.as.management.as7.service"; //$NON-NLS-1$
-
+
public static IJBoss7ManagementService findManagementService(IServer server) {
- BundleContext context = JBossServerCorePlugin.getDefault().getContext();
-
-// String tmp = "org.jboss.ide.eclipse.as.management.as7.service";
//$NON-NLS-1$
-// String clazz =
"org.jboss.ide.eclipse.as.management.as7.deployment.JBossManagementService";
//$NON-NLS-1$
- String iface = "IJBoss7ManagementService"; //$NON-NLS-1$
- String clazz3 = "org.jboss.ide.eclipse.as.core.server.internal.v7." + iface;
//$NON-NLS-1$
+ BundleContext context = JBossServerCorePlugin.getContext();
+
+ // String tmp = "org.jboss.ide.eclipse.as.management.as7.service";
//$NON-NLS-1$
+ // String clazz =
"org.jboss.ide.eclipse.as.management.as7.deployment.JBossManagementService";
//$NON-NLS-1$
+ // String iface = "IJBoss7ManagementService"; //$NON-NLS-1$
+ // String clazz3 = "org.jboss.ide.eclipse.as.core.server.internal.v7." +
iface; //$NON-NLS-1$
String requiredService = getRequiredServiceName(server);
- if( requiredService == null )
+ if (requiredService == null)
return null;
-
+
try {
- ServiceReference[] refs = context.getServiceReferences(clazz3, null);
- for( int i = 0; i < refs.length; i++ ) {
- Object compName = refs[i].getProperty("component.name"); //$NON-NLS-1$
- if( requiredService.equals(compName)) {
- Bundle b = refs[i].getBundle();
- Object service2 = context.getService(refs[i]);
- if( service2 instanceof IJBoss7ManagementService ) {
- return ((IJBoss7ManagementService)service2);
- }
+ Collection<ServiceReference<IJBoss7ManagementService>> references =
context.getServiceReferences(
+ IJBoss7ManagementService.class, null);
+ for (Iterator<ServiceReference<IJBoss7ManagementService>> iterator =
references.iterator();
+ iterator.hasNext();) {
+ ServiceReference<IJBoss7ManagementService> reference = iterator.next();
+ Object compName = reference.getProperty("component.name"); //$NON-NLS-1$
+ if (requiredService.equals(compName)) {
+ return context.getService(reference);
}
}
- } catch(InvalidSyntaxException ise ) {
+ } catch (InvalidSyntaxException ise) {
}
return null;
}
-
+
private static String getRequiredServiceName(IServer s) {
// TODO if required, make sure to add new versions here
return SERVICE_VERSION_70;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/META-INF/jboss-management-service.xml
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/META-INF/jboss-management-service.xml 2011-04-23
11:55:49 UTC (rev 30804)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/META-INF/jboss-management-service.xml 2011-04-23
13:58:56 UTC (rev 30805)
@@ -4,4 +4,5 @@
<service>
<provide
interface="org.jboss.ide.eclipse.as.core.server.internal.v7.IJBoss7ManagementService"/>
</service>
+ <property name="as.version" type="String"
value="7"/>
</scr:component>