incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r955108 - in /incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx: ./ cm/ framework/ permissionadmin/ provisioning/ test/blueprint/
Date Wed, 16 Jun 2010 01:20:31 GMT
Author: gawor
Date: Wed Jun 16 01:20:30 2010
New Revision: 955108

URL: http://svn.apache.org/viewvc?rev=955108&view=rev
Log:
ARIES-339: JMX test improvements. Based on patch from Bartosz Kowalewski

Modified:
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/cm/ConfigurationAdminMBeanTest.java
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/PackageStateMBeanTest.java
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminMBeanTest.java
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/provisioning/ProvisioningServiceMBeanTest.java
    incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/test/blueprint/BlueprintMBeanTest.java

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=955108&r1=955107&r2=955108&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
Wed Jun 16 01:20:30 2010
@@ -28,6 +28,7 @@ import static org.ops4j.pax.exam.OptionU
 import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
 import static org.junit.Assert.*;
 
+import javax.management.InstanceNotFoundException;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
@@ -49,6 +50,7 @@ import org.osgi.framework.InvalidSyntaxE
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.framework.Version;
+import org.osgi.jmx.framework.BundleStateMBean;
 import org.osgi.util.tracker.ServiceTracker;
 
 /**
@@ -83,6 +85,16 @@ public class AbstractIntegrationTest {
         assertNotNull(reference);
         MBeanServer mbeanService = (MBeanServer) bundleContext.getService(reference);
         assertNotNull(mbeanService);
+        
+        doSetUp();
+    }
+    
+    /**
+     * A hook for subclasses.
+     * 
+     * @throws Exception
+     */
+    protected void doSetUp() throws Exception {           
     }
     
     @After
@@ -91,6 +103,26 @@ public class AbstractIntegrationTest {
         //plainRegistration.unregister();
     }
     
+    protected void waitForMBean(ObjectName name) throws Exception {
+        waitForMBean(name, 10);        
+    }
+    
+    protected void waitForMBean(ObjectName name, int timeoutInSeconds) throws Exception {
+        int i=0;
+        while (true) {
+            try {
+                mbeanServer.getObjectInstance(name);
+                break;
+            } catch (InstanceNotFoundException e) {
+                if (i == timeoutInSeconds) {
+                    throw new Exception(name + " mbean is not available after waiting " +
timeoutInSeconds + " seconds");
+                }
+            }
+            i++;
+            Thread.sleep(1000);
+        }
+    }
+    
     @SuppressWarnings("unchecked")
     protected <T> T getMBean(String name, Class<T> type) {
         ObjectName objectName = null;

Modified: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/cm/ConfigurationAdminMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/cm/ConfigurationAdminMBeanTest.java?rev=955108&r1=955107&r2=955108&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/cm/ConfigurationAdminMBeanTest.java
(original)
+++ incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/cm/ConfigurationAdminMBeanTest.java
Wed Jun 16 01:20:30 2010
@@ -28,7 +28,6 @@ import static org.ops4j.pax.swissbox.tin
 import java.io.InputStream;
 import java.util.Dictionary;
 
-import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
 import javax.management.openmbean.TabularData;
 
@@ -37,7 +36,6 @@ import org.apache.aries.jmx.codec.Proper
 import org.apache.aries.jmx.test.bundlea.api.InterfaceA;
 import org.apache.aries.jmx.test.bundleb.api.InterfaceB;
 import org.apache.aries.jmx.test.bundleb.api.MSF;
-import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.ops4j.pax.exam.CoreOptions;
@@ -107,22 +105,9 @@ public class ConfigurationAdminMBeanTest
         return options;
     }
     
-    @Before
+    @Override
     public void doSetUp() throws Exception {
-        super.setUp();
-        int i=0;
-        while (true) {
-            try {
-                mbeanServer.getObjectInstance(new ObjectName(ConfigurationAdminMBean.OBJECTNAME));
-                break;
-            } catch (InstanceNotFoundException e) {
-                if (i == 5) {
-                    throw new Exception("ConfigurationAdminMBean not available after waiting
5 seconds");
-                }
-            }
-            i++;
-            Thread.sleep(1000);
-        }
+        waitForMBean(new ObjectName(ConfigurationAdminMBean.OBJECTNAME));
     }
     
     @Ignore("ManagedServiceFactory tests failing.. " +

Modified: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java?rev=955108&r1=955107&r2=955108&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java
(original)
+++ incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java
Wed Jun 16 01:20:30 2010
@@ -29,7 +29,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import javax.management.InstanceNotFoundException;
 import javax.management.Notification;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
@@ -37,7 +36,6 @@ import javax.management.openmbean.Tabula
 
 import org.apache.aries.jmx.AbstractIntegrationTest;
 import org.apache.aries.jmx.codec.BundleData.Header;
-import org.junit.Before;
 import org.junit.Test;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
@@ -106,22 +104,9 @@ public class BundleStateMBeanTest extend
         return options;
     }
     
-    @Before
+    @Override
     public void doSetUp() throws Exception {
-        super.setUp();
-        int i=0;
-        while (true) {
-            try {
-                mbeanServer.getObjectInstance(new ObjectName(BundleStateMBean.OBJECTNAME));
-                break;
-            } catch (InstanceNotFoundException e) {
-                if (i == 5) {
-                    throw new Exception("BundleStateMBean not available after waiting 5 seconds");
-                }
-            }
-            i++;
-            Thread.sleep(1000);
-        }
+        waitForMBean(new ObjectName(BundleStateMBean.OBJECTNAME));
     }
 
     @Test
@@ -204,7 +189,7 @@ public class BundleStateMBeanTest extend
         
         long[] requiring = mbean.getRequiringBundles(a.getBundleId());
         assertEquals(3, requiring.length);
-        assertTrue(b.getSymbolicName(), arrayContains(frag.getBundleId(), requiring));
+        assertTrue(b.getSymbolicName(), arrayContains(b.getBundleId(), requiring));
         assertTrue(frag.getSymbolicName(), arrayContains(frag.getBundleId(), requiring));
         assertTrue(d.getSymbolicName(), arrayContains(d.getBundleId(), requiring));
         

Modified: 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=955108&r1=955107&r2=955108&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java
(original)
+++ incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/FrameworkMBeanTest.java
Wed Jun 16 01:20:30 2010
@@ -27,6 +27,7 @@ import java.io.IOException;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 
+import javax.management.ObjectName;
 import javax.management.openmbean.CompositeData;
 
 import org.apache.aries.jmx.AbstractIntegrationTest;
@@ -58,6 +59,11 @@ public class FrameworkMBeanTest extends 
         return options;
     }
 
+    @Override
+    public void doSetUp() throws Exception {
+        waitForMBean(new ObjectName(FrameworkMBean.OBJECTNAME));
+    }
+    
     @Test
     public void testMBeanInterface() throws IOException {
         FrameworkMBean framework = getMBean(FrameworkMBean.OBJECTNAME, FrameworkMBean.class);

Modified: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/PackageStateMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/PackageStateMBeanTest.java?rev=955108&r1=955107&r2=955108&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/PackageStateMBeanTest.java
(original)
+++ incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/PackageStateMBeanTest.java
Wed Jun 16 01:20:30 2010
@@ -25,12 +25,10 @@ import static org.junit.Assert.assertTru
 import java.io.IOException;
 import java.util.Collection;
 
-import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
 import javax.management.openmbean.TabularData;
 
 import org.apache.aries.jmx.AbstractIntegrationTest;
-import org.junit.Before;
 import org.junit.Test;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
@@ -53,22 +51,9 @@ public class PackageStateMBeanTest exten
         return options;
     }
 
-    @Before
+    @Override
     public void doSetUp() throws Exception {
-        super.setUp();
-        int i = 0;
-        while (true) {
-            try {
-                mbeanServer.getObjectInstance(new ObjectName(PackageStateMBean.OBJECTNAME));
-                break;
-            } catch (InstanceNotFoundException e) {
-                if (i == 5) {
-                    throw new Exception("PackageStateMBean not available after waiting 5
seconds");
-                }
-            }
-            i++;
-            Thread.sleep(1000);
-        }
+        waitForMBean(new ObjectName(PackageStateMBean.OBJECTNAME));
     }
 
     @Test

Modified: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java?rev=955108&r1=955107&r2=955108&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
(original)
+++ incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
Wed Jun 16 01:20:30 2010
@@ -30,7 +30,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import javax.management.InstanceNotFoundException;
 import javax.management.Notification;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
@@ -40,7 +39,6 @@ import org.apache.aries.jmx.AbstractInte
 import org.apache.aries.jmx.codec.PropertyData;
 import org.apache.aries.jmx.test.bundlea.api.InterfaceA;
 import org.apache.aries.jmx.test.bundleb.api.InterfaceB;
-import org.junit.Before;
 import org.junit.Test;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Customizer;
@@ -110,24 +108,10 @@ public class ServiceStateMBeanTest exten
         return options;
     }
     
-    @Before
+    @Override
     public void doSetUp() throws Exception {
-        super.setUp();
-        int i=0;
-        while (true) {
-            try {
-                mbeanServer.getObjectInstance(new ObjectName(ServiceStateMBean.OBJECTNAME));
-                break;
-            } catch (InstanceNotFoundException e) {
-                if (i == 5) {
-                    throw new Exception("ServiceStateMBean not available after waiting 5
seconds");
-                }
-            }
-            i++;
-            Thread.sleep(1000);
-        }
-    }
-    
+        waitForMBean(new ObjectName(ServiceStateMBean.OBJECTNAME));
+    }    
     
     @Test
     public void testMBeanInterface() throws Exception {

Modified: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminMBeanTest.java?rev=955108&r1=955107&r2=955108&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminMBeanTest.java
(original)
+++ incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminMBeanTest.java
Wed Jun 16 01:20:30 2010
@@ -24,11 +24,9 @@ import static org.ops4j.pax.swissbox.tin
 
 import java.io.IOException;
 
-import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
 
 import org.apache.aries.jmx.AbstractIntegrationTest;
-import org.junit.Before;
 import org.junit.Test;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
@@ -70,22 +68,9 @@ public class PermissionAdminMBeanTest ex
         return options;
     }
     
-    @Before
+    @Override
     public void doSetUp() throws Exception {
-        super.setUp();
-        int i = 0;
-        while (true) {
-            try {
-                mbeanServer.getObjectInstance(new ObjectName(PermissionAdminMBean.OBJECTNAME));
-                break;
-            } catch (InstanceNotFoundException e) {
-                if (i == 5) {
-                    throw new Exception("PermissionAdminMBean not available after waiting
5 seconds");
-                }
-            }
-            i++;
-            Thread.sleep(1000);
-        }
+        waitForMBean(new ObjectName(PermissionAdminMBean.OBJECTNAME));
     }
 
     @Test

Modified: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/provisioning/ProvisioningServiceMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/provisioning/ProvisioningServiceMBeanTest.java?rev=955108&r1=955107&r2=955108&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/provisioning/ProvisioningServiceMBeanTest.java
(original)
+++ incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/provisioning/ProvisioningServiceMBeanTest.java
Wed Jun 16 01:20:30 2010
@@ -31,13 +31,11 @@ import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
 
-import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
 import javax.management.openmbean.TabularData;
 
 import org.apache.aries.jmx.AbstractIntegrationTest;
 import org.apache.aries.jmx.codec.PropertyData;
-import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.ops4j.pax.exam.CoreOptions;
@@ -70,27 +68,10 @@ public class ProvisioningServiceMBeanTes
         return options;
     }
 
-    @Before
+    @Override
     public void doSetUp() throws Exception {
-        super.setUp();
-        int i=0;
-        while (true) {
-            try {
-                mbeanServer.getObjectInstance(new ObjectName(ProvisioningServiceMBean.OBJECTNAME));
-                break;
-            } catch (InstanceNotFoundException e) {
-                if (i == 5) {
-                    throw new Exception("ProvisioningServiceMBean not available after waiting
5 seconds");
-                }
-            }
-            i++;
-            Thread.sleep(1000);
-        }
-       
-      
+        waitForMBean(new ObjectName(ProvisioningServiceMBean.OBJECTNAME));
     }
-    
-  
 
     @Ignore("For now.. Cannot find public repo for org.eclipse.equinox.ip")
     @Test

Modified: incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/test/blueprint/BlueprintMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/test/blueprint/BlueprintMBeanTest.java?rev=955108&r1=955107&r2=955108&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/test/blueprint/BlueprintMBeanTest.java
(original)
+++ incubator/aries/trunk/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/test/blueprint/BlueprintMBeanTest.java
Wed Jun 16 01:20:30 2010
@@ -21,9 +21,6 @@ package org.apache.aries.jmx.test.bluepr
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
 import javax.management.ObjectName;
 import javax.management.openmbean.TabularData;
@@ -43,21 +40,14 @@ import org.apache.aries.jmx.test.bluepri
 import org.apache.aries.jmx.test.blueprint.framework.RegistrationListenerValidator;
 import org.apache.aries.jmx.test.blueprint.framework.ServiceValidator;
 import org.apache.aries.jmx.test.blueprint.framework.ValueValidator;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
-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.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 
 public class BlueprintMBeanTest extends AbstractIntegrationTest {
@@ -79,27 +69,10 @@ public class BlueprintMBeanTest extends 
         return options;
     }  
 
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Before Test");
-       
-       // Wait MBeans register in server
-       int i=0;
-       while (true) {
-           try {
-               mbeanServer.getObjectInstance(new ObjectName(BlueprintStateMBean.OBJECTNAME));
-               mbeanServer.getObjectInstance(new ObjectName(BlueprintMetadataMBean.OBJECTNAME));
-               System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Found MBeans");
-               break;
-           } catch (InstanceNotFoundException e) {
-               if (i == 5) {
-                   throw new Exception(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
BlueprintStateMBean & BlueprintMetadataMBean are not found in server");
-               }
-           }
-           i++;
-           Thread.sleep(100);
-       }
+    @Override
+    public void doSetUp() throws Exception {
+        waitForMBean(new ObjectName(BlueprintStateMBean.OBJECTNAME));
+        waitForMBean(new ObjectName(BlueprintMetadataMBean.OBJECTNAME));
        
        // Wait enough time for osgi framework and blueprint bundles to be set up
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Waiting for bundles to be set up");



Mime
View raw message