You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by rw...@apache.org on 2009/12/15 09:42:15 UTC

svn commit: r890690 - in /geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test: ./ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/geronimo/ src/main/java/org/apache/geronimo/blueprint/ src/main/java/org/apache/geronimo/blu...

Author: rwonly
Date: Tue Dec 15 08:42:13 2009
New Revision: 890690

URL: http://svn.apache.org/viewvc?rev=890690&view=rev
Log:
the main work of integration test finished.

Added:
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/App.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/BlueprintMBeanTest.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanArgumentValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanPropertyValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BlueprintEventValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CollectionValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CompositeDataValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/MapEntryValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ObjectValueValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RefValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceListValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceListenerValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RegistrationListenerValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceReferenceValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/TargetValidator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/Util.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/Validator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ValueValidator.java
Modified:
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/pom.xml

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/pom.xml?rev=890690&r1=890689&r2=890690&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/pom.xml (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/pom.xml Tue Dec 15 08:42:13 2009
@@ -13,15 +13,12 @@
 
 	<dependencies>
         <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
-            <version>4.2.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
-            <version>4.2.0</version>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.5</version>
         </dependency>
+        
+        <!-- test target -->
 		<dependency>
             <groupId>org.apache.geronimo.blueprint</groupId>
             <artifactId>org.apache.geronimo.blueprint.jmx</artifactId>
@@ -31,30 +28,92 @@
             <groupId>org.apache.geronimo.blueprint</groupId>
             <artifactId>org.apache.geronimo.blueprint.jmx.impl</artifactId>
             <version>1.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <!-- test infrastructure bundles -->
+		<dependency>
+            <groupId>org.apache.geronimo.blueprint</groupId>
+            <artifactId>geronimo-blueprint</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.blueprint</groupId>
+            <artifactId>org.apache.geronimo.blueprint.sample</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.logging</groupId>
+            <artifactId>pax-logging-api</artifactId>
+            <version>1.4</version>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.sun.jdmk</groupId>
+                    <artifactId>jmxtools</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.sun.jmx</groupId>
+                    <artifactId>jmxri</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.logging</groupId>
+            <artifactId>pax-logging-service</artifactId>
+            <version>1.4</version>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.sun.jdmk</groupId>
+                    <artifactId>jmxtools</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.sun.jmx</groupId>
+                    <artifactId>jmxri</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.configadmin</artifactId>
+            <version>1.2.4</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <!-- test compiling -->
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.2.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>4.2.0</version>
+            <scope>test</scope>
         </dependency>
+        
         <!-- test container -->
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
             <artifactId>pax-exam</artifactId>
-            <version>1.0.0</version>
+            <version>1.1.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
             <artifactId>pax-exam-container-default</artifactId>
-            <version>1.0.0</version>
+            <version>1.1.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
             <artifactId>pax-exam-junit</artifactId>
-            <version>1.0.0</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.5</version>
+            <version>1.1.0</version>
             <scope>test</scope>
         </dependency>
 	</dependencies>

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/App.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/App.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/App.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/App.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,5 @@
+package org.apache.geronimo.blueprint.jmx.test;
+
+public class App {
+
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/BlueprintMBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/BlueprintMBeanTest.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/BlueprintMBeanTest.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/BlueprintMBeanTest.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,264 @@
+package org.apache.geronimo.blueprint.jmx.test;
+
+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;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+import org.apache.geronimo.blueprint.jmx.BlueprintStateMBean;
+import org.apache.geronimo.blueprint.jmx.test.framework.BeanPropertyValidator;
+import org.apache.geronimo.blueprint.jmx.test.framework.BeanValidator;
+import org.apache.geronimo.blueprint.jmx.test.framework.BlueprintEventValidator;
+import org.apache.geronimo.blueprint.jmx.test.framework.CollectionValidator;
+import org.apache.geronimo.blueprint.jmx.test.framework.MapEntryValidator;
+import org.apache.geronimo.blueprint.jmx.test.framework.RefValidator;
+import org.apache.geronimo.blueprint.jmx.test.framework.ReferenceListValidator;
+import org.apache.geronimo.blueprint.jmx.test.framework.ReferenceListenerValidator;
+import org.apache.geronimo.blueprint.jmx.test.framework.ReferenceValidator;
+import org.apache.geronimo.blueprint.jmx.test.framework.RegistrationListenerValidator;
+import org.apache.geronimo.blueprint.jmx.test.framework.ServiceValidator;
+import org.apache.geronimo.blueprint.jmx.test.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;
+
+@RunWith(JUnit4TestRunner.class)
+public class BlueprintMBeanTest {
+    
+    @Inject
+    private BundleContext rbc;
+    
+    MBeanServer mbs;
+    ServiceRegistration mbsr;
+    
+    // will run before each test
+    @Configuration
+    public static Option[] configuration()
+    {      
+      
+        System.out.println("***************************Configuration*****************************");
+        return CoreOptions.options(CoreOptions.equinox(), CoreOptions.provision(
+                CoreOptions.mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.configadmin"),
+                CoreOptions.mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api"),
+                CoreOptions.mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-service"),
+                CoreOptions.mavenBundle().groupId("org.apache.geronimo.blueprint").artifactId("geronimo-blueprint"),
+                CoreOptions.mavenBundle().groupId("org.apache.geronimo.blueprint").artifactId("org.apache.geronimo.blueprint.sample"),
+                CoreOptions.mavenBundle().groupId("org.apache.geronimo.blueprint").artifactId("org.apache.geronimo.blueprint.jmx"),
+                CoreOptions.mavenBundle().groupId("org.apache.geronimo.blueprint").artifactId("org.apache.geronimo.blueprint.jmx.impl")
+                )
+        );
+    }  
+    
+    @Before
+    public void setup() throws Exception {
+       System.out.println("****************************Before Test*********************************");
+       
+       // Create a MBean Server
+       //MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+       mbs = MBeanServerFactory.createMBeanServer();
+       
+       // Register as a service, so that the blueprint mbean impl can found the server.
+       mbsr = rbc.registerService(MBeanServer.class.getCanonicalName(), mbs, null);
+       
+       // Wait MBeans register in server
+       int i=0;
+       while (true){
+           try {
+               mbs.getObjectInstance(new ObjectName(BlueprintStateMBean.OBJECTNAME));
+               mbs.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(1000);
+       }
+       
+       // Wait enough time for osgi framework and blueprint bundles to be set up
+       System.out.println("**************************** Waiting *********************************");
+       Thread.sleep(5000);
+       
+    }
+    
+    @After
+    public void teardown(){
+        if (mbsr!=null) mbsr.unregister();
+    }
+        
+    @Test
+    public void BlueprintSample()throws Exception{
+        System.out.println("**************************** AAA ********************************");
+        
+        //////////////////////////////
+        //Test BlueprintStateMBean
+        //////////////////////////////
+        
+        //find the Blueprint Sample bundle id and the blueprint extender bundle id
+        long sampleBundleId = -1;
+        long extenderBundleId = -1;     // the blueprint extender bundle "org.apache.geronimo.blueprint.geronimo-blueprint" is also a blueprint bundle.
+        for (Bundle bundle : rbc.getBundles()){
+            if (bundle.getSymbolicName().equals("org.apache.geronimo.blueprint.sample")) sampleBundleId = bundle.getBundleId();
+            if (bundle.getSymbolicName().equals("org.apache.geronimo.blueprint")) extenderBundleId = bundle.getBundleId();
+        }
+        if (-1==sampleBundleId) fail("Blueprint Sample Bundle is not found!");
+        if (-1==extenderBundleId) fail("Blueprint Extender Bundle is not found!");
+        
+        //retrieve the proxy object
+        BlueprintStateMBean stateProxy = (BlueprintStateMBean) MBeanServerInvocationHandler.newProxyInstance(mbs, new ObjectName(BlueprintStateMBean.OBJECTNAME), BlueprintStateMBean.class, false);
+        
+        // test getBlueprintBundleIds
+        long[] bpBundleIds = stateProxy.getBlueprintBundleIds();
+        assertEquals(2, bpBundleIds.length);
+        // test getLastEvent
+        BlueprintEventValidator sampleValidator = new BlueprintEventValidator(sampleBundleId, extenderBundleId, 2);
+        sampleValidator.validate(stateProxy.getLastEvent(sampleBundleId));
+        // test getLastEvents
+        TabularData lastEvents = stateProxy.getLastEvents();
+        assertEquals(BlueprintStateMBean.OSGI_BLUEPRINT_EVENTS_TYPE,lastEvents.getTabularType());
+        sampleValidator.validate(lastEvents.get(new Long[]{sampleBundleId}));
+        
+        //////////////////////////////
+        //Test BlueprintMetadataMBean
+        //////////////////////////////
+        
+        //find the Blueprint Sample bundle's container service id
+        Bundle sampleBundle = rbc.getBundle(sampleBundleId);
+        String filter = "(&(osgi.blueprint.container.symbolicname=" // no similar one in interfaces
+                + sampleBundle.getSymbolicName() + ")(osgi.blueprint.container.version=" + sampleBundle.getVersion() + "))";
+        ServiceReference[] serviceReferences = null;
+        try {
+            serviceReferences = rbc.getServiceReferences(BlueprintContainer.class.getName(), filter);
+        } catch (InvalidSyntaxException e) {
+            throw new RuntimeException(e);
+        }
+        long sampleBlueprintContainerServiceId = (Long) serviceReferences[0].getProperty(Constants.SERVICE_ID);
+        
+        //retrieve the proxy object
+        BlueprintMetadataMBean metadataProxy = (BlueprintMetadataMBean) MBeanServerInvocationHandler.newProxyInstance(mbs, new ObjectName(BlueprintMetadataMBean.OBJECTNAME), BlueprintMetadataMBean.class, false);
+        
+        // test getBlueprintContainerServiceIds
+        long[] bpContainerServiceIds = metadataProxy.getBlueprintContainerServiceIds();
+        assertEquals(2, bpContainerServiceIds.length);
+        
+        // test getBlueprintContainerServiceId
+        assertEquals(sampleBlueprintContainerServiceId, metadataProxy.getBlueprintContainerServiceId(sampleBundleId));
+        
+        // test getComponentMetadata
+        // bean: foo
+        BeanValidator bv_foo = new BeanValidator("org.apache.geronimo.blueprint.sample.Foo", "init", "destroy");
+        
+        BeanPropertyValidator bpv_a = new BeanPropertyValidator("a");
+        bpv_a.setObjectValueValidator(new ValueValidator("5"));
+        
+        BeanPropertyValidator bpv_b = new BeanPropertyValidator("b");
+        bpv_b.setObjectValueValidator(new ValueValidator("-1"));
+        
+        BeanPropertyValidator bpv_bar = new BeanPropertyValidator("bar");
+        bpv_bar.setObjectValueValidator(new RefValidator("bar"));
+        
+        BeanPropertyValidator bpv_currency = new BeanPropertyValidator("currency");
+        bpv_currency.setObjectValueValidator(new ValueValidator("PLN"));
+        
+        BeanPropertyValidator bpv_date = new BeanPropertyValidator("date");
+        bpv_date.setObjectValueValidator(new ValueValidator("2009.04.17"));
+        
+        bv_foo.addPropertyValidators(bpv_a, bpv_b, bpv_bar, bpv_currency, bpv_date);
+        bv_foo.validate(metadataProxy.getComponentMetadata(sampleBlueprintContainerServiceId, "foo"));
+        
+        // bean: bar
+        BeanPropertyValidator bpv_value = new BeanPropertyValidator("value");
+        bpv_value.setObjectValueValidator(new ValueValidator("Hello FooBar"));
+        
+        BeanPropertyValidator bpv_context = new BeanPropertyValidator("context");
+        bpv_context.setObjectValueValidator(new RefValidator("blueprintBundleContext"));
+        
+        CollectionValidator cv = new CollectionValidator("java.util.List");
+        cv.addCollectionValueValidators(new ValueValidator("a list element"), new ValueValidator("5", "java.lang.Integer"));
+        BeanPropertyValidator bpv_list = new BeanPropertyValidator("list");
+        bpv_list.setObjectValueValidator(cv);
+        
+        BeanValidator bv_bar = new BeanValidator("org.apache.geronimo.blueprint.sample.Bar");
+        bv_bar.addPropertyValidators(bpv_value, bpv_context, bpv_list);
+        bv_bar.validate(metadataProxy.getComponentMetadata(sampleBlueprintContainerServiceId, "bar"));
+        
+        // service: ref=foo, no componentId set. So using it to test getComponentIdsByType.
+        String[] serviceComponentIds = metadataProxy.getComponentIdsByType(sampleBlueprintContainerServiceId, BlueprintMetadataMBean.SERVICE_METADATA);
+        assertEquals("There should be only one service component in this sample", 1, serviceComponentIds.length);
+        
+        MapEntryValidator mev = new MapEntryValidator();
+        mev.setKeyValueValidator(new ValueValidator("key"), new ValueValidator("value"));
+        
+        RegistrationListenerValidator rglrv = new RegistrationListenerValidator("serviceRegistered", "serviceUnregistered");
+        rglrv.setTargetValidator(new RefValidator("fooRegistrationListener"));
+        
+        ServiceValidator sv = new ServiceValidator(4);
+        sv.setTargetValidator(new RefValidator("foo"));
+        sv.addMapEntryValidator(mev);
+        sv.addRegistrationListenerValidator(rglrv);
+        sv.validate(metadataProxy.getComponentMetadata(sampleBlueprintContainerServiceId, serviceComponentIds[0]));
+        
+        // bean: fooRegistrationListener
+        BeanValidator bv_fooRegistrationListener = new BeanValidator("org.apache.geronimo.blueprint.sample.FooRegistrationListener");
+        bv_fooRegistrationListener.validate(metadataProxy.getComponentMetadata(sampleBlueprintContainerServiceId, "fooRegistrationListener"));
+        
+        // reference: ref2
+        ReferenceListenerValidator rlrv_1 = new ReferenceListenerValidator("bind", "unbind");
+        rlrv_1.setTargetValidator(new RefValidator("bindingListener"));
+        
+        ReferenceValidator rv = new ReferenceValidator("org.apache.geronimo.blueprint.sample.InterfaceA", 100);
+        rv.addReferenceListenerValidator(rlrv_1);
+        rv.validate(metadataProxy.getComponentMetadata(sampleBlueprintContainerServiceId, "ref2"));
+        
+        // bean:bindingListener
+        BeanValidator bv_bindingListener = new BeanValidator("org.apache.geronimo.blueprint.sample.BindingListener");
+        bv_bindingListener.validate(metadataProxy.getComponentMetadata(sampleBlueprintContainerServiceId, "bindingListener"));
+
+        // reference-list: ref-list
+        ReferenceListenerValidator rlrv_2 = new ReferenceListenerValidator("bind", "unbind");
+        rlrv_2.setTargetValidator(new RefValidator("listBindingListener"));
+        
+        ReferenceListValidator rlv_ref_list = new ReferenceListValidator("org.apache.geronimo.blueprint.sample.InterfaceA");
+        rlv_ref_list.addReferenceListenerValidator(rlrv_2);
+        rlv_ref_list.validate(metadataProxy.getComponentMetadata(sampleBlueprintContainerServiceId, "ref-list"));
+        
+        // bean: listBindingListener
+        BeanValidator bv_listBindingListener = new BeanValidator("org.apache.geronimo.blueprint.sample.BindingListener");
+        bv_listBindingListener.validate(metadataProxy.getComponentMetadata(sampleBlueprintContainerServiceId, "listBindingListener"));
+                
+        // bean: circularReference
+        ReferenceListenerValidator rlrv_3 = new ReferenceListenerValidator("bind", "unbind");
+        rlrv_3.setTargetValidator(new RefValidator("circularReference"));
+        
+        ReferenceListValidator rlv_2 = new ReferenceListValidator("org.apache.geronimo.blueprint.sample.InterfaceA", 2);
+        rlv_2.addReferenceListenerValidator(rlrv_3);
+        
+        BeanPropertyValidator bpv_list_2 = new BeanPropertyValidator("list");
+        bpv_list_2.setObjectValueValidator(rlv_2);
+        
+        BeanValidator bv_circularReference = new BeanValidator("org.apache.geronimo.blueprint.sample.BindingListener", "init");
+        bv_circularReference.addPropertyValidators(bpv_list_2);
+        bv_circularReference.validate(metadataProxy.getComponentMetadata(sampleBlueprintContainerServiceId, "circularReference"));
+    }
+    
+        
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanArgumentValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanArgumentValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanArgumentValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanArgumentValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,21 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class BeanArgumentValidator extends CompositeDataValidator{
+    
+    // if not set, means do not care about the value
+    private ObjectValueValidator objectValueValidator = null;
+    
+    public BeanArgumentValidator(int index, String valueType){
+        super(BlueprintMetadataMBean.BEAN_ARGUMENT_TYPE);
+        setExpectValue(BlueprintMetadataMBean.INDEX, index);
+        setExpectValue(BlueprintMetadataMBean.VALUE_TYPE, valueType);
+    }
+    
+    public void setValueValidator(ObjectValueValidator objectValueValidator){
+        this.objectValueValidator = objectValueValidator;
+    }
+    
+    
+}
\ No newline at end of file

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanPropertyValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanPropertyValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanPropertyValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanPropertyValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,32 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import javax.management.openmbean.CompositeData;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class BeanPropertyValidator extends CompositeDataValidator{
+    
+    // if not set, means do not care about the value
+    private ObjectValueValidator objectValueValidator = null;
+    
+    public BeanPropertyValidator(String name){
+        super(BlueprintMetadataMBean.BEAN_PROPERTY_TYPE);
+        setExpectValue(BlueprintMetadataMBean.NAME, name);            
+    }
+    
+    public void setObjectValueValidator(ObjectValueValidator objectValueValidator){
+        this.objectValueValidator = objectValueValidator;
+    }
+    
+    public void validate(CompositeData target){
+        super.validate(target);
+        
+        if (objectValueValidator != null){
+            Byte[] byteArrayValue = (Byte[])target.get(BlueprintMetadataMBean.VALUE);
+            CompositeData value = Util.decode(byteArrayValue);
+            
+            objectValueValidator.validate(value);
+        }
+    }
+    
+}
\ No newline at end of file

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BeanValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,83 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+
+public class BeanValidator extends CompositeDataValidator implements ObjectValueValidator{
+    
+    private boolean validateArgumentsFlag = true;
+    private List<BeanArgumentValidator> beanArgumentValidators = new ArrayList<BeanArgumentValidator>();
+    private boolean validatePropertiesFlag = true;
+    private List<BeanPropertyValidator> beanPropertyValidators = new ArrayList<BeanPropertyValidator>();
+    
+    public BeanValidator(String className){
+        super(BlueprintMetadataMBean.BEAN_METADATA_TYPE);
+        setExpectValue(BlueprintMetadataMBean.CLASS_NAME, className);
+    }
+    
+    public BeanValidator(String className, String initMethod){
+        super(BlueprintMetadataMBean.BEAN_METADATA_TYPE);
+        setExpectValue(BlueprintMetadataMBean.CLASS_NAME, className);
+        setExpectValue(BlueprintMetadataMBean.INIT_METHOD, initMethod);
+    }
+    
+    public BeanValidator(String className, String initMethod, String destroyMethod){
+        super(BlueprintMetadataMBean.BEAN_METADATA_TYPE);
+        setExpectValue(BlueprintMetadataMBean.CLASS_NAME, className);
+        setExpectValue(BlueprintMetadataMBean.INIT_METHOD, initMethod);
+        setExpectValue(BlueprintMetadataMBean.DESTROY_METHOD, destroyMethod);
+    }
+    
+    public void setValidateArgumentsFlag(boolean flag){
+        validateArgumentsFlag = flag;
+    }
+    
+    public void addArgumentValidators(BeanArgumentValidator... validators){
+        for (BeanArgumentValidator beanArgumentValidator : validators)
+            beanArgumentValidators.add(beanArgumentValidator);
+    }
+    
+    public void setValidatePropertiesFlag(boolean flag){
+        validatePropertiesFlag = flag;
+    }
+            
+    public void addPropertyValidators(BeanPropertyValidator... validators){
+        for (BeanPropertyValidator beanPropertyValidator : validators)
+            beanPropertyValidators.add(beanPropertyValidator);
+    }
+    
+    public void validate(CompositeData target){
+        super.validate(target);
+        
+        //Validate args
+        if (validateArgumentsFlag){
+            CompositeData[] args = (CompositeData[])target.get(BlueprintMetadataMBean.ARGUMENTS);  
+            assertNotNull(args); // at least CompositeData[0]
+            assertEquals("The size of arguments is not equals, expect " + beanArgumentValidators.size() + " but got " + args.length, 
+                    beanArgumentValidators.size(), args.length);
+            for (int i=0; i<beanArgumentValidators.size(); i++) // the order of the arg validators should be the same with the args
+                beanArgumentValidators.get(i).validate(args[i]);
+        }
+        
+        //Validate props
+        if (validatePropertiesFlag){
+            CompositeData[] props = (CompositeData[])target.get(BlueprintMetadataMBean.PROPERTIES);
+            assertNotNull(props);
+            assertEquals("The size of properties is not equals, expect " + beanPropertyValidators.size() + " but got " + props.length, 
+                    beanPropertyValidators.size(), props.length);
+            for (int i=0; i<beanPropertyValidators.size(); i++)
+                beanPropertyValidators.get(i).validate(props[i]);
+            
+        }
+        
+    }
+    
+}
\ No newline at end of file

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BlueprintEventValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BlueprintEventValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BlueprintEventValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/BlueprintEventValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,14 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintStateMBean;
+
+
+public class BlueprintEventValidator extends CompositeDataValidator{
+    public BlueprintEventValidator(long bundleId, long extenderBundleId, int eventType){
+        super(BlueprintStateMBean.OSGI_BLUEPRINT_EVENT_TYPE);  
+        setExpectValue(BlueprintStateMBean.BUNDLE_ID, bundleId);
+        setExpectValue(BlueprintStateMBean.EXTENDER_BUNDLE_ID, extenderBundleId);
+        setExpectValue(BlueprintStateMBean.EVENT_TYPE, eventType);
+    }
+    
+}
\ No newline at end of file

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CollectionValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CollectionValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CollectionValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CollectionValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,43 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import java.util.ArrayList;
+import java.util.List;
+import static org.junit.Assert.*;
+
+import javax.management.openmbean.CompositeData;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class CollectionValidator extends CompositeDataValidator implements ObjectValueValidator {
+    
+    private List<ObjectValueValidator> collectionValueValidators = new ArrayList<ObjectValueValidator>();
+    
+    public CollectionValidator(String collectionClass){
+        super(BlueprintMetadataMBean.COLLECTION_METADATA_TYPE);
+        setExpectValue(BlueprintMetadataMBean.COLLECTION_CLASS, collectionClass);
+    }
+    
+    public CollectionValidator(String collectionClass, String valueType){
+        super(BlueprintMetadataMBean.COLLECTION_METADATA_TYPE);
+        setExpectValue(BlueprintMetadataMBean.COLLECTION_CLASS, collectionClass);
+        setExpectValue(BlueprintMetadataMBean.VALUE_TYPE, valueType);
+    }
+    
+    public void addCollectionValueValidators (ObjectValueValidator...objectValueValidators){
+        for (ObjectValueValidator objectValueValidator: objectValueValidators)
+            collectionValueValidators.add(objectValueValidator);
+    }
+    
+    public void validate(CompositeData target){
+        super.validate(target);
+        if (collectionValueValidators.size() != 0){
+            Byte[][] allWrapValues = (Byte[][])target.get(BlueprintMetadataMBean.VALUES);
+            if ( collectionValueValidators.size() != allWrapValues.length )
+                fail("The quantity of the values is not the same, expect " +collectionValueValidators.size()+" but got "+ allWrapValues.length);
+            for(int i=0;i<collectionValueValidators.size();i++){
+                collectionValueValidators.get(i).validate(Util.decode(allWrapValues[i]));
+            }
+                
+        }
+    }
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CompositeDataValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CompositeDataValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CompositeDataValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/CompositeDataValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,40 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+
+abstract public class CompositeDataValidator {
+        
+        private CompositeType type;
+        private Map<String, Object> expectValues;
+                
+        protected CompositeDataValidator(CompositeType type){
+            this.type = type;
+            expectValues = new HashMap<String, Object>();
+        }
+                
+        void setExpectValue(String key, Object value){
+            expectValues.put(key, value);
+        }
+        
+        public void validate(CompositeData target){
+            if (!type.equals(target.getCompositeType()))
+                fail("Expect type is " + type + ", but target type is " +target.getCompositeType());
+            Set<String> keys = expectValues.keySet();
+            Iterator<String> it = keys.iterator();
+            while (it.hasNext()) {
+                String key = it.next();
+                assertEquals(expectValues.get(key), target.get(key));
+            }
+            
+        }
+        
+    }
\ No newline at end of file

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/MapEntryValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/MapEntryValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/MapEntryValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/MapEntryValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,32 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import javax.management.openmbean.CompositeData;
+import static junit.framework.Assert.*;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class MapEntryValidator extends CompositeDataValidator {
+    
+    ObjectValueValidator keyValidator = null;
+    
+    ObjectValueValidator valueValidator = null;
+    
+    public MapEntryValidator(){
+        super(BlueprintMetadataMBean.MAP_ENTRY_TYPE);
+    }
+    
+    public void setKeyValueValidator(ObjectValueValidator keyValidator, ObjectValueValidator valueValidator){
+        this.keyValidator = keyValidator;
+        this.valueValidator = valueValidator;        
+    }
+    
+    public void validate(CompositeData target){
+        super.validate(target); //do nothing
+        assertNotNull("keyValidator can not be null", keyValidator);
+        assertNotNull("valueValidator can not be null", valueValidator);
+        
+        keyValidator.validate(Util.decode((Byte[])target.get(BlueprintMetadataMBean.KEY)));
+        valueValidator.validate(Util.decode((Byte[])target.get(BlueprintMetadataMBean.VALUE)));
+    }
+    
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ObjectValueValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ObjectValueValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ObjectValueValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ObjectValueValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,5 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+public interface ObjectValueValidator extends Validator{
+
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RefValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RefValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RefValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RefValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,10 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class RefValidator extends CompositeDataValidator implements ObjectValueValidator, TargetValidator {
+    public RefValidator(String componentId){
+        super(BlueprintMetadataMBean.REF_METADATA_TYPE);
+        setExpectValue(BlueprintMetadataMBean.COMPONENT_ID, componentId);
+    }
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceListValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceListValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceListValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceListValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,19 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class ReferenceListValidator extends ServiceReferenceValidator {
+    
+    public ReferenceListValidator (String interfaceName){
+        super(BlueprintMetadataMBean.REFERENCE_LIST_METADATA_TYPE);
+        this.setExpectValue(BlueprintMetadataMBean.INTERFACE, interfaceName);
+    }
+    
+    public ReferenceListValidator (String interfaceName, int availability){
+        super(BlueprintMetadataMBean.REFERENCE_LIST_METADATA_TYPE);
+        this.setExpectValue(BlueprintMetadataMBean.INTERFACE, interfaceName);
+        this.setExpectValue(BlueprintMetadataMBean.AVAILABILITY, availability);
+    }
+    
+   
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceListenerValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceListenerValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceListenerValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceListenerValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,29 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import javax.management.openmbean.CompositeData;
+
+import static junit.framework.Assert.*;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class ReferenceListenerValidator extends CompositeDataValidator {
+    
+    TargetValidator listenerComponentValidator = null;
+    
+    public ReferenceListenerValidator(String bindMethod,String unbindMethod){
+        super(BlueprintMetadataMBean.REFERENCE_LISTENER_TYPE);
+        this.setExpectValue(BlueprintMetadataMBean.BIND_METHOD, bindMethod);
+        this.setExpectValue(BlueprintMetadataMBean.UNBIND_METHOD, unbindMethod);
+    }
+    
+    public void setTargetValidator(TargetValidator targetValidator){
+        this.listenerComponentValidator = targetValidator;
+    }
+    
+    public void validate(CompositeData target){
+        super.validate(target);
+        assertNotNull("ReferenceListenerValidator must have a TargetValidator for listener component", listenerComponentValidator);
+        listenerComponentValidator.validate(Util.decode((Byte[])target.get(BlueprintMetadataMBean.LISTENER_COMPONENT)));
+    }
+    
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ReferenceValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,13 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class ReferenceValidator extends ServiceReferenceValidator {
+    
+    public ReferenceValidator(String interfaceName, long timeout){
+        super(BlueprintMetadataMBean.REFERENCE_METADATA_TYPE);
+        this.setExpectValue(BlueprintMetadataMBean.INTERFACE, interfaceName);
+        this.setExpectValue(BlueprintMetadataMBean.TIMEOUT, timeout);
+    }
+    
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RegistrationListenerValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RegistrationListenerValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RegistrationListenerValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/RegistrationListenerValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,29 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import javax.management.openmbean.CompositeData;
+
+import static junit.framework.Assert.*;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class RegistrationListenerValidator extends CompositeDataValidator {
+    
+    TargetValidator listenerComponentValidator = null;
+    
+    public RegistrationListenerValidator(String registrationMethod,String unregistrationMethod){
+        super(BlueprintMetadataMBean.REGISTRATION_LISTENER_TYPE);
+        this.setExpectValue(BlueprintMetadataMBean.REGISTRATION_METHOD, registrationMethod);
+        this.setExpectValue(BlueprintMetadataMBean.UNREGISTRATION_METHOD, unregistrationMethod);
+    }
+    
+    public void setTargetValidator(TargetValidator targetValidator){
+        this.listenerComponentValidator = targetValidator;
+    }
+    
+    public void validate(CompositeData target){
+        super.validate(target);
+        assertNotNull("ReferenceListenerValidator must have a TargetValidator for listener component", listenerComponentValidator);
+        listenerComponentValidator.validate(Util.decode((Byte[])target.get(BlueprintMetadataMBean.LISTENER_COMPONENT)));
+    }
+    
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceReferenceValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceReferenceValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceReferenceValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceReferenceValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,36 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public abstract class ServiceReferenceValidator extends CompositeDataValidator implements ObjectValueValidator, TargetValidator {
+    private List<ReferenceListenerValidator> referenceListenerValidators = new ArrayList<ReferenceListenerValidator>();
+    
+    protected ServiceReferenceValidator(CompositeType type) {
+        super(type);
+    }
+    
+    public void addReferenceListenerValidator(ReferenceListenerValidator... validators){
+        for (ReferenceListenerValidator validator : validators)
+            this.referenceListenerValidators.add(validator);
+    }
+    
+    public void validate(CompositeData target){
+        super.validate(target);
+        if (referenceListenerValidators.size() != 0){
+            CompositeData[] referenceListeners = (CompositeData[])target.get(BlueprintMetadataMBean.REFERENCE_LISTENERS);
+            if ( referenceListenerValidators.size() != referenceListeners.length )
+                fail("The quantity of the listeners is not the same, expect " +referenceListenerValidators.size()+" but got "+ referenceListeners.length);
+            for (int i=0; i<referenceListenerValidators.size(); i++)
+                referenceListenerValidators.get(i).validate(referenceListeners[i]);
+        }
+    }
+    
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ServiceValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,61 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class ServiceValidator extends CompositeDataValidator implements ObjectValueValidator {
+    
+    TargetValidator serviceComponentValidator = null;
+    List<MapEntryValidator> servicePropertyValidators = new ArrayList<MapEntryValidator>();
+    List<RegistrationListenerValidator> registrationListenerValidators = new ArrayList<RegistrationListenerValidator>();
+    
+    public ServiceValidator(int autoExport){
+        super(BlueprintMetadataMBean.SERVICE_METADATA_TYPE);
+        this.setExpectValue(BlueprintMetadataMBean.AUTO_EXPORT, autoExport);
+    }
+    
+    public void setTargetValidator(TargetValidator targetValidator){
+        this.serviceComponentValidator = targetValidator;
+    }
+    
+    public void addMapEntryValidator(MapEntryValidator... validators){
+        for (MapEntryValidator validator : validators)
+            this.servicePropertyValidators.add(validator);
+    }
+        
+    public void addRegistrationListenerValidator(RegistrationListenerValidator... validators){
+        for (RegistrationListenerValidator validator : validators)
+            this.registrationListenerValidators.add(validator);
+    }
+    
+    public void validate(CompositeData target){
+        super.validate(target);
+        assertNotNull("ServiceValidator must have a TargetValidator for service component", serviceComponentValidator);
+        serviceComponentValidator.validate(Util.decode((Byte[])target.get(BlueprintMetadataMBean.SERVICE_COMPONENT)));
+        
+        if (servicePropertyValidators.size()!=0){
+            CompositeData[] serviceProperties = (CompositeData[])target.get(BlueprintMetadataMBean.SERVICE_PROPERTIES);
+            if ( servicePropertyValidators.size() != serviceProperties.length )
+                fail("The quantity of the service properties is not the same, expect " +servicePropertyValidators.size()+" but got "+ serviceProperties.length);
+            for (int i=0; i<servicePropertyValidators.size(); i++)
+                servicePropertyValidators.get(i).validate(serviceProperties[i]);
+        }
+        
+        if (registrationListenerValidators.size() != 0){
+            CompositeData[] registrationListeners = (CompositeData[])target.get(BlueprintMetadataMBean.REGISTRATION_LISTENERS);
+            if ( registrationListenerValidators.size() != registrationListeners.length )
+                fail("The quantity of the registration listeners is not the same, expect " +registrationListenerValidators.size()+" but got "+ registrationListeners.length);
+            for (int i=0; i<registrationListenerValidators.size(); i++)
+                registrationListenerValidators.get(i).validate(registrationListeners[i]);
+        }
+        
+    }
+    
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/TargetValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/TargetValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/TargetValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/TargetValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,5 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+public interface TargetValidator extends Validator {
+
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/Util.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/Util.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/Util.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/Util.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,30 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+import javax.management.openmbean.CompositeData;
+
+public class Util {
+    
+    public static CompositeData decode(Byte[] wrap){
+        if (null == wrap) return null;
+
+        byte[] prim = new byte[wrap.length];
+        for (int i = 0; i < wrap.length; i++) {
+            prim[i] = wrap[i];
+        }
+        
+        ByteArrayInputStream inBytes = new ByteArrayInputStream(prim);
+        ObjectInputStream inObject;
+        CompositeData data;
+        try {
+            inObject = new ObjectInputStream(inBytes);
+            data = (CompositeData) inObject.readObject();
+            inObject.close();
+            return data;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }         
+    }
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/Validator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/Validator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/Validator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/Validator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,7 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import javax.management.openmbean.CompositeData;
+
+public interface Validator {
+    public void validate(CompositeData target);
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ValueValidator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ValueValidator.java?rev=890690&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ValueValidator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/test/java/org/apache/geronimo/blueprint/jmx/test/framework/ValueValidator.java Tue Dec 15 08:42:13 2009
@@ -0,0 +1,18 @@
+package org.apache.geronimo.blueprint.jmx.test.framework;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+
+public class ValueValidator extends CompositeDataValidator implements ObjectValueValidator{
+    
+    public ValueValidator(String stringValue){
+        super(BlueprintMetadataMBean.VALUE_METADATA_TYPE);
+        setExpectValue(BlueprintMetadataMBean.STRING_VALUE, stringValue);
+    }
+    
+    public ValueValidator(String stringValue, String type){
+        super(BlueprintMetadataMBean.VALUE_METADATA_TYPE);
+        setExpectValue(BlueprintMetadataMBean.STRING_VALUE, stringValue);
+        setExpectValue(BlueprintMetadataMBean.TYPE, type);
+    }
+    
+}