You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by aw...@apache.org on 2009/12/15 00:17:15 UTC

svn commit: r890548 - in /incubator/aries/trunk/jmx: jmx-core/ jmx-itests/ jmx-itests/src/test/java/org/apache/aries/jmx/ jmx-itests/src/test/java/org/apache/aries/jmx/framework/

Author: awojtuniak
Date: Mon Dec 14 23:17:15 2009
New Revision: 890548

URL: http://svn.apache.org/viewvc?rev=890548&view=rev
Log:
ARIES-30 initial integration tests for FrameworkMBean and the rest of MBeans.

Added:
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java   (with props)
Modified:
    incubator/aries/trunk/jmx/jmx-core/pom.xml
    incubator/aries/trunk/jmx/jmx-itests/pom.xml
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java

Modified: incubator/aries/trunk/jmx/jmx-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-core/pom.xml?rev=890548&r1=890547&r2=890548&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-core/pom.xml (original)
+++ incubator/aries/trunk/jmx/jmx-core/pom.xml Mon Dec 14 23:17:15 2009
@@ -83,7 +83,7 @@
 						</Import-Package>
 						<!-- Not currently exporting anything -->
                         <Export-Package>
-                           !* 
+                           	org.apache.aries.jmx.codec;;version=${project.version} 
                         </Export-Package>
                         <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
                         <_removeheaders>Ignore-Package,Include-Resource,Private-Package,Bundle-DocURL</_removeheaders>

Modified: incubator/aries/trunk/jmx/jmx-itests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-itests/pom.xml?rev=890548&r1=890547&r2=890548&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/pom.xml (original)
+++ incubator/aries/trunk/jmx/jmx-itests/pom.xml Mon Dec 14 23:17:15 2009
@@ -42,9 +42,30 @@
 	<dependencies>
 		<dependency>
 			<groupId>org.apache.aries.jmx</groupId>
+			<artifactId>aries-jmx-api</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.jmx</groupId>
+			<artifactId>aries-jmx-core</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.core</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<!--<dependency>
+			<groupId>org.apache.aries.jmx</groupId>
 			<artifactId>aries-jmx</artifactId>
 			<scope>provided</scope>
 		</dependency>
+		-->
 		<dependency>
 			<groupId>org.ops4j.pax.exam</groupId>
 			<artifactId>pax-exam</artifactId>

Modified: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java?rev=890548&r1=890547&r2=890548&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java (original)
+++ incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java Mon Dec 14 23:17:15 2009
@@ -18,13 +18,24 @@
 
 import static org.ops4j.pax.exam.CoreOptions.mavenConfiguration;
 import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.junit.Assert.*;
 
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+
+import org.junit.After;
+import org.junit.Before;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Inject;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.Configuration;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
 
 /**
  * 
@@ -34,18 +45,57 @@
  */
 @RunWith(JUnit4TestRunner.class)
 public class AbstractIntegrationTest {
+    
+    ServiceRegistration registration;
+    ServiceReference reference;
+    MBeanServer mbeanServer;
 
     @Inject
-    protected BundleContext context;
+    protected BundleContext bundleContext;
     
     @Configuration
-    public static Option[] config()
+    public static Option[] configure()
     {
         return options(
+            CoreOptions.equinox(),
             mavenConfiguration()
         );
     }
     
-   
-   
-}
+    @Before
+    public void setUp() throws Exception {
+        mbeanServer = MBeanServerFactory.createMBeanServer();
+
+        registration = bundleContext.registerService(MBeanServer.class
+                .getCanonicalName(), mbeanServer, null);
+            
+        String key = MBeanServer.class.getCanonicalName();
+        System.out.println(key);
+
+        reference = bundleContext.getServiceReference(key);
+        assertNotNull(reference);
+        MBeanServer mbeanService = (MBeanServer) bundleContext.getService(reference);
+        assertNotNull(mbeanService);
+    }
+    
+    @After
+    public void tearDown() throws Exception {
+        bundleContext.ungetService(reference);
+        registration.unregister();
+    }
+    
+    protected <T> T getMBean(String name, Class<T> type) {
+        ObjectName objectName = null;
+        try {
+            objectName = new ObjectName(name);
+        } catch (Exception e) {
+            fail(e.toString());
+        }
+        assertNotNull(mbeanServer);
+        assertNotNull(objectName);
+        T mbean = (T) MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName,
+                type, false);
+        return mbean;
+    }
+
+}
\ No newline at end of file

Added: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java?rev=890548&view=auto
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java (added)
+++ incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java Mon Dec 14 23:17:15 2009
@@ -0,0 +1,53 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.jmx.framework;
+
+import java.io.IOException;
+
+import javax.management.openmbean.CompositeData;
+
+import static junit.framework.Assert.*;
+
+import org.apache.aries.jmx.AbstractIntegrationTest;
+import org.apache.aries.jmx.codec.BatchActionResult;
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.jmx.framework.FrameworkMBean;
+
+/**
+ * 
+ * 
+ * @version $Rev$ $Date$
+ */
+public class FrameworkMBeanTest extends AbstractIntegrationTest {
+
+    @Test
+    public void testSetBundleStartLevels() throws IOException {
+        FrameworkMBean framework = getMBean(FrameworkMBean.OBJECTNAME, FrameworkMBean.class);
+        assertNotNull(framework);
+        long[] bundleIds = new long[]{1,2};
+        int[] newlevels = new int[]{1,1};
+        CompositeData compData = framework.setBundleStartLevels(bundleIds, newlevels);
+        assertNotNull(compData);
+        BatchActionResult batch2 = BatchActionResult.from(compData);
+        Assert.assertNotNull(batch2.getCompleted());
+        Assert.assertTrue(batch2.isSuccess());
+        Assert.assertNull(batch2.getError());
+        Assert.assertNull(batch2.getRemainingItems());
+    }
+
+}
\ No newline at end of file

Propchange: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java
------------------------------------------------------------------------------
    svn:keywords = Revision Date