[jboss-cvs] JBossAS SVN: r68447 - trunk/testsuite/src/main/org/jboss/test/profileservice/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 20 00:29:42 EST 2007


Author: alex.loubyansky at jboss.com
Date: 2007-12-20 00:29:42 -0500 (Thu, 20 Dec 2007)
New Revision: 68447

Modified:
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
JBAS-4671 represent xa-connection-properties as a Map<String, String> in management interface

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2007-12-20 05:27:42 UTC (rev 68446)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2007-12-20 05:29:42 UTC (rev 68447)
@@ -30,6 +30,7 @@
 import java.util.List;
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
 
 import javax.naming.InitialContext;
 
@@ -68,6 +69,8 @@
 public class ProfileServiceUnitTestCase extends JBossTestCase
 {
    ManagementView activeView;
+   private Type mapType;
+   private MetaValueFactory metaValueFactory;
 
    /**
     * We need to define the order in which tests runs
@@ -440,6 +443,7 @@
       propValues.put("xa-datasource-class", "org.hsqldb.jdbcDriver");
       propValues.put("xa-resource-timeout", new Integer(256));
 
+/*
       ArrayList<XAConnectionPropertyMetaData> xaPropsValue = new ArrayList<XAConnectionPropertyMetaData>();
       XAConnectionPropertyMetaData xaPropMD = new XAConnectionPropertyMetaData();
       xaPropMD.setName("URL");
@@ -454,7 +458,15 @@
       xaPropMD.setValue("");
       xaPropsValue.add(xaPropMD);
       propValues.put("xa-datasource-properties", xaPropsValue);
+*/
+      HashMap<String, String> xaPropValues = new HashMap<String, String>();
+      xaPropValues.put("URL", "jdbc:hsqldb");
+      xaPropValues.put("User", "sa");
+      xaPropValues.put("Password", "");
 
+      MetaValue metaValue = getMetaValueFactory().create(xaPropValues, getMapType());
+      propValues.put("xa-datasource-properties", metaValue);
+
       createComponentTest("XADataSourceTemplate", propValues, "testXaDs",
          KnownComponentTypes.DataSourceTypes.XA.getType(), jndiName);
    }
@@ -677,16 +689,26 @@
       {
          ManagedProperty prop = dsMC.getProperty(propName);
          assertNotNull(prop);
-         if(prop.getMetaType().isSimple())
-            assertEquals(prop.getName(), propValues.get(propName), ((SimpleValue)prop.getValue()).getValue());
-         else
+         Object propValue = prop.getValue();
+         Object expectedValue = propValues.get(propName);
+         if(propValue instanceof MetaValue)
          {
-            Serializable expectedValue = propValues.get(propName);
-            Class valueType = expectedValue.getClass();
-            MetaValue metaValue = (MetaValue)prop.getValue();
-            Object value = MetaValueFactory.getInstance().unwrap(metaValue, valueType);
-            assertEquals(prop.getName(), expectedValue, value);
+            if(prop.getMetaType().isSimple())
+               assertEquals(prop.getName(), expectedValue, ((SimpleValue)propValue).getValue());
+            else
+            {
+               Type valueType = expectedValue.getClass();
+               if("xa-datasource-properties".equals(prop.getName()))
+                  valueType = getMapType();
+
+               propValue = getMetaValueFactory().unwrap((MetaValue)propValue, valueType);
+               expectedValue = getMetaValueFactory().unwrap((MetaValue)expectedValue, valueType);
+               assertEquals(prop.getName(), expectedValue, propValue);
+            }
          }
+         else
+            assertEquals(prop.getName(), expectedValue, propValue);
+         
          mcPropNames.remove(propName);
       }
 
@@ -752,4 +774,32 @@
       }
       return mc;
    }
+
+   private MetaValueFactory getMetaValueFactory()
+   {
+      if(metaValueFactory == null)
+         metaValueFactory = MetaValueFactory.getInstance();
+      return metaValueFactory;
+   }
+
+   private Type getMapType()
+   {
+      if(mapType == null)
+      {
+         try
+         {
+            mapType = getClass().getMethod("compositeValueMap").getGenericReturnType();
+         }
+         catch(NoSuchMethodException e)
+         {
+            throw new IllegalStateException("Failed to find compoditeValueMap method.");
+         }
+      }
+      return mapType;
+   }
+
+   public Map<String, String> compositeValueMap()
+   {
+      return null;
+   }
 }




More information about the jboss-cvs-commits mailing list