Author: thomas.diesler(a)jboss.com
Date: 2009-06-02 07:32:13 -0400 (Tue, 02 Jun 2009)
New Revision: 89663
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleA/SomeService.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleB/SomeBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleB/SomeBeanMBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/service/mcservice/mcservice-bundleB.bnd
Log:
Add JMX access to test
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-06-02
11:19:21 UTC (rev 89662)
+++
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-06-02
11:32:13 UTC (rev 89663)
@@ -29,6 +29,8 @@
import static org.jboss.osgi.spi.service.MicrocontainerService.BEAN_MBEAN_SERVER;
import static
org.jboss.osgi.spi.service.MicrocontainerService.BEAN_SYSTEM_BUNDLE_CONTEXT;
import static
org.jboss.osgi.spi.service.MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE;
+import static
org.jboss.test.osgi.service.microcontainer.bundleB.SomeBeanMBean.MBEAN_NAME;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -42,10 +44,12 @@
import org.jboss.osgi.spi.management.MBeanProxy;
import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
import org.jboss.osgi.spi.service.DeployerService;
+import org.jboss.osgi.spi.service.MicrocontainerService;
import org.jboss.osgi.spi.service.MicrocontainerServiceMBean;
import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.jboss.osgi.spi.testing.OSGiTest;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.test.osgi.service.microcontainer.bundleB.SomeBeanMBean;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -119,6 +123,10 @@
List<String> registeredBeans = mcService.getRegisteredBeans();
assertTrue("SomeBean registered",
registeredBeans.contains("SomeBean"));
+ // Access the bean through JMX
+ SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, MBEAN_NAME,
runtime.getMBeanServer());
+ assertEquals("hello", someBean.echo("hello"));
+
deployer.undeploy(getTestArchiveURL("service/mcservice-bundleB.jar"));
// Check whether the bean is unregistered
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleA/SomeService.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleA/SomeService.java 2009-06-02
11:19:21 UTC (rev 89662)
+++
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleA/SomeService.java 2009-06-02
11:32:13 UTC (rev 89663)
@@ -30,7 +30,7 @@
import org.osgi.framework.ServiceReference;
/**
- * A service that accesses the MicrocontainerService
+ * A service that accesses the {@link MicrocontainerService}
*
* @author thomas.diesler(a)jboss.com
* @since 24-Apr-2009
@@ -49,13 +49,6 @@
throw new IllegalStateException("No BundleContext as MC Bean");
}
-// public String callSomeBean(String msg)
-// {
-// MicrocontainerService mcService = getMicrocontainerService();
-// SomeBean bean = (SomeBean)mcService.getRegisteredBean(SomeBean.class.getName());
-// return bean.echo(msg);
-// }
-
public String echo(String msg)
{
return msg;
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleB/SomeBean.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleB/SomeBean.java 2009-06-02
11:19:21 UTC (rev 89662)
+++
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleB/SomeBean.java 2009-06-02
11:32:13 UTC (rev 89663)
@@ -24,8 +24,8 @@
//$Id$
import javax.management.MBeanServer;
-import javax.management.ObjectName;
+
/**
* An MC bean that accesses some OSGi service
*
@@ -43,12 +43,12 @@
public void create() throws Exception
{
- mbeanServer.registerMBean(this, new
ObjectName("jboss.osgi:bean=SomeBean"));
+ mbeanServer.registerMBean(this, MBEAN_NAME);
}
public void destroy() throws Exception
{
- mbeanServer.unregisterMBean(new ObjectName("jboss.osgi:bean=SomeBean"));
+ mbeanServer.unregisterMBean(MBEAN_NAME);
}
public String echo(String msg)
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleB/SomeBeanMBean.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleB/SomeBeanMBean.java 2009-06-02
11:19:21 UTC (rev 89662)
+++
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/bundleB/SomeBeanMBean.java 2009-06-02
11:32:13 UTC (rev 89663)
@@ -23,7 +23,13 @@
//$Id$
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+
public interface SomeBeanMBean
{
+ ObjectName MBEAN_NAME =
ObjectNameFactory.create("jboss.osgi:bean=SomeBean");
+
String echo(String msg);
}
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/service/mcservice/mcservice-bundleB.bnd
===================================================================
---
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/service/mcservice/mcservice-bundleB.bnd 2009-06-02
11:19:21 UTC (rev 89662)
+++
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/service/mcservice/mcservice-bundleB.bnd 2009-06-02
11:32:13 UTC (rev 89663)
@@ -4,7 +4,7 @@
Export-Package: org.jboss.test.osgi.service.microcontainer.bundleB
-Import-Package: javax.management
+Import-Package: javax.management, org.jboss.osgi.spi.management
Include-Resource: META-INF/mcservice-jboss-beans.xml=META-INF/mcservice-jboss-beans.xml
-removeheaders: Include-Resource
Show replies by date