[jboss-cvs] JBossAS SVN: r63962 - in projects/microcontainer/trunk: managed/src/main/org/jboss/managed and 37 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 11 02:10:15 EDT 2007
Author: adrian at jboss.org
Date: 2007-07-11 02:10:14 -0400 (Wed, 11 Jul 2007)
New Revision: 63962
Added:
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementConstants.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementObject.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementProperties.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementProperty.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/factory/
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/factory/ManagedObjectFactory.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/ManagedObjectFactoryBuilder.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/spi/
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/spi/factory/
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/spi/factory/ManagedObjectBuilder.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/spi/factory/ManagedObjectPopulator.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/AbstractManagedObjectFactoryTest.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/ManagedObjectFactoryTestSuite.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectAll.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectChangedName.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectExplicit.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectIgnored.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectNone.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertyDescription.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertyMandatory.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertySimpleManaged.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/Simple.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementObjectPropertiesUnitTestCase.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementObjectUnitTestCase.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/SimpleManagedObjectFactoryUnitTestCase.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/ManagedMockTestSuite.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeKey.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/Generic.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/EnumMetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/GenericMetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaTypeFactory.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/ArrayValue.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/ArrayValueSupport.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/EnumValue.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/EnumValueSupport.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/GenericValue.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/GenericValueSupport.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/MetaValueFactory.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/AbstractCompositeMetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/ClassMetaTypeBuilder.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/MetaTypeFactoryBuilder.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/MutableCompositeMetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/MetaValueFactoryBuilder.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/types/
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/types/MetaTypeBuilder.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/values/
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/values/MetaValueBuilder.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestEnum.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestGeneric.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestGenericComposite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestOverrideComposite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestOverrideCompositeBuilder.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestRecursiveComposite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestSimpleAnnotation.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestSimpleComposite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/AbstractMetaTypeFactoryTest.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/AnnotationMetaTypeFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/ArrayMetaTypeFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CollectionMetaTypeFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CompositeMetaTypeFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/EnumMetaTypeFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/MapMetaTypeFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/SimpleMetaTypeFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/SpecialMetaTypeFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/TypesFactoryTestSuite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestAnnotation.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestEnum.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestGeneric.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestGenericComposite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestOverrideComposite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestOverrideCompositeBuilder.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestRecursiveComposite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestSimpleComposite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/AbstractMetaValueFactoryTest.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/AnnotationValueFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ArrayValueFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CollectionValueFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CompositeValueFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/EnumValueFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MapValueFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/SimpleValueFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/SpecialValueFactoryUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ValuesFactoryTestSuite.java
Modified:
projects/microcontainer/trunk/managed/.classpath
projects/microcontainer/trunk/managed/.project
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/ManagedObject.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/DefaultFieldsImpl.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedObjectImpl.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedPropertyImpl.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedPropertyImplFactory.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/advice/TraceAdvice.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/advice/WrapperAdvice.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/ManagedAllTestSuite.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/ManagedTest.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/ManagedTestDelegate.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDOMFields.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDataSourceManagedObject.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockTest.java
projects/microcontainer/trunk/metatype/.classpath
projects/microcontainer/trunk/metatype/pom.xml
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/AbstractMetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ArrayMetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/CompositeMetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ImmutableCompositeMetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ImmutableTableMetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/SimpleMetaType.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/CompositeValueSupport.java
projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/TableValue.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/AbstractMetaTypeTest.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/MetaTypeAllTestSuite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockCompositeValue.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockMetaType.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockMetaValue.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockSimpleValue.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockTableValue.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ArrayMetaTypeUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ImmutableCompositeMetaTypeUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ImmutableTableMetaTypeUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/TypesTestSuite.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/CompositeValueSupportUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/SimpleValueSupportUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/TableValueSupportUnitTestCase.java
projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/ValuesTestSuite.java
Log:
[JBMICROCONT-181] - Checkin of incomplete work, to avoid Scott duplicating things. :-)
Modified: projects/microcontainer/trunk/managed/.classpath
===================================================================
--- projects/microcontainer/trunk/managed/.classpath 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/.classpath 2007-07-11 06:10:14 UTC (rev 63962)
@@ -1,36 +1,35 @@
-<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/main"/>
- <classpathentry kind="src" output="eclipse-target/tests-classes" path="src/tests"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/qdox/qdox/1.6/qdox-1.6.jar" sourcepath="M2_REPO/qdox/qdox/1.6/qdox-1.6-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
- <classpathentry kind="var" path="M2_REPO/ant/ant/1.6.5/ant-1.6.5.jar" sourcepath="M2_REPO/ant/ant/1.6.5/ant-1.6.5-sources.jar"/>
- <classpathentry kind="src" path="/jboss-container"/>
- <classpathentry kind="var" path="M2_REPO/sun-jaf/activation/1.0.2/activation-1.0.2.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA-sources.jar"/>
- <classpathentry kind="src" path="/jboss-metatype"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jbossxb/2.0.0.CR3/jbossxb-2.0.0.CR3.jar" sourcepath="M2_REPO/jboss/jbossxb/2.0.0.CR3/jbossxb-2.0.0.CR3-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-vfs/2.0.4.snapshot/jboss-vfs-2.0.4.snapshot.jar" sourcepath="M2_REPO/jboss/jboss-vfs/2.0.4.snapshot/jboss-vfs-2.0.4.snapshot-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-test/1.0.3.GA/jboss-test-1.0.3.GA.jar" sourcepath="M2_REPO/jboss/jboss-test/1.0.3.GA/jboss-test-1.0.3.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA.jar" sourcepath="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/javassist/3.6-beta/javassist-3.6-beta.jar" sourcepath="M2_REPO/org/jboss/javassist/3.6-beta/javassist-3.6-beta-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.8/log4j-1.2.8.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.7.1/xml-apis-2.7.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-slide/webdavlib/2.0/webdavlib-2.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-aop/2.0.0-SNAPSHOT/jboss-aop-2.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/jboss-aop/2.0.0-SNAPSHOT/jboss-aop-2.0.0-SNAPSHOT-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.5-SNAPSHOT/javassist-3.5-SNAPSHOT.jar" sourcepath="M2_REPO/javassist/javassist/3.5-SNAPSHOT/javassist-3.5-SNAPSHOT-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.7.1/xercesImpl-2.7.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/trove/trove/2.1.1/trove-2.1.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA.jar" sourcepath="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA-sources.jar"/>
- <classpathentry kind="output" path="eclipse-target/classes"/>
-</classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="src" path="src/tests" output="target/test-classes"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
+ <classpathentry kind="src" path="/jboss-metatype"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/qdox/qdox/1.6/qdox-1.6.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-test/1.0.3.GA/jboss-test-1.0.3.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-aop/2.0.0-SNAPSHOT/jboss-aop-2.0.0-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javassist/3.6-beta/javassist-3.6-beta.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.0.2/activation-1.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-slide/webdavlib/2.0/webdavlib-2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.8/log4j-1.2.8.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.7.1/xercesImpl-2.7.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbossxb/2.0.0.CR3/jbossxb-2.0.0.CR3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.5-SNAPSHOT/javassist-3.5-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/ant/ant/1.6.5/ant-1.6.5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.7.1/xml-apis-2.7.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-vfs/2.0.4.snapshot/jboss-vfs-2.0.4.snapshot.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/trove/trove/2.1.1/trove-2.1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar"/>
+ <classpathentry kind="src" path="/jboss-container"/>
+</classpath>
\ No newline at end of file
Modified: projects/microcontainer/trunk/managed/.project
===================================================================
--- projects/microcontainer/trunk/managed/.project 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/.project 2007-07-11 06:10:14 UTC (rev 63962)
@@ -2,8 +2,8 @@
<name>jboss-managed</name>
<comment>JBoss Microcontainer Managed</comment>
<projects>
+ <project>jboss-metatype</project>
<project>jboss-container</project>
- <project>jboss-metatype</project>
</projects>
<buildSpec>
<buildCommand>
Modified: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/ManagedObject.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/ManagedObject.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/ManagedObject.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -67,12 +67,4 @@
* @return the properties
*/
Set<ManagedProperty> getProperties();
-
-
- /**
- * Get the operations.
- * @return A possibly empty set of the operations assocated with
- * the managed object.
- */
- Set<ManagedOperation> getOperations();
}
Added: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementConstants.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementConstants.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementConstants.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,34 @@
+/*
+* 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.managed.api.annotation;
+
+/**
+ * ManagementConstants.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ManagementConstants
+{
+ /** Whether to generate the value */
+ String GENERATED = "%Generated%";
+}
Added: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementObject.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementObject.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementObject.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,44 @@
+/*
+* 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.managed.api.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * ManagementObject.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Target({ElementType.TYPE})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface ManagementObject
+{
+ /** The object name */
+ String name() default ManagementConstants.GENERATED;
+
+ /** What properties to include */
+ ManagementProperties properties() default ManagementProperties.ALL;
+}
Added: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementProperties.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementProperties.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementProperties.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,37 @@
+/*
+* 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.managed.api.annotation;
+
+/**
+ * ManagementProperities.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public enum ManagementProperties
+{
+ /** All properties by default */
+ ALL,
+
+ /** Only annotated properties */
+ EXPLICIT,
+}
Added: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementProperty.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementProperty.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/annotation/ManagementProperty.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,50 @@
+/*
+* 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.managed.api.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * ManagementProperty.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Target({ElementType.METHOD})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface ManagementProperty
+{
+ /** The description */
+ String description() default ManagementConstants.GENERATED;
+
+ /** Whether this property is mandatory */
+ boolean mandatory() default false;
+
+ /** Whether to create a managed object for the property */
+ boolean managed() default false;
+
+ /** Whether to ignore this property */
+ boolean ignored() default false;
+}
Added: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/factory/ManagedObjectFactory.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/factory/ManagedObjectFactory.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/factory/ManagedObjectFactory.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,77 @@
+/*
+* 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.managed.api.factory;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
+import org.jboss.managed.spi.factory.ManagedObjectBuilder;
+
+/**
+ * ManagedObjectFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ManagedObjectFactory
+{
+ /** The managed object factory instance */
+ private static ManagedObjectFactoryBuilder builder = new ManagedObjectFactoryBuilder();
+
+ /**
+ * Get the managed object factory instance
+ *
+ * @return the instance
+ */
+ public static ManagedObjectFactory getInstance()
+ {
+ return builder.create();
+ }
+
+ /**
+ * Create a managed object from the given object
+ *
+ * @param object the object
+ * @return the managed object
+ * @throws IllegalArgumentException for a null object
+ */
+ public abstract ManagedObject initManagedObject(Serializable object);
+
+ /**
+ * Create a shell managed object from the given class
+ *
+ * @param <T> the class
+ * @param clazz the class
+ * @return the managed object
+ * @throws IllegalArgumentException for a null class
+ */
+ public abstract <T extends Serializable> ManagedObject createManagedObject(Class<T> clazz);
+
+ /**
+ * Set a managed object builder
+ *
+ * @param clazz the class
+ * @param builder the builder (null to remove the builder)
+ */
+ public abstract void setBuilder(Class<?> clazz, ManagedObjectBuilder builder);
+}
Modified: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/DefaultFieldsImpl.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/DefaultFieldsImpl.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/DefaultFieldsImpl.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -39,82 +39,175 @@
public class DefaultFieldsImpl
implements Fields
{
+ /** The serialVersionUID */
private static final long serialVersionUID = 1;
+ /** The fields */
private HashMap<String, Serializable> fields = new HashMap<String, Serializable>();
+ /**
+ * Create a new DefaultFieldsImpl.
+ */
public DefaultFieldsImpl()
{
}
+
+ /**
+ * Create a new DefaultFieldsImpl.
+ *
+ * @param name the property name
+ */
public DefaultFieldsImpl(String name)
{
this.setName(name);
}
+ /**
+ * Get the property name
+ *
+ * @return the name
+ */
public String getName()
{
return getField(NAME, String.class);
}
+
+ /**
+ * Set the property name
+ *
+ * @param name the name
+ */
public void setName(String name)
{
setField(NAME, name);
}
+ /**
+ * Get the description
+ *
+ * @return the description
+ */
public String getDescription()
{
return getField(DESCRIPTION, String.class);
}
+
+ /**
+ * Set the description
+ *
+ * @param description the description
+ */
public void setDescription(String description)
{
setField(DESCRIPTION, description);
}
+ /**
+ * Get the meta type
+ *
+ * @return the meta type
+ */
public MetaType getMetaType()
{
return getField(META_TYPE, MetaType.class);
}
+
+ /**
+ * Set the meta type
+ *
+ * @param type the meta type
+ */
public void setMetaType(MetaType type)
{
setField(META_TYPE, type);
}
+ /**
+ * Get the value
+ *
+ * @return the value
+ */
public Object getValue()
{
return getField(VALUE);
}
+
+ /**
+ * Set the value
+ *
+ * @param value the value
+ */
public void setValue(Serializable value)
{
setField(VALUE, value);
}
+ /**
+ * Get the legal values
+ *
+ * @return the values
+ */
@SuppressWarnings("unchecked")
public Set<MetaValue> getLegalValues()
{
return getField(LEGAL_VALUES, Set.class);
}
+
+ /**
+ * Set the legal values
+ *
+ * @param values the values
+ */
public void setLegalValues(Set<MetaValue> values)
{
setField(LEGAL_VALUES, (Serializable)values);
}
+ /**
+ * Get the minimum value
+ *
+ * @return the minimum value
+ */
public Comparable getMinimumValue()
{
return getField(MINIMUM_VALUE, Comparable.class);
}
+
+ /**
+ * Set the minimum value
+ *
+ * @param value the value
+ */
public void setMinimumValue(Comparable value)
{
setField(MINIMUM_VALUE, (Serializable)value);
}
+ /**
+ * Get the maximum value
+ *
+ * @return the value
+ */
public Comparable getMaximumValue()
{
return getField(MAXIMUM_VALUE, Comparable.class);
}
+
+ /**
+ * Get the maximum value
+ *
+ * @param value the value
+ */
public void setMaximumValue(Comparable value)
{
setField(MAXIMUM_VALUE, (Serializable)value);
}
+ /**
+ * Get whether the property is mandatory
+ *
+ * @return true when mandaotry
+ */
public boolean isMandatory()
{
Boolean result = getField(MANDATORY, Boolean.class);
@@ -122,21 +215,49 @@
return false;
return result;
}
+
+ /**
+ * Set the mandatory value
+ *
+ * @param flag true when mandatory
+ */
public void setMandatory(boolean flag)
{
- setField(MANDATORY, flag);
+ if (flag)
+ setField(MANDATORY, flag);
+ else
+ setField(MANDATORY, null);
}
+ /**
+ * Get a field
+ *
+ * @param name the field name
+ */
public Serializable getField(String name)
{
return fields.get(name);
}
+ /**
+ * Set a field
+ *
+ * @param name the field name
+ * @param value the value
+ */
public void setField(String name, Serializable value)
{
fields.put(name, value);
}
+ /**
+ * Get a field
+ *
+ * @param <T> the expected type
+ * @param fieldName the field name
+ * @param expected the expected type
+ * @return the field value
+ */
@SuppressWarnings("unchecked")
public <T> T getField(String fieldName, Class<T> expected)
{
Modified: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedObjectImpl.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedObjectImpl.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedObjectImpl.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -26,7 +26,6 @@
import java.util.Set;
import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedOperation;
import org.jboss.managed.api.ManagedProperty;
/**
@@ -144,12 +143,7 @@
{
this.attachment = attachment;
}
-
- public Set<ManagedOperation> getOperations()
- {
- return null;
- }
-
+
@Override
public boolean equals(Object obj)
{
Modified: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedPropertyImpl.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedPropertyImpl.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedPropertyImpl.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -66,8 +66,8 @@
/**
* Create a new ManagedProperty that is not associated to
* a ManagedObject.
- *
- * @param name the property name
+ *
+ * @param name the managed property name
* @throws IllegalArgumentException for null fields or
* missing Fields.NAME
*/
@@ -106,6 +106,12 @@
{
return managedObject;
}
+
+ /**
+ * Set managed object
+ *
+ * @param managedObject the managed object
+ */
public void setManagedObject(ManagedObject managedObject)
{
this.managedObject = managedObject;
@@ -142,7 +148,7 @@
return expected.cast(result);
}
- throw new IllegalStateException("Field " + fieldName + " with value " + field + " is a of the expected type: " + expected.getName());
+ throw new IllegalStateException("Field " + fieldName + " with value " + field + " is not of the expected type: " + expected.getName());
}
// TODO metaType stuff
@@ -168,6 +174,12 @@
{
return getField(Fields.DESCRIPTION, String.class);
}
+
+ /**
+ * Set the description
+ *
+ * @param description the description
+ */
public void setDescription(String description)
{
setField(Fields.DESCRIPTION, description);
@@ -178,6 +190,12 @@
{
return getField(Fields.META_TYPE, MetaType.class);
}
+
+ /**
+ * Set the meta type
+ *
+ * @param type the meta type
+ */
public void setMetaType(MetaType type)
{
setField(Fields.META_TYPE, type);
@@ -198,6 +216,12 @@
{
return getField(Fields.LEGAL_VALUES, Set.class);
}
+
+ /**
+ * Set the legal values
+ *
+ * @param values the values
+ */
public void setLegalValues(Set<MetaValue> values)
{
setField(Fields.LEGAL_VALUES, (Serializable)values);
@@ -207,6 +231,12 @@
{
return getField(Fields.MINIMUM_VALUE, Comparable.class);
}
+
+ /**
+ * Set the minimum value
+ *
+ * @param value the value
+ */
public void setMinimumValue(Comparable value)
{
setField(Fields.MINIMUM_VALUE, (Serializable)value);
@@ -216,6 +246,12 @@
{
return getField(Fields.MAXIMUM_VALUE, Comparable.class);
}
+
+ /**
+ * Set the maximum value
+ *
+ * @param value the value
+ */
public void setMaximumValue(Comparable value)
{
setField(Fields.MAXIMUM_VALUE, (Serializable)value);
@@ -234,9 +270,18 @@
return false;
return result;
}
+
+ /**
+ * Set whether the field is mandatory
+ *
+ * @param flag true for mandatory
+ */
public void setMandatory(boolean flag)
{
- setField(Fields.MANDATORY, flag);
+ if (flag)
+ setField(Fields.MANDATORY, flag);
+ else
+ setField(Fields.MANDATORY, null);
}
@Override
@@ -269,7 +314,7 @@
return false;
ManagedProperty other = (ManagedProperty) obj;
- return getName().equals(other.getName()) && getManagedObject().equals(other.getManagedObject()) ;
+ return getName().equals(other.getName());
}
/**
Modified: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedPropertyImplFactory.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedPropertyImplFactory.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedPropertyImplFactory.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -32,6 +32,15 @@
*/
public class ManagedPropertyImplFactory
{
+ /**
+ * Create a new managed property
+ *
+ * @param name the property name
+ * @param description the property description
+ * @param metaType the metatype
+ * @param manadatory whether the property is mandatory
+ * @return the managed property
+ */
public static ManagedProperty newInstance(String name, String description,
String metaType, boolean manadatory)
{
Modified: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/advice/TraceAdvice.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/advice/TraceAdvice.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/advice/TraceAdvice.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -38,6 +38,13 @@
/** The log */
private static final Logger log = Logger.getLogger(TraceAdvice.class);
+ /**
+ * Interceptor
+ *
+ * @param invocation the invocation
+ * @return the result
+ * @throws Throwable for any problem
+ */
public Object invoke(Invocation invocation) throws Throwable
{
boolean trace = log.isTraceEnabled();
Modified: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/advice/WrapperAdvice.java
===================================================================
Added: 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 (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,374 @@
+/*
+* 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.managed.plugins.factory;
+
+import java.io.Serializable;
+import java.lang.ref.WeakReference;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.config.plugins.property.PropertyConfiguration;
+import org.jboss.config.spi.Configuration;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ManagementConstants;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.managed.spi.factory.ManagedObjectBuilder;
+import org.jboss.managed.spi.factory.ManagedObjectPopulator;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.GenericValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.reflect.spi.ClassInfo;
+
+/**
+ * AbstractManagedObjectFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractManagedObjectFactory extends ManagedObjectFactory implements ManagedObjectBuilder, ManagedObjectPopulator<Serializable>
+{
+ /** The configuration */
+ private static final Configuration configuration;
+
+ /** The managed object meta type */
+ public static final GenericMetaType MANAGED_OBJECT_META_TYPE = new GenericMetaType(ManagedObject.class.getName(), ManagedObject.class.getName());
+
+ /** The meta type factory */
+ private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+
+ /** The meta value factory */
+ private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+
+ /** The managed object builders */
+ private Map<Class, WeakReference<ManagedObjectBuilder>> builders = new WeakHashMap<Class, WeakReference<ManagedObjectBuilder>>();
+
+ static
+ {
+ configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
+ {
+ public Configuration run()
+ {
+ return new PropertyConfiguration();
+ }
+ });
+ }
+
+ @Override
+ public <T extends Serializable> ManagedObject createManagedObject(Class<T> clazz)
+ {
+ if (clazz == null)
+ throw new IllegalArgumentException("Null class");
+
+ ManagedObject result = createSkeletonManagedObject(clazz);
+ ManagedObjectPopulator<Serializable> populator = getPopulator(clazz);
+ populator.createObject(result, clazz);
+
+ return result;
+ }
+
+ @Override
+ public ManagedObject initManagedObject(Serializable object)
+ {
+ if (object == null)
+ throw new IllegalArgumentException("Null object");
+
+ Class<? extends Serializable> clazz = object.getClass();
+ ManagedObject result = createSkeletonManagedObject(clazz);
+ ManagedObjectPopulator<Serializable> populator = getPopulator(clazz);
+ populator.populateManagedObject(result, object);
+
+ return result;
+ }
+
+ @Override
+ public void setBuilder(Class<?> clazz, ManagedObjectBuilder builder)
+ {
+ synchronized (builders)
+ {
+ if (builder == null)
+ builders.remove(clazz);
+ builders.put(clazz, new WeakReference<ManagedObjectBuilder>(builder));
+ }
+ }
+
+ /**
+ * Create a skeleton managed object
+ *
+ * @param <T> the type
+ * @param clazz the clazz
+ * @return the skeleton managed object
+ */
+ protected <T extends Serializable> ManagedObject createSkeletonManagedObject(Class<T> clazz)
+ {
+ if (clazz == null)
+ throw new IllegalArgumentException("Null class");
+
+ ManagedObjectBuilder builder = getBuilder(clazz);
+ return builder.buildManagedObject(clazz);
+ }
+
+ public ManagedObject buildManagedObject(Class<? extends Serializable> clazz)
+ {
+ BeanInfo beanInfo = configuration.getBeanInfo(clazz);
+ ClassInfo classInfo = beanInfo.getClassInfo();
+
+ ManagementObject managementObject = classInfo.getUnderlyingAnnotation(ManagementObject.class);
+
+ String name = ManagementConstants.GENERATED;
+ if (managementObject != null)
+ name = managementObject.name();
+ if (ManagementConstants.GENERATED.equals(name))
+ name = classInfo.getName();
+
+ ManagementProperties propertyType = ManagementProperties.ALL;
+ if (managementObject != null)
+ propertyType = managementObject.properties();
+
+ Set<ManagedProperty> properties = new HashSet<ManagedProperty>();
+
+ Set<PropertyInfo> propertyInfos = beanInfo.getProperties();
+ if (propertyInfos != null && propertyInfos.isEmpty() == false)
+ {
+ for (PropertyInfo propertyInfo : propertyInfos)
+ {
+ // Ignore the "class" property
+ if ("class".equals(propertyInfo.getName()))
+ continue;
+
+ ManagementProperty managementProperty = propertyInfo.getUnderlyingAnnotation(ManagementProperty.class);
+
+ boolean includeProperty = (propertyType == ManagementProperties.ALL);
+ if (managementProperty != null)
+ includeProperty = (managementProperty.ignored() == false);
+
+ if (includeProperty)
+ {
+ Fields fields = new DefaultFieldsImpl();
+
+ String propertyName = propertyInfo.getName();
+ fields.setField(Fields.NAME, propertyName);
+
+ String description = ManagementConstants.GENERATED;
+ if (managementProperty != null)
+ description = managementProperty.description();
+ if (description.equals(ManagementConstants.GENERATED))
+ description = propertyName;
+ fields.setField(Fields.DESCRIPTION, description);
+
+ boolean mandatory = false;
+ if (managementProperty != null)
+ mandatory = managementProperty.mandatory();
+ if (mandatory)
+ fields.setField(Fields.MANDATORY, Boolean.TRUE);
+
+ boolean managed = false;
+ if (managementProperty != null)
+ managed = managementProperty.managed();
+
+ MetaType metaType;
+ if (managed)
+ {
+ metaType = MANAGED_OBJECT_META_TYPE;
+ }
+ else
+ {
+ metaType = metaTypeFactory.resolve(propertyInfo.getType());
+ }
+ fields.setField(Fields.META_TYPE, metaType);
+
+ // TODO others (legal values, min/max etc.)
+
+ ManagedPropertyImpl property = new ManagedPropertyImpl(fields);
+ properties.add(property);
+ }
+ }
+ }
+
+ ManagedObjectImpl result = new ManagedObjectImpl(name, properties);
+ for (ManagedProperty property : properties)
+ {
+ ManagedPropertyImpl managedPropertyImpl = (ManagedPropertyImpl) property;
+ managedPropertyImpl.setManagedObject(result);
+ }
+
+ return result;
+ }
+
+ public void createObject(ManagedObject managedObject, Class<? extends Serializable> clazz)
+ {
+ if (managedObject instanceof ManagedObjectImpl == false)
+ throw new IllegalStateException("Unable to create object " + managedObject.getClass().getName());
+
+ ManagedObjectImpl managedObjectImpl = (ManagedObjectImpl) managedObject;
+ Serializable object = createUnderlyingObject(managedObjectImpl, clazz);
+ populateManagedObject(managedObject, object);
+ }
+
+ public void populateManagedObject(ManagedObject managedObject, Serializable object)
+ {
+ if (managedObject instanceof ManagedObjectImpl == false)
+ throw new IllegalStateException("Unable to populate managed object " + managedObject.getClass().getName());
+
+ ManagedObjectImpl managedObjectImpl = (ManagedObjectImpl) managedObject;
+ managedObjectImpl.setAttachment(object);
+ populateValues(managedObjectImpl, object);
+ }
+
+ /**
+ * Create the underlying object
+ *
+ * @param managedObject the managed object
+ * @param clazz the class
+ * @return the object
+ */
+ protected Serializable createUnderlyingObject(ManagedObjectImpl managedObject, Class<? extends Serializable> clazz)
+ {
+ BeanInfo beanInfo = configuration.getBeanInfo(clazz);
+ try
+ {
+ Object result = beanInfo.newInstance();
+ return Serializable.class.cast(result);
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Unable to create new object for " + managedObject + " clazz=" + clazz, t);
+ }
+ }
+
+ /**
+ * Populate the values
+ *
+ * @param managedObject the managed object
+ * @param object the object
+ */
+ protected void populateValues(ManagedObjectImpl managedObject, Serializable object)
+ {
+ BeanInfo beanInfo = configuration.getBeanInfo(object.getClass());
+
+ Set<ManagedProperty> properties = managedObject.getProperties();
+ if (properties != null && properties.size() > 0)
+ {
+ for (ManagedProperty property : properties)
+ {
+ MetaValue value = getValue(beanInfo, property, object);
+ if (value != null)
+ property.setField(Fields.VALUE, value);
+ }
+ }
+ }
+
+ /**
+ * Get a value
+ *
+ * @param beanInfo the bean info
+ * @param property the property
+ * @param object the object
+ * @return the meta value
+ */
+ protected MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, Serializable object)
+ {
+ String name = property.getName();
+
+ PropertyInfo propertyInfo = beanInfo.getProperty(name);
+ if (propertyInfo == null)
+ throw new IllegalStateException("Unable to find property: " + name + " for " + object.getClass().getName());
+
+ Object value = null;
+ try
+ {
+ value = propertyInfo.get(object);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error getting property " + name + " for " + object.getClass().getName(), t);
+ }
+
+ if (value == null)
+ return null;
+
+ if (MANAGED_OBJECT_META_TYPE == property.getMetaType())
+ {
+ if (value instanceof Serializable == false)
+ throw new IllegalStateException("Object is not serializable: " + value.getClass().getName());
+ ManagedObject mo = initManagedObject((Serializable) value);
+ return new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo);
+ }
+
+ return metaValueFactory.create(value, propertyInfo.getType());
+ }
+
+ /**
+ * Get the builder for a class
+ *
+ * @param clazz the class
+ * @return the builder
+ */
+ protected ManagedObjectBuilder getBuilder(Class<?> clazz)
+ {
+ synchronized (builders)
+ {
+ WeakReference<ManagedObjectBuilder> weak = builders.get(clazz);
+ if (weak != null)
+ return weak.get();
+ }
+ return this;
+ }
+
+ /**
+ * Get the populator for a class
+ *
+ * @param clazz the class
+ * @return the populator
+ */
+ @SuppressWarnings("unchecked")
+ protected ManagedObjectPopulator<Serializable> getPopulator(Class<?> clazz)
+ {
+ ManagedObjectBuilder builder = getBuilder(clazz);
+ if (builder instanceof ManagedObjectPopulator)
+ return (ManagedObjectPopulator) builder;
+ return this;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/ManagedObjectFactoryBuilder.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/ManagedObjectFactoryBuilder.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/ManagedObjectFactoryBuilder.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,47 @@
+/*
+* 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.managed.plugins.factory;
+
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+
+/**
+ * ManagedObjectFactoryBuilder
+ *
+ * TODO this class only creates a singleton fixed implementation for now
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagedObjectFactoryBuilder
+{
+ /** The singleton */
+ private static final ManagedObjectFactory singleton = new AbstractManagedObjectFactory();
+
+ /**
+ * Create the factory
+ *
+ * @return the factory
+ */
+ public static ManagedObjectFactory create()
+ {
+ return singleton;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/spi/factory/ManagedObjectBuilder.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/spi/factory/ManagedObjectBuilder.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/spi/factory/ManagedObjectBuilder.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,43 @@
+/*
+* 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.managed.spi.factory;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.ManagedObject;
+
+/**
+ * ManagedObjectBuilder.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ManagedObjectBuilder
+{
+ /**
+ * Build the managed object
+ *
+ * @param clazz the class
+ * @return the managed object
+ */
+ ManagedObject buildManagedObject(Class<? extends Serializable> clazz);
+}
Added: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/spi/factory/ManagedObjectPopulator.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/spi/factory/ManagedObjectPopulator.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/spi/factory/ManagedObjectPopulator.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,52 @@
+/*
+* 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.managed.spi.factory;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.ManagedObject;
+
+/**
+ * ManagedObjectPopulator.
+ *
+ * @param <T> the underlying object
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ManagedObjectPopulator<T extends Serializable>
+{
+ /**
+ * Create a new underlying object
+ *
+ * @param managedObject the managed object
+ * @param clazz the class
+ */
+ void createObject(ManagedObject managedObject, Class<? extends Serializable> clazz);
+
+ /**
+ * Populate the managed object
+ *
+ * @param managedObject the managed object
+ * @param object the object used to populate the managed object
+ */
+ void populateManagedObject(ManagedObject managedObject, T object);
+}
Modified: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/ManagedAllTestSuite.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/ManagedAllTestSuite.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/ManagedAllTestSuite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -21,12 +21,13 @@
*/
package org.jboss.test.managed;
-import org.jboss.test.managed.mock.MockTest;
-
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+import org.jboss.test.managed.factory.ManagedObjectFactoryTestSuite;
+import org.jboss.test.managed.mock.ManagedMockTestSuite;
+
/**
* Managed All Test Suite.
*
@@ -36,16 +37,27 @@
*/
public class ManagedAllTestSuite extends TestSuite
{
+ /**
+ * For running the testsuite from the command line
+ *
+ * @param args the command line args
+ */
public static void main(String[] args)
{
TestRunner.run(suite());
}
+ /**
+ * Create the testsuite
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
TestSuite suite = new TestSuite("Managed All Tests");
- suite.addTest(MockTest.suite());
+ suite.addTest(ManagedMockTestSuite.suite());
+ suite.addTest(ManagedObjectFactoryTestSuite.suite());
return suite;
}
Modified: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/ManagedTest.java
===================================================================
Modified: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/ManagedTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/ManagedTestDelegate.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/ManagedTestDelegate.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -35,7 +35,7 @@
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @author Scott.Stark at jboss.com
- * @version $Revision: 58245 $
+ * @version $Revision:59255 $
*/
public class ManagedTestDelegate extends AbstractTestDelegate
{
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/AbstractManagedObjectFactoryTest.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/AbstractManagedObjectFactoryTest.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/AbstractManagedObjectFactoryTest.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,342 @@
+/*
+* 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.test.managed.factory;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Set;
+
+import junit.framework.TestSuite;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
+import org.jboss.managed.spi.factory.ManagedObjectBuilder;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.GenericValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.test.BaseTestCase;
+import org.jboss.util.Strings;
+
+/**
+ * AbstractManagedObjectFactoryTest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractManagedObjectFactoryTest extends BaseTestCase
+{
+ /** The managed object factory */
+ private static final ManagedObjectFactory managedObjectFactory = ManagedObjectFactory.getInstance();
+
+ /** The meta type factory */
+ private static final MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+
+ /** The meta value factory */
+ private static final MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+
+ /**
+ * Create a new testsuite for the class
+ *
+ * TODO move to BaseTestCase
+ * @param clazz the class
+ * @return the suite
+ */
+ public static TestSuite suite(Class<?> clazz)
+ {
+ return new TestSuite(clazz);
+ }
+
+ /**
+ * Create a new AbstractManagedObjectFactoryTest.
+ *
+ * @param name the test name
+ */
+ public AbstractManagedObjectFactoryTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Initialize a managed object
+ *
+ * @param object the object
+ * @return the managed object
+ */
+ protected ManagedObject initManagedObject(Serializable object)
+ {
+ ManagedObject result = managedObjectFactory.initManagedObject(object);
+ getLog().debug("Inited managed: " + result + " for object=" + Strings.defaultToString(object));
+ return result;
+ }
+
+ /**
+ * Create a managed object
+ *
+ * @param <T> the type
+ * @param clazz the type
+ * @return the managed object
+ */
+ protected <T extends Serializable> ManagedObject createManagedObject(Class<T> clazz)
+ {
+ ManagedObject result = managedObjectFactory.createManagedObject(clazz);
+ getLog().debug("Created managed: " + result + " for class=" + clazz.getName());
+ return result;
+ }
+
+ /**
+ * Set a builder for a class
+ *
+ * @param clazz the class
+ * @param builder the builder
+ */
+ protected void setBuilder(Class<?> clazz, ManagedObjectBuilder builder)
+ {
+ managedObjectFactory.setBuilder(clazz, builder);
+ }
+
+ /**
+ * Resolve a meta type
+ *
+ * @param clazz the class
+ * @return the meta type
+ */
+ protected MetaType resolve(Class<?> clazz)
+ {
+ return metaTypeFactory.resolve(clazz);
+ }
+
+ /**
+ * Create and check a managed object
+ *
+ * @param clazz the object
+ * @return the managed obejct
+ */
+ protected ManagedObject createAndCheckDefaultManagedObject(Class<? extends Serializable> clazz)
+ {
+ ManagedObject managedObject = createManagedObject(clazz);
+ checkManagedObjectDefaults(clazz, managedObject);
+ checkDefaultManagedProperties(managedObject, clazz);
+ return managedObject;
+ }
+
+ /**
+ * Initialize and check a managed object
+ *
+ * @param test the object
+ * @return the managed object
+ */
+ protected ManagedObject checkManagedObject(Serializable test)
+ {
+ ManagedObject managedObject = initManagedObject(test);
+ checkManagedObjectDefaults(test.getClass(), managedObject);
+ checkDefaultManagedProperties(managedObject, test.getClass());
+ return managedObject;
+ }
+
+ /**
+ * Check managed object defaults
+ *
+ * @param clazz the class
+ * @param managedObject the managed object
+ */
+ protected void checkManagedObjectDefaults(Class<? extends Serializable> clazz, ManagedObject managedObject)
+ {
+ checkManagedObjectDefaults(clazz, managedObject, null);
+ }
+
+ /**
+ * Check managed object defaults
+ *
+ * @param clazz the class
+ * @param managedObject the managed object
+ * @param expectedAttachment the expected attachment
+ */
+ protected void checkManagedObjectDefaults(Class<? extends Serializable> clazz, ManagedObject managedObject, Object expectedAttachment)
+ {
+ checkManagedObject(clazz, managedObject, clazz.getName(), expectedAttachment);
+ }
+
+ /**
+ * Check a managed object
+ *
+ * @param clazz the class
+ * @param managedObject the managed object
+ * @param name the managed object name
+ * @param expectedAttachment the expected attachment
+ */
+ protected void checkManagedObject(Class<? extends Serializable> clazz, ManagedObject managedObject, String name, Object expectedAttachment)
+ {
+ getLog().debug("CheckMangedObject: clazz=" + clazz.getName() + " managedObject=" + managedObject + " name=" + name + " expectedAttachment=" + Strings.defaultToString(expectedAttachment));
+ assertNotNull(managedObject);
+ String managedObjectName = managedObject.getName();
+ getLog().debug("... name=" + managedObjectName);
+ assertEquals(name, managedObjectName);
+ Object attachment = managedObject.getAttachment();
+ getLog().debug("... attachment=" + Strings.defaultToString(attachment));
+ assertInstanceOf(attachment, clazz, false);
+ if (expectedAttachment != null)
+ assertTrue("ManagedObject should have the correct attachment expected " + Strings.defaultToString(expectedAttachment) + " got " + Strings.defaultToString(attachment), expectedAttachment == attachment);
+ }
+
+ /**
+ * Check default managed properties
+ *
+ * @param managedObject the managed object
+ * @param clazz the class
+ */
+ protected void checkDefaultManagedProperties(ManagedObject managedObject, Class<?> clazz)
+ {
+ CompositeMetaType metaType = assertInstanceOf(resolve(clazz), CompositeMetaType.class);
+ Set<String> expectedNames = metaType.itemSet();
+ Set<String> propertyNames = managedObject.getPropertyNames();
+ getLog().debug("checkDefaultProperties");
+ getLog().debug("... expectedNames=" + expectedNames);
+ getLog().debug("..... actualNames=" + propertyNames);
+ assertEquals("Expected properties " + expectedNames + " got " + propertyNames, expectedNames.size(), propertyNames.size());
+ for (String name : expectedNames)
+ {
+ ManagedProperty managedProperty = managedObject.getProperty(name);
+ assertNotNull("Expected property '" + name + "' in " + propertyNames, managedProperty);
+ assertEquals(managedObject, managedProperty.getManagedObject());
+ }
+ }
+
+ /**
+ * Check managed properties
+ *
+ * @param managedObject the managed object
+ * @param names the expected property names
+ */
+ protected void checkManagedProperties(ManagedObject managedObject, String... names)
+ {
+ Set<String> propertyNames = managedObject.getPropertyNames();
+ getLog().debug("checkManagedProperties");
+ getLog().debug("... expectedNames=" + Arrays.asList(names));
+ getLog().debug("..... actualNames=" + propertyNames);
+ assertEquals("Expected properties " + Arrays.asList(names) + " got " + propertyNames, names.length, propertyNames.size());
+ for (String name : names)
+ {
+ ManagedProperty managedProperty = managedObject.getProperty(name);
+ assertNotNull("Expected property '" + name + "' in " + propertyNames, managedProperty);
+ assertEquals(managedObject, managedProperty.getManagedObject());
+ }
+ }
+
+ /**
+ * Check property defaults
+ *
+ * @param managedObject the managed object
+ * @param name the property name
+ * @param clazz the property class
+ */
+ protected void checkPropertyDefaults(ManagedObject managedObject, String name, Class<?> clazz)
+ {
+ checkPropertyDefaults(managedObject, name, clazz, null);
+ }
+
+ /**
+ * Check property defaults
+ *
+ * @param managedObject the managed object
+ * @param name the property name
+ * @param clazz the property class
+ * @param value the expected property value
+ */
+ protected void checkPropertyDefaults(ManagedObject managedObject, String name, Class<?> clazz, Object value)
+ {
+ checkProperty(managedObject, name, clazz, name, false, value);
+ }
+
+ /**
+ * Check property
+ *
+ * @param managedObject the managed object
+ * @param name the property name
+ * @param clazz the property class
+ * @param description the property description
+ * @param mandatory whether the property is expected mandatory
+ * @param value the expected property value
+ */
+ protected void checkProperty(ManagedObject managedObject, String name, Class<?> clazz, String description, boolean mandatory, Object value)
+ {
+ MetaType expectedType = resolve(clazz);
+ MetaValue expectedValue = metaValueFactory.create(value, clazz);
+ checkProperty(managedObject, name, expectedType, expectedValue, description, mandatory);
+ }
+
+ /**
+ * Check a property is a managed object
+ *
+ * @param managedObject the managed object
+ * @param name the property name
+ * @param description the property description
+ * @param mandatory whether the property is expected mandatory
+ * @param value the expected property value
+ */
+ protected void checkPropertyIsManagedObject(ManagedObject managedObject, String name, String description, boolean mandatory, Object value)
+ {
+ GenericMetaType expectedType = AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE;
+ MetaValue expectedValue = new GenericValueSupport(expectedType, initManagedObject((Serializable) value));
+ checkProperty(managedObject, name, expectedType, expectedValue, description, mandatory);
+ }
+
+ /**
+ * Check a property
+ *
+ * @param managedObject the managed object
+ * @param name the property name
+ * @param expectedType the expected meta type
+ * @param expectedValue the expected meta value
+ * @param description the property description
+ * @param mandatory whether the property is expected mandatory
+ */
+ protected void checkProperty(ManagedObject managedObject, String name, MetaType expectedType, MetaValue expectedValue, String description, boolean mandatory)
+ {
+ getLog().debug("checkProperty name=" + name + " type=" + expectedType + " desc=" + description + " mandatory=" + mandatory + " value=" + expectedValue);
+ ManagedProperty managedProperty = managedObject.getProperty(name);
+ getLog().debug("... managedProperty=" + managedProperty);
+ assertNotNull("Expected property " + name + " in " + managedObject.getPropertyNames(), managedProperty);
+ String propertyName = managedProperty.getName();
+ getLog().debug("... name=" + propertyName);
+ assertEquals("Property '" + name + "' has the wrong name", name, propertyName);
+ String propertyDescription = managedProperty.getDescription();
+ getLog().debug("... description=" + propertyDescription);
+ assertEquals("Property '" + name + "' has the wrong description", description, propertyDescription);
+ boolean propertyMandatory = managedProperty.isMandatory();
+ getLog().debug("... mandatory=" + propertyMandatory);
+ assertEquals("Property '" + name + "' has the wrong mandatory flag", mandatory, propertyMandatory);
+ getLog().debug("... expected metaType=" + expectedType);
+ MetaType actualType = managedProperty.getMetaType();
+ getLog().debug("..... actual metaType=" + expectedType);
+ assertEquals("Property '" + name + "' has the wrong type", expectedType, actualType);
+ getLog().debug("... expected value=" + expectedValue);
+ Object actualValue = managedProperty.getValue();
+ getLog().debug("..... actual value=" + actualValue);
+ assertEquals("Property '" + name + "' has the wrong value", expectedValue, actualValue);
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/ManagedObjectFactoryTestSuite.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/ManagedObjectFactoryTestSuite.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/ManagedObjectFactoryTestSuite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.test.managed.factory;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.managed.factory.test.ManagementObjectPropertiesUnitTestCase;
+import org.jboss.test.managed.factory.test.ManagementObjectUnitTestCase;
+import org.jboss.test.managed.factory.test.ManagementPropertyUnitTestCase;
+import org.jboss.test.managed.factory.test.SimpleManagedObjectFactoryUnitTestCase;
+
+/**
+ * ManagedObjectFactory Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37459 $
+ */
+public class ManagedObjectFactoryTestSuite extends TestSuite
+{
+ /**
+ * For running the testsuite from the command line
+ *
+ * @param args the command line args
+ */
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ /**
+ * Create the testsuite
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ManagedObjectFactory Tests");
+
+ suite.addTest(SimpleManagedObjectFactoryUnitTestCase.suite());
+ suite.addTest(ManagementObjectUnitTestCase.suite());
+ suite.addTest(ManagementObjectPropertiesUnitTestCase.suite());
+ suite.addTest(ManagementPropertyUnitTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectAll.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectAll.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectAll.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,60 @@
+/*
+* 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.test.managed.factory.support;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+
+/**
+ * ManagementObjectAll.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at ManagementObject(properties=ManagementProperties.ALL)
+public class ManagementObjectAll implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * Get property 1
+ *
+ * @return null
+ */
+ public String getProperty1()
+ {
+ return null;
+ }
+
+ /**
+ * Get property 2
+ *
+ * @return null
+ */
+ public String getProperty2()
+ {
+ return null;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectChangedName.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectChangedName.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectChangedName.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,40 @@
+/*
+* 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.test.managed.factory.support;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+
+/**
+ * ManagementObjectChangedName.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at ManagementObject(name="changed")
+public class ManagementObjectChangedName implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectExplicit.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectExplicit.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectExplicit.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -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.test.managed.factory.support;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * ManagementObjectExplicit.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at ManagementObject(properties=ManagementProperties.EXPLICIT)
+public class ManagementObjectExplicit implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * Get property 1
+ *
+ * @return null
+ */
+ @ManagementProperty
+ public String getProperty1()
+ {
+ return null;
+ }
+
+ /**
+ * Get property 2
+ *
+ * @return null
+ */
+ public String getProperty2()
+ {
+ return null;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectIgnored.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectIgnored.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectIgnored.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -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.test.managed.factory.support;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * ManagementObjectIgnored.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at ManagementObject(properties=ManagementProperties.ALL)
+public class ManagementObjectIgnored implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * Get property 1
+ *
+ * @return null
+ */
+ @ManagementProperty(ignored=true)
+ public String getProperty1()
+ {
+ return null;
+ }
+
+ /**
+ * Get property 2
+ *
+ * @return null
+ */
+ public String getProperty2()
+ {
+ return null;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectNone.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectNone.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementObjectNone.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,60 @@
+/*
+* 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.test.managed.factory.support;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+
+/**
+ * ManagementObjectNone.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at ManagementObject(properties=ManagementProperties.EXPLICIT)
+public class ManagementObjectNone implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * Get property 1
+ *
+ * @return null
+ */
+ public String getProperty1()
+ {
+ return null;
+ }
+
+ /**
+ * Get property 2
+ *
+ * @return null
+ */
+ public String getProperty2()
+ {
+ return null;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertyDescription.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertyDescription.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertyDescription.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,49 @@
+/*
+* 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.test.managed.factory.support;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * ManagementPropertyDescription.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagementPropertyDescription implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * Get property
+ *
+ * @return null
+ */
+ @ManagementProperty(description="changed")
+ public String getProperty()
+ {
+ return null;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertyMandatory.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertyMandatory.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertyMandatory.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,49 @@
+/*
+* 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.test.managed.factory.support;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * ManagementPropertyMandatory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagementPropertyMandatory implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * Get property
+ *
+ * @return null
+ */
+ @ManagementProperty(mandatory=true)
+ public String getProperty()
+ {
+ return null;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertySimpleManaged.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertySimpleManaged.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/ManagementPropertySimpleManaged.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,51 @@
+/*
+* 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.test.managed.factory.support;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * ManagementPropertySimpleManaged.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagementPropertySimpleManaged implements Serializable
+{
+ private ManagementObjectAll property = new ManagementObjectAll();
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * Get property
+ *
+ * @return property
+ */
+ @ManagementProperty(managed=true)
+ public ManagementObjectAll getProperty()
+ {
+ return property;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/Simple.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/Simple.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/Simple.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,479 @@
+/*
+* 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.test.managed.factory.support;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+/**
+ * Simple.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class Simple implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1;
+
+ private BigDecimal bigDecimalValue;
+
+ private BigInteger bigIntegerValue;
+
+ private boolean booleanvalue;
+
+ private Boolean booleanValue;
+
+ private byte bytevalue;
+
+ private Byte byteValue;
+
+ private char charactervalue;
+
+ private Character characterValue;
+
+ private Date dateValue;
+
+ private double doublevalue;
+
+ private Double doubleValue;
+
+ private float floatvalue;
+
+ private Float floatValue;
+
+ private int integervalue;
+
+ private Integer integerValue;
+
+ private long longvalue;
+
+ private Long longValue;
+
+ private short shortvalue;
+
+ private Short shortValue;
+
+ private String stringValue;
+
+ /**
+ * Get the bigDecimalValue.
+ *
+ * @return the bigDecimalValue.
+ */
+ public BigDecimal getBigDecimalValue()
+ {
+ return bigDecimalValue;
+ }
+
+ /**
+ * Set the bigDecimalValue.
+ *
+ * @param bigDecimalValue the bigDecimalValue.
+ */
+ public void setBigDecimalValue(BigDecimal bigDecimalValue)
+ {
+ this.bigDecimalValue = bigDecimalValue;
+ }
+
+ /**
+ * Get the bigIntegerValue.
+ *
+ * @return the bigIntegerValue.
+ */
+ public BigInteger getBigIntegerValue()
+ {
+ return bigIntegerValue;
+ }
+
+ /**
+ * Set the bigIntegerValue.
+ *
+ * @param bigIntegerValue the bigIntegerValue.
+ */
+ public void setBigIntegerValue(BigInteger bigIntegerValue)
+ {
+ this.bigIntegerValue = bigIntegerValue;
+ }
+
+ /**
+ * Get the booleanvalue.
+ *
+ * @return the booleanvalue.
+ */
+ public boolean isBooleanvalue()
+ {
+ return booleanvalue;
+ }
+
+ /**
+ * Set the booleanvalue.
+ *
+ * @param booleanvalue the booleanvalue.
+ */
+ public void setBooleanvalue(boolean booleanvalue)
+ {
+ this.booleanvalue = booleanvalue;
+ }
+
+ /**
+ * Get the booleanValue.
+ *
+ * @return the booleanValue.
+ */
+ public Boolean getBooleanValue()
+ {
+ return booleanValue;
+ }
+
+ /**
+ * Set the booleanValue.
+ *
+ * @param booleanValue the booleanValue.
+ */
+ public void setBooleanValue(Boolean booleanValue)
+ {
+ this.booleanValue = booleanValue;
+ }
+
+ /**
+ * Get the bytevalue.
+ *
+ * @return the bytevalue.
+ */
+ public byte getBytevalue()
+ {
+ return bytevalue;
+ }
+
+ /**
+ * Set the bytevalue.
+ *
+ * @param bytevalue the bytevalue.
+ */
+ public void setBytevalue(byte bytevalue)
+ {
+ this.bytevalue = bytevalue;
+ }
+
+ /**
+ * Get the byteValue.
+ *
+ * @return the byteValue.
+ */
+ public Byte getByteValue()
+ {
+ return byteValue;
+ }
+
+ /**
+ * Set the byteValue.
+ *
+ * @param byteValue the byteValue.
+ */
+ public void setByteValue(Byte byteValue)
+ {
+ this.byteValue = byteValue;
+ }
+
+ /**
+ * Get the charactervalue.
+ *
+ * @return the charactervalue.
+ */
+ public char getCharactervalue()
+ {
+ return charactervalue;
+ }
+
+ /**
+ * Set the charactervalue.
+ *
+ * @param charactervalue the charactervalue.
+ */
+ public void setCharactervalue(char charactervalue)
+ {
+ this.charactervalue = charactervalue;
+ }
+
+ /**
+ * Get the characterValue.
+ *
+ * @return the characterValue.
+ */
+ public Character getCharacterValue()
+ {
+ return characterValue;
+ }
+
+ /**
+ * Set the characterValue.
+ *
+ * @param characterValue the characterValue.
+ */
+ public void setCharacterValue(Character characterValue)
+ {
+ this.characterValue = characterValue;
+ }
+
+ /**
+ * Get the dateValue.
+ *
+ * @return the dateValue.
+ */
+ public Date getDateValue()
+ {
+ return dateValue;
+ }
+
+ /**
+ * Set the dateValue.
+ *
+ * @param dateValue the dateValue.
+ */
+ public void setDateValue(Date dateValue)
+ {
+ this.dateValue = dateValue;
+ }
+
+ /**
+ * Get the doublevalue.
+ *
+ * @return the doublevalue.
+ */
+ public double getDoublevalue()
+ {
+ return doublevalue;
+ }
+
+ /**
+ * Set the doublevalue.
+ *
+ * @param doublevalue the doublevalue.
+ */
+ public void setDoublevalue(double doublevalue)
+ {
+ this.doublevalue = doublevalue;
+ }
+
+ /**
+ * Get the doubleValue.
+ *
+ * @return the doubleValue.
+ */
+ public Double getDoubleValue()
+ {
+ return doubleValue;
+ }
+
+ /**
+ * Set the doubleValue.
+ *
+ * @param doubleValue the doubleValue.
+ */
+ public void setDoubleValue(Double doubleValue)
+ {
+ this.doubleValue = doubleValue;
+ }
+
+ /**
+ * Get the floatvalue.
+ *
+ * @return the floatvalue.
+ */
+ public float getFloatvalue()
+ {
+ return floatvalue;
+ }
+
+ /**
+ * Set the floatvalue.
+ *
+ * @param floatvalue the floatvalue.
+ */
+ public void setFloatvalue(float floatvalue)
+ {
+ this.floatvalue = floatvalue;
+ }
+
+ /**
+ * Get the floatValue.
+ *
+ * @return the floatValue.
+ */
+ public Float getFloatValue()
+ {
+ return floatValue;
+ }
+
+ /**
+ * Set the floatValue.
+ *
+ * @param floatValue the floatValue.
+ */
+ public void setFloatValue(Float floatValue)
+ {
+ this.floatValue = floatValue;
+ }
+
+ /**
+ * Get the integervalue.
+ *
+ * @return the integervalue.
+ */
+ public int getIntegervalue()
+ {
+ return integervalue;
+ }
+
+ /**
+ * Set the integervalue.
+ *
+ * @param integervalue the integervalue.
+ */
+ public void setIntegervalue(int integervalue)
+ {
+ this.integervalue = integervalue;
+ }
+
+ /**
+ * Get the integerValue.
+ *
+ * @return the integerValue.
+ */
+ public Integer getIntegerValue()
+ {
+ return integerValue;
+ }
+
+ /**
+ * Set the integerValue.
+ *
+ * @param integerValue the integerValue.
+ */
+ public void setIntegerValue(Integer integerValue)
+ {
+ this.integerValue = integerValue;
+ }
+
+ /**
+ * Get the longvalue.
+ *
+ * @return the longvalue.
+ */
+ public long getLongvalue()
+ {
+ return longvalue;
+ }
+
+ /**
+ * Set the longvalue.
+ *
+ * @param longvalue the longvalue.
+ */
+ public void setLongvalue(long longvalue)
+ {
+ this.longvalue = longvalue;
+ }
+
+ /**
+ * Get the longValue.
+ *
+ * @return the longValue.
+ */
+ public Long getLongValue()
+ {
+ return longValue;
+ }
+
+ /**
+ * Set the longValue.
+ *
+ * @param longValue the longValue.
+ */
+ public void setLongValue(Long longValue)
+ {
+ this.longValue = longValue;
+ }
+
+ /**
+ * Get the shortvalue.
+ *
+ * @return the shortvalue.
+ */
+ public short getShortvalue()
+ {
+ return shortvalue;
+ }
+
+ /**
+ * Set the shortvalue.
+ *
+ * @param shortvalue the shortvalue.
+ */
+ public void setShortvalue(short shortvalue)
+ {
+ this.shortvalue = shortvalue;
+ }
+
+ /**
+ * Get the shortValue.
+ *
+ * @return the shortValue.
+ */
+ public Short getShortValue()
+ {
+ return shortValue;
+ }
+
+ /**
+ * Set the shortValue.
+ *
+ * @param shortValue the shortValue.
+ */
+ public void setShortValue(Short shortValue)
+ {
+ this.shortValue = shortValue;
+ }
+
+ /**
+ * Get the stringValue.
+ *
+ * @return the stringValue.
+ */
+ public String getStringValue()
+ {
+ return stringValue;
+ }
+
+ /**
+ * Set the stringValue.
+ *
+ * @param stringValue the stringValue.
+ */
+ public void setStringValue(String stringValue)
+ {
+ this.stringValue = stringValue;
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementObjectPropertiesUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementObjectPropertiesUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementObjectPropertiesUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,100 @@
+/*
+* 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.test.managed.factory.test;
+
+import junit.framework.Test;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
+import org.jboss.test.managed.factory.support.ManagementObjectAll;
+import org.jboss.test.managed.factory.support.ManagementObjectExplicit;
+import org.jboss.test.managed.factory.support.ManagementObjectIgnored;
+import org.jboss.test.managed.factory.support.ManagementObjectNone;
+
+/**
+ * ManagementObjectPropertiesUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagementObjectPropertiesUnitTestCase extends AbstractManagedObjectFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(ManagementObjectPropertiesUnitTestCase.class);
+ }
+
+ /**
+ * Create a new ManagementObjectPropertiesUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public ManagementObjectPropertiesUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test all properties included
+ */
+ public void testAll()
+ {
+ ManagedObject managedObject = createManagedObject(ManagementObjectAll.class);
+ checkManagedObjectDefaults(ManagementObjectAll.class, managedObject);
+ checkManagedProperties(managedObject, "property1", "property2");
+ }
+
+ /**
+ * Test some properties ignored
+ */
+ public void testIgnored()
+ {
+ ManagedObject managedObject = createManagedObject(ManagementObjectIgnored.class);
+ checkManagedObjectDefaults(ManagementObjectIgnored.class, managedObject);
+ checkManagedProperties(managedObject, "property2");
+ }
+
+ /**
+ * Test no properties included
+ */
+ public void testNone()
+ {
+ ManagedObject managedObject = createManagedObject(ManagementObjectNone.class);
+ checkManagedObjectDefaults(ManagementObjectNone.class, managedObject);
+ checkManagedProperties(managedObject, new String[0]);
+ }
+
+ /**
+ * Test explicit properties included
+ */
+ public void testExplicit()
+ {
+ ManagedObject managedObject = createManagedObject(ManagementObjectExplicit.class);
+ checkManagedObjectDefaults(ManagementObjectExplicit.class, managedObject);
+ checkManagedProperties(managedObject, "property1");
+ }
+}
\ No newline at end of file
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementObjectUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementObjectUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementObjectUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,66 @@
+/*
+* 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.test.managed.factory.test;
+
+import junit.framework.Test;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
+import org.jboss.test.managed.factory.support.ManagementObjectChangedName;
+
+/**
+ * ManagementObjectUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagementObjectUnitTestCase extends AbstractManagedObjectFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(ManagementObjectUnitTestCase.class);
+ }
+
+ /**
+ * Create a new ManagementObjectUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public ManagementObjectUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the changed name
+ */
+ public void testChangedName()
+ {
+ ManagedObject managedObject = createManagedObject(ManagementObjectChangedName.class);
+ checkManagedObject(ManagementObjectChangedName.class, managedObject, "changed", null);
+ }
+}
\ No newline at end of file
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,87 @@
+/*
+* 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.test.managed.factory.test;
+
+import junit.framework.Test;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
+import org.jboss.test.managed.factory.support.ManagementPropertyDescription;
+import org.jboss.test.managed.factory.support.ManagementPropertyMandatory;
+import org.jboss.test.managed.factory.support.ManagementPropertySimpleManaged;
+
+/**
+ * ManagementPropertyUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagementPropertyUnitTestCase extends AbstractManagedObjectFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(ManagementPropertyUnitTestCase.class);
+ }
+
+ /**
+ * Create a new ManagementPropertyUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public ManagementPropertyUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the overridden description
+ */
+ public void testDescription()
+ {
+ ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyDescription.class);
+ checkProperty(managedObject, "property", String.class, "changed", false, null);
+ }
+
+ /**
+ * Test the overridden mandatory
+ */
+ public void testMandatory()
+ {
+ ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyMandatory.class);
+ checkProperty(managedObject, "property", String.class, "property", true, null);
+ }
+
+ /**
+ * Test the overidden property to managed object
+ */
+ public void testSimpleManaged()
+ {
+ ManagementPropertySimpleManaged test = new ManagementPropertySimpleManaged();
+ ManagedObject managedObject = checkManagedObject(test);
+ checkPropertyIsManagedObject(managedObject, "property", "property", false, test.getProperty());
+ }
+}
\ No newline at end of file
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/SimpleManagedObjectFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/SimpleManagedObjectFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/SimpleManagedObjectFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,151 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.managed.factory.test;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+import junit.framework.Test;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
+import org.jboss.test.managed.factory.support.Simple;
+
+/**
+ * SimpleManagedObjectFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleManagedObjectFactoryUnitTestCase extends AbstractManagedObjectFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(SimpleManagedObjectFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new SimpleManagedObjectFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public SimpleManagedObjectFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the correct managed object is generated for a simple type
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleSkeleton() throws Exception
+ {
+ ManagedObject managedObject = createManagedObject(Simple.class);
+ checkManagedObjectDefaults(Simple.class, managedObject);
+ checkDefaultManagedProperties(managedObject, Simple.class);
+ checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class);
+ checkPropertyDefaults(managedObject, "bigIntegerValue", BigInteger.class);
+ checkPropertyDefaults(managedObject, "booleanvalue", Boolean.TYPE, Boolean.FALSE);
+ checkPropertyDefaults(managedObject, "booleanValue", Boolean.class);
+ checkPropertyDefaults(managedObject, "bytevalue", Byte.TYPE, new Byte((byte) 0));
+ checkPropertyDefaults(managedObject, "byteValue", Byte.class);
+ checkPropertyDefaults(managedObject, "charactervalue", Character.TYPE, new Character('\0'));
+ checkPropertyDefaults(managedObject, "characterValue", Character.class);
+ checkPropertyDefaults(managedObject, "dateValue", Date.class);
+ checkPropertyDefaults(managedObject, "doublevalue", Double.TYPE, new Double(0));
+ checkPropertyDefaults(managedObject, "doubleValue", Double.class);
+ checkPropertyDefaults(managedObject, "floatvalue", Float.TYPE, new Float(0));
+ checkPropertyDefaults(managedObject, "floatValue", Float.class);
+ checkPropertyDefaults(managedObject, "integervalue", Integer.TYPE, new Integer(0));
+ checkPropertyDefaults(managedObject, "integerValue", Integer.class);
+ checkPropertyDefaults(managedObject, "longvalue", Long.TYPE, new Long(0));
+ checkPropertyDefaults(managedObject, "longValue", Long.class);
+ checkPropertyDefaults(managedObject, "shortvalue", Short.TYPE, new Short((short) 0));
+ checkPropertyDefaults(managedObject, "shortValue", Short.class);
+ checkPropertyDefaults(managedObject, "stringValue", String.class);
+ }
+
+ /**
+ * Test the correct managed object is generated for a simple value
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimple() throws Exception
+ {
+ BigDecimal bigDecimal = new BigDecimal(10);
+ BigInteger bigInteger = BigInteger.ONE;
+ Date date = new Date(System.currentTimeMillis());
+
+ Simple simple = new Simple();
+ simple.setBigDecimalValue(bigDecimal);
+ simple.setBigIntegerValue(bigInteger);
+ simple.setBooleanvalue(true);
+ simple.setBooleanValue(Boolean.FALSE);
+ simple.setBytevalue((byte) 1);
+ simple.setByteValue(new Byte((byte) 2));
+ simple.setCharactervalue('a');
+ simple.setCharacterValue(new Character('b'));
+ simple.setDateValue(date);
+ simple.setDoublevalue(1);
+ simple.setDoubleValue(new Double(2));
+ simple.setFloatvalue(1);
+ simple.setFloatValue(new Float(2));
+ simple.setIntegervalue(1);
+ simple.setIntegerValue(new Integer(2));
+ simple.setLongvalue(1);
+ simple.setLongValue(new Long(2));
+ simple.setShortvalue((short) 1);
+ simple.setShortValue(new Short((short) 2));
+ simple.setStringValue("Hello");
+
+ ManagedObject managedObject = initManagedObject(simple);
+ checkManagedObjectDefaults(Simple.class, managedObject, simple);
+ checkDefaultManagedProperties(managedObject, Simple.class);
+ checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal);
+ checkPropertyDefaults(managedObject, "bigIntegerValue", BigInteger.class, bigInteger);
+ checkPropertyDefaults(managedObject, "booleanvalue", Boolean.TYPE, Boolean.TRUE);
+ checkPropertyDefaults(managedObject, "booleanValue", Boolean.class, Boolean.FALSE);
+ checkPropertyDefaults(managedObject, "bytevalue", Byte.TYPE, new Byte((byte) 1));
+ checkPropertyDefaults(managedObject, "byteValue", Byte.class, new Byte((byte) 2));
+ checkPropertyDefaults(managedObject, "charactervalue", Character.TYPE, new Character('a'));
+ checkPropertyDefaults(managedObject, "characterValue", Character.class, new Character('b'));
+ checkPropertyDefaults(managedObject, "dateValue", Date.class, date);
+ checkPropertyDefaults(managedObject, "doublevalue", Double.TYPE, new Double(1));
+ checkPropertyDefaults(managedObject, "doubleValue", Double.class, new Double(2));
+ checkPropertyDefaults(managedObject, "floatvalue", Float.TYPE, new Float(1));
+ checkPropertyDefaults(managedObject, "floatValue", Float.class, new Float(2));
+ checkPropertyDefaults(managedObject, "integervalue", Integer.TYPE, new Integer(1));
+ checkPropertyDefaults(managedObject, "integerValue", Integer.class, new Integer(2));
+ checkPropertyDefaults(managedObject, "longvalue", Long.TYPE, new Long(1));
+ checkPropertyDefaults(managedObject, "longValue", Long.class, new Long(2));
+ checkPropertyDefaults(managedObject, "shortvalue", Short.TYPE, new Short((short) 1));
+ checkPropertyDefaults(managedObject, "shortValue", Short.class, new Short((short) 2));
+ checkPropertyDefaults(managedObject, "stringValue", String.class, "Hello");
+ }
+}
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/ManagedMockTestSuite.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/ManagedMockTestSuite.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/ManagedMockTestSuite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.test.managed.mock;
+
+import org.jboss.test.managed.mock.MockTest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Managed Mock Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37459 $
+ */
+public class ManagedMockTestSuite extends TestSuite
+{
+ /**
+ * For running the testsuite from the command line
+ *
+ * @param args the command line args
+ */
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ /**
+ * Create the testsuite
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Managed Mock Tests");
+
+ suite.addTest(MockTest.suite());
+
+ return suite;
+ }
+}
Modified: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDOMFields.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDOMFields.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDOMFields.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -22,26 +22,15 @@
package org.jboss.test.managed.mock;
import java.io.Serializable;
-import java.util.ArrayList;
import org.jboss.managed.api.Fields;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
- * DOMFields illustrates a Fields implementation backed by a DOM element.
+ * DOMFields.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
* @version $Revision: 1.1 $
*/
public class MockDOMFields implements Fields
@@ -54,7 +43,6 @@
/** The element name */
private String elementName;
- private MetaType elementType;
/**
* Create a new DOMFields.
@@ -64,74 +52,38 @@
*/
public MockDOMFields(Element element, String elementName)
{
- this(element, elementName, SimpleMetaType.STRING);
- }
- public MockDOMFields(Element element, String elementName, MetaType elementType)
- {
this.element = element;
this.elementName = elementName;
- this.elementType = elementType;
}
public Serializable getField(String name)
{
- Serializable field = null;
if (NAME.equals(name))
- field = elementName;
- else if (VALUE.equals(name))
+ return elementName;
+ if (VALUE.equals(name))
{
NodeList nodes = element.getElementsByTagName(elementName);
if (nodes.getLength() == 0)
return null;
- else if (elementType instanceof SimpleMetaType)
+ else
{
Element element = (Element) nodes.item(0);
return element.getTextContent();
}
- else if (elementType instanceof CompositeMetaType)
- {
- Element element = (Element) nodes.item(0);
- NodeList propNodes = element.getChildNodes();
- ArrayList<String> keys = new ArrayList<String>();
- ArrayList<MetaValue> values = new ArrayList<MetaValue>();
- for(int n = 0; n < propNodes.getLength(); n ++)
- {
- Node node = propNodes.item(n);
- if( node.getNodeType() != Node.ELEMENT_NODE )
- continue;
- Element prop = (Element) node;
- keys.add(prop.getNodeName());
- values.add(SimpleValueSupport.wrap(prop.getTextContent()));
- }
- CompositeMetaType propsType = (CompositeMetaType) elementType;
- String[] propsKeys = new String[keys.size()];
- keys.toArray(propsKeys);
- MetaValue[] propsValues = new MetaValue[values.size()];
- values.toArray(propsValues);
- field = new CompositeValueSupport(propsType, propsKeys, propsValues);
- }
- else
- {
- throw new IllegalStateException("Unable to build value for type: "+elementType);
- }
}
- else if (META_TYPE.equals(name))
- field = elementType;
- return field;
+ return null;
}
- /**
- * Handle setting the VALUE field.
- */
public void setField(String name, Serializable value)
{
if (VALUE.equals(name))
{
+ String string = (String) value;
NodeList nodes = element.getElementsByTagName(elementName);
Element childElement = null;
if (nodes.getLength() == 0)
{
- if (value == null)
+ if (string == null || string.length() == 0)
return;
childElement = element.getOwnerDocument().createElement(elementName);
element.appendChild(childElement);
@@ -139,94 +91,15 @@
else
{
childElement = (Element) nodes.item(0);
- if (value == null)
+ if (string == null || string.length() == 0)
{
element.removeChild(childElement);
return;
}
}
-
- if( value instanceof CompositeValue )
- handleCompositeValue(childElement, (CompositeValue)value);
- else if( value instanceof SimpleValue )
- handleSimpleValue(childElement, (SimpleValue)value);
- else
- {
- String string = value.toString();
- if (value == null || string.length() == 0)
- {
- element.removeChild(childElement);
- }
- else
- {
- childElement.setTextContent(string);
- }
- }
+ childElement.setTextContent(string);
return;
}
throw new UnsupportedOperationException("setField " + name);
}
-
- /**
- * Map a CompositeValue into a text element structure
- * @param childElement
- * @param cvalue
- */
- protected void handleCompositeValue(Element childElement, CompositeValue cvalue)
- {
- if (cvalue == null || cvalue.values().size() == 0)
- {
- element.removeChild(childElement);
- return;
- }
-
-
- for(String key : cvalue.getMetaType().keySet())
- {
- if( cvalue.containsKey(key) )
- {
- MetaValue value = cvalue.get(key);
- Element keyElement = null;
- NodeList nodes = childElement.getElementsByTagName(key);
- if (nodes.getLength() == 0)
- {
- keyElement = childElement.getOwnerDocument().createElement(key);
- childElement.appendChild(keyElement);
- }
- else
- {
- keyElement = (Element) nodes.item(0);
- if (value == null)
- {
- childElement.removeChild(keyElement);
- continue;
- }
- }
- // We only handle SimpleValue types
- if( !(value instanceof SimpleValue) )
- throw new IllegalArgumentException(key+" value type is not a SimpleValue, "+value);
- SimpleValue svalue = (SimpleValue) value;
- handleSimpleValue(keyElement, svalue);
- }
- }
- }
-
- /**
- * Map a SimpleValue to a text element
- * @param childElement
- * @param svalue
- */
- protected void handleSimpleValue(Element childElement, SimpleValue svalue)
- {
- Serializable value = svalue.getValue();
- if (value == null)
- {
- element.removeChild(childElement);
- }
- else
- {
- String string = value.toString();
- childElement.setTextContent(string);
- }
- }
}
Modified: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDataSourceManagedObject.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDataSourceManagedObject.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDataSourceManagedObject.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -29,10 +29,6 @@
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.plugins.ManagedObjectImpl;
import org.jboss.managed.plugins.ManagedPropertyImpl;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.util.xml.DOMWriter;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
@@ -83,16 +79,13 @@
properties.add(new ManagedPropertyImpl(this, new MockDOMFields(element, "connection-url")));
properties.add(new ManagedPropertyImpl(this, new MockDOMFields(element, "user")));
properties.add(new ManagedPropertyImpl(this, new MockDOMFields(element, "password")));
- // Add a CompositeMetaType field
- String[] itemNames = {"conn-prop1", "conn-prop2"};
- String[] itemDescriptions = {"conn-prop1 description", "conn-prop2 description"};
- MetaType[] itemTypes = {SimpleMetaType.STRING, SimpleMetaType.STRING};
- CompositeMetaType propsType = new ImmutableCompositeMetaType("java.lang.Properties", "DS connection properties",
- itemNames, itemDescriptions, itemTypes);
- MockDOMFields cpField = new MockDOMFields(element, "connection-props", propsType);
- properties.add(new ManagedPropertyImpl(this, cpField));
}
-
+
+ /**
+ * Pretty print the xml
+ *
+ * @return the xml
+ */
public String prettyPrint()
{
return DOMWriter.printNode(document, true);
Modified: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockTest.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockTest.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockTest.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.managed.mock;
+import java.io.Serializable;
import java.util.HashMap;
import junit.framework.Test;
@@ -29,11 +30,6 @@
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.plugins.advice.WrapperAdvice;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.test.managed.ManagedTest;
/**
@@ -44,16 +40,31 @@
*/
public class MockTest extends ManagedTest
{
+ /**
+ * Create a testsuite for this this
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
return suite(MockTest.class);
}
+ /**
+ * Create a new MockTest.
+ *
+ * @param name the test name
+ */
public MockTest(String name)
{
super(name);
}
+ /**
+ * Test the mock
+ *
+ * @throws Exception for any problem
+ */
public void testMock() throws Exception
{
MockDataSourceManagedObject mock = new MockDataSourceManagedObject();
@@ -67,10 +78,7 @@
getLog().debug(mock.prettyPrint());
getLog().debug("Adding jndi-name...");
- ManagedProperty jndiName = mo.getProperty("jndi-name");
- MetaType jndiType = jndiName.getMetaType();
- assertTrue("jndi-name MetaType is not null", jndiType != null);
- jndiName.setValue("DefaultDS");
+ mo.getProperty("jndi-name").setValue("DefaultDS");
getLog().debug(mock.prettyPrint());
getLog().debug("Adding user and password...");
@@ -78,17 +86,6 @@
mo.getProperty("password").setValue("Tiger");
getLog().debug(mock.prettyPrint());
- getLog().debug("Adding connection-props...");
- ManagedProperty connProps = mo.getProperty("connection-props");
- CompositeMetaType connPropsType = (CompositeMetaType) connProps.getMetaType();
- String[] propsKeys = {"conn-prop2", "conn-prop1"};
- MetaValue[] propsValues = {SimpleValueSupport.wrap("conn-prop2-value"),
- SimpleValueSupport.wrap("conn-prop1-value")};
- CompositeValueSupport connPropsValue = new CompositeValueSupport(connPropsType,
- propsKeys, propsValues);
- mo.getProperty("connection-props").setValue(connPropsValue);
- getLog().debug(mock.prettyPrint());
-
getLog().debug("Changing jndi-name...");
mo.getProperty("jndi-name").setValue("ChangedDS");
getLog().debug(mock.prettyPrint());
@@ -101,16 +98,20 @@
for (ManagedProperty property : mo.getProperties())
getLog().debug(property.getName() + "=" + property.getValue());
- jndiName = mo.getProperty("jndi-name");
+ ManagedProperty jndiName = mo.getProperty("jndi-name");
getLog().debug("Displaying jndi-name field values...");
getLog().debug("jndi-name name field is: " + jndiName.getFields().getField(Fields.NAME));
getLog().debug("jndi-name value field is: " + jndiName.getFields().getField(Fields.VALUE));
- getLog().debug("jndi-name type field is: " + jndiName.getFields().getField(Fields.META_TYPE));
assertEquals(mo, jndiName.getManagedObject());
}
+ /**
+ * Test the managed object serialization
+ *
+ * @throws Exception for any problem
+ */
public void testManagedObjectSerialization()
throws Exception
{
@@ -121,14 +122,6 @@
mo.getProperty("user").setValue("Scott");
mo.getProperty("password").setValue("Tiger");
mo.getProperty("jndi-name").setValue("ChangedDS");
- ManagedProperty connProps = mo.getProperty("connection-props");
- CompositeMetaType connPropsType = (CompositeMetaType) connProps.getMetaType();
- String[] propsKeys = {"conn-prop2", "conn-prop1"};
- MetaValue[] propsValues = {SimpleValueSupport.wrap("conn-prop2-value"),
- SimpleValueSupport.wrap("conn-prop1-value")};
- CompositeValueSupport connPropsValue = new CompositeValueSupport(connPropsType,
- propsKeys, propsValues);
- mo.getProperty("connection-props").setValue(connPropsValue);
getLog().debug(mock.prettyPrint());
@@ -138,9 +131,14 @@
assertEquals("jndiName", "ChangedDS", mo2.getProperty("jndi-name").getValue());
assertEquals("user", "Scott", mo2.getProperty("user").getValue());
assertEquals("password", "Tiger", mo2.getProperty("password").getValue());
- ManagedProperty connProps2 = mo2.getProperty("connection-props");
- assertEquals("connPropsValue", connPropsValue, connProps2.getValue());
}
+
+ /**
+ * Test the managed object property map serialization
+ *
+ * @throws Exception for any problem
+ */
+ @SuppressWarnings("unchecked")
public void testManagedPropertyMapSerialization()
throws Exception
{
@@ -159,10 +157,8 @@
props.put(jndiName.getName(), jndiName);
props.put(user.getName(), user);
props.put(password.getName(), password);
-
- byte[] data = super.serialize(props);
- HashMap<String, ManagedProperty> props2 =
- (HashMap<String, ManagedProperty>) super.deserialize(data);
+
+ HashMap<String, ManagedProperty> props2 = serializeDeserialize(props, HashMap.class);
ManagedProperty jndiName2 = props2.get("jndi-name");
assertEquals("jndiName", "ChangedDS", jndiName2.getValue());
@@ -173,7 +169,26 @@
ManagedProperty password2 = props2.get("password");
assertEquals("password", "Tiger", password2.getValue());
}
+
+ /**
+ * Serialize/deserialize
+ *
+ * TODO move to AbstractTestCase
+ * @param <T> the expected type
+ * @param value the value
+ * @param expected the expected type
+ * @return the result
+ * @throws Exception for any problem
+ */
+ protected <T> T serializeDeserialize(Serializable value, Class<T> expected) throws Exception
+ {
+ byte[] bytes = serialize(value);
+ Object result = deserialize(bytes);
+ return assertInstanceOf(result, expected);
+
+ }
+ @Override
protected void configureLogging()
{
enableTrace("org.jboss.managed.plugins.advice");
Modified: projects/microcontainer/trunk/metatype/.classpath
===================================================================
--- projects/microcontainer/trunk/metatype/.classpath 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/.classpath 2007-07-11 06:10:14 UTC (rev 63962)
@@ -1,22 +1,23 @@
<classpath>
<classpathentry kind="src" path="src/main"/>
- <classpathentry kind="src" path="src/tests" output="eclipse-target/tests-classes"/>
- <classpathentry kind="output" path="eclipse-target/classes"/>
+ <classpathentry kind="src" path="src/tests" output="target/test-classes"/>
+ <classpathentry kind="src" path="/jboss-container"/>
+ <classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-slide/webdavlib/2.0/webdavlib-2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.8/log4j-1.2.8.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-test/1.0.3.GA/jboss-test-1.0.3.GA.jar" sourcepath="M2_REPO/jboss/jboss-test/1.0.3.GA/jboss-test-1.0.3.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-test/1.0.3.GA/jboss-test-1.0.3.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.7.1/xml-apis-2.7.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA.jar" sourcepath="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-slide/webdavlib/2.0/webdavlib-2.0.jar"/>
<classpathentry kind="var" path="M2_REPO/apache-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.8/log4j-1.2.8.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA.jar" sourcepath="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
</classpath>
\ No newline at end of file
Modified: projects/microcontainer/trunk/metatype/pom.xml
===================================================================
--- projects/microcontainer/trunk/metatype/pom.xml 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/pom.xml 2007-07-11 06:10:14 UTC (rev 63962)
@@ -13,14 +13,16 @@
<description>JBoss Microcontainer Metatype</description>
<dependencies>
<!-- Global dependencies -->
- <!-- none -->
- <!-- Test dependencies -->
<dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-container</artifactId>
+ </dependency>
+ <dependency>
<groupId>jboss</groupId>
<artifactId>jboss-common-core</artifactId>
<version>2.0.4.GA</version>
- <scope>test</scope>
</dependency>
+ <!-- Test dependencies -->
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-test</artifactId>
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeKey.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeKey.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/CompositeKey.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,36 @@
+/*
+* 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.metatype.api.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * CompositeKey.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface CompositeKey
+{
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/Generic.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/Generic.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/annotations/Generic.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,42 @@
+/*
+* 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.metatype.api.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Generic.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Generic
+{
+ /**
+ * The generic type name
+ *
+ * @return the generic type name
+ */
+ String type() default "";
+}
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/AbstractMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/AbstractMetaType.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/AbstractMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -125,6 +125,31 @@
return description;
}
+ public boolean isEnum()
+ {
+ return false;
+ }
+
+ public boolean isComposite()
+ {
+ return false;
+ }
+
+ public boolean isSimple()
+ {
+ return false;
+ }
+
+ public boolean isGeneric()
+ {
+ return false;
+ }
+
+ public boolean isTable()
+ {
+ return false;
+ }
+
public boolean isArray()
{
return array;
@@ -132,15 +157,6 @@
public abstract boolean isValue(Object obj);
- @Override
- public abstract boolean equals(Object obj);
-
- @Override
- public abstract int hashCode();
-
- @Override
- public abstract String toString();
-
/**
* Initialise the object
*
@@ -170,9 +186,9 @@
// Check the underlying class
boolean ok = false;
- for (int i = 0; i < ALLOWED_CLASSNAMES.length; i++)
+ for (int i = 0; i < ALLOWED_CLASSNAMES.size(); i++)
{
- if (testClassName.equals(ALLOWED_CLASSNAMES[i]))
+ if (testClassName.equals(ALLOWED_CLASSNAMES.get(i)))
{
ok = true;
break;
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ArrayMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ArrayMetaType.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ArrayMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -21,16 +21,13 @@
*/
package org.jboss.metatype.api.types;
-import java.io.Serializable;
-
/**
* ArrayMetaType.
*
- * @param <T> the underlying type
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class ArrayMetaType<T extends Serializable> extends AbstractMetaType<T>
+public class ArrayMetaType extends AbstractMetaType
{
/** The serialVersionUID */
private static final long serialVersionUID = -2062790692152055156L;
@@ -48,10 +45,11 @@
private transient String cachedToString = null;
/**
- * Generate the class and type name
+ * Generate the class name
*
* @param dimension the dimension
* @param elementType the element type
+ * @return the class name
*/
private static String genName(int dimension, MetaType elementType)
{
@@ -71,17 +69,42 @@
}
/**
+ * Generate the type name
+ *
+ * @param dimension the dimension
+ * @param elementType the element type
+ * @return the type name
+ */
+ private static String genType(int dimension, MetaType elementType)
+ {
+ if (dimension < 1)
+ throw new IllegalArgumentException("negative dimension");
+ if (elementType == null)
+ throw new IllegalArgumentException("null element type");
+ if (elementType instanceof ArrayMetaType)
+ throw new IllegalArgumentException("array type cannot be an element of an array type");
+ StringBuilder buffer = new StringBuilder();
+ for (int i=0; i < dimension; i++)
+ buffer.append('[');
+ buffer.append('L');
+ buffer.append(elementType.getTypeName());
+ buffer.append(';');
+ return buffer.toString();
+ }
+
+ /**
* Generate the description
*
* @param dimension the dimension
* @param elementType the element type
+ * @return the description
*/
private static String genDesc(int dimension, MetaType elementType)
{
StringBuilder buffer = new StringBuilder();
buffer.append(new Integer(dimension));
buffer.append("-dimension array of ");
- buffer.append(elementType.getClassName());
+ buffer.append(elementType.getTypeName());
return buffer.toString();
}
@@ -94,7 +117,7 @@
*/
public ArrayMetaType(int dimension, MetaType elementType)
{
- super(genName(dimension, elementType), genDesc(dimension, elementType));
+ super(genName(dimension, elementType), genType(dimension, elementType), genDesc(dimension, elementType));
this.dimension = dimension;
this.elementType = elementType;
}
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/CompositeMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/CompositeMetaType.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/CompositeMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -37,7 +37,7 @@
* @param itemName the item name
* @return true when it does, false otherwise
*/
- boolean containsKey(String itemName);
+ boolean containsItem(String itemName);
/**
* Retrieve the description for an item name
@@ -60,5 +60,12 @@
*
* @return the Set
*/
+ Set<String> itemSet();
+
+ /**
+ * Retrieve an unmodifiable Set view of all the item names in ascending order.
+ *
+ * @return the Set
+ */
Set<String> keySet();
}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/EnumMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/EnumMetaType.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/EnumMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,101 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metatype.api.types;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.metatype.api.values.SimpleValue;
+
+/**
+ * EnumMetaType.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class EnumMetaType extends AbstractMetaType
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 6786422588217893696L;
+
+ /** The valid values */
+ private List<String> validValues;
+
+ /**
+ * Create a new EnumMetaType.
+ *
+ * @param className the class name
+ * @param validValues the valid values
+ */
+ public EnumMetaType(String className, List<String> validValues)
+ {
+ super(String.class.getName(), className, className);
+ if (validValues == null)
+ throw new IllegalArgumentException("Null valid values");
+ this.validValues = validValues;
+ }
+
+ /**
+ * Get the valid values
+ *
+ * @return the valid values
+ */
+ public List<String> getValidValues()
+ {
+ return Collections.unmodifiableList(validValues);
+ }
+
+ @Override
+ public boolean isEnum()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isValue(Object obj)
+ {
+ if (obj == null || obj instanceof SimpleValue == false)
+ return false;
+
+ SimpleValue value = (SimpleValue) obj;
+ if (SimpleMetaType.STRING == value.getMetaType() == false)
+ return false;
+ return validValues.contains(value.getValue());
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null || obj instanceof EnumMetaType == false)
+ return false;
+ EnumMetaType other = (EnumMetaType) obj;
+ return getTypeName().equals(other.getTypeName()) && getValidValues().equals(other.getValidValues());
+ }
+
+ @Override
+ public String toString()
+ {
+ return getTypeName() + "{" + validValues + "}";
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/GenericMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/GenericMetaType.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/GenericMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,86 @@
+/*
+* 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.metatype.api.types;
+
+import java.io.Serializable;
+
+import org.jboss.metatype.api.values.GenericValue;
+
+/**
+ * GenericMetaType.<p>
+ *
+ * This type allows objects that otherwise wouldn't otherwise be metatypes
+ * to be passed as is inside the type system. Assuming that both
+ * sides understand the value.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenericMetaType extends AbstractMetaType<Serializable>
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 6783554622082477064L;
+
+ /**
+ * Create a new GenericMetaType.
+ *
+ * @param typeName the type name
+ * @param description the description
+ */
+ public GenericMetaType(String typeName, String description)
+ {
+ super(GenericValue.class.getName(), typeName, description);
+ }
+
+ @Override
+ public boolean isGeneric()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isValue(Object obj)
+ {
+ if (obj == null || obj instanceof GenericValue == false)
+ return false;
+
+ // TODO some other check, e.g. typeName?
+ return true;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null || obj instanceof GenericMetaType == false)
+ return false;
+ GenericMetaType other = (GenericMetaType) obj;
+ return getTypeName().equals(other.getTypeName());
+ }
+
+ @Override
+ public String toString()
+ {
+ return "GenericMetaType:" + getTypeName();
+ }
+}
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ImmutableCompositeMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ImmutableCompositeMetaType.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ImmutableCompositeMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -21,12 +21,8 @@
*/
package org.jboss.metatype.api.types;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.TreeMap;
-
import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.plugins.types.AbstractCompositeMetaType;
/**
* ImmutableCompositeMetaType.
@@ -34,17 +30,11 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class ImmutableCompositeMetaType extends AbstractMetaType implements CompositeMetaType
+public class ImmutableCompositeMetaType extends AbstractCompositeMetaType
{
/** The serialVersionUID */
private static final long serialVersionUID = 1133171306971861455L;
- /** Item names to descriptions */
- private TreeMap<String, String> nameToDescription;
-
- /** Item names to meta types */
- private TreeMap<String, MetaType> nameToType;
-
/** Cached hash code */
private transient int cachedHashCode = Integer.MIN_VALUE;
@@ -57,7 +47,7 @@
* The three arrays are internally copied. Future changes to these
* arrays do not alter the composite type.<p>
*
- * getClassName() returns {@link CompositeValue}<p>
+ * getClassName() returns {@link CompositeValue}
*
* @param typeName the name of the composite type, cannot be null or empty
* @param description the human readable description of the composite type, cannot be null or empty
@@ -80,100 +70,13 @@
*/
public ImmutableCompositeMetaType(String typeName, String description, String[] itemNames, String[] itemDescriptions, MetaType[] itemTypes)
{
- super(CompositeValue.class.getName(), typeName, description);
- if (itemNames == null || itemNames.length == 0)
- throw new IllegalArgumentException("null or empty itemNames");
- if (itemDescriptions == null || itemDescriptions.length == 0)
- throw new IllegalArgumentException("null or empty itemDescriptions");
- if (itemTypes == null || itemTypes.length == 0)
- throw new IllegalArgumentException("null or empty itemTypes");
- if (itemNames.length != itemDescriptions.length)
- throw new IllegalArgumentException("wrong number of itemDescriptions");
- if (itemNames.length != itemTypes.length)
- throw new IllegalArgumentException("wrong number of itemTypes");
- nameToDescription = new TreeMap<String, String>();
- nameToType = new TreeMap<String, MetaType>();
- for (int i = 0; i < itemNames.length; ++i)
- {
- if (itemNames[i] == null)
- throw new IllegalArgumentException("null item name " + i);
- String itemName = itemNames[i].trim();
- if (itemName.length() == 0)
- throw new IllegalArgumentException("empty item name " + i);
- if (nameToDescription.containsKey(itemName))
- throw new IllegalArgumentException("duplicate item name " + itemName);
- if (itemDescriptions[i] == null)
- throw new IllegalArgumentException("null item description " + i);
- String itemDescription = itemDescriptions[i].trim();
- if (itemDescription.length() == 0)
- throw new IllegalArgumentException("empty item description " + i);
- if (itemTypes[i] == null)
- throw new IllegalArgumentException("null item type " + i);
- nameToDescription.put(itemName, itemDescription);
- nameToType.put(itemName, itemTypes[i]);
- }
+ super(typeName, description, itemNames, itemDescriptions, itemTypes, false);
}
- public boolean containsKey(String itemName)
- {
- if (itemName == null)
- return false;
- return nameToDescription.containsKey(itemName);
- }
-
- public String getDescription(String itemName)
- {
- if (itemName == null)
- return null;
- return nameToDescription.get(itemName);
- }
-
- public MetaType getType(String itemName)
- {
- if (itemName == null)
- return null;
- return nameToType.get(itemName);
- }
-
- public Set<String> keySet()
- {
- return Collections.unmodifiableSet(nameToDescription.keySet());
- }
-
@Override
- public boolean isValue(Object obj)
- {
- if (obj == null || obj instanceof CompositeValue == false)
- return false;
- return equals(((CompositeValue) obj).getMetaType());
- }
-
- @Override
public boolean equals(Object obj)
{
- if (this == obj)
- return true;
- if (obj == null || obj instanceof ImmutableCompositeMetaType == false)
- return false;
-
- ImmutableCompositeMetaType other = (ImmutableCompositeMetaType) obj;
- if (this.getTypeName().equals(other.getTypeName()) == false)
- return false;
- Iterator<String> thisNames = this.keySet().iterator();
- Iterator<String> otherNames = other.keySet().iterator();
- while(thisNames.hasNext() && otherNames.hasNext())
- {
- String thisName = thisNames.next();
- String otherName = otherNames.next();
- if (thisName.equals(otherName) == false)
- return false;
- if (this.getType(thisName).equals(other.getType(otherName)) == false)
- return false;
- }
- if (thisNames.hasNext() || otherNames.hasNext())
- return false;
-
- return true;
+ return equalsImpl(obj);
}
@Override
@@ -181,35 +84,15 @@
{
if (cachedHashCode != Integer.MIN_VALUE)
return cachedHashCode;
- cachedHashCode = getTypeName().hashCode();
- for (Iterator i = nameToType.values().iterator(); i.hasNext();)
- cachedHashCode += i.next().hashCode();
- for (Iterator i = nameToDescription.keySet().iterator(); i.hasNext();)
- cachedHashCode += i.next().hashCode();
+ cachedHashCode = hashCodeImpl();
return cachedHashCode;
}
@Override
public String toString()
{
- if (cachedToString != null)
- return cachedToString;
- StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
- buffer.append("{items=");
- Iterator<String> thisNames = keySet().iterator();
- while(thisNames.hasNext())
- {
- String thisName = thisNames.next();
- buffer.append("[");
- buffer.append("name=");
- buffer.append(thisName);
- buffer.append(" type=");
- buffer.append(getType(thisName));
- buffer.append("]");
- if (thisNames.hasNext())
- buffer.append(", ");
- }
- cachedToString = buffer.toString();
+ if (cachedToString == null)
+ cachedToString = super.toString();
return cachedToString;
}
}
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ImmutableTableMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ImmutableTableMetaType.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/ImmutableTableMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -28,6 +28,12 @@
import org.jboss.metatype.api.values.TableValue;
+/**
+ * ImmutableTableMetaType.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
public class ImmutableTableMetaType extends AbstractMetaType implements TableMetaType
{
/** The serialVersionUID */
@@ -77,7 +83,7 @@
String indexName = indexNames[i].trim();
if (indexName.length() == 0)
throw new IllegalArgumentException("empty index name " + i);
- if (rowType.containsKey(indexName) == false)
+ if (rowType.containsItem(indexName) == false)
throw new IllegalArgumentException("no item name " + indexName);
this.indexNames.add(indexName);
}
@@ -94,6 +100,12 @@
}
@Override
+ public boolean isTable()
+ {
+ return true;
+ }
+
+ @Override
public boolean isValue(Object obj)
{
if (obj == null || obj instanceof TableValue == false)
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaType.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -24,9 +24,15 @@
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
+import java.util.List;
+import org.jboss.metatype.api.values.ArrayValue;
import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.GenericValue;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.TableValue;
@@ -57,10 +63,13 @@
* java.math.BigDecimal<br>
* java.math.BigInteger<br>
* {@link SimpleValue}<br>
+ * {@link EnumValue}<br>
+ * {@link GenericValue}<br>
+ * {@link ArrayValue}<br>
* {@link CompositeValue}<br>
* {@link TableValue}
*/
- String[] ALLOWED_CLASSNAMES =
+ List<String> ALLOWED_CLASSNAMES = Collections.unmodifiableList(Arrays.asList(new String[]
{
Void.class.getName(),
Boolean.class.getName(),
@@ -76,9 +85,12 @@
BigDecimal.class.getName(),
BigInteger.class.getName(),
SimpleValue.class.getName(),
+ EnumValue.class.getName(),
+ GenericValue.class.getName(),
+ ArrayValue.class.getName(),
CompositeValue.class.getName(),
TableValue.class.getName()
- };
+ }));
/**
* Retrieve the class name of the values of this meta
@@ -111,6 +123,41 @@
boolean isArray();
/**
+ * Retrieve whether the class name of the type is an enum
+ *
+ * @return true when it is an enum or false otherwise
+ */
+ boolean isEnum();
+
+ /**
+ * Retrieve whether the class name of the type is simple
+ *
+ * @return true when it is simple or false otherwise
+ */
+ boolean isSimple();
+
+ /**
+ * Retrieve whether the class name of the type is generic
+ *
+ * @return true when it is generic or false otherwise
+ */
+ boolean isGeneric();
+
+ /**
+ * Retrieve whether the class name of the type is composite
+ *
+ * @return true when it is composite or false otherwise
+ */
+ boolean isComposite();
+
+ /**
+ * Retrieve whether the class name of the type is a table
+ *
+ * @return true when it is a table or false otherwise
+ */
+ boolean isTable();
+
+ /**
* Whether the passed value is one of those described by this meta type.
*
* @param obj the object to test
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaTypeFactory.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaTypeFactory.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/MetaTypeFactory.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,95 @@
+/*
+* 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.metatype.api.types;
+
+import java.lang.reflect.Type;
+
+import org.jboss.metatype.plugins.types.MetaTypeFactoryBuilder;
+import org.jboss.metatype.spi.types.MetaTypeBuilder;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * MetaTypeFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class MetaTypeFactory
+{
+ /** The singleton builder */
+ private static final MetaTypeFactoryBuilder builder = new MetaTypeFactoryBuilder();
+
+ /**
+ * Get the metatype factory
+ *
+ * @return the instance
+ */
+ public static final MetaTypeFactory getInstance()
+ {
+ return builder.create();
+ }
+
+ /**
+ * Resolve a metatype
+ *
+ * @param type the type
+ * @return the metatype
+ * @throws IllegalArgumentException for a null type
+ */
+ public abstract MetaType resolve(Type type);
+
+ /**
+ * Resolve a metatype
+ *
+ * @param type the type
+ * @return the metatype
+ * @throws IllegalArgumentException for a null type
+ */
+ public abstract MetaType resolve(TypeInfo type);
+
+ /**
+ * Resolve a metatype
+ *
+ * @param className the class name
+ * @param classLoader the classloader
+ * @return the metatype
+ * @throws IllegalArgumentException for a null className or classloader
+ * @throws ClassNotFoundException when the class is not found
+ */
+ public MetaType resolve(String className, ClassLoader classLoader) throws ClassNotFoundException
+ {
+ if (className == null)
+ throw new IllegalArgumentException("Null className");
+ if (classLoader == null)
+ throw new IllegalArgumentException("Null classLoader");
+ Class clazz = classLoader.loadClass(className);
+ return resolve(clazz);
+ }
+
+ /**
+ * Set a meta type builder
+ *
+ * @param clazz the class
+ * @param builder the builder
+ */
+ public abstract void setBuilder(Class<?> clazz, MetaTypeBuilder builder);
+}
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/SimpleMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/SimpleMetaType.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/types/SimpleMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -108,28 +108,45 @@
*
* @param className the class name of the simple type
* @return the simple type
+ * @throws IllegalArgumentException for a null className or if it is not a simple type
*/
public static SimpleMetaType resolve(String className)
{
+ SimpleMetaType result = isSimpleType(className);
+ if (result != null)
+ return result;
+ throw new IllegalArgumentException("Class is not a simple type: " + className);
+ }
+
+ /**
+ * Return the simple type if the class name is a simple type
+ * otherwise null.
+ *
+ * @param className the class name of the simple type
+ * @return the simple type
+ * @throws IllegalArgumentException for a null className
+ */
+ public static SimpleMetaType isSimpleType(String className)
+ {
if (className == null)
throw new IllegalArgumentException("Null class name");
if (className.equals(STRING.getClassName()))
return STRING;
- if (className.equals(INTEGER.getClassName()))
+ if (className.equals(INTEGER.getClassName()) || className.equals(Integer.TYPE.getName()))
return INTEGER;
- if (className.equals(BOOLEAN.getClassName()))
+ if (className.equals(BOOLEAN.getClassName()) || className.equals(Boolean.TYPE.getName()))
return BOOLEAN;
- if (className.equals(LONG.getClassName()))
+ if (className.equals(LONG.getClassName()) || className.equals(Long.TYPE.getName()))
return LONG;
- if (className.equals(BYTE.getClassName()))
+ if (className.equals(BYTE.getClassName()) || className.equals(Byte.TYPE.getName()))
return BYTE;
- if (className.equals(CHARACTER.getClassName()))
+ if (className.equals(CHARACTER.getClassName()) || className.equals(Character.TYPE.getName()))
return CHARACTER;
- if (className.equals(DOUBLE.getClassName()))
+ if (className.equals(DOUBLE.getClassName()) || className.equals(Double.TYPE.getName()))
return DOUBLE;
- if (className.equals(FLOAT.getClassName()))
+ if (className.equals(FLOAT.getClassName()) || className.equals(Float.TYPE.getName()))
return FLOAT;
- if (className.equals(SHORT.getClassName()))
+ if (className.equals(SHORT.getClassName()) || className.equals(Short.TYPE.getName()))
return SHORT;
if (className.equals(BIGDECIMAL.getClassName()))
return BIGDECIMAL;
@@ -139,7 +156,7 @@
return VOID;
if (className.equals(DATE.getClassName()))
return DATE;
- throw new IllegalArgumentException(className);
+ return null;
}
/**
@@ -160,6 +177,12 @@
}
@Override
+ public boolean isSimple()
+ {
+ return true;
+ }
+
+ @Override
public boolean isValue(Object obj)
{
if (obj == null || obj instanceof SimpleValue == false)
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/ArrayValue.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/ArrayValue.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/ArrayValue.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metatype.api.values;
+
+import org.jboss.metatype.api.types.ArrayMetaType;
+
+/**
+ * ArrayValue.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ArrayValue extends MetaValue
+{
+ ArrayMetaType getMetaType();
+
+ /**
+ * Get the underlying value
+ *
+ * @return the underlying value
+ */
+ public Object[] getValue();
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/ArrayValueSupport.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/ArrayValueSupport.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/ArrayValueSupport.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,144 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metatype.api.values;
+
+import java.util.Arrays;
+
+import org.jboss.metatype.api.types.ArrayMetaType;
+
+/**
+ * ArrayValue.
+ *
+ * TODO tests
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ArrayValueSupport extends AbstractMetaValue implements ArrayValue
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1131827130033538066L;
+
+ /** The array meta type */
+ private ArrayMetaType metaType;
+
+ /** The value */
+ private Object[] value;
+
+ /**
+ * Create a new ArrayValueSupport.
+ *
+ * @param metaType the array meta type
+ * @throws IllegalArgumentException for a null array MetaType
+ */
+ public ArrayValueSupport(ArrayMetaType metaType)
+ {
+ if (metaType == null)
+ throw new IllegalArgumentException("Null array meta type");
+ this.metaType = metaType;
+ }
+
+ /**
+ * Create a new ArrayValueSupport.
+ *
+ * @param metaType the array meta type
+ * @param value the value
+ * @throws IllegalArgumentException for a null array MetaType
+ */
+ public ArrayValueSupport(ArrayMetaType metaType, Object[] value)
+ {
+ this(metaType);
+ this.value = value;
+ }
+
+ public ArrayMetaType getMetaType()
+ {
+ return metaType;
+ }
+
+ /**
+ * Get the value.
+ *
+ * @return the value.
+ */
+ public Object[] getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param value the value.
+ */
+ public void setValue(Object[] value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+
+ if (obj == null || obj instanceof ArrayValue == false)
+ return false;
+
+ ArrayValue other = (ArrayValue) obj;
+ if (metaType.equals(other.getMetaType()) == false)
+ return false;
+
+ Object[] otherValue = other.getValue();
+ if (value == null && otherValue == null)
+ return true;
+ if (value == null && otherValue != null)
+ return false;
+ return Arrays.deepEquals(value, otherValue);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ if (value == null)
+ return 0;
+ return value.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return metaType + ":" + Arrays.deepToString(value);
+ }
+
+ @Override
+ public MetaValue clone()
+ {
+ ArrayValueSupport result = (ArrayValueSupport) super.clone();
+
+ if (value != null && value.length > 0)
+ {
+ result.value = new Object[value.length];
+ System.arraycopy(value, 0, value, 0, value.length);
+ }
+ return result;
+ }
+}
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/CompositeValueSupport.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/CompositeValueSupport.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/CompositeValueSupport.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -24,10 +24,13 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectStreamField;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Map.Entry;
@@ -69,26 +72,22 @@
* @param metaType the composite meta type of the data
* @param itemNames the names of the values
* @param itemValues the values
- * @throws IllegalArgumentException for a null or empty argument or when the items do not match the
- * CompositeType
+ * @throws IllegalArgumentException for a null metaType
*/
public CompositeValueSupport(CompositeMetaType metaType, String[] itemNames, MetaValue[] itemValues)
{
if (metaType == null)
throw new IllegalArgumentException("null meta type");
if (itemNames == null)
- throw new IllegalArgumentException("null itemNames");
+ itemNames = new String[0];
if (itemValues == null)
- throw new IllegalArgumentException("null itemValues");
- if (itemNames.length == 0)
- throw new IllegalArgumentException("empty itemNames");
- if (itemValues.length == 0)
- throw new IllegalArgumentException("empty itemValues");
+ itemValues = new MetaValue[0];
if (itemNames.length != itemValues.length)
throw new IllegalArgumentException("itemNames has size " + itemNames.length + " but itemValues has size " + itemValues.length);
- int compositeNameSize = metaType.keySet().size();
- if (itemNames.length != compositeNameSize)
+ Set<String> compositeNames = metaType.keySet();
+ int compositeNameSize = compositeNames.size();
+ if (itemNames.length > compositeNameSize)
throw new IllegalArgumentException("itemNames has size " + itemNames.length + " but composite type has size " + compositeNameSize);
this.metaType = metaType;
@@ -102,20 +101,40 @@
throw new IllegalArgumentException("duplicate item name " + itemNames[i]);
MetaType itemType = metaType.getType(itemNames[i]);
if (itemType == null)
- throw new IllegalArgumentException("item name not in composite type " + itemNames[i]);
+ throw new IllegalArgumentException("item name not in composite type: " + itemNames[i]);
if (itemValues[i] != null && itemType.isValue(itemValues[i]) == false)
throw new IllegalArgumentException("item value " + itemValues[i] + " for item name " + itemNames[i] + " is not a " + itemType);
contents.put(itemNames[i], itemValues[i]);
}
+
+ if (itemNames.length < compositeNameSize)
+ {
+ List<String> itemList = Arrays.asList(itemNames);
+ for (String name : compositeNames)
+ {
+ if (itemList.contains(name) == false)
+ contents.put(name, null);
+ }
+ }
}
/**
* Construct Composite Value
*
+ * @param metaType the composite meta type of the data
+ * @throws IllegalArgumentException for a null metaType
+ */
+ public CompositeValueSupport(CompositeMetaType metaType)
+ {
+ this(metaType, null, null);
+ }
+
+ /**
+ * Construct Composite Value
+ *
* @param compositeMetaType the composite type of the data
* @param items map of strings to values
- * @throws IllegalArgumentException for a null or empty argument or when the items do not match the
- * CompositeType
+ * @throws IllegalArgumentException for a null metaType
*/
public CompositeValueSupport(CompositeMetaType compositeMetaType, Map<String, MetaValue> items)
{
@@ -133,6 +152,20 @@
return contents.get(key);
}
+ /**
+ * Set an item value
+ *
+ * @param key the key
+ * @param value the value
+ */
+ public void set(String key, MetaValue value)
+ {
+ MetaType itemType = validateKey(key);
+ if (value != null && itemType.isValue(value) == false)
+ throw new IllegalArgumentException("item value " + value + " for item name " + key + " is not a " + itemType);
+ contents.put(key, value);
+ }
+
public MetaValue[] getAll(String[] keys)
{
if (keys == null)
@@ -175,13 +208,12 @@
CompositeValue other = (CompositeValue) obj;
if (getMetaType().equals(other.getMetaType()) == false)
return false;
- if (values().size() != other.values().size())
- return false;
-
- for (String key : contents.keySet())
+
+ for (String key : getMetaType().keySet())
{
Object thisValue = this.get(key);
Object otherValue = other.get(key);
+
if ((thisValue == null && otherValue == null || thisValue != null && thisValue.equals(otherValue)) == false)
return false;
}
@@ -195,8 +227,9 @@
return cachedHashCode;
cachedHashCode = getMetaType().hashCode();
- for (Object value : contents.values())
+ for (String key : getMetaType().keySet())
{
+ Object value = contents.get(key);
if (value != null)
cachedHashCode += value.hashCode();
}
@@ -209,14 +242,16 @@
{
CompositeMetaType metaType = getMetaType();
StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
- buffer.append(": netaType=[");
+ buffer.append(": metaType=[");
buffer.append(metaType);
- buffer.append("] mappings=[");
+ buffer.append("] items=[");
Iterator keys = metaType.keySet().iterator();
while(keys.hasNext())
{
Object key = keys.next();
- buffer.append(key + "=" + contents.get(key));
+ buffer.append(key).append("=");
+ Object value = contents.get(key);
+ buffer.append(value);
if (keys.hasNext())
buffer.append(",");
}
@@ -228,16 +263,19 @@
* Validates the key against the composite type
*
* @param key the key to check
+ * @return the meta type
* @throws IllegalArgumentException for a null or empty key or when
* the key not a valid item name for the composite type
*/
- private void validateKey(String key)
+ private MetaType validateKey(String key)
{
if (key == null || key.length() == 0)
throw new IllegalArgumentException("null or empty key");
CompositeMetaType metaType = getMetaType();
- if (metaType.containsKey(key) == false)
+ MetaType result = metaType.getType(key);
+ if (result == null)
throw new IllegalArgumentException("no such item name " + key + " for composite type " + metaType);
+ return result;
}
/**
@@ -245,19 +283,18 @@
*
* @param metaType the composite type of the data
* @param items map of strings to values
- * @throws IllegalArgumentException for a null or empty argument or when the items do not match the
- * CompositeType
+ * @throws IllegalArgumentException for a metaType
*/
private void init(CompositeMetaType metaType, Map<String, MetaValue> items)
{
if (metaType == null)
throw new IllegalArgumentException("null meta type");
if (items == null)
- throw new IllegalArgumentException("null items");
- if (items.size() == 0)
- throw new IllegalArgumentException("empty items");
- int compositeNameSize = metaType.keySet().size();
- if (items.size() != compositeNameSize)
+ items = Collections.emptyMap();
+
+ Set<String> compositeNames = metaType.keySet();
+ int compositeNameSize = compositeNames.size();
+ if (items.size() > compositeNameSize)
throw new IllegalArgumentException("items has size " + items.size() + " but composite type has size " + compositeNameSize);
this.metaType = metaType;
@@ -276,6 +313,15 @@
throw new IllegalArgumentException("item value " + value + " for item name " + key + " is not a " + itemType);
contents.put(key, value);
}
+
+ if (items.size() < compositeNameSize)
+ {
+ for (String name : compositeNames)
+ {
+ if (items.containsKey(name) == false)
+ contents.put(name, null);
+ }
+ }
}
@SuppressWarnings("unchecked")
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/EnumValue.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/EnumValue.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/EnumValue.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metatype.api.values;
+
+import org.jboss.metatype.api.types.EnumMetaType;
+
+/**
+ * EnumValue.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface EnumValue extends MetaValue
+{
+ EnumMetaType getMetaType();
+
+ /**
+ * Get the underlying value
+ *
+ * @return the underlying value
+ */
+ public String getValue();
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/EnumValueSupport.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/EnumValueSupport.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/EnumValueSupport.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,118 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metatype.api.values;
+
+import org.jboss.metatype.api.types.EnumMetaType;
+
+/**
+ * EnumValue.
+ *
+ * TODO tests
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class EnumValueSupport extends AbstractMetaValue implements EnumValue
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -6472212391813711803L;
+
+ /** The enum meta type */
+ private EnumMetaType metaType;
+
+ /** The value */
+ private String value;
+
+ /**
+ * Create a new EnumValueSupport.
+ *
+ * @param metaType the enum meta type
+ * @param value the value
+ * @throws IllegalArgumentException for a null enum MetaType
+ */
+ public EnumValueSupport(EnumMetaType metaType, String value)
+ {
+ if (metaType == null)
+ throw new IllegalArgumentException("Null enum meta type");
+ this.metaType = metaType;
+ this.value = value;
+ }
+
+ public EnumMetaType getMetaType()
+ {
+ return metaType;
+ }
+
+ /**
+ * Get the value.
+ *
+ * @return the value.
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param value the value.
+ */
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+
+ if (obj == null || obj instanceof EnumValue == false)
+ return false;
+
+ EnumValue other = (EnumValue) obj;
+ if (metaType.equals(other.getMetaType()) == false)
+ return false;
+
+ Object otherValue = other.getValue();
+ if (value == null && otherValue == null)
+ return true;
+ if (value == null && otherValue != null)
+ return false;
+ return value.equals(otherValue);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ if (value == null)
+ return 0;
+ return value.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return metaType + ":" + value;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/GenericValue.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/GenericValue.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/GenericValue.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metatype.api.values;
+
+import java.io.Serializable;
+
+import org.jboss.metatype.api.types.GenericMetaType;
+
+/**
+ * GenericValue.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface GenericValue extends MetaValue
+{
+ GenericMetaType getMetaType();
+
+ /**
+ * Get the underlying value
+ *
+ * @return the underlying value
+ */
+ public Serializable getValue();
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/GenericValueSupport.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/GenericValueSupport.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/GenericValueSupport.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,120 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metatype.api.values;
+
+import java.io.Serializable;
+
+import org.jboss.metatype.api.types.GenericMetaType;
+
+/**
+ * GenericValue.
+ *
+ * TODO tests
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenericValueSupport extends AbstractMetaValue implements GenericValue
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 5552880928848272037L;
+
+ /** The generic meta type */
+ private GenericMetaType metaType;
+
+ /** The value */
+ private Serializable value;
+
+ /**
+ * Create a new GenericValueSupport.
+ *
+ * @param metaType the generic meta type
+ * @param value the value
+ * @throws IllegalArgumentException for a null generic MetaType
+ */
+ public GenericValueSupport(GenericMetaType metaType, Serializable value)
+ {
+ if (metaType == null)
+ throw new IllegalArgumentException("Null generic meta type");
+ this.metaType = metaType;
+ this.value = value;
+ }
+
+ public GenericMetaType getMetaType()
+ {
+ return metaType;
+ }
+
+ /**
+ * Get the value.
+ *
+ * @return the value.
+ */
+ public Serializable getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param value the value.
+ */
+ public void setValue(Serializable value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+
+ if (obj == null || obj instanceof GenericValue == false)
+ return false;
+
+ GenericValue other = (GenericValue) obj;
+ if (metaType.equals(other.getMetaType()) == false)
+ return false;
+
+ Object otherValue = other.getValue();
+ if (value == null && otherValue == null)
+ return true;
+ if (value == null && otherValue != null)
+ return false;
+ return value.equals(otherValue);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ if (value == null)
+ return 0;
+ return value.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return metaType + ":" + value;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/MetaValueFactory.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/MetaValueFactory.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/MetaValueFactory.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,84 @@
+/*
+* 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.metatype.api.values;
+
+import java.lang.reflect.Type;
+
+import org.jboss.metatype.plugins.values.MetaValueFactoryBuilder;
+import org.jboss.metatype.spi.values.MetaValueBuilder;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * MetaValueFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class MetaValueFactory
+{
+ /** The singleton builder */
+ private static final MetaValueFactoryBuilder builder = new MetaValueFactoryBuilder();
+
+ /**
+ * Get the metatype factory
+ *
+ * @return the instance
+ */
+ public static final MetaValueFactory getInstance()
+ {
+ return builder.create();
+ }
+
+ /**
+ * Create a meta value
+ *
+ * @param value the value
+ * @return the meta value
+ */
+ public abstract MetaValue create(Object value);
+
+ /**
+ * Create a meta value
+ *
+ * @param value the value
+ * @param type the type
+ * @return the meta value
+ */
+ public abstract MetaValue create(Object value, Type type);
+
+ /**
+ * Create a meta value
+ *
+ * @param value the value
+ * @param type the type
+ * @return the meta value
+ */
+ public abstract MetaValue create(Object value, TypeInfo type);
+
+ /**
+ * Set a meta value builder.
+ *
+ * @param clazz the class
+ * @param builder the builder
+ */
+ public abstract void setBuilder(Class<?> clazz, MetaValueBuilder builder);
+}
Modified: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/TableValue.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/TableValue.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/api/values/TableValue.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -27,6 +27,12 @@
import org.jboss.metatype.api.types.TableMetaType;
+/**
+ * TableValue.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
public interface TableValue extends MetaValue
{
TableMetaType getMetaType();
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/AbstractCompositeMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/AbstractCompositeMetaType.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/AbstractCompositeMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,297 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metatype.plugins.types;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.jboss.metatype.api.types.AbstractMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+
+/**
+ * ImmutableCompositeMetaType.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractCompositeMetaType extends AbstractMetaType implements CompositeMetaType
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -7421421680257307598L;
+
+ /** Item names to descriptions */
+ private TreeMap<String, String> nameToDescription;
+
+ /** Item names to meta types */
+ private TreeMap<String, MetaType> nameToType;
+
+ /** The keys */
+ private Set<String> keys;
+
+ /**
+ * Construct a composite meta type. The parameters are checked for validity.<p>
+ *
+ * The three arrays are internally copied. Future changes to these
+ * arrays do not alter the composite type.<p>
+ *
+ * getClassName() returns {@link CompositeValue}
+ *
+ * @param typeName the name of the composite type, cannot be null or empty
+ * @param description the human readable description of the composite type, cannot be null or empty
+ * @param itemNames the names of the items described by this type. Cannot
+ * be null, must contain at least one element, the elements cannot
+ * be null or empty. The order of the items is unimportant when
+ * determining equality.
+ * @param itemDescriptions the human readable descriptions of the items
+ * in the same order as the itemNames, cannot be null must have the
+ * same number of elements as the itemNames. The elements cannot
+ * be null or empty.
+ * @param itemTypes the MetaTypes of the items in the same order as the
+ * item names, cannot be null must have the
+ * same number of elements as the itemNames. The elements cannot
+ * be null.
+ * @param ignoreItems whether to ignore items
+ * @exception IllegalArgumentException when a parameter does not match
+ * what is described above or when itemNames contains a duplicate name.
+ * The names are case sensitive, leading and trailing whitespace
+ * is ignored.
+ */
+ protected AbstractCompositeMetaType(String typeName, String description, String[] itemNames, String[] itemDescriptions, MetaType[] itemTypes, boolean ignoreItems)
+ {
+ super(CompositeValue.class.getName(), typeName, description);
+ if (ignoreItems)
+ {
+ nameToDescription = new TreeMap<String, String>();
+ nameToType = new TreeMap<String, MetaType>();
+ return;
+ }
+ if (itemNames == null || itemNames.length == 0)
+ throw new IllegalArgumentException("null or empty itemNames");
+ if (itemDescriptions == null || itemDescriptions.length == 0)
+ throw new IllegalArgumentException("null or empty itemDescriptions");
+ if (itemTypes == null || itemTypes.length == 0)
+ throw new IllegalArgumentException("null or empty itemTypes");
+ if (itemNames.length != itemDescriptions.length)
+ throw new IllegalArgumentException("wrong number of itemDescriptions");
+ if (itemNames.length != itemTypes.length)
+ throw new IllegalArgumentException("wrong number of itemTypes");
+ nameToDescription = new TreeMap<String, String>();
+ nameToType = new TreeMap<String, MetaType>();
+ for (int i = 0; i < itemNames.length; ++i)
+ {
+ try
+ {
+ addItem(itemNames[i], itemDescriptions[i], itemTypes[i]);
+ }
+ catch (IllegalArgumentException e)
+ {
+ IllegalArgumentException e1 = new IllegalArgumentException(e.getMessage() + " for item " + i);
+ e1.setStackTrace(e.getStackTrace());
+ throw e1;
+ }
+ }
+ }
+
+ /**
+ * Construct a composite meta type with no items.
+ *
+ * @param typeName the name of the composite type, cannot be null or empty
+ * @param description the human readable description of the composite type, cannot be null or empty
+ * @throws IllegalArgumentException when a parameter does not match what is described above.
+ */
+ protected AbstractCompositeMetaType(String typeName, String description)
+ {
+ this(typeName, description, null, null, null, true);
+ }
+
+ /**
+ * Set the keys
+ *
+ * @param keySet the key set
+ */
+ protected void setKeys(Set<String> keySet)
+ {
+ if (keySet != null)
+ {
+ for (String key : keySet)
+ {
+ if (containsItem(key) == false)
+ throw new IllegalArgumentException("Key " + key + " is not an item " + itemSet());
+ }
+ }
+ keys = keySet;
+ }
+
+ /**
+ * Add an item
+ *
+ * @param itemName the item name
+ * @param itemDescription the item description
+ * @param itemType the item type
+ * @throws IllegalArgumentException for a null or empty item name, description or type or duplicate item
+ */
+ protected void addItem(String itemName, String itemDescription, MetaType itemType)
+ {
+ if (itemName == null)
+ throw new IllegalArgumentException("null item name");
+ itemName = itemName.trim();
+ if (itemName.length() == 0)
+ throw new IllegalArgumentException("empty item name");
+ if (nameToDescription.containsKey(itemName))
+ throw new IllegalArgumentException("duplicate item name " + itemName);
+ if (itemDescription == null)
+ throw new IllegalArgumentException("null item description");
+ itemDescription = itemDescription.trim();
+ if (itemDescription.length() == 0)
+ throw new IllegalArgumentException("empty item description");
+ if (itemType == null)
+ throw new IllegalArgumentException("null item type");
+ nameToDescription.put(itemName, itemDescription);
+ nameToType.put(itemName, itemType);
+ }
+
+ public boolean containsItem(String itemName)
+ {
+ if (itemName == null)
+ return false;
+ return nameToDescription.containsKey(itemName);
+ }
+
+ public String getDescription(String itemName)
+ {
+ if (itemName == null)
+ return null;
+ return nameToDescription.get(itemName);
+ }
+
+ @Override
+ public boolean isComposite()
+ {
+ return true;
+ }
+
+ public MetaType getType(String itemName)
+ {
+ if (itemName == null)
+ return null;
+ return nameToType.get(itemName);
+ }
+
+ public Set<String> itemSet()
+ {
+ return Collections.unmodifiableSet(nameToDescription.keySet());
+ }
+
+ public Set<String> keySet()
+ {
+ if (keys == null)
+ return itemSet();
+ return Collections.unmodifiableSet(keys);
+ }
+
+ @Override
+ public boolean isValue(Object obj)
+ {
+ if (obj == null || obj instanceof CompositeValue == false)
+ return false;
+ return equalsImpl(((CompositeValue) obj).getMetaType());
+ }
+
+ /**
+ * Implementation of equals
+ *
+ * @param obj the object to check
+ * @return true when equals false otherwise
+ */
+ protected boolean equalsImpl(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null || obj instanceof CompositeMetaType == false)
+ return false;
+
+ CompositeMetaType other = (CompositeMetaType) obj;
+ if (this.getTypeName().equals(other.getTypeName()) == false)
+ return false;
+ Iterator<String> thisNames = this.keySet().iterator();
+ Iterator<String> otherNames = other.keySet().iterator();
+ while(thisNames.hasNext() && otherNames.hasNext())
+ {
+ String thisName = thisNames.next();
+ String otherName = otherNames.next();
+ if (thisName.equals(otherName) == false)
+ return false;
+
+ if (this.getType(thisName).equals(other.getType(otherName)) == false)
+ return false;
+ }
+ if (thisNames.hasNext() || otherNames.hasNext())
+ return false;
+
+ return true;
+ }
+
+ /**
+ * Hashcode implementation
+ *
+ * @return the hash code
+ */
+ protected int hashCodeImpl()
+ {
+ int hashCode = getTypeName().hashCode();
+ for (Object o : nameToType.values())
+ hashCode += o.hashCode();
+ for (Object o : keySet())
+ hashCode += o.hashCode();
+ return hashCode;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
+ buffer.append('{').append(getTypeName());
+ Iterator<String> thisNames = keySet().iterator();
+ if (thisNames.hasNext())
+ {
+ buffer.append(" items=");
+ while(thisNames.hasNext())
+ {
+ String thisName = thisNames.next();
+ buffer.append("[");
+ buffer.append("name=");
+ buffer.append(thisName);
+ buffer.append(" type=");
+ buffer.append(getType(thisName).getTypeName());
+ buffer.append("]");
+ if (thisNames.hasNext())
+ buffer.append(", ");
+ }
+ }
+ buffer.append('}');
+ return buffer.toString();
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/ClassMetaTypeBuilder.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/ClassMetaTypeBuilder.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/ClassMetaTypeBuilder.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,53 @@
+/*
+* 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.metatype.plugins.types;
+
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.spi.types.MetaTypeBuilder;
+
+/**
+ * ClassMetaTypeBuilder.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassMetaTypeBuilder implements MetaTypeBuilder
+{
+ /** The singleton instance */
+ public static final ClassMetaTypeBuilder INSTANCE = new ClassMetaTypeBuilder();
+
+ /** The MetaType for Class */
+ public static final MetaType CLASS_META_TYPE = new ImmutableCompositeMetaType(
+ Class.class.getName(),
+ Class.class.getName(),
+ new String[] { "name" },
+ new String[] { "The class name" },
+ new MetaType[] { SimpleMetaType.STRING }
+ );
+
+ public MetaType buildMetaType()
+ {
+ return CLASS_META_TYPE;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,402 @@
+/*
+* 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.metatype.plugins.types;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Type;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.config.plugins.property.PropertyConfiguration;
+import org.jboss.config.spi.Configuration;
+import org.jboss.metatype.api.annotations.CompositeKey;
+import org.jboss.metatype.api.annotations.Generic;
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.EnumMetaType;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableTableMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.types.TableMetaType;
+import org.jboss.metatype.spi.types.MetaTypeBuilder;
+import org.jboss.reflect.spi.ArrayInfo;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.EnumConstantInfo;
+import org.jboss.reflect.spi.EnumInfo;
+import org.jboss.reflect.spi.InterfaceInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * DefaultMetaTypeFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultMetaTypeFactory extends MetaTypeFactory
+{
+ /** The map key */
+ public static final String MAP_KEY = "key";
+
+ /** The map value */
+ public static final String MAP_VALUE = "value";
+
+ /** Map index names */
+ public static final String[] MAP_INDEX_NAMES = { MAP_KEY };
+
+ /** Map item names */
+ public static final String[] MAP_ITEM_NAMES = { MAP_KEY, MAP_VALUE };
+
+ /** The configuration */
+ private static Configuration configuration;
+
+ static
+ {
+ configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
+ {
+ public Configuration run()
+ {
+ return new PropertyConfiguration();
+ }
+ });
+ }
+
+ /** The object type info */
+ private TypeInfo objectTypeInfo = configuration.getTypeInfo(Object.class);
+
+ /** The builders */
+ private Map<Class, WeakReference<MetaTypeBuilder>> builders = new WeakHashMap<Class, WeakReference<MetaTypeBuilder>>();
+
+ /**
+ * Create a new DefaultMetaTypeFactory.
+ */
+ public DefaultMetaTypeFactory()
+ {
+ // Special types
+ setBuilder(Class.class, ClassMetaTypeBuilder.INSTANCE);
+ }
+
+ @Override
+ public MetaType resolve(Type type)
+ {
+ TypeInfo typeInfo = configuration.getTypeInfo(type);
+ return resolve(typeInfo);
+ }
+
+ /**
+ * Resolve the meta type
+ *
+ * @param typeInfo the type
+ * @return the meta type
+ */
+ public MetaType resolve(TypeInfo typeInfo)
+ {
+ // Look for a cached value
+ MetaType result = typeInfo.getAttachment(MetaType.class);
+ if (result == null)
+ {
+ // Generate it
+ result = generate(typeInfo);
+
+ // Cache it
+ typeInfo.setAttachment(MetaType.class.getName(), result);
+ }
+
+ // Return the result
+ return result;
+ }
+
+ public void setBuilder(Class<?> clazz, MetaTypeBuilder builder)
+ {
+ synchronized (builders)
+ {
+ if (builder == null)
+ builders.remove(clazz);
+ builders.put(clazz, new WeakReference<MetaTypeBuilder>(builder));
+ }
+ }
+
+ /**
+ * Generate the metatype
+ *
+ * @param typeInfo the type info
+ * @return the metatype
+ */
+ public MetaType generate(TypeInfo typeInfo)
+ {
+ MetaType result = isBuilder(typeInfo);
+ if (result != null)
+ return result;
+
+ result = isGeneric(typeInfo);
+ if (result != null)
+ return result;
+
+ if (typeInfo.isEnum())
+ return generateEnum((EnumInfo) typeInfo);
+
+ ClassInfo annotationType = isAnnotation(typeInfo);
+ if (annotationType != null)
+ return generateAnnotation(annotationType);
+
+ if (typeInfo.isArray())
+ return generateArray((ArrayInfo) typeInfo);
+
+ if (typeInfo.isCollection())
+ return generateCollection((ClassInfo) typeInfo);
+
+ if (typeInfo.isMap())
+ return generateMap((ClassInfo) typeInfo);
+
+ result = SimpleMetaType.isSimpleType(typeInfo.getName());
+ if (result != null)
+ return result;
+
+ return generateBean((ClassInfo) typeInfo);
+ }
+
+ /**
+ * Generate an enum metatype
+ *
+ * @param typeInfo the type info
+ * @return the metatype
+ */
+ public EnumMetaType generateEnum(EnumInfo typeInfo)
+ {
+ EnumConstantInfo[] constants = typeInfo.getEnumConstants();
+ List<String> validValues = new ArrayList<String>(constants.length);
+ for (EnumConstantInfo constant : constants)
+ validValues.add(constant.getName());
+ return new EnumMetaType(typeInfo.getName(), validValues);
+ }
+
+ /**
+ * Whether this type is an annotation
+ *
+ * @param typeInfo the type info
+ * @return the annotation type info
+ */
+ public ClassInfo isAnnotation(TypeInfo typeInfo)
+ {
+ if (typeInfo.isAnnotation())
+ return (ClassInfo) typeInfo;
+
+ if (typeInfo instanceof ClassInfo)
+ {
+ ClassInfo classInfo = (ClassInfo) typeInfo;
+ InterfaceInfo[] interfaces = classInfo.getInterfaces();
+ if (interfaces != null)
+ {
+ for (int i = 0; i < interfaces.length; ++i)
+ {
+ if (interfaces[i].isAnnotation())
+ return interfaces[i];
+ }
+ }
+ }
+
+ // Doesn't look like an annotation
+ return null;
+ }
+
+ /**
+ * Generate an annotation metatype
+ *
+ * @param typeInfo the type info
+ * @return the metatype
+ */
+ public CompositeMetaType generateAnnotation(ClassInfo typeInfo)
+ {
+ return generateBean(typeInfo);
+ }
+
+ /**
+ * Generate an array metatype
+ *
+ * @param typeInfo the type info
+ * @return the metatype
+ */
+ public ArrayMetaType generateArray(ArrayInfo typeInfo)
+ {
+ int dimension = 1;
+ TypeInfo componentType = typeInfo.getComponentType();
+ while (componentType.isArray())
+ {
+ ++dimension;
+ componentType = ((ArrayInfo) componentType).getComponentType();
+ }
+ MetaType componentMetaType = resolve(componentType);
+ return new ArrayMetaType(dimension, componentMetaType);
+ }
+
+ /**
+ * Generate a collection metatype
+ *
+ * @param typeInfo the type info
+ * @return the metatype
+ */
+ public ArrayMetaType generateCollection(ClassInfo typeInfo)
+ {
+ TypeInfo elementType = objectTypeInfo;
+
+ TypeInfo[] types = typeInfo.getActualTypeArguments();
+ if (types != null)
+ elementType = types[0];
+
+ MetaType elementMetaType = resolve(elementType);
+ return new ArrayMetaType(1, elementMetaType);
+ }
+
+ /**
+ * Generate a map metatype
+ *
+ * @param typeInfo the type info
+ * @return the metatype
+ */
+ public TableMetaType generateMap(ClassInfo typeInfo)
+ {
+ TypeInfo keyType = objectTypeInfo;
+ TypeInfo valueType = objectTypeInfo;
+
+ TypeInfo[] types = typeInfo.getActualTypeArguments();
+ if (types != null)
+ {
+ keyType = types[0];
+ valueType = types[1];
+ }
+ return createMapType(keyType, valueType);
+ }
+
+ /**
+ * Create a map type
+ *
+ * @param keyType the key type
+ * @param valueType the value type
+ * @return the map type
+ */
+ public TableMetaType createMapType(TypeInfo keyType, TypeInfo valueType)
+ {
+ String name = Map.class.getName();
+ MetaType[] itemTypes = { resolve(keyType), resolve(valueType) };
+ CompositeMetaType entryType = createMapEntryType(itemTypes);
+ return new ImmutableTableMetaType(name, name, entryType, MAP_INDEX_NAMES);
+ }
+
+ /**
+ * Create a map entry type
+ *
+ * @param itemTypes the item types
+ * @return the map entry type
+ */
+ public static CompositeMetaType createMapEntryType(MetaType[] itemTypes)
+ {
+ String entryName = Map.Entry.class.getName();
+ return new ImmutableCompositeMetaType(entryName, entryName, MAP_ITEM_NAMES, MAP_ITEM_NAMES, itemTypes);
+ }
+
+ /**
+ * Generate a bean metatype
+ *
+ * @param typeInfo the type info
+ * @return the metatype
+ */
+ public CompositeMetaType generateBean(ClassInfo typeInfo)
+ {
+ BeanInfo beanInfo = configuration.getBeanInfo(typeInfo);
+ MutableCompositeMetaType result = new MutableCompositeMetaType(typeInfo.getName(), typeInfo.getName());
+ typeInfo.setAttachment(MetaType.class.getName(), result);
+
+ Set<String> keys = null;
+ Set<PropertyInfo> properties = beanInfo.getProperties();
+ if (properties != null && properties.size() > 0)
+ {
+ for (PropertyInfo property : properties)
+ {
+ String name = property.getName();
+ if ("class".equals(name) == false)
+ {
+ TypeInfo itemTypeInfo = property.getType();
+ MetaType metaType = resolve(itemTypeInfo);
+ result.addItem(name, name, metaType);
+ if (property.isAnnotationPresent(CompositeKey.class))
+ {
+ if (keys == null)
+ keys = new LinkedHashSet<String>();
+ keys.add(name);
+ }
+ }
+ }
+ }
+ if (keys != null)
+ result.setKeys(keys);
+ result.freeze();
+ return result;
+ }
+
+ /**
+ * Check for builders
+ *
+ * @param typeInfo the type info
+ * @return the meta type when it is special
+ */
+ public MetaType isBuilder(TypeInfo typeInfo)
+ {
+ MetaTypeBuilder builder = null;
+ synchronized (builders)
+ {
+ WeakReference<MetaTypeBuilder> weak = builders.get(typeInfo.getType());
+ if (weak != null)
+ builder = weak.get();
+ }
+ if (builder == null)
+ return null;
+ return builder.buildMetaType();
+ }
+
+ /**
+ * Check for generic
+ *
+ * @param typeInfo the type info
+ * @return the meta type when it is generic
+ */
+ public GenericMetaType isGeneric(TypeInfo typeInfo)
+ {
+ if (typeInfo instanceof ClassInfo == false)
+ return null;
+
+ ClassInfo classInfo = (ClassInfo) typeInfo;
+ Generic generic = classInfo.getUnderlyingAnnotation(Generic.class);
+ if (generic != null)
+ return new GenericMetaType(typeInfo.getName(), typeInfo.getName());
+ return null;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/MetaTypeFactoryBuilder.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/MetaTypeFactoryBuilder.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/MetaTypeFactoryBuilder.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,47 @@
+/*
+* 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.metatype.plugins.types;
+
+import org.jboss.metatype.api.types.MetaTypeFactory;
+
+/**
+ * MetaTypeFactoryBuilder.
+ *
+ * TODO this class only creates a singleton fixed implementation for now
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MetaTypeFactoryBuilder
+{
+ /** The singleton */
+ private static final MetaTypeFactory singleton = new DefaultMetaTypeFactory();
+
+ /**
+ * Create the factory
+ *
+ * @return the factory
+ */
+ public static MetaTypeFactory create()
+ {
+ return singleton;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/MutableCompositeMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/MutableCompositeMetaType.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/types/MutableCompositeMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,126 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metatype.plugins.types;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.Set;
+
+import org.jboss.metatype.api.types.MetaType;
+
+/**
+ * MutableCompositeMetaType.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MutableCompositeMetaType extends AbstractCompositeMetaType
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -8580367706705513814L;
+
+ /** Whether the composite type is frozen */
+ private transient boolean frozen = false;
+
+ /** Cached hash code */
+ private transient int cachedHashCode = Integer.MIN_VALUE;
+
+ /** Cached string representation */
+ private transient String cachedToString = null;
+
+ /**
+ * Construct a composite meta type with no items.
+ *
+ * @param typeName the name of the composite type, cannot be null or empty
+ * @param description the human readable description of the composite type, cannot be null or empty
+ * @throws IllegalArgumentException when a parameter does not match what is described above.
+ */
+ public MutableCompositeMetaType(String typeName, String description)
+ {
+ super(typeName, description);
+ }
+
+ @Override
+ public void addItem(String itemName, String itemDescription, MetaType itemType)
+ {
+ if (frozen)
+ throw new IllegalStateException("The type is frozen");
+ super.addItem(itemName, itemDescription, itemType);
+ }
+
+ @Override
+ public void setKeys(Set<String> keySet)
+ {
+ if (frozen)
+ throw new IllegalStateException("The type is frozen");
+ super.setKeys(keySet);
+ }
+
+ /**
+ * Freeze the metatype
+ */
+ public void freeze()
+ {
+ frozen = true;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ // If we aren't frozen yet, use identity
+ if (frozen == false)
+ return super.equals(obj);
+
+ return equalsImpl(obj);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ // If we aren't frozen yet, use identity
+ if (frozen == false)
+ return super.hashCode();
+
+ if (cachedHashCode != Integer.MIN_VALUE)
+ return cachedHashCode;
+ cachedHashCode = hashCodeImpl();
+ return cachedHashCode;
+ }
+
+ @Override
+ public String toString()
+ {
+ // If we aren't frozen yet, don't cache
+ if (frozen == false)
+ return super.toString();
+
+ if (cachedToString == null)
+ cachedToString = super.toString();
+ return cachedToString;
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ freeze();
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,458 @@
+/*
+* 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.metatype.plugins.values;
+
+import java.io.Serializable;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Type;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Stack;
+import java.util.WeakHashMap;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.config.plugins.property.PropertyConfiguration;
+import org.jboss.config.spi.Configuration;
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.EnumMetaType;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.types.TableMetaType;
+import org.jboss.metatype.api.values.ArrayValue;
+import org.jboss.metatype.api.values.ArrayValueSupport;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.EnumValueSupport;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.GenericValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.api.values.TableValue;
+import org.jboss.metatype.api.values.TableValueSupport;
+import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory;
+import org.jboss.metatype.spi.values.MetaValueBuilder;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * DefaultMetaValueFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultMetaValueFactory extends MetaValueFactory
+{
+ /** The metatype factory */
+ private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+
+ /** The configuration */
+ private static Configuration configuration;
+
+ static
+ {
+ configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
+ {
+ public Configuration run()
+ {
+ return new PropertyConfiguration();
+ }
+ });
+ }
+
+ /** The thread local stack of objects mapped to meta values */
+ private ThreadLocal<Stack<Map<Object, MetaValue>>> mappingStack = new ThreadLocal<Stack<Map<Object, MetaValue>>>()
+ {
+ protected Stack<Map<Object, MetaValue>> initialValue()
+ {
+ return new Stack<Map<Object, MetaValue>>();
+ }
+
+ };
+
+ /** The builders */
+ private Map<Class, WeakReference<MetaValueBuilder>> builders = new WeakHashMap<Class, WeakReference<MetaValueBuilder>>();
+
+ public void setBuilder(Class<?> clazz, MetaValueBuilder builder)
+ {
+ synchronized (builders)
+ {
+ if (builder == null)
+ builders.remove(clazz);
+ builders.put(clazz, new WeakReference<MetaValueBuilder>(builder));
+ }
+ }
+
+ /**
+ * Create a simple value
+ *
+ * @param <T> the simple type
+ * @param type the type
+ * @param value the value
+ * @return the simple value
+ */
+ public static <T extends Serializable> SimpleValue<T> createSimpleValue(SimpleMetaType<T> type, T value)
+ {
+ if (value == null)
+ return null;
+
+ return new SimpleValueSupport<T>(type, value);
+ }
+
+ /**
+ * Create an enum value
+ *
+ * @param <T> the enum type
+ * @param type the type
+ * @param value the value
+ * @return the enum value
+ */
+ public static <T extends Enum> EnumValue createEnumValue(EnumMetaType type, T value)
+ {
+ if (value == null)
+ return null;
+
+ return new EnumValueSupport(type, value.name());
+ }
+
+ /**
+ * Create a generic value
+ *
+ * @param type the type
+ * @param value the value
+ * @param mapping the mapping
+ * @return the enum value
+ */
+ public static GenericValue createGenericValue(GenericMetaType type, Object value, Map<Object, MetaValue> mapping)
+ {
+ if (value == null)
+ return null;
+
+ if (value instanceof Serializable == false)
+ throw new IllegalArgumentException("Not serializable: " + value.getClass().getName());
+
+ GenericValue result = new GenericValueSupport(type, (Serializable) value);
+ mapping.put(value, result);
+ return result;
+ }
+
+ /**
+ * Create an array value
+ *
+ * @param type the type
+ * @param value the value
+ * @param mapping the mapping
+ * @return the composite value
+ */
+ public ArrayValue createArrayValue(ArrayMetaType type, Object value, Map<Object, MetaValue> mapping)
+ {
+ if (value == null)
+ return null;
+
+ ArrayValueSupport result = new ArrayValueSupport(type);
+ mapping.put(value, result);
+
+ Object[] array = null;
+
+ MetaType elementType = type.getElementType();
+ int dimension = type.getDimension();
+
+ Object[] oldArray = null;
+ Class<?> componentType;
+ try
+ {
+ componentType = Class.forName(type.getClassName());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to determine component type for " + type, e);
+ }
+
+ ClassInfo classInfo = configuration.getClassInfo(value.getClass());
+ if (classInfo.isArray())
+ oldArray = (Object[]) value;
+ else if (classInfo.isCollection())
+ {
+ Collection c = (Collection) value;
+ oldArray = c.toArray();
+ }
+ else
+ throw new UnsupportedOperationException("Cannot construct array for " + value.getClass());
+
+ array = createArray(elementType, componentType.getComponentType(), dimension, oldArray);
+ result.setValue(array);
+ return result;
+ }
+
+ /**
+ * Create an array
+ *
+ * @param elementType the element type
+ * @param componentType the component type
+ * @param dimension the dimension
+ * @param oldArray the old array
+ * @return the array
+ */
+ protected Object[] createArray(MetaType elementType, Class<?> componentType, int dimension, Object[] oldArray)
+ {
+ if (oldArray == null)
+ return null;
+
+ Object[] newArray = new Object[oldArray.length];
+
+ if (dimension > 1)
+ {
+ for (int i = 0; i < oldArray.length; ++i)
+ {
+ Object[] nestedOld = (Object[]) oldArray[i];
+ Object[] result = createArray(elementType, componentType.getComponentType(), dimension-1, nestedOld);
+ newArray[i] = result;
+ }
+ }
+ else
+ {
+ for (int i = 0; i < oldArray.length; ++i)
+ newArray[i] = internalCreate(oldArray[i], null, elementType);
+ }
+
+ return newArray;
+ }
+
+ /**
+ * Create a composite value
+ *
+ * @param type the type
+ * @param value the value
+ * @param mapping the mapping
+ * @return the composite value
+ */
+ public CompositeValue createCompositeValue(CompositeMetaType type, Object value, Map<Object, MetaValue> mapping)
+ {
+ if (value == null)
+ return null;
+
+ CompositeValueSupport result = new CompositeValueSupport(type);
+ mapping.put(value, result);
+
+
+ BeanInfo beanInfo;
+ try
+ {
+ ClassLoader cl = value.getClass().getClassLoader();
+ if (cl == null)
+ beanInfo = configuration.getBeanInfo(value.getClass());
+ else
+ beanInfo = configuration.getBeanInfo(type.getTypeName(), cl);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error retrieving BeanInfo for " + type);
+ }
+
+ for (String name : type.keySet())
+ {
+ MetaType itemType = type.getType(name);
+ Object itemValue = null;
+ try
+ {
+ itemValue = beanInfo.getProperty(value, name);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error getting property: " + name + " for " + value.getClass(), t);
+ }
+
+ MetaValue item = internalCreate(itemValue, null, itemType);
+ result.set(name, item);
+ }
+
+ return result;
+ }
+
+ /**
+ * Create a table value
+ *
+ * @param type the type
+ * @param value the value
+ * @param mapping the mapping
+ * @return the table value
+ */
+ @SuppressWarnings("unchecked")
+ public TableValue createTableValue(TableMetaType type, Map value, Map<Object, MetaValue> mapping)
+ {
+ if (value == null)
+ return null;
+
+ TableValueSupport table = new TableValueSupport(type);
+ mapping.put(value, table);
+
+ CompositeMetaType entryType = type.getRowType();
+ MetaType keyType = entryType.getType(DefaultMetaTypeFactory.MAP_KEY);
+ MetaType valType = entryType.getType(DefaultMetaTypeFactory.MAP_VALUE);
+
+ for (Iterator<Map.Entry> i = value.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = i.next();
+ MetaValue key = internalCreate(entry.getKey(), null, keyType);
+ MetaValue val = internalCreate(entry.getValue(), null, valType);
+ CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val });
+ table.put(data);
+ }
+
+ return table;
+ }
+
+ @Override
+ public MetaValue create(Object value)
+ {
+ return internalCreate(value, null, null);
+ }
+
+ @Override
+ public MetaValue create(Object value, Type type)
+ {
+ TypeInfo typeInfo = configuration.getTypeInfo(type);
+ return internalCreate(value, typeInfo, null);
+ }
+
+ @Override
+ public MetaValue create(Object value, TypeInfo type)
+ {
+ return internalCreate(value, type, null);
+ }
+
+ /**
+ * Create a meta value from the object
+ *
+ * @param value the value
+ * @param type the type
+ * @param metaType the metaType
+ * @return the meta value
+ */
+ protected MetaValue internalCreate(Object value, TypeInfo type, MetaType metaType)
+ {
+ if (value == null)
+ return null;
+
+ if (type == null)
+ type = configuration.getTypeInfo(value.getClass());
+
+ boolean start = (metaType == null);
+ if (metaType == null)
+ {
+ metaType = metaTypeFactory.resolve(type);
+ }
+
+ // For more complicated values we need to keep a mapping of objects to meta values
+ // this avoids duplicate meta value construction and recursion
+ Map<Object, MetaValue> mapping = null;
+ if (start)
+ {
+ // This is the start of the mapping
+ mapping = new HashMap<Object, MetaValue>();
+ mappingStack.get().push(mapping);
+ }
+ else
+ {
+ // Check the existing mapping
+ mapping = mappingStack.get().peek();
+ MetaValue result = mapping.get(value);
+ // Seen this before
+ if (result != null)
+ return result;
+ }
+
+ try
+ {
+ MetaValue result = isBuilder(metaType, type, value, mapping);
+ if (result == null)
+ {
+ if (metaType.isSimple())
+ result = createSimpleValue((SimpleMetaType<Serializable>) metaType, (Serializable) value);
+ else if (metaType.isEnum())
+ result = createEnumValue((EnumMetaType) metaType, (Enum) value);
+ else if (metaType.isArray())
+ result = createArrayValue((ArrayMetaType) metaType, value, mapping);
+ else if (metaType.isComposite())
+ result = createCompositeValue((CompositeMetaType) metaType, value, mapping);
+ else if (metaType.isTable())
+ result = createTableValue((TableMetaType) metaType, (Map) value, mapping);
+ else if (metaType.isGeneric())
+ result = createGenericValue((GenericMetaType) metaType, value, mapping);
+ else
+ throw new IllegalStateException("Unknown metaType: " + metaType);
+ }
+ return result;
+ }
+ finally
+ {
+ // Remove the mapping from the stack
+ if (start)
+ mappingStack.get().pop();
+ }
+ }
+
+ /**
+ * Check for a builder
+ *
+ * @param metaType the meta type
+ * @param type the type
+ * @param value the value
+ * @param mapping the mappings
+ * @return the meta value
+ */
+ @SuppressWarnings("unchecked")
+ protected MetaValue isBuilder(MetaType metaType, TypeInfo type, Object value, Map<Object, MetaValue> mapping)
+ {
+ MetaValueBuilder builder = null;
+ synchronized (builders)
+ {
+ WeakReference<MetaValueBuilder> weak = builders.get(type.getType());
+ if (weak != null)
+ builder = weak.get();
+ }
+ if (builder == null)
+ return null;
+ MetaValue result = builder.buildMetaValue(metaType, value);
+ if (result != null)
+ mapping.put(value, result);
+
+ return result;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/MetaValueFactoryBuilder.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/MetaValueFactoryBuilder.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/plugins/values/MetaValueFactoryBuilder.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,47 @@
+/*
+* 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.metatype.plugins.values;
+
+import org.jboss.metatype.api.values.MetaValueFactory;
+
+/**
+ * MetaValueFactoryBuilder.
+ *
+ * TODO this class only creates a singleton fixed implementation for now
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MetaValueFactoryBuilder
+{
+ /** The singleton */
+ private static final MetaValueFactory singleton = new DefaultMetaValueFactory();
+
+ /**
+ * Create the factory
+ *
+ * @return the factory
+ */
+ public static MetaValueFactory create()
+ {
+ return singleton;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/types/MetaTypeBuilder.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/types/MetaTypeBuilder.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/types/MetaTypeBuilder.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,40 @@
+/*
+* 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.metatype.spi.types;
+
+import org.jboss.metatype.api.types.MetaType;
+
+/**
+ * MetaTypeBuilder.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MetaTypeBuilder
+{
+ /**
+ * Build the meta type
+ *
+ * @return the meta type
+ */
+ MetaType buildMetaType();
+}
Added: projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/values/MetaValueBuilder.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/values/MetaValueBuilder.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/main/org/jboss/metatype/spi/values/MetaValueBuilder.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,44 @@
+/*
+* 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.metatype.spi.values;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * MetaValueBuilder.
+ *
+ * @param <T> the object type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MetaValueBuilder<T>
+{
+ /**
+ * Build the meta value
+ *
+ * @param metaType the meta type
+ * @param object the object
+ * @return the meta value
+ */
+ MetaValue buildMetaValue(MetaType metaType, T object);
+}
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/AbstractMetaTypeTest.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/AbstractMetaTypeTest.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/AbstractMetaTypeTest.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -25,10 +25,13 @@
import java.util.Map;
import junit.framework.TestSuite;
+
+import org.jboss.metatype.api.types.ArrayMetaType;
import org.jboss.metatype.api.types.CompositeMetaType;
import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.types.TableMetaType;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
@@ -45,7 +48,7 @@
/**
* Create a new testsuite for the class
*
- * TODO added to BaseTestCase - remove once jboss-test is updated
+ * TODO move to BaseTestCase
* @param clazz the class
* @return the suite
*/
@@ -54,61 +57,121 @@
return new TestSuite(clazz);
}
+ /**
+ * Create a new AbstractMetaTypeTest.
+ *
+ * @param name the test name
+ */
public AbstractMetaTypeTest(String name)
{
super(name);
}
+ /**
+ * Initialise string value 1
+ *
+ * @return the value
+ */
protected SimpleValue<String> initStringValue1()
{
return SimpleValueSupport.wrap("value1");
}
+ /**
+ * Initialise string value 2
+ *
+ * @return the value
+ */
protected SimpleValue<String> initStringValue2()
{
return SimpleValueSupport.wrap("value2");
}
+ /**
+ * Initialise string name 1
+ *
+ * @return the name
+ */
protected SimpleValue<String> initStringName1()
{
return SimpleValueSupport.wrap("name1");
}
+ /**
+ * Initialise the empty string
+ *
+ * @return the empty string
+ */
protected SimpleValue<String> initStringEmpty()
{
return SimpleValueSupport.wrap("");
}
+ /**
+ * Initialise the null string
+ *
+ * @return the null string
+ */
protected SimpleValue<String> initStringNull()
{
return new SimpleValueSupport<String>(SimpleMetaType.STRING, null);
}
+ /**
+ * Initialise the wrong string
+ *
+ * @return the wrong string
+ */
protected SimpleValue<String> initStringWrong()
{
return SimpleValueSupport.wrap("wrong");
}
+ /**
+ * Initialise the integer 2
+ *
+ * @return the value
+ */
protected SimpleValue<Integer> initInteger2()
{
return SimpleValueSupport.wrap(new Integer(2));
}
+ /**
+ * Initialise the integer 3
+ *
+ * @return the value
+ */
protected SimpleValue<Integer> initInteger3()
{
return SimpleValueSupport.wrap(new Integer(3));
}
+ /**
+ * Initialise the integer 4
+ *
+ * @return the value
+ */
protected SimpleValue<Integer> initInteger4()
{
return SimpleValueSupport.wrap(new Integer(4));
}
+ /**
+ * Initialise the null integer
+ *
+ * @return the value
+ */
protected SimpleValue<Integer> initIntegerNull()
{
return new SimpleValueSupport<Integer>(SimpleMetaType.INTEGER, null);
}
+ /**
+ * Initialise map values
+ *
+ * @return the value
+ */
protected Map<String, MetaValue> initMapValues()
{
Map<String, MetaValue> map = new HashMap<String, MetaValue>();
@@ -117,6 +180,11 @@
return map;
}
+ /**
+ * Initialise map values 2
+ *
+ * @return the value
+ */
protected Map<String, MetaValue> initMapValues2()
{
Map<String, MetaValue> map = new HashMap<String, MetaValue>();
@@ -125,6 +193,11 @@
return map;
}
+ /**
+ * Initialise map values 3
+ *
+ * @return the value
+ */
protected Map<String, MetaValue> initMapValues3()
{
Map<String, MetaValue> map = new HashMap<String, MetaValue>();
@@ -133,6 +206,11 @@
return map;
}
+ /**
+ * Initialise map values 4
+ *
+ * @return the value
+ */
protected Map<String, MetaValue> initMapValues4()
{
Map<String, MetaValue> map = new HashMap<String, MetaValue>();
@@ -141,26 +219,51 @@
return map;
}
+ /**
+ * Initialise map keys
+ *
+ * @return the keys
+ */
protected String[] initKeys()
{
return new String[] { "name1", "name2" };
}
+ /**
+ * Initialise map values
+ *
+ * @return the values
+ */
protected MetaValue[] initValues()
{
return new MetaValue[] { initStringValue1(), initInteger2() };
}
+ /**
+ * Initialise map values 2
+ *
+ * @return the values
+ */
protected MetaValue[] initValues2()
{
return new MetaValue[] { initStringValue1(), initInteger3() };
}
+ /**
+ * Initialise map values 4
+ *
+ * @return the values
+ */
protected MetaValue[] initValues4()
{
return new MetaValue[] { initStringValue1(), initInteger4() };
}
+ /**
+ * Initialise a composite meta type
+ *
+ * @return the type
+ */
protected CompositeMetaType initCompositeMetaType()
{
String[] itemNames = new String[] { "name1", "name2" };
@@ -170,6 +273,11 @@
return compositeMetaType;
}
+ /**
+ * Initialise a composite meta type 2
+ *
+ * @return the type
+ */
protected CompositeMetaType initCompositeMetaType2()
{
String[] itemNames = new String[] { "name1", "name2" };
@@ -178,4 +286,54 @@
CompositeMetaType compositeMetaType = new ImmutableCompositeMetaType("typeName2", "description", itemNames, itemDescriptions, itemTypes);
return compositeMetaType;
}
+
+ /**
+ * Print a composite type
+ *
+ * @param context the context
+ * @param type the type
+ */
+ protected void printComposite(String context, CompositeMetaType type)
+ {
+ getLog().debug(context + " className=" + type.getClassName() + " typeName=" + type.getTypeName() + " description=" + type.getDescription() + " items=" + type.keySet());
+ }
+
+ /**
+ * Test an array type
+ *
+ * @param expected the expected
+ * @param actual the actual
+ * @throws Exception for any problem
+ */
+ protected void testArray(ArrayMetaType expected, ArrayMetaType actual) throws Exception
+ {
+ getLog().debug("Array MetaType: className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription() + " dim=" + actual.getDimension());
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test a table type
+ *
+ * @param expected the expected
+ * @param actual the actual
+ * @throws Exception for any problem
+ */
+ protected void testTable(TableMetaType expected, TableMetaType actual) throws Exception
+ {
+ getLog().debug("Table MetaType: className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription() + " index=" + actual.getIndexNames() + " row=" + actual.getRowType());
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test a composite type
+ *
+ * @param expected the expected
+ * @param actual the actual
+ * @throws Exception for any problem
+ */
+ protected void testComposite(CompositeMetaType expected, CompositeMetaType actual) throws Exception
+ {
+ printComposite("Composite MetaType", actual);
+ assertEquals(expected, actual);
+ }
}
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/MetaTypeAllTestSuite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/MetaTypeAllTestSuite.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/MetaTypeAllTestSuite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -21,7 +21,9 @@
*/
package org.jboss.test.metatype;
+import org.jboss.test.metatype.types.factory.test.TypesFactoryTestSuite;
import org.jboss.test.metatype.types.test.TypesTestSuite;
+import org.jboss.test.metatype.values.factory.test.ValuesFactoryTestSuite;
import org.jboss.test.metatype.values.test.ValuesTestSuite;
import junit.framework.Test;
@@ -36,17 +38,29 @@
*/
public class MetaTypeAllTestSuite extends TestSuite
{
+ /**
+ * For running the testsuite from the command line
+ *
+ * @param args the command line args
+ */
public static void main(String[] args)
{
TestRunner.run(suite());
}
+ /**
+ * Create the testsuite
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
TestSuite suite = new TestSuite("MetaType All Tests");
suite.addTest(TypesTestSuite.suite());
+ suite.addTest(TypesFactoryTestSuite.suite());
suite.addTest(ValuesTestSuite.suite());
+ suite.addTest(ValuesFactoryTestSuite.suite());
return suite;
}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestEnum.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestEnum.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestEnum.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,38 @@
+/*
+* 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.test.metatype.types.factory.support;
+
+/**
+ * TestEnum.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public enum TestEnum
+{
+ /** ONE */
+ ONE,
+ /** TWO */
+ TWO,
+ /** THREE */
+ THREE
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestGeneric.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestGeneric.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestGeneric.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,35 @@
+/*
+* 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.test.metatype.types.factory.support;
+
+import org.jboss.metatype.api.annotations.Generic;
+
+/**
+ * TestGeneric.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Generic
+public class TestGeneric
+{
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestGenericComposite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestGenericComposite.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestGenericComposite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,54 @@
+/*
+* 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.test.metatype.types.factory.support;
+
+/**
+ * TestGenericComposite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestGenericComposite
+{
+ /** Generic property */
+ private TestGeneric generic;
+
+ /**
+ * Get the generic property
+ *
+ * @return the property
+ */
+ public TestGeneric getGeneric()
+ {
+ return generic;
+ }
+
+ /**
+ * Set the generic property
+ *
+ * @param generic the generic property
+ */
+ public void setGeneric(TestGeneric generic)
+ {
+ this.generic = generic;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestOverrideComposite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestOverrideComposite.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestOverrideComposite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,55 @@
+/*
+* 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.test.metatype.types.factory.support;
+
+/**
+ * TestOverrideComposite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestOverrideComposite
+{
+ /** The something property */
+ private String something;
+
+ /**
+ * Get the something.
+ *
+ * @return the something.
+ */
+ public String getSomething()
+ {
+ return something;
+ }
+
+ /**
+ * Set the something.
+ *
+ * @param something the something.
+ */
+ public void setSomething(String something)
+ {
+ this.something = something;
+ }
+
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestOverrideCompositeBuilder.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestOverrideCompositeBuilder.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestOverrideCompositeBuilder.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,44 @@
+/*
+* 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.test.metatype.types.factory.support;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.metatype.spi.types.MetaTypeBuilder;
+
+/**
+ * TestOverrideCompositeBuilder.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestOverrideCompositeBuilder implements MetaTypeBuilder
+{
+ public MetaType buildMetaType()
+ {
+ MutableCompositeMetaType result = new MutableCompositeMetaType(TestOverrideComposite.class.getName(), TestOverrideComposite.class.getName());
+ result.addItem("somethingElse", "somethingElse", SimpleMetaType.STRING);
+ result.freeze();
+ return result;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestRecursiveComposite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestRecursiveComposite.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestRecursiveComposite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,90 @@
+/*
+* 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.test.metatype.types.factory.support;
+
+import org.jboss.metatype.api.annotations.CompositeKey;
+
+/**
+ * TestRecursiveComposite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestRecursiveComposite
+{
+ /** The id */
+ private String id;
+
+ /** The other */
+ private TestRecursiveComposite other;
+
+ /**
+ * Create a new TestRecursiveComposite.
+ *
+ * @param id the id
+ */
+ public TestRecursiveComposite(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * Get the id
+ *
+ * @return the id
+ */
+ @CompositeKey
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Set the id
+ *
+ * @param id the id
+ */
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * Get the other.
+ *
+ * @return the other.
+ */
+ public TestRecursiveComposite getOther()
+ {
+ return other;
+ }
+
+ /**
+ * Set the other.
+ *
+ * @param other the other.
+ */
+ public void setOther(TestRecursiveComposite other)
+ {
+ this.other = other;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestSimpleAnnotation.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestSimpleAnnotation.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestSimpleAnnotation.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,38 @@
+/*
+* 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.test.metatype.types.factory.support;
+
+/**
+ * TestSimpleAnnotation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public @interface TestSimpleAnnotation
+{
+ /**
+ * The something
+ *
+ * @return the something
+ */
+ String something() default "";
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestSimpleComposite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestSimpleComposite.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/support/TestSimpleComposite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,54 @@
+/*
+* 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.test.metatype.types.factory.support;
+
+/**
+ * TestSimpleComposite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestSimpleComposite
+{
+ /** The something */
+ private String something;
+
+ /**
+ * Get the something.
+ *
+ * @return the something.
+ */
+ public String getSomething()
+ {
+ return something;
+ }
+
+ /**
+ * Set the something.
+ *
+ * @param something the something.
+ */
+ public void setSomething(String something)
+ {
+ this.something = something;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/AbstractMetaTypeFactoryTest.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/AbstractMetaTypeFactoryTest.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/AbstractMetaTypeFactoryTest.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.types.factory.test;
+
+import java.lang.reflect.Type;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.spi.types.MetaTypeBuilder;
+import org.jboss.test.metatype.AbstractMetaTypeTest;
+
+/**
+ * AbstractMetaTypeFactoryTest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractMetaTypeFactoryTest extends AbstractMetaTypeTest
+{
+ /** The metatype factory */
+ private static final MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+
+ /**
+ * Create a new AbstractMetaTypeFactoryTest.
+ *
+ * @param name the test name
+ */
+ public AbstractMetaTypeFactoryTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Set a builder
+ *
+ * @param clazz the clazz
+ * @param builder the builder
+ */
+ protected void setBuilder(Class clazz, MetaTypeBuilder builder)
+ {
+ metaTypeFactory.setBuilder(clazz, builder);
+ }
+
+ /**
+ * Resolve a metatype
+ *
+ * @param type the type
+ * @return the meta type
+ */
+ protected MetaType resolve(Type type)
+ {
+ return metaTypeFactory.resolve(type);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/AnnotationMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/AnnotationMetaTypeFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/AnnotationMetaTypeFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.types.factory.test;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.test.metatype.types.factory.support.TestSimpleAnnotation;
+
+/**
+ * AnnotationMetaTypeFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnnotationMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest
+{
+ /**
+ * Create a new testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(AnnotationMetaTypeFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new AnnotationMetaTypeFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public AnnotationMetaTypeFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the composite type generated for a simple annotation
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleAnnotation() throws Exception
+ {
+ MetaType result = resolve(TestSimpleAnnotation.class);
+ CompositeMetaType actual = assertInstanceOf(result, CompositeMetaType.class);
+
+ MutableCompositeMetaType expected = new MutableCompositeMetaType(TestSimpleAnnotation.class.getName(), TestSimpleAnnotation.class.getName());
+ expected.addItem("something", "something", SimpleMetaType.STRING);
+ expected.freeze();
+
+ testComposite(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/ArrayMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/ArrayMetaTypeFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/ArrayMetaTypeFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,116 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.types.factory.test;
+
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.test.metatype.types.factory.support.TestSimpleComposite;
+
+import junit.framework.Test;
+
+/**
+ * ArrayMetaTypeFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ArrayMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(ArrayMetaTypeFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new ArrayMetaTypeFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public ArrayMetaTypeFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the correct meta type is generated for a simple array
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleArray() throws Exception
+ {
+ String[] array = new String[0];
+ MetaType result = resolve(array.getClass());
+ ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class);
+ ArrayMetaType expected = new ArrayMetaType(1, SimpleMetaType.STRING);
+ testArray(expected, actual);
+ }
+
+ /**
+ * Test the correct meta type is generated for a composite array
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleCompositeArray() throws Exception
+ {
+ TestSimpleComposite[] array = new TestSimpleComposite[0];
+ MetaType result = resolve(array.getClass());
+ MetaType composite = resolve(TestSimpleComposite.class);
+ ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class);
+ ArrayMetaType expected = new ArrayMetaType(1, composite);
+ testArray(expected, actual);
+ }
+
+ /**
+ * Test the correct meta type is generated for a multidimensional simple array
+ *
+ * @throws Exception for any problem
+ */
+ public void testMultiSimpleArray() throws Exception
+ {
+ String[][] array = new String[0][0];
+ MetaType result = resolve(array.getClass());
+ ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class);
+ ArrayMetaType expected = new ArrayMetaType(2, SimpleMetaType.STRING);
+ testArray(expected, actual);
+ }
+
+ /**
+ * Test the correct meta type is generated for a mutli dimensional composite array
+ *
+ * @throws Exception for any problem
+ */
+ public void testMultiSimpleCompositeArray() throws Exception
+ {
+ TestSimpleComposite[][] array = new TestSimpleComposite[0][0];
+ MetaType result = resolve(array.getClass());
+ MetaType composite = resolve(TestSimpleComposite.class);
+ ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class);
+ ArrayMetaType expected = new ArrayMetaType(2, composite);
+ testArray(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CollectionMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CollectionMetaTypeFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CollectionMetaTypeFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,201 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.types.factory.test;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.test.metatype.types.factory.support.TestSimpleComposite;
+
+/**
+ * CollectionMetaTypeFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class CollectionMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(CollectionMetaTypeFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new CollectionMetaTypeFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public CollectionMetaTypeFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Signature method for a simple collection
+ *
+ * @return the signature
+ */
+ public Collection<String> simpleCollection()
+ {
+ return null;
+ }
+
+ /**
+ * Signature method for a composite collection
+ *
+ * @return the signature
+ */
+ public static Collection<TestSimpleComposite> simpleCompositeCollection()
+ {
+ return null;
+ }
+
+ /**
+ * Signature method for a list
+ *
+ * @return the signature
+ */
+ public List<String> simpleList()
+ {
+ return null;
+ }
+
+ /**
+ * Signature method for a composite list
+ *
+ * @return the signature
+ */
+ public static List<TestSimpleComposite> simpleCompositeList()
+ {
+ return null;
+ }
+
+ /**
+ * Signature method for a composite set
+ *
+ * @return the signature
+ */
+ public Set<String> simpleSet()
+ {
+ return null;
+ }
+
+ /**
+ * Signature method for a composite set
+ *
+ * @return the signature
+ */
+ public static Set<TestSimpleComposite> simpleCompositeSet()
+ {
+ return null;
+ }
+
+ /**
+ * Test the correct meta type is generated for a simple collection
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleCollection() throws Exception
+ {
+ testCollection("simpleCollection", String.class);
+ }
+
+ /**
+ * Test the correct meta type is generated for a composite collection
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleCompositeCollection() throws Exception
+ {
+ testCollection("simpleCompositeCollection", TestSimpleComposite.class);
+ }
+
+ /**
+ * Test the correct meta type is generated for a simple list
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleList() throws Exception
+ {
+ testCollection("simpleList", String.class);
+ }
+
+ /**
+ * Test the correct meta type is generated for a composite list
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleCompositeList() throws Exception
+ {
+ testCollection("simpleCompositeList", TestSimpleComposite.class);
+ }
+
+ /**
+ * Test the correct meta type is generated for a simple set
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleSet() throws Exception
+ {
+ testCollection("simpleSet", String.class);
+ }
+
+ /**
+ * Test the correct meta type is generated for a composite set
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleCompositeSet() throws Exception
+ {
+ testCollection("simpleCompositeSet", TestSimpleComposite.class);
+ }
+
+ /**
+ * Test the correct meta type is generated for a collection
+ *
+ * @param methodName the method name to lookup the connection signature
+ * @param elementClass the expected element type of the collection
+ * @throws Exception for any problem
+ */
+ protected void testCollection(String methodName, Type elementClass) throws Exception
+ {
+ Method method = getClass().getMethod(methodName, null);
+ Type collectionType = method.getGenericReturnType();
+ MetaType result = resolve(collectionType);
+ ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class);
+ MetaType elementType = resolve(elementClass);
+ ArrayMetaType expected = new ArrayMetaType(1, elementType);
+ testArray(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CompositeMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CompositeMetaTypeFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/CompositeMetaTypeFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,100 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.types.factory.test;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.test.metatype.types.factory.support.TestRecursiveComposite;
+import org.jboss.test.metatype.types.factory.support.TestSimpleComposite;
+
+import junit.framework.Test;
+
+/**
+ * CompositeMetaTypeFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class CompositeMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(CompositeMetaTypeFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new CompositeMetaTypeFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public CompositeMetaTypeFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the correct metatype is generated for a simple composite
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleComposite() throws Exception
+ {
+ MetaType result = resolve(TestSimpleComposite.class);
+ CompositeMetaType actual = assertInstanceOf(result, CompositeMetaType.class);
+
+ MutableCompositeMetaType expected = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName());
+ expected.addItem("something", "something", SimpleMetaType.STRING);
+ expected.freeze();
+
+ testComposite(expected, actual);
+ }
+
+ /**
+ * Test the correct metatype is generated for a recursive composite
+ *
+ * @throws Exception for any problem
+ */
+ public void testRecursiveComposite() throws Exception
+ {
+ MetaType result = resolve(TestRecursiveComposite.class);
+ CompositeMetaType actual = assertInstanceOf(result, CompositeMetaType.class);
+
+ MutableCompositeMetaType expected = new MutableCompositeMetaType(TestRecursiveComposite.class.getName(), TestRecursiveComposite.class.getName());
+ expected.addItem("id", "id", SimpleMetaType.STRING);
+ expected.addItem("other", "other", expected);
+ Set<String> keys = Collections.singleton("id");
+ expected.setKeys(keys);
+ expected.freeze();
+
+ testComposite(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/EnumMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/EnumMetaTypeFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/EnumMetaTypeFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,77 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.types.factory.test;
+
+import java.util.ArrayList;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.EnumMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.test.metatype.types.factory.support.TestEnum;
+
+/**
+ * EnumMetaTypeFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class EnumMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(EnumMetaTypeFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new EnumMetaTypeFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public EnumMetaTypeFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the correct metatype is generated for an enum
+ *
+ * @throws Exception for any problem
+ */
+ public void testEnumType() throws Exception
+ {
+ MetaType result = resolve(TestEnum.class);
+ EnumMetaType actual = assertInstanceOf(result, EnumMetaType.class);
+ ArrayList<String> expectedValues = new ArrayList<String>(3);
+ expectedValues.add("ONE");
+ expectedValues.add("TWO");
+ expectedValues.add("THREE");
+ EnumMetaType expected = new EnumMetaType(TestEnum.class.getName(), expectedValues);
+ getLog().debug("Enum MetaType: className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription() + " values=" + actual.getValidValues());
+ assertEquals(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/MapMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/MapMetaTypeFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/MapMetaTypeFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,148 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.types.factory.test;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableTableMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.TableMetaType;
+import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory;
+import org.jboss.test.metatype.types.factory.support.TestSimpleComposite;
+
+/**
+ * MapMetaTypeFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MapMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(MapMetaTypeFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new MapMetaTypeFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public MapMetaTypeFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Signature method for a simple map
+ *
+ * @return the signature
+ */
+ public Map<String, Integer> simpleMap()
+ {
+ return null;
+ }
+
+ /**
+ * Signature method for a map with a composite key
+ *
+ * @return the signature
+ */
+ public Map<TestSimpleComposite, Integer> compositeKeyMap()
+ {
+ return null;
+ }
+
+ /**
+ * Signature method for a map with a composite value
+ *
+ * @return the signature
+ */
+ public Map<String, TestSimpleComposite> compositeValueMap()
+ {
+ return null;
+ }
+
+ /**
+ * Test the correct meta type is generated for a simple map
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleMap() throws Exception
+ {
+ testMap("simpleMap", String.class, Integer.class);
+ }
+
+ /**
+ * Test the correct meta type is generated for a map with a composite key
+ *
+ * @throws Exception for any problem
+ */
+ public void testCompositeKeyMap() throws Exception
+ {
+ testMap("compositeKeyMap", TestSimpleComposite.class, Integer.class);
+ }
+
+ /**
+ * Test the correct meta type is generated for a map with a composite value
+ *
+ * @throws Exception for any problem
+ */
+ public void testCompositeValueMap() throws Exception
+ {
+ testMap("compositeValueMap", String.class, TestSimpleComposite.class);
+ }
+
+ /**
+ * Test the correct meta type is generated for a map
+ *
+ * @param methodName the method name to lookup the connection signature
+ * @param keyClass the expected key type
+ * @param valueClass the expected value type
+ * @throws Exception for any problem
+ */
+ protected void testMap(String methodName, Type keyClass, Type valueClass) throws Exception
+ {
+ Method method = getClass().getMethod(methodName, null);
+ Type collectionType = method.getGenericReturnType();
+ MetaType result = resolve(collectionType);
+ TableMetaType actual = assertInstanceOf(result, TableMetaType.class);
+ MetaType keyType = resolve(keyClass);
+ MetaType valueType = resolve(valueClass);
+ MetaType[] itemTypes = { keyType, valueType };
+ String entryName = Map.Entry.class.getName();
+ CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes);
+ TableMetaType expected = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES);
+ testTable(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/SimpleMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/SimpleMetaTypeFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/SimpleMetaTypeFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,126 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.types.factory.test;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+
+/**
+ * SimpleMetaTypeFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(SimpleMetaTypeFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new SimpleMetaTypeFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public SimpleMetaTypeFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ SimpleMetaType[] expected = new SimpleMetaType[]
+ {
+ SimpleMetaType.BIGDECIMAL,
+ SimpleMetaType.BIGINTEGER,
+ SimpleMetaType.BOOLEAN,
+ SimpleMetaType.BOOLEAN,
+ SimpleMetaType.BYTE,
+ SimpleMetaType.BYTE,
+ SimpleMetaType.CHARACTER,
+ SimpleMetaType.CHARACTER,
+ SimpleMetaType.DATE,
+ SimpleMetaType.DOUBLE,
+ SimpleMetaType.DOUBLE,
+ SimpleMetaType.FLOAT,
+ SimpleMetaType.FLOAT,
+ SimpleMetaType.INTEGER,
+ SimpleMetaType.INTEGER,
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ SimpleMetaType.SHORT,
+ SimpleMetaType.SHORT,
+ SimpleMetaType.STRING,
+ SimpleMetaType.VOID
+ };
+
+ Class[] classes = new Class[]
+ {
+ BigDecimal.class,
+ BigInteger.class,
+ Boolean.class,
+ Boolean.TYPE,
+ Byte.class,
+ Byte.TYPE,
+ Character.class,
+ Character.TYPE,
+ Date.class,
+ Double.class,
+ Double.TYPE,
+ Float.class,
+ Float.TYPE,
+ Integer.class,
+ Integer.TYPE,
+ Long.class,
+ Long.TYPE,
+ Short.class,
+ Short.TYPE,
+ String.class,
+ Void.class
+ };
+
+ /**
+ * Test the simple meta types are generated correctly
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleTypes() throws Exception
+ {
+ for (int i = 0; i < expected.length; ++i)
+ {
+ String className = classes[i].getName();
+ MetaType actual = resolve(classes[i]);
+ getLog().debug("SimpleMetaType: " + className + " className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription());
+ assertEquals(expected[i], actual);
+ }
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/SpecialMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/SpecialMetaTypeFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/SpecialMetaTypeFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,126 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.types.factory.test;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.plugins.types.ClassMetaTypeBuilder;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.test.metatype.types.factory.support.TestGeneric;
+import org.jboss.test.metatype.types.factory.support.TestGenericComposite;
+import org.jboss.test.metatype.types.factory.support.TestOverrideComposite;
+import org.jboss.test.metatype.types.factory.support.TestOverrideCompositeBuilder;
+
+/**
+ * SpecialMetaTypeFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SpecialMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(SpecialMetaTypeFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new SpecialMetaTypeFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public SpecialMetaTypeFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the meta type is generated correctly for java.lang.Class
+ *
+ * @throws Exception for any problem
+ */
+ public void testClass() throws Exception
+ {
+ MetaType actual = resolve(Class.class);
+ getLog().debug("Class MetaType: " + " className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription());
+ assertEquals(ClassMetaTypeBuilder.CLASS_META_TYPE, actual);
+ }
+
+ /**
+ * Test the meta type is generated correctly for a generic type
+ *
+ * @throws Exception for any problem
+ */
+ public void testGeneric() throws Exception
+ {
+ MetaType actual = resolve(TestGeneric.class);
+ getLog().debug("Generic MetaType: " + " className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription());
+ GenericMetaType expected = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName());
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test the meta type is generated correctly for a generic composite
+ *
+ * @throws Exception for any problem
+ */
+ public void testGenericComposite() throws Exception
+ {
+ MetaType actual = resolve(TestGenericComposite.class);
+ printComposite("GenericComposite MetaType: ", assertInstanceOf(actual, CompositeMetaType.class));
+ MutableCompositeMetaType expected = new MutableCompositeMetaType(TestGenericComposite.class.getName(), TestGenericComposite.class.getName());
+ GenericMetaType generic = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName());
+ expected.addItem("generic", "generic", generic);
+ expected.freeze();
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test the meta type is generated correctly for a builder
+ *
+ * @throws Exception for any problem
+ */
+ public void testBuilder() throws Exception
+ {
+ TestOverrideCompositeBuilder builder = new TestOverrideCompositeBuilder();
+ setBuilder(TestOverrideComposite.class, builder);
+ try
+ {
+ MetaType expected = builder.buildMetaType();
+ MetaType actual = resolve(TestOverrideComposite.class);
+ getLog().debug("Builder: " + actual);
+ assertEquals(expected, actual);
+ }
+ finally
+ {
+ setBuilder(TestOverrideComposite.class, null);
+ }
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/TypesFactoryTestSuite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/TypesFactoryTestSuite.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/factory/test/TypesFactoryTestSuite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.test.metatype.types.factory.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Types Factory Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 55115 $
+ */
+public class TypesFactoryTestSuite extends TestSuite
+{
+ /**
+ * For running the testsuite from the command line
+ *
+ * @param args the command line args
+ */
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ /**
+ * Create the testsuite
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Types Factory Tests");
+
+ suite.addTest(SimpleMetaTypeFactoryUnitTestCase.suite());
+ suite.addTest(SpecialMetaTypeFactoryUnitTestCase.suite());
+ suite.addTest(EnumMetaTypeFactoryUnitTestCase.suite());
+ suite.addTest(ArrayMetaTypeFactoryUnitTestCase.suite());
+ suite.addTest(CollectionMetaTypeFactoryUnitTestCase.suite());
+ suite.addTest(MapMetaTypeFactoryUnitTestCase.suite());
+ suite.addTest(CompositeMetaTypeFactoryUnitTestCase.suite());
+ suite.addTest(AnnotationMetaTypeFactoryUnitTestCase.suite());
+
+ return suite;
+ }
+}
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockCompositeValue.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockCompositeValue.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockCompositeValue.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -38,6 +38,11 @@
/** The serialVersionUID */
private static final long serialVersionUID = 1L;
+ /**
+ * Create a new MockCompositeValue.
+ *
+ * @param metaType the meta type
+ */
public MockCompositeValue(CompositeMetaType metaType)
{
super(metaType);
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockMetaType.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockMetaType.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockMetaType.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -36,6 +36,13 @@
{
private static final long serialVersionUID = -1;
+ /**
+ * Create a new MockMetaType.
+ *
+ * @param className the class name
+ * @param typeName the type name
+ * @param description the description
+ */
public MockMetaType(String className, String typeName, String description)
{
super(className, typeName, description);
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockMetaValue.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockMetaValue.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockMetaValue.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -37,6 +37,11 @@
private MetaType metaType;
+ /**
+ * Create a new MockMetaValue.
+ *
+ * @param metaType the meta type
+ */
public MockMetaValue(MetaType metaType)
{
this.metaType = metaType;
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockSimpleValue.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockSimpleValue.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockSimpleValue.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -38,6 +38,11 @@
/** The serialVersionUID */
private static final long serialVersionUID = 1L;
+ /**
+ * Create a new MockSimpleValue.
+ *
+ * @param metaType the meta type
+ */
public MockSimpleValue(SimpleMetaType<T> metaType)
{
super(metaType);
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockTableValue.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockTableValue.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/support/MockTableValue.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -41,6 +41,11 @@
/** The serialVersionUID */
private static final long serialVersionUID = 1L;
+ /**
+ * Create a new MockTableValue.
+ *
+ * @param metaType the meta type
+ */
public MockTableValue(TableMetaType metaType)
{
super(metaType);
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ArrayMetaTypeUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ArrayMetaTypeUnitTestCase.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ArrayMetaTypeUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -44,16 +44,31 @@
*/
public class ArrayMetaTypeUnitTestCase extends AbstractMetaTypeTest
{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
return suite(ArrayMetaTypeUnitTestCase.class);
}
+ /**
+ * Create a new ArrayMetaTypeUnitTestCase.
+ *
+ * @param name the test name
+ */
public ArrayMetaTypeUnitTestCase(String name)
{
super(name);
}
+ /**
+ * Test the meta type for an array meta type
+ *
+ * @throws Exception for any problem
+ */
public void testArrayTypeMetaType() throws Exception
{
ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);
@@ -63,18 +78,33 @@
assertTrue("Type should be an array", arrayType.isArray());
}
+ /**
+ * Test the the dimension for an array meta type
+ *
+ * @throws Exception for any problem
+ */
public void testGetDimension() throws Exception
{
ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);
assertEquals("Dimension should be 3", 3, arrayType.getDimension());
}
- public void testElementOpenType() throws Exception
+ /**
+ * Test the element type
+ *
+ * @throws Exception for any problem
+ */
+ public void testElementType() throws Exception
{
ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);
assertEquals("Element MetaType should be " + SimpleMetaType.STRING, SimpleMetaType.STRING, arrayType.getElementType());
}
+ /**
+ * Test the isValue for an array meta type
+ *
+ * @throws Exception for any problem
+ */
public void testIsValueSimpleValue() throws Exception
{
SimpleMetaType<String> simpleType = SimpleMetaType.STRING;
@@ -95,6 +125,11 @@
assertFalse("compData1 should not be a value of array type, wrong element type", compArrayType3.isValue(compData1));
}
+ /**
+ * Test the isValue for an array meta type
+ *
+ * @throws Exception for any problem
+ */
public void testIsValueComposite() throws Exception
{
String[] itemNames = new String[] { "name1", "name2" };
@@ -118,6 +153,11 @@
assertFalse("compData1 should not be a value of array type, wrong element type", compArrayType3.isValue(compData1));
}
+ /**
+ * Test the isValue for an array meta type
+ *
+ * @throws Exception for any problem
+ */
public void testIsValueTable() throws Exception
{
String[] itemNames = new String[] { "name1", "name2" };
@@ -142,6 +182,11 @@
assertFalse("tabData1 should not be a value of array type, wrong element type", tabArrayType3.isValue(tabData1));
}
+ /**
+ * Test the equals for an array meta type
+ *
+ * @throws Exception for any problem
+ */
public void testEquals() throws Exception
{
ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);
@@ -164,6 +209,11 @@
assertNotSame("should not be equal, wrong element type", arrayType2, arrayType);
}
+ /**
+ * Test the hashCode for an array meta type
+ *
+ * @throws Exception for any problem
+ */
public void testHashCode() throws Exception
{
ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);
@@ -172,6 +222,11 @@
assertTrue("Wrong hash code generated", myHashCode == arrayType.hashCode());
}
+ /**
+ * Test the toString for an array meta type
+ *
+ * @throws Exception for any problem
+ */
public void testToString() throws Exception
{
ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);
@@ -183,6 +238,11 @@
assertTrue("toString() should contain the element type", toString.indexOf(SimpleMetaType.STRING.toString()) != -1);
}
+ /**
+ * Test the serialization for an array meta type
+ *
+ * @throws Exception for any problem
+ */
public void testSerialization() throws Exception
{
ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING);
@@ -193,6 +253,11 @@
assertEquals(arrayType, result);
}
+ /**
+ * Test the errors for an array meta type
+ *
+ * @throws Exception for any problem
+ */
public void testErrors() throws Exception
{
try
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ImmutableCompositeMetaTypeUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ImmutableCompositeMetaTypeUnitTestCase.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ImmutableCompositeMetaTypeUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -40,16 +40,31 @@
*/
public class ImmutableCompositeMetaTypeUnitTestCase extends AbstractMetaTypeTest
{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
return suite(ImmutableCompositeMetaTypeUnitTestCase.class);
}
+ /**
+ * Create a new ImmutableCompositeMetaTypeUnitTestCase.
+ *
+ * @param name the test name
+ */
public ImmutableCompositeMetaTypeUnitTestCase(String name)
{
super(name);
}
+ /**
+ * Test the metatype for a composite type
+ *
+ * @throws Exception for any problem
+ */
public void testCompositeMetaTypeMetaType() throws Exception
{
CompositeMetaType compositeType = initCompositeMetaType();
@@ -59,16 +74,26 @@
assertTrue("Composite meta type should not be an array", compositeType.isArray() == false);
}
- public void testContainsKey() throws Exception
+ /**
+ * Test the containsItem for a composite type
+ *
+ * @throws Exception for any problem
+ */
+ public void testContainsItem() throws Exception
{
CompositeMetaType compositeType = initCompositeMetaType();
- assertTrue("Composite type should contain key name1", compositeType.containsKey("name1") == true);
- assertTrue("Composite type should contain key name2", compositeType.containsKey("name2") == true);
- assertTrue("Composite type should not contain key nameX", compositeType.containsKey("nameX") == false);
- assertTrue("Composite type should not contain key null", compositeType.containsKey(null) == false);
- assertTrue("Composite type should not contain key <empty>", compositeType.containsKey("") == false);
+ assertTrue("Composite type should contain key name1", compositeType.containsItem("name1") == true);
+ assertTrue("Composite type should contain key name2", compositeType.containsItem("name2") == true);
+ assertTrue("Composite type should not contain key nameX", compositeType.containsItem("nameX") == false);
+ assertTrue("Composite type should not contain key null", compositeType.containsItem(null) == false);
+ assertTrue("Composite type should not contain key <empty>", compositeType.containsItem("") == false);
}
+ /**
+ * Test the description for a composite type item
+ *
+ * @throws Exception for any problem
+ */
public void testGetDescriptionForItemName() throws Exception
{
CompositeMetaType compositeType = initCompositeMetaType();
@@ -76,6 +101,11 @@
assertEquals("desc2", compositeType.getDescription("name2"));
}
+ /**
+ * Test the type for a composite type item
+ *
+ * @throws Exception for any problem
+ */
public void testGetTypeForItemName() throws Exception
{
CompositeMetaType compositeType = initCompositeMetaType();
@@ -83,6 +113,11 @@
assertEquals(SimpleMetaType.INTEGER, compositeType.getType("name2"));
}
+ /**
+ * Test the key set for a composite type
+ *
+ * @throws Exception for any problem
+ */
public void testKeySet() throws Exception
{
CompositeMetaType compositeType = initCompositeMetaType();
@@ -92,11 +127,21 @@
assertTrue("Should contain name2", keys.contains("name2"));
}
+ /**
+ * Test the isValue for a composite type
+ *
+ * @throws Exception for any problem
+ */
public void testIsValue() throws Exception
{
// TODO testIsValue
}
+ /**
+ * Test the equals for a composite type
+ *
+ * @throws Exception for any problem
+ */
public void testEquals() throws Exception
{
CompositeMetaType compositeType = initCompositeMetaType();;
@@ -129,6 +174,11 @@
compositeType2.equals(compositeType) == false);
}
+ /**
+ * Test the hashCode for a composite type
+ *
+ * @throws Exception for any problem
+ */
public void testHashCode() throws Exception
{
CompositeMetaType compositeType = initCompositeMetaType();
@@ -141,6 +191,11 @@
assertTrue("Wrong hash code generated", myHashCode == compositeType.hashCode());
}
+ /**
+ * Test the toString for a composite type
+ *
+ * @throws Exception for any problem
+ */
public void testToString() throws Exception
{
CompositeMetaType compositeType = initCompositeMetaType();
@@ -150,10 +205,15 @@
assertTrue("toString() should contain the composite type class name", toString.indexOf(compositeType.getClass().getSimpleName()) != -1);
assertTrue("toString() should contain the item name name1", toString.indexOf("name1") != -1);
assertTrue("toString() should contain the item name name2", toString.indexOf("name2") != -1);
- assertTrue("toString() should contain " + SimpleMetaType.STRING, toString.indexOf(SimpleMetaType.STRING.toString()) != -1);
- assertTrue("toString() should contain " + SimpleMetaType.INTEGER, toString.indexOf(SimpleMetaType.INTEGER.toString()) != -1);
+ assertTrue("toString() should contain " + SimpleMetaType.STRING.getTypeName(), toString.indexOf(SimpleMetaType.STRING.getTypeName()) != -1);
+ assertTrue("toString() should contain " + SimpleMetaType.INTEGER.getTypeName(), toString.indexOf(SimpleMetaType.INTEGER.getTypeName()) != -1);
}
+ /**
+ * Test the serialization for a composite type
+ *
+ * @throws Exception for any problem
+ */
public void testSerialization() throws Exception
{
CompositeMetaType compositeType = initCompositeMetaType();
@@ -162,6 +222,11 @@
assertEquals(compositeType, result);
}
+ /**
+ * Test the errors for a composite type
+ *
+ * @throws Exception for any problem
+ */
public void testErrors() throws Exception
{
String[] itemNames = new String[] { "name1", "name2" };
@@ -327,6 +392,11 @@
}
}
+ /**
+ * Initialise a test composite metatype
+ *
+ * @return the meta type
+ */
protected CompositeMetaType initCompositeMetaType()
{
String[] itemNames = new String[] { "name1", "name2" };
@@ -336,6 +406,11 @@
return compositeType;
}
+ /**
+ * Initialise a test composite metatype with different item types
+ *
+ * @return the meta type
+ */
protected CompositeMetaType initCompositeMetaTypeDifferentItemTypes()
{
String[] itemNames = new String[] { "name1", "name2" };
@@ -345,6 +420,11 @@
return compositeType;
}
+ /**
+ * Initialise a test composite metatype with a different type name
+ *
+ * @return the meta type
+ */
protected CompositeMetaType initCompositeMetaTypeDifferentTypeName()
{
String[] itemNames = new String[] { "name1", "name2" };
@@ -354,6 +434,11 @@
return compositeType;
}
+ /**
+ * Initialise a test composite metatype with different item names
+ *
+ * @return the meta type
+ */
protected CompositeMetaType initCompositeMetaTypeDifferentItemNames()
{
String[] itemNames = new String[] { "nameX", "name2" };
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ImmutableTableMetaTypeUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ImmutableTableMetaTypeUnitTestCase.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/ImmutableTableMetaTypeUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -43,16 +43,31 @@
*/
public class ImmutableTableMetaTypeUnitTestCase extends AbstractMetaTypeTest
{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
return suite(ImmutableTableMetaTypeUnitTestCase.class);
}
+ /**
+ * Create a new ImmutableTableMetaTypeUnitTestCase.
+ *
+ * @param name the test name
+ */
public ImmutableTableMetaTypeUnitTestCase(String name)
{
super(name);
}
+ /**
+ * Test the metatype for a table type
+ *
+ * @throws Exception for any problem
+ */
public void testTableMetaType() throws Exception
{
TableMetaType tableType = initTableMetaType();
@@ -63,6 +78,11 @@
assertTrue("Tabular type should not be an array", tableType.isArray() == false);
}
+ /**
+ * Test the getRow for a table type
+ *
+ * @throws Exception for any problem
+ */
public void testGetRowType() throws Exception
{
CompositeMetaType rowType = initRowType();
@@ -71,6 +91,11 @@
assertEquals(rowType, tableType.getRowType());
}
+ /**
+ * Test the getIndexNames for a table type
+ *
+ * @throws Exception for any problem
+ */
public void testIndexNames() throws Exception
{
TableMetaType tableType = initTableMetaType();
@@ -84,11 +109,21 @@
assertTrue("second index is name2", i.next().equals("name2"));
}
+ /**
+ * Test the isValue for a table type
+ *
+ * @throws Exception for any problem
+ */
public void testIsValue() throws Exception
{
// TODO testIsValue
}
+ /**
+ * Test the equals for a table type
+ *
+ * @throws Exception for any problem
+ */
public void testEquals() throws Exception
{
TableMetaType tableType = initTableMetaType();
@@ -113,6 +148,11 @@
assertNotSame("should not be equal, they have different index names", tableType2, tableType);
}
+ /**
+ * Test the hashCdoe for a table type
+ *
+ * @throws Exception for any problem
+ */
public void testHashCode() throws Exception
{
CompositeMetaType rowType = initRowType();
@@ -122,6 +162,11 @@
assertTrue("Wrong hash code generated", myHashCode == tableType.hashCode());
}
+ /**
+ * Test the toString for a table type
+ *
+ * @throws Exception for any problem
+ */
public void testToString() throws Exception
{
CompositeMetaType rowType = initRowType();
@@ -136,6 +181,11 @@
assertTrue("toString() should contain the index name2", toString.indexOf("name2") != -1);
}
+ /**
+ * Test the serialization for a table type
+ *
+ * @throws Exception for any problem
+ */
public void testSerialization() throws Exception
{
TableMetaType tableType = initTableMetaType();
@@ -144,6 +194,11 @@
assertEquals(tableType, result);
}
+ /**
+ * Test the errors for a table type
+ *
+ * @throws Exception for any problem
+ */
public void testErrors() throws Exception
{
CompositeMetaType rowType = initRowType();
@@ -249,6 +304,12 @@
}
}
+ /**
+ * Initialise a test row type
+ *
+ * @return the test row type
+ * @throws Exception for any problem
+ */
protected CompositeMetaType initRowType() throws Exception
{
String[] itemNames = new String[] { "name1", "name2" };
@@ -258,6 +319,12 @@
return rowType;
}
+ /**
+ * Initialise a test table type
+ *
+ * @return the type
+ * @throws Exception for any problem
+ */
protected TableMetaType initTableMetaType() throws Exception
{
CompositeMetaType rowType = initRowType();
@@ -267,6 +334,12 @@
return tableType;
}
+ /**
+ * Initialise a test table type with a different type name
+ *
+ * @return the type
+ * @throws Exception for any problem
+ */
protected TableMetaType initTableMetaTypeDifferentTypeName() throws Exception
{
CompositeMetaType rowType = initRowType();
@@ -276,6 +349,12 @@
return tableType;
}
+ /**
+ * Initialise a test row type 2
+ *
+ * @return the type
+ * @throws Exception for any problem
+ */
protected CompositeMetaType initRowType2() throws Exception
{
String[] itemNames = new String[] { "name1", "name2" };
@@ -285,6 +364,12 @@
return rowType;
}
+ /**
+ * Initialise a test table type with different row types
+ *
+ * @return the type
+ * @throws Exception for any problem
+ */
protected TableMetaType initTableMetaTypeDifferentRowTypes() throws Exception
{
CompositeMetaType rowType = initRowType2();
@@ -294,6 +379,12 @@
return tableType;
}
+ /**
+ * Initialise a test table type with different index names
+ *
+ * @return the type
+ * @throws Exception for any problem
+ */
protected TableMetaType initTableMetaTypeDifferentIndexNames() throws Exception
{
CompositeMetaType rowType = initRowType();
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -23,14 +23,16 @@
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.Arrays;
import java.util.Date;
import java.util.List;
import junit.framework.Test;
import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.ArrayValue;
import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.GenericValue;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.TableValue;
import org.jboss.test.metatype.AbstractMetaTypeTest;
@@ -44,39 +46,61 @@
*/
public class MetaTypeUnitTestCase extends AbstractMetaTypeTest
{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
return suite(MetaTypeUnitTestCase.class);
}
+ /**
+ * Create a new MetaTypeUnitTestCase.
+ *
+ * @param name the test name
+ */
public MetaTypeUnitTestCase(String name)
{
super(name);
}
+ /**
+ * Test the allowed classes
+ *
+ * @throws Exception for any problem
+ */
public void testAllowedClasses() throws Exception
{
- String[] allowedClassNames = MetaType.ALLOWED_CLASSNAMES;
- assertEquals(16, allowedClassNames.length);
- List<String> names = Arrays.asList(allowedClassNames);
- checkMetaType(names, Void.class);
- checkMetaType(names, Boolean.class);
- checkMetaType(names, Character.class);
- checkMetaType(names, Byte.class);
- checkMetaType(names, Short.class);
- checkMetaType(names, Integer.class);
- checkMetaType(names, Long.class);
- checkMetaType(names, Float.class);
- checkMetaType(names, Double.class);
- checkMetaType(names, String.class);
- checkMetaType(names, Date.class);
- checkMetaType(names, BigDecimal.class);
- checkMetaType(names, BigInteger.class);
- checkMetaType(names, SimpleValue.class);
- checkMetaType(names, CompositeValue.class);
- checkMetaType(names, TableValue.class);
+ List<String> allowedClassNames = MetaType.ALLOWED_CLASSNAMES;
+ assertEquals(19, allowedClassNames.size());
+ checkMetaType(allowedClassNames, Void.class);
+ checkMetaType(allowedClassNames, Boolean.class);
+ checkMetaType(allowedClassNames, Character.class);
+ checkMetaType(allowedClassNames, Byte.class);
+ checkMetaType(allowedClassNames, Short.class);
+ checkMetaType(allowedClassNames, Integer.class);
+ checkMetaType(allowedClassNames, Long.class);
+ checkMetaType(allowedClassNames, Float.class);
+ checkMetaType(allowedClassNames, Double.class);
+ checkMetaType(allowedClassNames, String.class);
+ checkMetaType(allowedClassNames, Date.class);
+ checkMetaType(allowedClassNames, BigDecimal.class);
+ checkMetaType(allowedClassNames, BigInteger.class);
+ checkMetaType(allowedClassNames, SimpleValue.class);
+ checkMetaType(allowedClassNames, EnumValue.class);
+ checkMetaType(allowedClassNames, GenericValue.class);
+ checkMetaType(allowedClassNames, ArrayValue.class);
+ checkMetaType(allowedClassNames, CompositeValue.class);
+ checkMetaType(allowedClassNames, TableValue.class);
}
+ /**
+ * Test the simple constructor
+ *
+ * @throws Exception for any problem
+ */
public void testConstructorSimple() throws Exception
{
MetaType test = new MockMetaType("java.lang.Void", "type", "description");
@@ -86,6 +110,11 @@
assertEquals(false, test.isArray());
}
+ /**
+ * Test the array constructor
+ *
+ * @throws Exception for any problem
+ */
public void testConstructorArray() throws Exception
{
MetaType test = new MockMetaType("[[Ljava.lang.Void;", "type", "description");
@@ -95,16 +124,31 @@
assertEquals(true, test.isArray());
}
+ /**
+ * Test the simple serialization
+ *
+ * @throws Exception for any problem
+ */
public void testSerializationSimple() throws Exception
{
testSerialization("java.lang.Void", "type", "description");
}
+ /**
+ * Test the array serialization
+ *
+ * @throws Exception for any problem
+ */
public void testSerializationArray() throws Exception
{
testSerialization("[[Ljava.lang.Void;", "type", "description");
}
+ /**
+ * Test the errors
+ *
+ * @throws Exception for any problem
+ */
public void testErrors() throws Exception
{
try
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -40,11 +40,21 @@
*/
public class SimpleMetaTypeUnitTestCase extends AbstractMetaTypeTest
{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
return suite(SimpleMetaTypeUnitTestCase.class);
}
+ /**
+ * Create a new SimpleMetaTypeUnitTestCase.
+ *
+ * @param name the test name
+ */
public SimpleMetaTypeUnitTestCase(String name)
{
super(name);
@@ -120,6 +130,11 @@
new SimpleValueSupport(SimpleMetaType.VOID, null)
};
+ /**
+ * Test the simple types
+ *
+ * @throws Exception for any problem
+ */
public void testSimpleTypes() throws Exception
{
for (int i = 0; i < types.length; i++)
@@ -132,6 +147,11 @@
}
}
+ /**
+ * Test the equals
+ *
+ * @throws Exception for any problem
+ */
public void testEquals() throws Exception
{
for (int i = 0; i < types.length; i++)
@@ -153,6 +173,11 @@
}
}
+ /**
+ * Test the isValue
+ *
+ * @throws Exception for any problem
+ */
public void testIsValue() throws Exception
{
for (int i = 0; i < types.length; ++i)
@@ -185,6 +210,11 @@
}
}
+ /**
+ * Test the hashCode
+ *
+ * @throws Exception for any problem
+ */
public void testHashCode() throws Exception
{
for (int i = 0; i < types.length; i++)
@@ -196,6 +226,11 @@
}
}
+ /**
+ * Test the toString
+ *
+ * @throws Exception for any problem
+ */
public void testToString() throws Exception
{
String smt = SimpleMetaType.class.getSimpleName();
@@ -209,6 +244,11 @@
}
}
+ /**
+ * Test the serialization
+ *
+ * @throws Exception for any problem
+ */
public void testSerialization() throws Exception
{
for (int i = 0; i < types.length; i++)
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/TypesTestSuite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/TypesTestSuite.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/types/test/TypesTestSuite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -33,11 +33,21 @@
*/
public class TypesTestSuite extends TestSuite
{
+ /**
+ * For running the testsuite from the command line
+ *
+ * @param args the command line args
+ */
public static void main(String[] args)
{
TestRunner.run(suite());
}
+ /**
+ * Create the testsuite
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
TestSuite suite = new TestSuite("Types Tests");
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestAnnotation.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestAnnotation.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestAnnotation.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,42 @@
+/*
+* 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.test.metatype.values.factory.support;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * TestAnnotation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface TestAnnotation
+{
+ /**
+ * The something
+ *
+ * @return the something
+ */
+ String something() default "";
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestEnum.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestEnum.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestEnum.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,38 @@
+/*
+* 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.test.metatype.values.factory.support;
+
+/**
+ * TestEnum.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public enum TestEnum
+{
+ /** ONE */
+ ONE,
+ /** TWO */
+ TWO,
+ /** THREE */
+ THREE
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestGeneric.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestGeneric.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestGeneric.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,90 @@
+/*
+* 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.test.metatype.values.factory.support;
+
+import java.io.Serializable;
+
+import org.jboss.metatype.api.annotations.Generic;
+
+/**
+ * TestGeneric.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Generic
+public class TestGeneric implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+ /** The id */
+ String id;
+
+ /**
+ * Create a new TestGeneric.
+ *
+ * @param id the id
+ */
+ public TestGeneric(String id)
+ {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+ if (obj == null || obj instanceof TestGeneric == false)
+ return false;
+
+ TestGeneric other = (TestGeneric) obj;
+ return id.equals(other.id);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return id.hashCode();
+ }
+
+ /**
+ * Get the id.
+ *
+ * @return the id.
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Set the id.
+ *
+ * @param id the id.
+ */
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestGenericComposite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestGenericComposite.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestGenericComposite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,53 @@
+/*
+* 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.test.metatype.values.factory.support;
+
+/**
+ * TestGenericComposite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestGenericComposite
+{
+ private TestGeneric generic;
+
+ /**
+ * Get the generic.
+ *
+ * @return the generic.
+ */
+ public TestGeneric getGeneric()
+ {
+ return generic;
+ }
+
+ /**
+ * Set the generic.
+ *
+ * @param generic the generic.
+ */
+ public void setGeneric(TestGeneric generic)
+ {
+ this.generic = generic;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestOverrideComposite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestOverrideComposite.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestOverrideComposite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,63 @@
+/*
+* 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.test.metatype.values.factory.support;
+
+/**
+ * TestOverrideComposite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestOverrideComposite
+{
+ private String something;
+
+ /**
+ * Create a new TestOverrideComposite.
+ *
+ * @param something the something
+ */
+ public TestOverrideComposite(String something)
+ {
+ this.something = something;
+ }
+
+ /**
+ * Get the something.
+ *
+ * @return the something.
+ */
+ public String getSomething()
+ {
+ return something;
+ }
+
+ /**
+ * Set the something.
+ *
+ * @param something the something.
+ */
+ public void setSomething(String something)
+ {
+ this.something = something;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestOverrideCompositeBuilder.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestOverrideCompositeBuilder.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestOverrideCompositeBuilder.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,57 @@
+/*
+* 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.test.metatype.values.factory.support;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.metatype.spi.types.MetaTypeBuilder;
+import org.jboss.metatype.spi.values.MetaValueBuilder;
+
+/**
+ * TestOverrideCompositeBuilder.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestOverrideCompositeBuilder implements MetaTypeBuilder, MetaValueBuilder<TestOverrideComposite>
+{
+ public MetaType buildMetaType()
+ {
+ MutableCompositeMetaType result = new MutableCompositeMetaType(TestOverrideComposite.class.getName(), TestOverrideComposite.class.getName());
+ result.addItem("somethingElse", "somethingElse", SimpleMetaType.STRING);
+ result.freeze();
+ return result;
+ }
+
+ public MetaValue buildMetaValue(MetaType metaType, TestOverrideComposite object)
+ {
+ CompositeMetaType compositeType = (CompositeMetaType) metaType;
+ CompositeValueSupport result = new CompositeValueSupport(compositeType);
+ result.set("somethingElse", SimpleValueSupport.wrap(object.getSomething()));
+ return result;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestRecursiveComposite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestRecursiveComposite.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestRecursiveComposite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,88 @@
+/*
+* 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.test.metatype.values.factory.support;
+
+import org.jboss.metatype.api.annotations.CompositeKey;
+
+/**
+ * TestRecursiveComposite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestRecursiveComposite
+{
+ private String id;
+
+ private TestRecursiveComposite other;
+
+ /**
+ * Create a new TestRecursiveComposite.
+ *
+ * @param id
+ */
+ public TestRecursiveComposite(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * Get the id.
+ *
+ * @return the id.
+ */
+ @CompositeKey
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Set the id.
+ *
+ * @param id the id.
+ */
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * Get the other.
+ *
+ * @return the other.
+ */
+ public TestRecursiveComposite getOther()
+ {
+ return other;
+ }
+
+ /**
+ * Set the other.
+ *
+ * @param other the other.
+ */
+ public void setOther(TestRecursiveComposite other)
+ {
+ this.other = other;
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestSimpleComposite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestSimpleComposite.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/support/TestSimpleComposite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,79 @@
+/*
+* 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.test.metatype.values.factory.support;
+
+/**
+ * TestSimpleComposite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestSimpleComposite
+{
+ private String something;
+
+ /**
+ * Create a new TestSimpleComposite.
+ *
+ * @param something the something
+ */
+ public TestSimpleComposite(String something)
+ {
+ this.something = something;
+ }
+
+ /**
+ * Get the something.
+ *
+ * @return the something.
+ */
+ public String getSomething()
+ {
+ return something;
+ }
+
+ /**
+ * Set the something.
+ *
+ * @param something the something.
+ */
+ public void setSomething(String something)
+ {
+ this.something = something;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+ if (obj == null || obj instanceof TestSimpleComposite == false)
+ return false;
+
+ TestSimpleComposite other = (TestSimpleComposite) obj;
+ return something.equals(other.something);
+ }
+
+ public int hashCode()
+ {
+ return something.hashCode();
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/AbstractMetaValueFactoryTest.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/AbstractMetaValueFactoryTest.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/AbstractMetaValueFactoryTest.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,103 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.values.factory.test;
+
+import java.lang.reflect.Type;
+
+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.metatype.spi.types.MetaTypeBuilder;
+import org.jboss.metatype.spi.values.MetaValueBuilder;
+import org.jboss.test.metatype.AbstractMetaTypeTest;
+
+/**
+ * AbstractMetaValueFactoryTest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractMetaValueFactoryTest extends AbstractMetaTypeTest
+{
+ /** The metatype factory */
+ private static final MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+
+ /** The meta value factory */
+ private static final MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+
+ /**
+ * Create a new AbstractMetaValueFactoryTest.
+ *
+ * @param name the test name
+ */
+ public AbstractMetaValueFactoryTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Set a builder
+ *
+ * @param clazz the clazz
+ * @param builder the builder
+ */
+ protected void setBuilder(Class clazz, MetaValueBuilder builder)
+ {
+ metaTypeFactory.setBuilder(clazz, (MetaTypeBuilder) builder);
+ metaValueFactory.setBuilder(clazz, builder);
+ }
+
+ /**
+ * Resolve a meta type
+ *
+ * @param type the type
+ * @return the meta type
+ */
+ protected MetaType resolve(Type type)
+ {
+ return metaTypeFactory.resolve(type);
+ }
+
+ /**
+ * Create a meta value
+ *
+ * @param value the value
+ * @return the meta value
+ */
+ protected MetaValue createMetaValue(Object value)
+ {
+ return metaValueFactory.create(value);
+ }
+
+ /**
+ * Create a meta value
+ *
+ * @param value the value
+ * @param type the type
+ * @return the meta value
+ */
+ protected MetaValue createMetaValue(Object value, Type type)
+ {
+ return metaValueFactory.create(value, type);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/AnnotationValueFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/AnnotationValueFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/AnnotationValueFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,83 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.values.factory.test;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.test.metatype.values.factory.support.TestAnnotation;
+
+/**
+ * AnnotationValueFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at TestAnnotation(something="Hello")
+public class AnnotationValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(AnnotationValueFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new AnnotationValueFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public AnnotationValueFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the correct value is generated for a simple annotation
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleAnnotation() throws Exception
+ {
+ MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestAnnotation.class.getName(), TestAnnotation.class.getName());
+ compositeType.addItem("something", "something", SimpleMetaType.STRING);
+ compositeType.freeze();
+
+ String[] compositeNames = { "something" };
+ CompositeValue expected = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") });
+
+ TestAnnotation annotation = getClass().getAnnotation(TestAnnotation.class);
+ MetaValue result = createMetaValue(annotation);
+ CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
+ getLog().debug("Annotation Value: " + actual);
+ assertEquals(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ArrayValueFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ArrayValueFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ArrayValueFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,125 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.values.factory.test;
+
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.values.ArrayValue;
+import org.jboss.metatype.api.values.ArrayValueSupport;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.test.metatype.values.factory.support.TestSimpleComposite;
+
+import junit.framework.Test;
+
+/**
+ * ArrayValueFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ArrayValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(ArrayValueFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new ArrayValueFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public ArrayValueFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the correct value is generated for a simple array
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleArray() throws Exception
+ {
+ String[] array = { "Hello", "Goodbye" };
+ ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class);
+ MetaValue[] metaArray = { SimpleValueSupport.wrap("Hello"), SimpleValueSupport.wrap("Goodbye") };
+ ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
+
+ MetaValue result = createMetaValue(array);
+ ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
+ getLog().debug("Array Value: " + actual);
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test the correct value is generated for a composite array
+ *
+ * @throws Exception for any problem
+ */
+ public void testCompositeArray() throws Exception
+ {
+ TestSimpleComposite hello = new TestSimpleComposite("Hello");
+ TestSimpleComposite goodbye = new TestSimpleComposite("Goodbye");
+ TestSimpleComposite[] array = { hello, goodbye };
+ ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class);
+ CompositeMetaType compositeType = assertInstanceOf(resolve(TestSimpleComposite.class), CompositeMetaType.class);
+ String[] itemNames = { "something" };
+ MetaValue[] itemValues = { SimpleValueSupport.wrap("Hello") };
+ CompositeValue helloValue = new CompositeValueSupport(compositeType, itemNames, itemValues);
+ itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye") };
+ CompositeValue goodbyeValue = new CompositeValueSupport(compositeType, itemNames, itemValues);
+ MetaValue[] metaArray = { helloValue, goodbyeValue };
+ ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
+
+ MetaValue result = createMetaValue(array);
+ ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
+ getLog().debug("Array Value: " + actual);
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test the correct value is generated for a mutlidimensional array
+ *
+ * @throws Exception for any problem
+ */
+ public void testMultipleArray() throws Exception
+ {
+ String[][] array = { { "Hello" }, { "Goodbye" } };
+ ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class);
+ Object[][] metaArray = { { SimpleValueSupport.wrap("Hello") }, { SimpleValueSupport.wrap("Goodbye") } };
+ ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
+
+ MetaValue result = createMetaValue(array);
+ ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
+ getLog().debug("Array Value: " + actual);
+ assertEquals(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CollectionValueFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CollectionValueFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CollectionValueFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,259 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.values.factory.test;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.values.ArrayValue;
+import org.jboss.metatype.api.values.ArrayValueSupport;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.test.metatype.values.factory.support.TestSimpleComposite;
+
+import junit.framework.Test;
+
+/**
+ * CollectionValueFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class CollectionValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(CollectionValueFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new CollectionValueFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public CollectionValueFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Create a test simple collection
+ *
+ * @return the test value
+ */
+ public Collection<String> simpleCollection()
+ {
+ Collection<String> result = new ArrayList<String>();
+ result.add("Hello");
+ result.add("Goodbye");
+ return result;
+ }
+
+ /**
+ * Create a test composite collection
+ *
+ * @return the test value
+ */
+ public Collection<TestSimpleComposite> compositeCollection()
+ {
+ Collection<TestSimpleComposite> result = new ArrayList<TestSimpleComposite>();
+ result.add(new TestSimpleComposite("Hello"));
+ result.add(new TestSimpleComposite("Goodbye"));
+ return result;
+ }
+
+ /**
+ * Create a test simple list
+ *
+ * @return the test value
+ */
+ public List<String> simpleList()
+ {
+ List<String> result = new ArrayList<String>();
+ result.add("Hello");
+ result.add("Goodbye");
+ return result;
+ }
+
+ /**
+ * Create a test composite list
+ *
+ * @return the test value
+ */
+ public List<TestSimpleComposite> compositeList()
+ {
+ List<TestSimpleComposite> result = new ArrayList<TestSimpleComposite>();
+ result.add(new TestSimpleComposite("Hello"));
+ result.add(new TestSimpleComposite("Goodbye"));
+ return result;
+ }
+
+ /**
+ * Create a test simple set
+ *
+ * @return the test value
+ */
+ public Set<String> simpleSet()
+ {
+ Set<String> result = new LinkedHashSet<String>();
+ result.add("Hello");
+ result.add("Goodbye");
+ return result;
+ }
+
+ /**
+ * Create a test composite set
+ *
+ * @return the test value
+ */
+ public Set<TestSimpleComposite> compositeSet()
+ {
+ Set<TestSimpleComposite> result = new LinkedHashSet<TestSimpleComposite>();
+ result.add(new TestSimpleComposite("Hello"));
+ result.add(new TestSimpleComposite("Goodbye"));
+ return result;
+ }
+
+ /**
+ * Test the correct value is generated for a simple collection
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleCollection() throws Exception
+ {
+ testSimple("simpleCollection", simpleCollection());
+ }
+
+ /**
+ * Test the correct value is generated for a composite collection
+ *
+ * @throws Exception for any problem
+ */
+ public void testCompositeCollection() throws Exception
+ {
+ testComposite("compositeCollection", compositeCollection());
+ }
+
+ /**
+ * Test the correct value is generated for a simple list
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleList() throws Exception
+ {
+ testSimple("simpleList", simpleList());
+ }
+
+ /**
+ * Test the correct value is generated for a composite list
+ *
+ * @throws Exception for any problem
+ */
+ public void testCompositeList() throws Exception
+ {
+ testComposite("compositeList", compositeList());
+ }
+
+ /**
+ * Test the correct value is generated for a simple set
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleSet() throws Exception
+ {
+ testSimple("simpleSet", simpleSet());
+ }
+
+ /**
+ * Test the correct value is generated for a composite set
+ *
+ * @throws Exception for any problem
+ */
+ public void testCompositeSet() throws Exception
+ {
+ testComposite("compositeSet", compositeSet());
+ }
+
+ /**
+ * Test a simple collection
+ *
+ * @param methodName that gives the collection
+ * @param collection the collection value
+ * @throws Exception for any problem
+ */
+ public void testSimple(String methodName, Collection<String> collection) throws Exception
+ {
+ Method method = getClass().getMethod(methodName, null);
+ Type type = method.getGenericReturnType();
+
+ ArrayMetaType arrayType = assertInstanceOf(resolve(type), ArrayMetaType.class);
+ MetaValue[] metaArray = { SimpleValueSupport.wrap("Hello"), SimpleValueSupport.wrap("Goodbye") };
+ ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
+
+ MetaValue result = createMetaValue(collection, type);
+ ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
+ getLog().debug("Collection Value: " + actual);
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test a composite collection
+ *
+ * @param methodName that gives the collection
+ * @param collection the collection value
+ * @throws Exception for any problem
+ */
+ public void testComposite(String methodName, Collection<TestSimpleComposite> collection) throws Exception
+ {
+ Method method = getClass().getMethod(methodName, null);
+ Type type = method.getGenericReturnType();
+
+ ArrayMetaType arrayType = assertInstanceOf(resolve(type), ArrayMetaType.class);
+ CompositeMetaType compositeType = assertInstanceOf(resolve(TestSimpleComposite.class), CompositeMetaType.class);
+ String[] itemNames = { "something" };
+ MetaValue[] itemValues = { SimpleValueSupport.wrap("Hello") };
+ CompositeValue helloValue = new CompositeValueSupport(compositeType, itemNames, itemValues);
+ itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye") };
+ CompositeValue goodbyeValue = new CompositeValueSupport(compositeType, itemNames, itemValues);
+ MetaValue[] metaArray = { helloValue, goodbyeValue };
+ ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
+
+ MetaValue result = createMetaValue(collection, type);
+ ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
+ getLog().debug("Collection Value: " + actual);
+ assertEquals(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CompositeValueFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CompositeValueFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/CompositeValueFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,111 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.values.factory.test;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.test.metatype.values.factory.support.TestRecursiveComposite;
+import org.jboss.test.metatype.values.factory.support.TestSimpleComposite;
+
+import junit.framework.Test;
+
+/**
+ * CompositeValueFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class CompositeValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(CompositeValueFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new CompositeValueFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public CompositeValueFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the correct value is generated for a simple composite
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleComposite() throws Exception
+ {
+ MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName());
+ compositeType.addItem("something", "something", SimpleMetaType.STRING);
+ compositeType.freeze();
+
+ String[] compositeNames = { "something" };
+ CompositeValue expected = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") });
+
+ MetaValue result = createMetaValue(new TestSimpleComposite("Hello"));
+ CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
+ getLog().debug("Composite Value: " + actual);
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test the correct value is generated for a recursive composite
+ *
+ * @throws Exception for any problem
+ */
+ public void testRecursiveComposite() throws Exception
+ {
+ MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestRecursiveComposite.class.getName(), TestRecursiveComposite.class.getName());
+ compositeType.addItem("id", "id", SimpleMetaType.STRING);
+ compositeType.addItem("other", "other", compositeType);
+ Set<String> keys = Collections.singleton("id");
+ compositeType.setKeys(keys);
+ compositeType.freeze();
+
+ CompositeValueSupport expected = new CompositeValueSupport(compositeType);
+ expected.set("id", SimpleValueSupport.wrap("Hello"));
+ expected.set("other", expected);
+
+ TestRecursiveComposite object = new TestRecursiveComposite("Hello");
+ object.setOther(object);
+ MetaValue result = createMetaValue(object);
+ CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
+ getLog().debug("Composite Value: " + actual);
+ assertEquals(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/EnumValueFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/EnumValueFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/EnumValueFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.values.factory.test;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.EnumMetaType;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.EnumValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.test.metatype.values.factory.support.TestEnum;
+
+/**
+ * EnumValueFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class EnumValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(EnumValueFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new EnumValueFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public EnumValueFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the correct value is generate for an enum
+ *
+ * @throws Exception for any problem
+ */
+ public void testEnum() throws Exception
+ {
+ EnumMetaType enumType = assertInstanceOf(resolve(TestEnum.class), EnumMetaType.class);
+ EnumValue expected = new EnumValueSupport(enumType, TestEnum.ONE.name());
+
+ MetaValue result = createMetaValue(TestEnum.ONE);
+ EnumValue actual = assertInstanceOf(result, EnumValue.class);
+
+ getLog().debug("Enum Value: " + actual);
+ assertEquals(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MapValueFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MapValueFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/MapValueFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,231 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.values.factory.test;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableTableMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.types.TableMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.api.values.TableValue;
+import org.jboss.metatype.api.values.TableValueSupport;
+import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.test.metatype.values.factory.support.TestSimpleComposite;
+
+/**
+ * MapValueFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MapValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(MapValueFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new MapValueFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public MapValueFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * The signature and value to test a simple map
+ *
+ * @return the value
+ */
+ public Map<String, Integer> simpleMap()
+ {
+ Map<String, Integer> result = new LinkedHashMap<String, Integer>();
+ result.put("Hello", new Integer(1));
+ result.put("Goodbye", new Integer(2));
+ return result;
+ }
+
+ /**
+ * The signature and value to test a map with a composite key
+ *
+ * @return the value
+ */
+ public Map<TestSimpleComposite, Integer> compositeKeyMap()
+ {
+ Map<TestSimpleComposite, Integer> result = new LinkedHashMap<TestSimpleComposite, Integer>();
+ result.put(new TestSimpleComposite("Hello"), new Integer(1));
+ result.put(new TestSimpleComposite("Goodbye"), new Integer(2));
+ return result;
+ }
+
+ /**
+ * The signature and value to test a map with a composite value
+ *
+ * @return the value
+ */
+ public Map<String, TestSimpleComposite> compositeValueMap()
+ {
+ Map<String, TestSimpleComposite> result = new LinkedHashMap<String, TestSimpleComposite>();
+ result.put("Hello", new TestSimpleComposite("Hello"));
+ result.put("Goodbye", new TestSimpleComposite("Goodbye"));
+ return result;
+ }
+
+ /**
+ * Test a simple map
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleMap() throws Exception
+ {
+ Method method = getClass().getMethod("simpleMap", null);
+ Type collectionType = method.getGenericReturnType();
+ Map<String, Integer> map = simpleMap();
+
+ MetaType keyType = resolve(String.class);
+ MetaType valueType = resolve(Integer.class);
+ MetaType[] itemTypes = { keyType, valueType };
+ String entryName = Map.Entry.class.getName();
+ CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes);
+ TableMetaType tableType = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES);
+
+ TableValue expected = new TableValueSupport(tableType);
+ String[] itemNames = DefaultMetaTypeFactory.MAP_ITEM_NAMES;
+
+ MetaValue[] itemValues = new MetaValue[] { SimpleValueSupport.wrap("Hello"), SimpleValueSupport.wrap(new Integer(1)) };
+ expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));
+
+ itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye"), SimpleValueSupport.wrap(new Integer(2)) };
+ expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));
+
+ MetaValue result = createMetaValue(map, collectionType);
+ TableValue actual = assertInstanceOf(result, TableValue.class);
+
+ getLog().debug("Map Value: " + actual);
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test a composite key map
+ *
+ * @throws Exception for any problem
+ */
+ public void testCompositeKeyMap() throws Exception
+ {
+ Method method = getClass().getMethod("compositeKeyMap", null);
+ Type collectionType = method.getGenericReturnType();
+ Map<TestSimpleComposite, Integer> map = compositeKeyMap();
+
+ MetaType keyType = resolve(TestSimpleComposite.class);
+ MetaType valueType = resolve(Integer.class);
+ MetaType[] itemTypes = { keyType, valueType };
+ String entryName = Map.Entry.class.getName();
+ CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes);
+ TableMetaType tableType = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES);
+
+ TableValue expected = new TableValueSupport(tableType);
+ String[] itemNames = DefaultMetaTypeFactory.MAP_ITEM_NAMES;
+
+ MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName());
+ compositeType.addItem("something", "something", SimpleMetaType.STRING);
+ compositeType.freeze();
+
+ String[] compositeNames = { "something" };
+ CompositeValue compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") });
+
+ MetaValue[] itemValues = new MetaValue[] { compositeValue, SimpleValueSupport.wrap(new Integer(1)) };
+ expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));
+
+ compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Goodbye") });
+ itemValues = new MetaValue[] { compositeValue, SimpleValueSupport.wrap(new Integer(2)) };
+ expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));
+
+ MetaValue result = createMetaValue(map, collectionType);
+ TableValue actual = assertInstanceOf(result, TableValue.class);
+
+ getLog().debug("Map Value: " + actual);
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test a composite value map
+ *
+ * @throws Exception for any problem
+ */
+ public void testCompositeValueMap() throws Exception
+ {
+ Method method = getClass().getMethod("compositeValueMap", null);
+ Type collectionType = method.getGenericReturnType();
+ Map<String, TestSimpleComposite> map = compositeValueMap();
+
+ MetaType keyType = resolve(String.class);
+ MetaType valueType = resolve(TestSimpleComposite.class);
+ MetaType[] itemTypes = { keyType, valueType };
+ String entryName = Map.Entry.class.getName();
+ CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes);
+ TableMetaType tableType = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES);
+
+ TableValue expected = new TableValueSupport(tableType);
+ String[] itemNames = DefaultMetaTypeFactory.MAP_ITEM_NAMES;
+
+ MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName());
+ compositeType.addItem("something", "something", SimpleMetaType.STRING);
+ compositeType.freeze();
+
+ String[] compositeNames = { "something" };
+ CompositeValue compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") });
+
+ MetaValue[] itemValues = new MetaValue[] { SimpleValueSupport.wrap("Hello"), compositeValue };
+ expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));
+
+ compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Goodbye") });
+ itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye"), compositeValue };
+ expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));
+
+ MetaValue result = createMetaValue(map, collectionType);
+ TableValue actual = assertInstanceOf(result, TableValue.class);
+
+ getLog().debug("Map Value: " + actual);
+ assertEquals(expected, actual);
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/SimpleValueFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/SimpleValueFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/SimpleValueFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,126 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.values.factory.test;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+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 junit.framework.Test;
+
+/**
+ * SimpleValueFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(SimpleValueFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new SimpleValueFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public SimpleValueFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ BigDecimal BIG_DECIMAL = new BigDecimal(1);
+ BigInteger BIG_INTEGER = BigInteger.ONE;
+ Boolean BOOLEAN = new Boolean(false);
+ Byte BYTE = Byte.MAX_VALUE;
+ Character CHARACTER = new Character('a');
+ Date DATE = new Date(System.currentTimeMillis());
+ Double DOUBLE = new Double(1);
+ Float FLOAT = new Float(1);
+ Integer INTEGER = new Integer(1);
+ Long LONG = new Long(1);
+ Short SHORT = new Short(Short.MAX_VALUE);
+ String STRING = new String("hello");
+
+ Object[] values = new Object[]
+ {
+ BIG_DECIMAL,
+ BIG_INTEGER,
+ BOOLEAN,
+ BYTE,
+ CHARACTER,
+ DATE,
+ DOUBLE,
+ FLOAT,
+ INTEGER,
+ LONG,
+ SHORT,
+ STRING,
+ };
+
+ @SuppressWarnings("unchecked")
+ SimpleValue[] metaValues = new SimpleValue[]
+ {
+ new SimpleValueSupport<BigDecimal>(SimpleMetaType.BIGDECIMAL, BIG_DECIMAL),
+ new SimpleValueSupport<BigInteger>(SimpleMetaType.BIGINTEGER, BIG_INTEGER),
+ new SimpleValueSupport<Boolean>(SimpleMetaType.BOOLEAN, BOOLEAN),
+ new SimpleValueSupport<Byte>(SimpleMetaType.BYTE, BYTE),
+ new SimpleValueSupport<Character>(SimpleMetaType.CHARACTER, CHARACTER),
+ new SimpleValueSupport<Date>(SimpleMetaType.DATE, DATE),
+ new SimpleValueSupport<Double>(SimpleMetaType.DOUBLE, DOUBLE),
+ new SimpleValueSupport<Float>(SimpleMetaType.FLOAT, FLOAT),
+ new SimpleValueSupport<Integer>(SimpleMetaType.INTEGER, INTEGER),
+ new SimpleValueSupport<Long>(SimpleMetaType.LONG, LONG),
+ new SimpleValueSupport<Short>(SimpleMetaType.SHORT, SHORT),
+ new SimpleValueSupport<String>(SimpleMetaType.STRING, STRING),
+ };
+
+ /**
+ * Test the generated simple values
+ *
+ * @throws Exception for any problem
+ */
+ public void testSimpleValues() throws Exception
+ {
+ for (int i = 0; i < values.length; i++)
+ {
+ Object value = values[i];
+ MetaValue result = createMetaValue(value);
+ SimpleValue actual = assertInstanceOf(result, SimpleValue.class);
+ SimpleValue expected = metaValues[i];
+ getLog().debug("Simple Value: expected=" + expected + " actual=" + actual);
+ assertEquals(expected, actual);
+ }
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/SpecialValueFactoryUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/SpecialValueFactoryUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/SpecialValueFactoryUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,169 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.test.metatype.values.factory.test;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.GenericValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.test.metatype.values.factory.support.TestGeneric;
+import org.jboss.test.metatype.values.factory.support.TestGenericComposite;
+import org.jboss.test.metatype.values.factory.support.TestOverrideComposite;
+import org.jboss.test.metatype.values.factory.support.TestOverrideCompositeBuilder;
+
+/**
+ * SpecialValueFactoryUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SpecialValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(SpecialValueFactoryUnitTestCase.class);
+ }
+
+ /**
+ * Create a new SpecialValueFactoryUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public SpecialValueFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the value generated for a class
+ *
+ * @throws Exception for any problem
+ */
+ public void testClass() throws Exception
+ {
+ CompositeMetaType metaType = assertInstanceOf(resolve(Class.class), CompositeMetaType.class);
+ String[] itemNames = { "name" };
+ MetaValue[] itemValues = { SimpleValueSupport.wrap(Class.class.getName()) };
+ CompositeValue expected = new CompositeValueSupport(metaType, itemNames, itemValues);
+
+ MetaValue result = createMetaValue(Class.class);
+ CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
+ getLog().debug("Class.class: " + actual);
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test the value generated for an object
+ *
+ * @throws Exception for any problem
+ */
+ public void testObject() throws Exception
+ {
+ CompositeMetaType metaType = assertInstanceOf(resolve(Object.class), CompositeMetaType.class);
+ CompositeValue expected = new CompositeValueSupport(metaType, new String[0], new MetaValue[0]);
+
+ MetaValue result = createMetaValue(new Object());
+ CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
+ getLog().debug("new Object(): " + actual);
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test the value generated for a generic
+ *
+ * @throws Exception for any problem
+ */
+ public void testGeneric() throws Exception
+ {
+ TestGeneric test = new TestGeneric("Hello");
+ GenericMetaType generic = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName());
+ GenericValue expected = new GenericValueSupport(generic, test);
+
+ MetaValue result = createMetaValue(test);
+ GenericValue actual = assertInstanceOf(result, GenericValue.class);
+ getLog().debug("Generic: " + actual);
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test the value generated for a generic composite
+ *
+ * @throws Exception for any problem
+ */
+ public void testGenericComposite() throws Exception
+ {
+ TestGeneric test = new TestGeneric("Hello");
+ TestGenericComposite composite = new TestGenericComposite();
+ composite.setGeneric(test);
+ GenericMetaType generic = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName());
+ GenericValue genericValue = new GenericValueSupport(generic, test);
+ MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestGenericComposite.class.getName(), TestGenericComposite.class.getName());
+ compositeType.addItem("generic", "generic", generic);
+ compositeType.freeze();
+ CompositeValueSupport expected = new CompositeValueSupport(compositeType);
+ expected.set("generic", genericValue);
+
+ MetaValue result = createMetaValue(composite);
+ CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
+ getLog().debug("GenericComposite: " + actual);
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * Test the value generated with a builder
+ *
+ * @throws Exception for any problem
+ */
+ public void testBuilder() throws Exception
+ {
+ TestOverrideCompositeBuilder builder = new TestOverrideCompositeBuilder();
+ setBuilder(TestOverrideComposite.class, builder);
+ try
+ {
+ TestOverrideComposite value = new TestOverrideComposite("Hello");
+
+ MetaType metaType = builder.buildMetaType();
+ MetaValue expected = builder.buildMetaValue(metaType, value);
+
+ MetaValue actual = createMetaValue(value);
+ getLog().debug("Builder: " + actual);
+ assertEquals(expected, actual);
+ }
+ finally
+ {
+ setBuilder(TestOverrideComposite.class, null);
+ }
+ }
+}
Added: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ValuesFactoryTestSuite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ValuesFactoryTestSuite.java (rev 0)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/factory/test/ValuesFactoryTestSuite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.test.metatype.values.factory.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Values Factory Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 55115 $
+ */
+public class ValuesFactoryTestSuite extends TestSuite
+{
+ /**
+ * For running the testsuite from the command line
+ *
+ * @param args the command line args
+ */
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ /**
+ * Create the testsuite
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Values Factory Tests");
+
+ suite.addTest(SimpleValueFactoryUnitTestCase.suite());
+ suite.addTest(SpecialValueFactoryUnitTestCase.suite());
+ suite.addTest(EnumValueFactoryUnitTestCase.suite());
+ suite.addTest(ArrayValueFactoryUnitTestCase.suite());
+ suite.addTest(CollectionValueFactoryUnitTestCase.suite());
+ suite.addTest(MapValueFactoryUnitTestCase.suite());
+ suite.addTest(CompositeValueFactoryUnitTestCase.suite());
+ suite.addTest(AnnotationValueFactoryUnitTestCase.suite());
+
+ return suite;
+ }
+}
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/CompositeValueSupportUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/CompositeValueSupportUnitTestCase.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/CompositeValueSupportUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -42,16 +42,31 @@
*/
public class CompositeValueSupportUnitTestCase extends AbstractMetaTypeTest
{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
return suite(CompositeValueSupportUnitTestCase.class);
}
+ /**
+ * Create a new CompositeValueSupportUnitTestCase.
+ *
+ * @param name the test name
+ */
public CompositeValueSupportUnitTestCase(String name)
{
super(name);
}
+ /**
+ * Test the composite value
+ *
+ * @throws Exception for any problem
+ */
public void testCompositeValueSupport() throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
@@ -62,6 +77,11 @@
new CompositeValueSupport(compositeMetaType, keys, values);
}
+ /**
+ * Test the meta type for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testGetCompositeMetaType() throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
@@ -70,6 +90,11 @@
assertEquals(compositeMetaType, v.getMetaType());
}
+ /**
+ * Test the get for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testGet()throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
@@ -80,6 +105,11 @@
assertEquals(initInteger2(), v.get("name2"));
}
+ /**
+ * Test the getAll for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testGetAll() throws Exception
{
SimpleValue<String> value1 = initStringValue1();
@@ -100,6 +130,11 @@
assertEquals(integer2, result[0]);
}
+ /**
+ * Test the containsKey for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testContainsKey() throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
@@ -112,6 +147,11 @@
assertFalse("data should not contain key <empty>", v.containsKey(""));
}
+ /**
+ * Test the containsValue for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testContainsValue() throws Exception
{
SimpleValue<String> value1 = initStringValue1();
@@ -146,6 +186,11 @@
assertFalse("data should not contain key null", v.containsValue(null));
}
+ /**
+ * Test the values for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testValues() throws Exception
{
SimpleValue<String> value1 = initStringValue1();
@@ -184,6 +229,11 @@
assertFalse("data values should not have null", values.contains(null));
}
+ /**
+ * Test the equals for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testEquals() throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
@@ -212,6 +262,11 @@
assertNotSame("data2 should not be equal with data with different value", v2, v);
}
+ /**
+ * Test the hashCode for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testHashCode() throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
@@ -222,6 +277,11 @@
assertEquals("Wrong hash code generated", myHashCode, v.hashCode());
}
+ /**
+ * Test the toString for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testToString() throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
@@ -237,6 +297,11 @@
assertTrue(toString + " should contain " + new Integer(2), toString.indexOf(new Integer(2).toString()) != -1);
}
+ /**
+ * Test the serialization for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testSerialization() throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
@@ -247,6 +312,11 @@
assertEquals(v, result);
}
+ /**
+ * Test the errors for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testErrorsArray() throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
@@ -335,16 +405,6 @@
try
{
- new CompositeValueSupport(compositeMetaType, new String[] { "name1" }, new MetaValue[] { initStringValue1() });
- fail("Excepted IllegalArgumentException for mismatch in number of itemNames for CompositeType/CompositeData");
- }
- catch (Throwable t)
- {
- checkThrowable(IllegalArgumentException.class, t);
- }
-
- try
- {
new CompositeValueSupport(compositeMetaType, new String[] { "name1", "wrongName" }, itemValues);
fail("Excepted IllegalArgumentException for an item name not in the composite type");
}
@@ -367,6 +427,11 @@
new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[] { initStringValue1(), initIntegerNull() });
}
+ /**
+ * Test the errors for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testErrorsMap() throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
@@ -384,26 +449,6 @@
try
{
- new CompositeValueSupport(compositeMetaType, null);
- fail("Excepted IllegalArgumentException for null map");
- }
- catch (Throwable t)
- {
- checkThrowable(IllegalArgumentException.class, t);
- }
-
- try
- {
- new CompositeValueSupport(compositeMetaType, new HashMap<String, MetaValue>());
- fail("Excepted IllegalArgumentException for empty map");
- }
- catch (Throwable t)
- {
- checkThrowable(IllegalArgumentException.class, t);
- }
-
- try
- {
HashMap<String, MetaValue> map2 = new HashMap<String, MetaValue>();
map2.put("name1", initStringValue1());
map2.put(null, initInteger2());
@@ -432,18 +477,6 @@
{
HashMap<String, MetaValue> map2 = new HashMap<String, MetaValue>();
map2.put("name1", initStringValue1());
- new CompositeValueSupport(compositeMetaType, map2);
- fail("Excepted IllegalArgumentException for mismatch in number of items for CompositeType/CompositeData");
- }
- catch (Throwable t)
- {
- checkThrowable(IllegalArgumentException.class, t);
- }
-
- try
- {
- HashMap<String, MetaValue> map2 = new HashMap<String, MetaValue>();
- map2.put("name1", initStringValue1());
map2.put("wrongName", initInteger2());
new CompositeValueSupport(compositeMetaType, map2);
fail("Excepted IllegalArgumentException for an item name not in the composite type");
@@ -477,6 +510,11 @@
new CompositeValueSupport(compositeMetaType, map2);
}
+ /**
+ * Test the errors for a composite value
+ *
+ * @throws Exception for any problem
+ */
public void testErrors() throws Exception
{
CompositeMetaType compositeMetaType = initCompositeMetaType();
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/SimpleValueSupportUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/SimpleValueSupportUnitTestCase.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/SimpleValueSupportUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -36,33 +36,63 @@
*/
public class SimpleValueSupportUnitTestCase extends AbstractMetaTypeTest
{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
return suite(SimpleValueSupportUnitTestCase.class);
}
+ /**
+ * Create a new SimpleValueSupportUnitTestCase.
+ *
+ * @param name the test name
+ */
public SimpleValueSupportUnitTestCase(String name)
{
super(name);
}
+ /**
+ * Test the simple value
+ *
+ * @throws Exception for any problem
+ */
public void testSimpleValueSupport() throws Exception
{
initStringValue1();
}
+ /**
+ * Test the meta type for a simple value
+ *
+ * @throws Exception for any problem
+ */
public void testGetSimpleMetaType() throws Exception
{
SimpleValue<String> value = initStringValue1();
assertEquals(SimpleMetaType.STRING, value.getMetaType());
}
+ /**
+ * Test the getValue for a simple value
+ *
+ * @throws Exception for any problem
+ */
public void testGetValue()throws Exception
{
SimpleValue<String> value = initStringValue1();
assertEquals("value1", value.getValue());
}
+ /**
+ * Test the setValue for a simple value
+ *
+ * @throws Exception for any problem
+ */
public void testSetValue()throws Exception
{
SimpleValueSupport<String> value = (SimpleValueSupport<String>) initStringValue1();
@@ -70,6 +100,11 @@
assertEquals("value2", value.getValue());
}
+ /**
+ * Test the equals for a simple value
+ *
+ * @throws Exception for any problem
+ */
public void testEquals() throws Exception
{
SimpleValue<String> v = initStringValue1();
@@ -96,6 +131,11 @@
assertNotSame("data2 should not be equal with data with different value", v2, v);
}
+ /**
+ * Test the hashCode for a simple value
+ *
+ * @throws Exception for any problem
+ */
public void testHashCode() throws Exception
{
SimpleValue<String> v = initStringValue1();
@@ -104,6 +144,11 @@
assertEquals("Wrong hash code generated", myHashCode, v.hashCode());
}
+ /**
+ * Test the toString for a simple value
+ *
+ * @throws Exception for any problem
+ */
public void testToString() throws Exception
{
SimpleValue<String> v = initStringValue1();
@@ -114,6 +159,11 @@
assertTrue("toString() should contain value1", toString.indexOf("value1") != -1);
}
+ /**
+ * Test the serialization for a simple value
+ *
+ * @throws Exception for any problem
+ */
public void testSerialization() throws Exception
{
SimpleValue<String> v = initStringValue1();
@@ -122,6 +172,11 @@
assertEquals(v, result);
}
+ /**
+ * Test the errors for a simple value
+ *
+ * @throws Exception for any problem
+ */
public void testErrors() throws Exception
{
try
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/TableValueSupportUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/TableValueSupportUnitTestCase.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/TableValueSupportUnitTestCase.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -47,16 +47,31 @@
*/
public class TableValueSupportUnitTestCase extends AbstractMetaTypeTest
{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
return suite(TableValueSupportUnitTestCase.class);
}
+ /**
+ * Create a new TableValueSupportUnitTestCase.
+ *
+ * @param name the test name
+ */
public TableValueSupportUnitTestCase(String name)
{
super(name);
}
+ /**
+ * Test the table value support
+ *
+ * @throws Exception for any problem
+ */
public void testTableValueSupport() throws Exception
{
TableMetaType tableType = initTableType();
@@ -65,7 +80,12 @@
new TableValueSupport(tableType, 100, .5f);
}
- public void testGetTabularType() throws Exception
+ /**
+ * Test the table type for a table value
+ *
+ * @throws Exception for any problem
+ */
+ public void testGetTableType() throws Exception
{
TableMetaType tableType = initTableType();
@@ -73,6 +93,11 @@
assertTrue("Expected the same table type", data.getMetaType().equals(tableType));
}
+ /**
+ * Test the calculate index for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testCalculateIndex() throws Exception
{
TableMetaType tableType = initTableType();
@@ -92,6 +117,11 @@
assertEquals("Expected index element 1 to be 3", index[1], initInteger3());
}
+ /**
+ * Test the contains key for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testContainsKey() throws Exception
{
TableMetaType tableType = initTableType();
@@ -117,6 +147,11 @@
assertFalse("Didn't expect removed data in containsKey", data.containsKey(index));
}
+ /**
+ * Test the contains value for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testContainsValue() throws Exception
{
TableMetaType tableType = initTableType();
@@ -146,6 +181,11 @@
assertFalse("Didn't expect removed data in containsValue", data.containsValue(compData));
}
+ /**
+ * Test the get for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testGet() throws Exception
{
TableMetaType tableType = initTableType();
@@ -168,6 +208,11 @@
assertNull("Didn't expect removed data in get", data.get(index));
}
+ /**
+ * Test the put for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testPut() throws Exception
{
TableMetaType tableType = initTableType();
@@ -192,6 +237,11 @@
assertEquals("Data should be present after remove/put", compData, data.get(index));
}
+ /**
+ * Test the remove for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testRemove() throws Exception
{
TableMetaType tableType = initTableType();
@@ -207,6 +257,11 @@
assertEquals("Remove on data present returns the data", compData, data.remove(index));
}
+ /**
+ * Test the put all for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testPutAll() throws Exception
{
TableMetaType tableType = initTableType();
@@ -234,6 +289,11 @@
assertTrue("Put all original data still present", data.containsValue(compData));
}
+ /**
+ * Test the clear for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testClear() throws Exception
{
TableMetaType tableType = initTableType();
@@ -253,6 +313,11 @@
assertTrue("Clear should clear the data", data.isEmpty());
}
+ /**
+ * Test the size for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testSize() throws Exception
{
TableMetaType tableType = initTableType();
@@ -279,6 +344,11 @@
assertEquals("Expected no elements", 0, data.size());
}
+ /**
+ * Test the isEmpty for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testIsEmpty() throws Exception
{
TableMetaType tableType = initTableType();
@@ -296,6 +366,11 @@
assertTrue("Expected no elements", data.isEmpty());
}
+ /**
+ * Test the keySet for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testKeySet() throws Exception
{
TableMetaType tableType = initTableType();
@@ -315,6 +390,11 @@
assertTrue("Key set should contain index [value1, 4]", keySet.contains(Arrays.asList(initValues4())));
}
+ /**
+ * Test the values for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testValues() throws Exception
{
TableMetaType tableType = initTableType();
@@ -334,8 +414,12 @@
assertTrue("Values should contain index compData3", values.contains(compData3));
}
- public void testClone()
- throws Exception
+ /**
+ * Test the clone for a table value
+ *
+ * @throws Exception for any problem
+ */
+ public void testClone() throws Exception
{
TableMetaType tableType = initTableType();
@@ -354,6 +438,11 @@
assertTrue("Should be a shallow clone", compData == compDataClone);
}
+ /**
+ * Test the equals for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testEquals() throws Exception
{
TableMetaType tableType = initTableType();
@@ -393,6 +482,11 @@
assertNotSame("Instances with different composite values are not equal", data2, data);
}
+ /**
+ * Test the hashCode for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testHashCode() throws Exception
{
TableMetaType tableType = initTableType();
@@ -409,6 +503,11 @@
assertEquals("Wrong hash code generated", myHashCode, data.hashCode());
}
+ /**
+ * Test the toString for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testToString() throws Exception
{
TableMetaType tableType = initTableType();
@@ -432,6 +531,11 @@
toString.indexOf(Arrays.asList(data.calculateIndex(compData3)) + "=" + compData3) != -1);
}
+ /**
+ * Test the serialization for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testSerialization() throws Exception
{
TableMetaType tableType = initTableType();
@@ -449,6 +553,11 @@
assertEquals(data, result);
}
+ /**
+ * Test the errors for a table value
+ *
+ * @throws Exception for any problem
+ */
public void testErrors() throws Exception
{
TableMetaType tableType = initTableType();
@@ -656,6 +765,11 @@
}
}
+ /**
+ * Initialize a test table type
+ *
+ * @return the type
+ */
protected TableMetaType initTableType()
{
CompositeMetaType rowType = initCompositeMetaType();
@@ -665,6 +779,11 @@
return tableType;
}
+ /**
+ * Initialize a test table type 2
+ *
+ * @return the type
+ */
protected TableMetaType initTableType2()
{
CompositeMetaType rowType = initCompositeMetaType();
@@ -674,11 +793,23 @@
return tableType;
}
+ /**
+ * Initialize a test composite value
+ *
+ * @param tableValue the table value
+ * @return the type
+ */
protected CompositeValue initCompositeValue(TableValue tableValue)
{
return initCompositeValue(tableValue.getMetaType().getRowType());
}
+ /**
+ * Initialize a test composite value
+ *
+ * @param rowType the row type
+ * @return the type
+ */
protected CompositeValue initCompositeValue(CompositeMetaType rowType)
{
Map<String, MetaValue> map = initMapValues();
@@ -686,11 +817,23 @@
return compData;
}
+ /**
+ * Initialize a test composite value 2
+ *
+ * @param tableValue the table value
+ * @return the type
+ */
protected CompositeValue initCompositeValue2(TableValue tableValue)
{
return initCompositeValue2(tableValue.getMetaType().getRowType());
}
+ /**
+ * Initialize a test composite value 2
+ *
+ * @param rowType the row type
+ * @return the type
+ */
protected CompositeValue initCompositeValue2(CompositeMetaType rowType)
{
Map<String, MetaValue> map = initMapValues2();
@@ -698,6 +841,12 @@
return compData;
}
+ /**
+ * Initialize a test composite value 3
+ *
+ * @param tableValue the table value
+ * @return the type
+ */
protected CompositeValue initCompositeValue3(TableValue tableValue)
{
Map<String, MetaValue> map = initMapValues3();
@@ -705,6 +854,12 @@
return compData;
}
+ /**
+ * Initialize a test composite value 4
+ *
+ * @param tableValue the table value
+ * @return the type
+ */
protected CompositeValue initCompositeValue4(TableValue tableValue)
{
Map<String, MetaValue> map = initMapValues4();
Modified: projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/ValuesTestSuite.java
===================================================================
--- projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/ValuesTestSuite.java 2007-07-11 03:57:42 UTC (rev 63961)
+++ projects/microcontainer/trunk/metatype/src/tests/org/jboss/test/metatype/values/test/ValuesTestSuite.java 2007-07-11 06:10:14 UTC (rev 63962)
@@ -33,11 +33,21 @@
*/
public class ValuesTestSuite extends TestSuite
{
+ /**
+ * For running the testsuite from the command line
+ *
+ * @param args the command line args
+ */
public static void main(String[] args)
{
TestRunner.run(suite());
}
+ /**
+ * Create the testsuite
+ *
+ * @return the testsuite
+ */
public static Test suite()
{
TestSuite suite = new TestSuite("Values Tests");
More information about the jboss-cvs-commits
mailing list