[jboss-cvs] JBossAS SVN: r64442 - in projects/microcontainer/trunk: deployers-impl/src/tests/org/jboss/test/deployers/managed/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 2 23:39:54 EDT 2007
Author: scott.stark at jboss.org
Date: 2007-08-02 23:39:53 -0400 (Thu, 02 Aug 2007)
New Revision: 64442
Added:
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/LocalDataSourceMetaData.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/XADataSourceMetaData.java
Modified:
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/DSMetaData.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
Log:
Test obtaining the ManagedObjects from an instance
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/DSMetaData.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/DSMetaData.java 2007-08-02 23:42:54 UTC (rev 64441)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/DSMetaData.java 2007-08-03 03:39:53 UTC (rev 64442)
@@ -80,5 +80,10 @@
{
return deployments;
}
+ public void setDeployments(List<ConnMetaData> deployments)
+ {
+ this.deployments.clear();
+ this.deployments.addAll(deployments);
+ }
}
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/LocalDataSourceMetaData.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/LocalDataSourceMetaData.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/LocalDataSourceMetaData.java 2007-08-03 03:39:53 UTC (rev 64442)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.deployers.deployer.support;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class LocalDataSourceMetaData extends ConnMetaData
+{
+
+}
Property changes on: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/LocalDataSourceMetaData.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/XADataSourceMetaData.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/XADataSourceMetaData.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/XADataSourceMetaData.java 2007-08-03 03:39:53 UTC (rev 64442)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.deployers.deployer.support;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class XADataSourceMetaData extends ConnMetaData
+{
+ private static final long serialVersionUID = 1;
+
+ private String xaDataSourceClass;
+ private int xaResourceTimeout;
+
+ public XADataSourceMetaData()
+ {
+ }
+
+ public String getXaDataSourceClass()
+ {
+ return xaDataSourceClass;
+ }
+
+ public void setXaDataSourceClass(String xaDataSourceClass)
+ {
+ this.xaDataSourceClass = xaDataSourceClass;
+ }
+
+ public int getXaResourceTimeout()
+ {
+ return xaResourceTimeout;
+ }
+
+ public void setXaResourceTimeout(int xaResourceTimeout)
+ {
+ this.xaResourceTimeout = xaResourceTimeout;
+ }
+
+}
Property changes on: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/deployer/support/XADataSourceMetaData.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java 2007-08-02 23:42:54 UTC (rev 64441)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java 2007-08-03 03:39:53 UTC (rev 64442)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.deployers.managed.test;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -44,7 +45,10 @@
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.test.deployers.AbstractDeployerTest;
import org.jboss.test.deployers.deployer.support.AllowedDsTypes;
+import org.jboss.test.deployers.deployer.support.ConnMetaData;
import org.jboss.test.deployers.deployer.support.DSMetaData;
+import org.jboss.test.deployers.deployer.support.LocalDataSourceMetaData;
+import org.jboss.test.deployers.deployer.support.XADataSourceMetaData;
import org.jboss.test.deployers.managed.support.TestAttachment;
import org.jboss.test.deployers.managed.support.TestManagedObjectDeployer;
import org.jboss.util.graph.Graph;
@@ -133,7 +137,7 @@
}
/**
- * Validate the ManagedObject for DSMetaData
+ * Validate the ManagedObjectFactory for DSMetaData class
*
*/
public void testDSMetaDataManagedObjectFactory()
@@ -170,8 +174,9 @@
Object[] values = value.getValue();
assertEquals(1, values.length);
// Validate the ConnMetaData ManagedObject
- ManagedObject connMO = ManagedObject.class.cast(values[0]);
- props = connMO.getProperties();
+ ManagedObject localConnMO = ManagedObject.class.cast(values[0]);
+ assertEquals(ConnMetaData.class.getName(), localConnMO.getName());
+ props = localConnMO.getProperties();
assertEquals(8, props.size());
propsMap.clear();
for(ManagedProperty prop : props)
@@ -185,6 +190,96 @@
assertTrue(dsTypeValues.containsAll(AllowedDsTypes.values));
}
+ /**
+ * Validate the ManagedObjectFactory for DSMetaData instance
+ *
+ */
+ public void testDSMetaDataManagedObjectFactoryInit()
+ {
+ ManagedObjectFactory mof = ManagedObjectFactory.getInstance();
+ DSMetaData dsmd = new DSMetaData();
+ LocalDataSourceMetaData ds = new LocalDataSourceMetaData();
+ XADataSourceMetaData xads = new XADataSourceMetaData();
+ ArrayList<ConnMetaData> deployments = new ArrayList<ConnMetaData>();
+ deployments.add(ds);
+ deployments.add(xads);
+ dsmd.setDeployments(deployments);
+ ManagedObject mo = mof.initManagedObject(dsmd);
+
+ // Validate the expected properties
+ Set<ManagedProperty> props = mo.getProperties();
+ assertEquals(2, props.size());
+ HashMap<String, ManagedProperty> propsMap = new HashMap<String, ManagedProperty>();
+ for(ManagedProperty prop : props)
+ {
+ propsMap.put(prop.getName(), prop);
+ }
+ log.info("DSMetaData properties: "+props);
+
+ // display-name
+ ManagedProperty displayName = propsMap.get("display-name");
+ assertNotNull(displayName);
+ assertEquals("display name of DS deployment", displayName.getDescription());
+ assertEquals(SimpleMetaType.STRING, displayName.getMetaType());
+
+ // deployments
+ ManagedProperty dsDeployments = propsMap.get("deployments");
+ assertNotNull(deployments);
+ assertEquals("The DS connection factories", dsDeployments.getDescription());
+ MetaType deploymentsType = new ArrayMetaType(1, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
+ assertEquals(deploymentsType, dsDeployments.getMetaType());
+ ArrayValue value = ArrayValue.class.cast(dsDeployments.getValue());
+ ArrayMetaType valueType = value.getMetaType();
+ assertEquals(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, valueType.getElementType());
+
+ Object[] values = value.getValue();
+ assertEquals(2, values.length);
+ ManagedObject localConnMO = null;
+ ManagedObject xaConnMO = null;
+ for(Object md : values)
+ {
+ ManagedObject tmpMO = ManagedObject.class.cast(md);
+ if (tmpMO.getName().equals(LocalDataSourceMetaData.class.getName()))
+ localConnMO = tmpMO;
+ if (tmpMO.getName().equals(XADataSourceMetaData.class.getName()))
+ xaConnMO = tmpMO;
+ }
+ assertNotNull(localConnMO);
+ assertNotNull(xaConnMO);
+
+ // Validate the LocalDataSourceMetaData ManagedObject
+ props = localConnMO.getProperties();
+ assertEquals(8, props.size());
+ propsMap.clear();
+ for(ManagedProperty prop : props)
+ {
+ propsMap.put(prop.getName(), prop);
+ }
+ log.info("LocalDataSourceMetaData properties: "+props);
+ ManagedProperty dsType = propsMap.get("datasource-type");
+ assertNotNull(dsType);
+ Set<MetaValue> dsTypeValues = dsType.getLegalValues();
+ assertTrue(dsTypeValues.containsAll(AllowedDsTypes.values));
+
+ // Validate the XADataSourceMetaData ManagedObject
+ props = xaConnMO.getProperties();
+ assertEquals(10, props.size());
+ propsMap.clear();
+ for(ManagedProperty prop : props)
+ {
+ propsMap.put(prop.getName(), prop);
+ }
+ log.info("XADataSourceMetaData properties: "+props);
+ ManagedProperty xaDataSourceClass = propsMap.get("xaDataSourceClass");
+ assertNotNull(xaDataSourceClass);
+ ManagedProperty xaResourceTimeout = propsMap.get("xaResourceTimeout");
+ assertNotNull(xaResourceTimeout);
+ ManagedProperty secDomain = propsMap.get("security-domain");
+ assertNotNull(secDomain);
+ MetaType secDomainType = secDomain.getMetaType();
+ assertEquals(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, secDomainType);
+ }
+
protected DeployerClient getMainDeployer()
{
return createMainDeployer(deployer);
Modified: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2007-08-02 23:42:54 UTC (rev 64441)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2007-08-03 03:39:53 UTC (rev 64442)
@@ -209,13 +209,17 @@
fields.setField(Fields.PROPERTY_INFO, info);
}
- String propertyName = managementProperty.name();
+ String propertyName = propertyInfo.getName();
+ if (managementProperty != null)
+ propertyName = managementProperty.name();
if( propertyName.length() == 0 )
propertyName = propertyInfo.getName();
fields.setField(Fields.NAME, propertyName);
// This should probably always the the propertyInfo name?
- String mappedName = managementProperty.mappedName();
+ String mappedName = propertyInfo.getName();
+ if (managementProperty != null)
+ managementProperty.mappedName();
if( mappedName.length() == 0 )
mappedName = propertyInfo.getName();
fields.setField(Fields.MAPPED_NAME, mappedName);
More information about the jboss-cvs-commits
mailing list