[jboss-cvs] JBossAS SVN: r70033 - in projects/microcontainer/trunk: classloading/src/main/org/jboss/classloading/plugins/metadata and 15 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 22 04:49:08 EST 2008
Author: adrian at jboss.org
Date: 2008-02-22 04:49:08 -0500 (Fri, 22 Feb 2008)
New Revision: 70033
Added:
projects/microcontainer/trunk/classloading-vfs/src/tests/org/jboss/test/classloading/vfs/metadata/test/ManagedObjectVFSClassLoaderFactoryUnitTestCase.java
projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/plugins/metadata/VersionMetaMapper.java
projects/microcontainer/trunk/classloading/src/tests/org/jboss/test/classloading/metadata/test/ManagedObjectClassLoadingMetaDataUnitTestCase.java
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/deployment0/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/deployment0/META-INF/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/deployment0/META-INF/jboss-classloading.xml
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/ManagedObjectClassLoadingParserUnitTestCase.java
Modified:
projects/microcontainer/trunk/classloading-vfs/.classpath
projects/microcontainer/trunk/classloading-vfs/src/main/org/jboss/classloading/spi/vfs/metadata/VFSClassLoaderFactory.java
projects/microcontainer/trunk/classloading-vfs/src/tests/org/jboss/test/classloading/ClassLoadingVFSTestSuite.java
projects/microcontainer/trunk/classloading/.classpath
projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/helpers/NameAndVersionRangeSupport.java
projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/helpers/NameAndVersionSupport.java
projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/metadata/ClassLoadingMetaData.java
projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/version/Version.java
projects/microcontainer/trunk/classloading/src/tests/org/jboss/test/classloading/metadata/MetaDataTestSuite.java
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java
Log:
ManagedObject handling for ClassLoadingMetaData and subclasses
Modified: projects/microcontainer/trunk/classloading/.classpath
===================================================================
--- projects/microcontainer/trunk/classloading/.classpath 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/classloading/.classpath 2008-02-22 09:49:08 UTC (rev 70033)
@@ -26,5 +26,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/jboss-container"/>
<classpathentry combineaccessrules="false" kind="src" path="/jboss-dependency"/>
<classpathentry combineaccessrules="false" kind="src" path="/jboss-kernel"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-metatype"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-managed"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Added: projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/plugins/metadata/VersionMetaMapper.java
===================================================================
--- projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/plugins/metadata/VersionMetaMapper.java (rev 0)
+++ projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/plugins/metadata/VersionMetaMapper.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* 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.classloading.plugins.metadata;
+
+import java.lang.reflect.Type;
+
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * VersionMetaMapper.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class VersionMetaMapper extends MetaMapper<Version>
+{
+ public Type mapToType()
+ {
+ return String.class;
+ }
+
+ public MetaValue createMetaValue(MetaType<?> metaType, Version object)
+ {
+ return SimpleValueSupport.wrap(object.toString());
+ }
+
+ public Version unwrapMetaValue(MetaValue metaValue)
+ {
+ if (SimpleMetaType.STRING.equals(metaValue.getMetaType()) == false)
+ throw new IllegalArgumentException("Not a string: " + metaValue);
+
+ SimpleValue<?> simple = (SimpleValue<?>) metaValue;
+ String value = (String) simple.getValue();
+ return Version.parseVersion(value);
+ }
+
+}
Modified: projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/helpers/NameAndVersionRangeSupport.java
===================================================================
--- projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/helpers/NameAndVersionRangeSupport.java 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/helpers/NameAndVersionRangeSupport.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -28,6 +28,8 @@
import org.jboss.classloading.spi.version.Version;
import org.jboss.classloading.spi.version.VersionRange;
+import org.jboss.metatype.api.annotations.CompositeKey;
+import org.jboss.metatype.api.annotations.CompositeValue;
/**
* NameAndVersionRangeSupport.
@@ -97,6 +99,7 @@
*
* @param name the name.
*/
+ @CompositeKey
@XmlAttribute
public void setName(String name)
{
@@ -120,6 +123,7 @@
*
* @param versionRange the versionRange.
*/
+ @CompositeValue(ignore=true)
@XmlTransient
public void setVersionRange(VersionRange versionRange)
{
@@ -143,6 +147,7 @@
*
* @param fromVersion the fromVersion.
*/
+ @CompositeValue(ignore=true)
@XmlTransient
public void setFrom(Object fromVersion)
{
@@ -171,6 +176,8 @@
*
* @param fromVersion the fromVersion.
*/
+ @CompositeKey
+ @CompositeValue(name="from")
@XmlAttribute(name="from")
public void setFromVersion(Version fromVersion)
{
@@ -192,6 +199,7 @@
*
* @param fromVersionInclusive the fromVersionInclusive.
*/
+ @CompositeKey
@XmlAttribute(name="from-inclusive")
public void setFromVersionInclusive(boolean fromVersionInclusive)
{
@@ -213,6 +221,7 @@
*
* @param toVersion the toVersion.
*/
+ @CompositeValue(ignore=true)
@XmlTransient
public void setTo(Object toVersion)
{
@@ -224,7 +233,6 @@
*
* @return the toVersion.
*/
- @XmlAttribute(name="to")
public Version getToVersion()
{
Object to = getTo();
@@ -242,6 +250,9 @@
*
* @param toVersion the toVersion.
*/
+ @CompositeKey
+ @CompositeValue(name="to")
+ @XmlAttribute(name="to")
public void setToVersion(Version toVersion)
{
setTo(toVersion);
@@ -262,6 +273,7 @@
*
* @param toVersionInclusive the toVersionInclusive.
*/
+ @CompositeKey
@XmlAttribute(name="to-inclusive")
public void setToVersionInclusive(boolean toVersionInclusive)
{
@@ -273,6 +285,7 @@
*
* @param version the version
*/
+ @CompositeValue(ignore=true)
@XmlAttribute(name="version")
public void setVersion(Version version)
{
Modified: projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/helpers/NameAndVersionSupport.java
===================================================================
--- projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/helpers/NameAndVersionSupport.java 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/helpers/NameAndVersionSupport.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -28,6 +28,9 @@
import org.jboss.classloading.spi.version.Version;
import org.jboss.classloading.spi.version.VersionComparatorRegistry;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.metatype.api.annotations.CompositeKey;
+import org.jboss.metatype.api.annotations.CompositeValue;
/**
* NameAndVersionSupport.
@@ -96,6 +99,8 @@
*
* @param name the name.
*/
+ @CompositeKey
+ @ManagementProperty
@XmlAttribute
public void setName(String name)
{
@@ -119,6 +124,7 @@
*
* @param version the version.
*/
+ @CompositeValue(ignore=true)
@XmlTransient
public void setVersion(Object version)
{
@@ -147,6 +153,9 @@
*
* @param version the version.
*/
+ @CompositeKey
+ @CompositeValue(name="version")
+ @ManagementProperty(name="version")
@XmlAttribute(name="version")
public void setTheVersion(Version version)
{
Modified: projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/metadata/ClassLoadingMetaData.java
===================================================================
--- projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/metadata/ClassLoadingMetaData.java 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/metadata/ClassLoadingMetaData.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -30,6 +30,9 @@
import org.jboss.classloader.spi.filter.ClassFilter;
import org.jboss.classloader.spi.filter.PackageClassFilter;
import org.jboss.classloading.spi.helpers.NameAndVersionSupport;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
/**
* ClassLoadingMetaData.
@@ -37,6 +40,7 @@
* @author <a href="adrian at jboss.org">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
+ at ManagementObject(properties=ManagementProperties.EXPLICIT, name="org.jboss.classloading.spi.metadata.ClassLoadingMetaData")
public class ClassLoadingMetaData extends NameAndVersionSupport
{
/** The serialVersionUID */
@@ -102,6 +106,7 @@
*
* @param domain the domain.
*/
+ @ManagementProperty
@XmlAttribute
public void setDomain(String domain)
{
@@ -123,6 +128,7 @@
*
* @param parentDomain the parentDomain.
*/
+ @ManagementProperty
@XmlAttribute
public void setParentDomain(String parentDomain)
{
@@ -144,6 +150,7 @@
*
* @param exportAll the exportAll.
*/
+ @ManagementProperty
@XmlAttribute(name="export-all")
public void setExportAll(ExportAll exportAll)
{
@@ -165,6 +172,7 @@
*
* @param includedPackages the includedPackages.
*/
+ @ManagementProperty(name="included")
@XmlAttribute(name="included")
public void setIncludedPackages(String includedPackages)
{
@@ -215,6 +223,7 @@
*
* @param excludedPackages the excludedPackages.
*/
+ @ManagementProperty(name="excluded")
@XmlAttribute(name="excluded")
public void setExcludedPackages(String excludedPackages)
{
@@ -265,6 +274,7 @@
*
* @param excludedExportPackages the excludedExportPackages.
*/
+ @ManagementProperty(name="excludedExport")
@XmlAttribute(name="excludedExport")
public void setExcludedExportPackages(String excludedExportPackages)
{
@@ -315,6 +325,7 @@
*
* @param importAll the importAll.
*/
+ @ManagementProperty
@XmlAttribute(name="import-all")
public void setImportAll(boolean importAll)
{
@@ -336,6 +347,7 @@
*
* @param classLoadingCompliance the j2seClassLoadingCompliance.
*/
+ @ManagementProperty(name="parentFirst")
@XmlAttribute(name="parent-first")
public void setJ2seClassLoadingCompliance(boolean classLoadingCompliance)
{
@@ -357,6 +369,7 @@
*
* @param cacheable the cacheable.
*/
+ @ManagementProperty(name="cache")
@XmlAttribute(name="cache")
public void setCacheable(boolean cacheable)
{
@@ -378,6 +391,7 @@
*
* @param blackListable the blackListable.
*/
+ @ManagementProperty(name="blackList")
@XmlAttribute(name="blackList")
public void setBlackListable(boolean blackListable)
{
@@ -400,6 +414,7 @@
* @param capabilities the capabilities.
* @throws IllegalArgumentException for null capabilities
*/
+ @ManagementProperty
public void setCapabilities(CapabilitiesMetaData capabilities)
{
if (capabilities == null)
@@ -435,6 +450,7 @@
* @param requirements the requirements.
* @throws IllegalArgumentException for null requirements
*/
+ @ManagementProperty
public void setRequirements(RequirementsMetaData requirements)
{
if (requirements == null)
Modified: projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/version/Version.java
===================================================================
--- projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/version/Version.java 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/version/Version.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -26,6 +26,9 @@
import java.util.StringTokenizer;
import java.util.regex.Pattern;
+import org.jboss.classloading.plugins.metadata.VersionMetaMapper;
+import org.jboss.metatype.api.annotations.MetaMapping;
+
/**
* Version.
*
@@ -33,6 +36,7 @@
* @author <a href="adrian at jboss.org">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
+ at MetaMapping(VersionMetaMapper.class)
public class Version implements Serializable, Comparable<Version>
{
/** The serialVersionUID */
Modified: projects/microcontainer/trunk/classloading/src/tests/org/jboss/test/classloading/metadata/MetaDataTestSuite.java
===================================================================
--- projects/microcontainer/trunk/classloading/src/tests/org/jboss/test/classloading/metadata/MetaDataTestSuite.java 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/classloading/src/tests/org/jboss/test/classloading/metadata/MetaDataTestSuite.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -28,6 +28,7 @@
import org.jboss.test.classloading.metadata.test.CapabilitiesMetaDataUnitTestCase;
import org.jboss.test.classloading.metadata.test.ClassLoadingMetaDataFactoryUnitTestCase;
import org.jboss.test.classloading.metadata.test.ClassLoadingMetaDataUnitTestCase;
+import org.jboss.test.classloading.metadata.test.ManagedObjectClassLoadingMetaDataUnitTestCase;
import org.jboss.test.classloading.metadata.test.ModuleCapabilityUnitTestCase;
import org.jboss.test.classloading.metadata.test.ModuleRequirementUnitTestCase;
import org.jboss.test.classloading.metadata.test.NameAndVersionRangeUnitTestCase;
@@ -74,6 +75,7 @@
suite.addTest(RequirementsMetaDataUnitTestCase.suite());
suite.addTest(ClassLoadingMetaDataFactoryUnitTestCase.suite());
suite.addTest(ClassLoadingMetaDataUnitTestCase.suite());
+ suite.addTest(ManagedObjectClassLoadingMetaDataUnitTestCase.suite());
suite.addTest(ClassLoadingMetaDataXmlUnitTestCase.suite());
return suite;
Added: projects/microcontainer/trunk/classloading/src/tests/org/jboss/test/classloading/metadata/test/ManagedObjectClassLoadingMetaDataUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/classloading/src/tests/org/jboss/test/classloading/metadata/test/ManagedObjectClassLoadingMetaDataUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/classloading/src/tests/org/jboss/test/classloading/metadata/test/ManagedObjectClassLoadingMetaDataUnitTestCase.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -0,0 +1,238 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.classloading.metadata.test;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+
+import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.classloading.spi.metadata.RequirementsMetaData;
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * ManagedObjectClassLoadingMetaDataUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagedObjectClassLoadingMetaDataUnitTestCase extends BaseTestCase
+{
+ private ManagedObjectFactory moFactory = ManagedObjectFactory.getInstance();
+ private MetaTypeFactory mtFactory = MetaTypeFactory.getInstance();
+ private MetaValueFactory mvFactory = MetaValueFactory.getInstance();
+
+ public static Test suite()
+ {
+ return suite(ManagedObjectClassLoadingMetaDataUnitTestCase.class);
+ }
+
+ public ManagedObjectClassLoadingMetaDataUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected ManagedObject assertManagedObject(ClassLoadingMetaData test)
+ {
+ ManagedObject result = moFactory.initManagedObject(test, null, null);
+ assertNotNull(result);
+ List<String> expectedProperties = Arrays.asList("name", "version", "domain", "parentDomain", "exportAll", "included", "excluded", "excludedExport", "importAll", "parentFirst", "cache", "blackList", "capabilities", "requirements");
+ Set<String> actualProperties = result.getPropertyNames();
+ for (String expected : expectedProperties)
+ {
+ if (actualProperties.contains(expected) == false)
+ fail("Expected property: " + expected);
+ }
+ for (String actual : actualProperties)
+ {
+ if (expectedProperties.contains(actual) == false)
+ fail("Did not expect property: " + actual);
+ }
+ return result;
+ }
+
+ protected ManagedProperty assertManagedProperty(ManagedObject mo, String name, MetaType<?> metaType, MetaValue metaValue)
+ {
+ ManagedProperty property = mo.getProperty(name);
+ assertNotNull("No property " + name, property);
+ assertEquals(metaType, property.getMetaType());
+ assertEquals(metaValue, property.getValue());
+ return property;
+ }
+
+ protected <T> ManagedProperty assertManagedProperty(ManagedObject mo, String name, Class<T> type, T value)
+ {
+ MetaType<?> metaType = mtFactory.resolve(type);
+
+ MetaValue metaValue = null;
+ if (value != null)
+ metaValue = mvFactory.create(value);
+ return assertManagedProperty(mo, name, metaType, metaValue);
+ }
+
+ public void testConstructor() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "name", String.class, "<unknown>");
+ assertManagedProperty(mo, "version", Version.class, Version.DEFAULT_VERSION);
+ assertManagedProperty(mo, "domain", String.class, null);
+ assertManagedProperty(mo, "parentDomain", String.class, null);
+ assertManagedProperty(mo, "exportAll", ExportAll.class, null);
+ assertManagedProperty(mo, "included", String.class, null);
+ assertManagedProperty(mo, "excluded", String.class, null);
+ assertManagedProperty(mo, "excludedExport", String.class, null);
+ assertManagedProperty(mo, "importAll", Boolean.class, false);
+ assertManagedProperty(mo, "parentFirst", Boolean.class, true);
+ assertManagedProperty(mo, "capabilities", CapabilitiesMetaData.class, new CapabilitiesMetaData());
+ assertManagedProperty(mo, "requirements", RequirementsMetaData.class, new RequirementsMetaData());
+ }
+
+ public void testSetName() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setName("test");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "name", String.class, "test");
+ }
+
+ public void testSetVersion() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setVersion("1.0.0");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "version", Version.class, Version.parseVersion("1.0.0"));
+ }
+
+ public void testSetDomain() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setDomain("domain");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "domain", String.class, "domain");
+ }
+
+ public void testSetParentDomain() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setParentDomain("parentDomain");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "parentDomain", String.class, "parentDomain");
+ }
+
+ public void testSetExportAll() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setExportAll(ExportAll.ALL);
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "exportAll", ExportAll.class, ExportAll.ALL);
+ }
+
+ public void testSetIncludedPackages() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setIncludedPackages("Included");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "included", String.class, "Included");
+ }
+
+ public void testSetExcludedPackages() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setExcludedPackages("Excluded");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "excluded", String.class, "Excluded");
+ }
+
+ public void testSetExcludedExportPackages() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setExcludedExportPackages("ExcludedExport");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "excludedExport", String.class, "ExcludedExport");
+ }
+
+ public void testSetImportAll() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setImportAll(true);
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "importAll", Boolean.class, true);
+ }
+
+ public void testJ2seClassLoadingComplaince() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setJ2seClassLoadingCompliance(false);
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "parentFirst", Boolean.class, false);
+ }
+
+ public void testCacheable() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setCacheable(false);
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "cache", Boolean.class, false);
+ }
+
+ public void testBlackList() throws Exception
+ {
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.setBlackListable(false);
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "blackList", Boolean.class, false);
+ }
+
+ public void testCapabilities() throws Exception
+ {
+ ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.getCapabilities().addCapability(factory.createModule("module"));
+ test.getCapabilities().addCapability(factory.createPackage("package"));
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "requirements", RequirementsMetaData.class, test.getRequirements());
+ }
+
+ public void testRequirements() throws Exception
+ {
+ ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
+ ClassLoadingMetaData test = new ClassLoadingMetaData();
+ test.getRequirements().addRequirement(factory.createRequireModule("module"));
+ test.getRequirements().addRequirement(factory.createRequirePackage("package"));
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "requirements", RequirementsMetaData.class, test.getRequirements());
+ }
+}
Modified: projects/microcontainer/trunk/classloading-vfs/.classpath
===================================================================
--- projects/microcontainer/trunk/classloading-vfs/.classpath 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/classloading-vfs/.classpath 2008-02-22 09:49:08 UTC (rev 70033)
@@ -27,6 +27,8 @@
<classpathentry combineaccessrules="false" kind="src" path="/jboss-container"/>
<classpathentry combineaccessrules="false" kind="src" path="/jboss-dependency"/>
<classpathentry combineaccessrules="false" kind="src" path="/jboss-kernel"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-metatype"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-managed"/>
<classpathentry combineaccessrules="false" kind="src" path="/jboss-classloading"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: projects/microcontainer/trunk/classloading-vfs/src/main/org/jboss/classloading/spi/vfs/metadata/VFSClassLoaderFactory.java
===================================================================
--- projects/microcontainer/trunk/classloading-vfs/src/main/org/jboss/classloading/spi/vfs/metadata/VFSClassLoaderFactory.java 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/classloading-vfs/src/main/org/jboss/classloading/spi/vfs/metadata/VFSClassLoaderFactory.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -36,6 +36,7 @@
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.classloading.spi.version.Version;
import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule;
+import org.jboss.managed.api.annotation.ManagementProperty;
/**
* VFSClassLoaderFactory.
@@ -115,6 +116,7 @@
*
* @param classLoaderSystemName the classLoaderSystemName.
*/
+ @ManagementProperty(name="system")
@XmlAttribute(name="system")
public void setClassLoaderSystemName(String classLoaderSystemName)
{
@@ -138,6 +140,7 @@
*
* @param contextName the contextName.
*/
+ @ManagementProperty(name="context")
@XmlAttribute(name="context")
public void setContextName(String contextName)
{
@@ -159,6 +162,7 @@
*
* @param roots the roots.
*/
+ @ManagementProperty(name="roots")
@XmlElement(name="root")
public void setRoots(List<String> roots)
{
Modified: projects/microcontainer/trunk/classloading-vfs/src/tests/org/jboss/test/classloading/ClassLoadingVFSTestSuite.java
===================================================================
--- projects/microcontainer/trunk/classloading-vfs/src/tests/org/jboss/test/classloading/ClassLoadingVFSTestSuite.java 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/classloading-vfs/src/tests/org/jboss/test/classloading/ClassLoadingVFSTestSuite.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -27,6 +27,7 @@
import org.jboss.test.classloading.vfs.metadata.test.DomainUnitTestCase;
import org.jboss.test.classloading.vfs.metadata.test.ImportAllUnitTestCase;
+import org.jboss.test.classloading.vfs.metadata.test.ManagedObjectVFSClassLoaderFactoryUnitTestCase;
import org.jboss.test.classloading.vfs.metadata.test.ModuleDependencyUnitTestCase;
import org.jboss.test.classloading.vfs.metadata.test.PackageDependencyUnitTestCase;
import org.jboss.test.classloading.vfs.metadata.test.ReExportModuleUnitTestCase;
@@ -70,6 +71,7 @@
suite.addTest(ModuleDependencyUnitTestCase.suite());
suite.addTest(PackageDependencyUnitTestCase.suite());
suite.addTest(VFSClassLoaderFactoryUnitTestCase.suite());
+ suite.addTest(ManagedObjectVFSClassLoaderFactoryUnitTestCase.suite());
suite.addTest(ReExportModuleUnitTestCase.suite());
suite.addTest(ReExportPackageUnitTestCase.suite());
suite.addTest(UsesPackageUnitTestCase.suite());
Added: projects/microcontainer/trunk/classloading-vfs/src/tests/org/jboss/test/classloading/vfs/metadata/test/ManagedObjectVFSClassLoaderFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/classloading-vfs/src/tests/org/jboss/test/classloading/vfs/metadata/test/ManagedObjectVFSClassLoaderFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/classloading-vfs/src/tests/org/jboss/test/classloading/vfs/metadata/test/ManagedObjectVFSClassLoaderFactoryUnitTestCase.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -0,0 +1,273 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.classloading.vfs.metadata.test;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+
+import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.classloading.spi.metadata.RequirementsMetaData;
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * ManagedObjectVFSClassLoaderFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagedObjectVFSClassLoaderFactoryUnitTestCase extends BaseTestCase
+{
+ private ManagedObjectFactory moFactory = ManagedObjectFactory.getInstance();
+ private MetaTypeFactory mtFactory = MetaTypeFactory.getInstance();
+ private MetaValueFactory mvFactory = MetaValueFactory.getInstance();
+
+ public static Test suite()
+ {
+ return suite(ManagedObjectVFSClassLoaderFactoryUnitTestCase.class);
+ }
+
+ public ManagedObjectVFSClassLoaderFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected ManagedObject assertManagedObject(VFSClassLoaderFactory test)
+ {
+ ManagedObject result = moFactory.initManagedObject(test, null, null);
+ assertNotNull(result);
+ List<String> expectedProperties = Arrays.asList("name", "version", "context", "domain", "parentDomain", "exportAll", "included", "excluded", "excludedExport", "importAll", "parentFirst", "cache", "blackList", "system", "roots", "capabilities", "requirements");
+ Set<String> actualProperties = result.getPropertyNames();
+ for (String expected : expectedProperties)
+ {
+ if (actualProperties.contains(expected) == false)
+ fail("Expected property: " + expected);
+ }
+ for (String actual : actualProperties)
+ {
+ if (expectedProperties.contains(actual) == false)
+ fail("Did not expect property: " + actual);
+ }
+ return result;
+ }
+
+ protected ManagedProperty assertManagedProperty(ManagedObject mo, String name, MetaType<?> metaType, MetaValue metaValue)
+ {
+ ManagedProperty property = mo.getProperty(name);
+ assertNotNull("No property " + name, property);
+ assertEquals(metaType, property.getMetaType());
+ assertEquals(metaValue, property.getValue());
+ return property;
+ }
+
+ protected ManagedProperty assertManagedProperty(ManagedObject mo, String name, Type type, Object value)
+ {
+ MetaType<?> metaType = mtFactory.resolve(type);
+
+ MetaValue metaValue = null;
+ if (value != null)
+ metaValue = mvFactory.create(value, type);
+ return assertManagedProperty(mo, name, metaType, metaValue);
+ }
+
+ protected <T> ManagedProperty assertManagedProperty(ManagedObject mo, String name, Class<T> type, T value)
+ {
+ return assertManagedProperty(mo, name, (Type) type, value);
+ }
+
+ public void testConstructor() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "name", String.class, "<unknown>");
+ assertManagedProperty(mo, "version", Version.class, Version.DEFAULT_VERSION);
+ assertManagedProperty(mo, "domain", String.class, null);
+ assertManagedProperty(mo, "parentDomain", String.class, null);
+ assertManagedProperty(mo, "exportAll", ExportAll.class, null);
+ assertManagedProperty(mo, "included", String.class, null);
+ assertManagedProperty(mo, "excluded", String.class, null);
+ assertManagedProperty(mo, "excludedExport", String.class, null);
+ assertManagedProperty(mo, "importAll", Boolean.class, false);
+ assertManagedProperty(mo, "parentFirst", Boolean.class, true);
+ assertManagedProperty(mo, "capabilities", CapabilitiesMetaData.class, new CapabilitiesMetaData());
+ assertManagedProperty(mo, "requirements", RequirementsMetaData.class, new RequirementsMetaData());
+ }
+
+ public void testSetName() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setName("test");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "name", String.class, "test");
+ }
+
+ public void testSetVersion() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setVersion("1.0.0");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "version", Version.class, Version.parseVersion("1.0.0"));
+ }
+
+ public void testContext() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setContextName("context");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "context", String.class, "context");
+ }
+
+ public void testSetDomain() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setDomain("domain");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "domain", String.class, "domain");
+ }
+
+ public void testSetParentDomain() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setParentDomain("parentDomain");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "parentDomain", String.class, "parentDomain");
+ }
+
+ public void testSetExportAll() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setExportAll(ExportAll.ALL);
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "exportAll", ExportAll.class, ExportAll.ALL);
+ }
+
+ public void testSetIncludedPackages() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setIncludedPackages("Included");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "included", String.class, "Included");
+ }
+
+ public void testSetExcludedPackages() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setExcludedPackages("Excluded");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "excluded", String.class, "Excluded");
+ }
+
+ public void testSetExcludedExportPackages() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setExcludedExportPackages("ExcludedExport");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "excludedExport", String.class, "ExcludedExport");
+ }
+
+ public void testSetImportAll() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setImportAll(true);
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "importAll", Boolean.class, true);
+ }
+
+ public void testJ2seClassLoadingComplaince() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setJ2seClassLoadingCompliance(false);
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "parentFirst", Boolean.class, false);
+ }
+
+ public void testCacheable() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setCacheable(false);
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "cache", Boolean.class, false);
+ }
+
+ public void testBlackList() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setBlackListable(false);
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "blackList", Boolean.class, false);
+ }
+
+ public void testSetSystem() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.setClassLoaderSystemName("test");
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "system", String.class, "test");
+ }
+
+ public void testSetRoots() throws Exception
+ {
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ List<String> roots = Arrays.asList("test1", "test2");
+ test.setRoots(roots);
+ ManagedObject mo = assertManagedObject(test);
+ Field field = getClass().getField("rootsSignature");
+ assertManagedProperty(mo, "roots", field.getGenericType(), roots);
+ }
+
+ public static List<String> rootsSignature;
+
+ public void testCapabilities() throws Exception
+ {
+ ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.getCapabilities().addCapability(factory.createModule("module"));
+ test.getCapabilities().addCapability(factory.createPackage("package"));
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "requirements", RequirementsMetaData.class, test.getRequirements());
+ }
+
+ public void testRequirements() throws Exception
+ {
+ ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
+ VFSClassLoaderFactory test = new VFSClassLoaderFactory();
+ test.getRequirements().addRequirement(factory.createRequireModule("module"));
+ test.getRequirements().addRequirement(factory.createRequirePackage("package"));
+ ManagedObject mo = assertManagedObject(test);
+ assertManagedProperty(mo, "requirements", RequirementsMetaData.class, test.getRequirements());
+ }
+}
Modified: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml 2008-02-22 09:49:08 UTC (rev 70033)
@@ -109,6 +109,7 @@
<parameter>org.jboss.classloading.spi.metadata.ClassLoadingMetaData</parameter>
</constructor>
<property name="name">jboss-classloading.xml</property>
+ <property name="buildManagedObject">true</property>
</bean>
<bean name="ClassLoadingDefaultDeployer" class="org.jboss.deployers.plugins.classloading.ClassLoadingDefaultDeployer">
<property name="defaultMetaData">
Added: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/deployment0/META-INF/jboss-classloading.xml
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/deployment0/META-INF/jboss-classloading.xml (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/deployment0/META-INF/jboss-classloading.xml 2008-02-22 09:49:08 UTC (rev 70033)
@@ -0,0 +1,3 @@
+<classloading xmlns="urn:jboss:classloading:1.0" name="test">
+</classloading>
+
Modified: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java 2008-02-22 09:44:34 UTC (rev 70032)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -25,6 +25,7 @@
import org.jboss.test.deployers.vfs.classloader.test.DeploymentDependsOnDeploymentClassLoaderUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.DeploymentDependsOnManualClassLoaderUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.InMemoryClasesUnitTestCase;
+import org.jboss.test.deployers.vfs.classloader.test.ManagedObjectClassLoadingParserUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.ManualDependsOnDeploymentClassLoaderUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.VFSClassLoaderDependenciesUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.VFSUndeployOrderClassLoaderUnitTestCase;
@@ -57,6 +58,7 @@
suite.addTest(DeploymentDependsOnManualClassLoaderUnitTestCase.suite());
suite.addTest(ManualDependsOnDeploymentClassLoaderUnitTestCase.suite());
suite.addTest(DeploymentDependsOnDeploymentClassLoaderUnitTestCase.suite());
+ suite.addTest(ManagedObjectClassLoadingParserUnitTestCase.suite());
return suite;
}
Added: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/ManagedObjectClassLoadingParserUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/ManagedObjectClassLoadingParserUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/ManagedObjectClassLoadingParserUnitTestCase.java 2008-02-22 09:49:08 UTC (rev 70033)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.vfs.classloader.test;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+
+import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.classloading.spi.metadata.RequirementsMetaData;
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+
+/**
+ * ManagedObjectClassLoadingParserUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagedObjectClassLoadingParserUnitTestCase extends BootstrapDeployersTest
+{
+ private MetaTypeFactory mtFactory = MetaTypeFactory.getInstance();
+ private MetaValueFactory mvFactory = MetaValueFactory.getInstance();
+
+ public static Test suite()
+ {
+ return suite(ManagedObjectClassLoadingParserUnitTestCase.class);
+ }
+
+ public ManagedObjectClassLoadingParserUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected ManagedProperty assertManagedProperty(ManagedObject mo, String name, MetaType<?> metaType, MetaValue metaValue)
+ {
+ ManagedProperty property = mo.getProperty(name);
+ assertNotNull("No property " + name, property);
+ assertEquals(metaType, property.getMetaType());
+ assertEquals(metaValue, property.getValue());
+ return property;
+ }
+
+ protected <T> ManagedProperty assertManagedProperty(ManagedObject mo, String name, Class<T> type, T value)
+ {
+ MetaType<?> metaType = mtFactory.resolve(type);
+
+ MetaValue metaValue = null;
+ if (value != null)
+ metaValue = mvFactory.create(value);
+ return assertManagedProperty(mo, name, metaType, metaValue);
+ }
+
+ public void testManagedObject() throws Exception
+ {
+ VFSDeploymentUnit unit0 = addDeployment("/classloader", "deployment0");
+ try
+ {
+ ManagedDeployment managedDeployment = getDeployerClient().getManagedDeployment(unit0.getName());
+ assertNotNull(managedDeployment);
+ ManagedObject mo = managedDeployment.getManagedObject(ClassLoadingMetaData.class.getName());
+ assertNotNull(mo);
+ getLog().debug("ManagedObject: " + mo + " properties=" + mo.getProperties());
+
+ List<String> expectedProperties = Arrays.asList("name", "version", "domain", "parentDomain", "exportAll", "included", "excluded", "excludedExport", "importAll", "parentFirst", "cache", "blackList", "capabilities", "requirements");
+ Set<String> actualProperties = mo.getPropertyNames();
+ for (String expected : expectedProperties)
+ {
+ if (actualProperties.contains(expected) == false)
+ fail("Expected property: " + expected);
+ }
+ for (String actual : actualProperties)
+ {
+ if (expectedProperties.contains(actual) == false)
+ fail("Did not expect property: " + actual);
+ }
+
+ assertManagedProperty(mo, "name", String.class, "test");
+ assertManagedProperty(mo, "version", Version.class, Version.DEFAULT_VERSION);
+ assertManagedProperty(mo, "domain", String.class, null);
+ assertManagedProperty(mo, "parentDomain", String.class, null);
+ assertManagedProperty(mo, "exportAll", ExportAll.class, null);
+ assertManagedProperty(mo, "included", String.class, null);
+ assertManagedProperty(mo, "excluded", String.class, null);
+ assertManagedProperty(mo, "excludedExport", String.class, null);
+ assertManagedProperty(mo, "importAll", Boolean.class, false);
+ assertManagedProperty(mo, "parentFirst", Boolean.class, true);
+ assertManagedProperty(mo, "capabilities", CapabilitiesMetaData.class, new CapabilitiesMetaData());
+ assertManagedProperty(mo, "requirements", RequirementsMetaData.class, new RequirementsMetaData());
+
+ }
+ finally
+ {
+ undeploy(unit0);
+ }
+ }
+}
More information about the jboss-cvs-commits
mailing list