[jboss-svn-commits] JBoss Common SVN: r2124 - in jbossxb/trunk: . src/main/java/org/jboss/xb/binding src/test/java/org/jboss/test/xml src/test/java/org/jboss/test/xml/any src/test/java/org/jboss/test/xml/book src/test/java/org/jboss/test/xml/choice src/test/java/org/jboss/test/xml/collections src/test/java/org/jboss/test/xml/config src/test/java/org/jboss/test/xml/immutable src/test/java/org/jboss/test/xml/initializer src/test/java/org/jboss/test/xml/jbxb src/test/java/org/jboss/test/xml/jbxb/characters src/test/java/org/jboss/test/xml/jbxb/defaults src/test/java/org/jboss/test/xml/jbxb/minOccurs src/test/java/org/jboss/test/xml/multispaced src/test/java/org/jboss/test/xml/multispaced/pm src/test/java/org/jboss/test/xml/multispaced/pm/jdbc src/test/java/org/jboss/test/xml/person src/test/java/org/jboss/test/xml/po src/test/java/org/jboss/test/xml/pojoserver src/test/java/org/jboss/test/xml/pojoserver/deployment src/test/java/org/jboss/test/xml/pojoserver/metadata src/test/java/org/jbo! ss/test/xml/sandbox src/test/resources src/test/resources/org/jboss/test/xml src/test/resources/xml src/test/resources/xml/aop src/test/resources/xml/book src/test/resources/xml/jbxb src/test/resources/xml/jbxb/characters src/test/resources/xml/jbxb/defaults src/test/resources/xml/jbxb/minOccurs src/test/resources/xml/loginconfig src/test/resources/xml/multispaced src/test/resources/xml/naming src/test/resources/xml/pojoserver src/test/resources/xml/soapenc
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Oct 12 08:05:04 EDT 2006
Author: alex.loubyansky at jboss.com
Date: 2006-10-12 08:03:53 -0400 (Thu, 12 Oct 2006)
New Revision: 2124
Added:
jbossxb/trunk/src/test/java/org/jboss/test/xml/AnnotatedPojoServerUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/AnnotationsUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/AnyUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/ArrayWrapperUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/AttributesUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/BasicArraysUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/BooleanPatternUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/CollectionsUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/Dom2SaxUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/EnumUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/ExceptionUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/IntrospectionUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/JbxbCharactersUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/JbxbPojoServerUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/MappingTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/MapsUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/MinOccurs0UnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/MiscUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/ModelGroupBindingUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/MultispacedUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/NamespaceRegistryUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/PoUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/PojoServerTestBase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/PojoServerUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/QNameAttributesUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaBindingInitializerUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaImportUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaIncludeUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemalessTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/SimpleTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/SimpleTypeBindingUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/SoapEncUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/SundayUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/Validator.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/WildcardUnresolvedElementsUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/WildcardWrapperUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/XMLNameToJavaIdentifierUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/XercesBugTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/XsiTypeUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/any/
jbossxb/trunk/src/test/java/org/jboss/test/xml/any/Container.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/book/
jbossxb/trunk/src/test/java/org/jboss/test/xml/book/Book.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookCharacter.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookGenericObjectModelFactory.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookGenericObjectModelProvider.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookObjectFactory.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookObjectProvider.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/book/DateDatatypeConverter.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/
jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Choice1.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Choice2.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Root.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/collections/
jbossxb/trunk/src/test/java/org/jboss/test/xml/collections/Collections.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/config/
jbossxb/trunk/src/test/java/org/jboss/test/xml/config/Config.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/
jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child1.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child2.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child3.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/ImmutableChoice.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Parent.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/
jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/Container.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/ContainerInitializer.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/Simple.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/SimpleInitializer.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/
jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/characters/
jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/characters/Binding.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/defaults/
jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/defaults/DefaultsUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/defaults/JBean.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/minOccurs/
jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/minOccurs/Schema1UnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanAttributeMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanConstructorMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaDataFactory.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaDataProvider.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanNotificationMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanOperationMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPm.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPmMetaDataFactory.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPmMetaDataProvider.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/person/
jbossxb/trunk/src/test/java/org/jboss/test/xml/person/Address.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/person/Person.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/po/
jbossxb/trunk/src/test/java/org/jboss/test/xml/po/Item.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/po/PurchaseOrder.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/po/USAddress.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBean.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBeanFactory.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBeanImpl.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/deployment/
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/deployment/AbstractKernelDeployment.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractAnnotationAttributeMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractAnnotationMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractArrayMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractBeanMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractCollectionMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractConstructorMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDemandMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDependencyMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDependencyValueMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractFeatureMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractLifecycleMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractListMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractMapMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractMapMetaDataEntry.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractParameterMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractPropertyMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractSetMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractSupplyMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractTypeMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractValueMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AnnotationAttributeMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AnnotationMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/BeanMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ConstructorMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerMode.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerState.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerStateDataTypeConverter.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DataTypeConverter.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DemandMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DependencyMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DependencyValueMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/FeatureMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/GenericBeanFactory.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/LifecycleMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/MetaDataVisitor.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/MetaDataVisitorNode.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ParameterMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/PropertyInitializer.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/PropertyMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/StringValueMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/SupplyMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ValueMetaData.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/
jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice1.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice2.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice3.java
jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Root.java
jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xsd
jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxNotSimple.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxSimple.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipNotSimple.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipSimple.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictNotSimple.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictSimple.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xsd
jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCase.xsd
jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseSimple.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseWildcard.xml
jbossxb/trunk/src/test/resources/xml/
jbossxb/trunk/src/test/resources/xml/SchemaIncludeUnitTestCase.xsd
jbossxb/trunk/src/test/resources/xml/SchemaIncludeUnitTestCaseIncluded.xsd
jbossxb/trunk/src/test/resources/xml/annotated-bean-deployer_1_0.xsd
jbossxb/trunk/src/test/resources/xml/any.xml
jbossxb/trunk/src/test/resources/xml/any.xsd
jbossxb/trunk/src/test/resources/xml/aop/
jbossxb/trunk/src/test/resources/xml/aop/bean.xml
jbossxb/trunk/src/test/resources/xml/aop/test-aop.xml
jbossxb/trunk/src/test/resources/xml/bean-deployer_1_0.xsd
jbossxb/trunk/src/test/resources/xml/book/
jbossxb/trunk/src/test/resources/xml/book/annotated_books.xsd
jbossxb/trunk/src/test/resources/xml/book/book-dtd.xml
jbossxb/trunk/src/test/resources/xml/book/book-xs.xml
jbossxb/trunk/src/test/resources/xml/book/books.dtd
jbossxb/trunk/src/test/resources/xml/book/books.xsd
jbossxb/trunk/src/test/resources/xml/choice.xsd
jbossxb/trunk/src/test/resources/xml/collections.xml
jbossxb/trunk/src/test/resources/xml/collections.xsd
jbossxb/trunk/src/test/resources/xml/immutable.xsd
jbossxb/trunk/src/test/resources/xml/jbxb-bean-deployer_1_0.xsd
jbossxb/trunk/src/test/resources/xml/jbxb/
jbossxb/trunk/src/test/resources/xml/jbxb/characters/
jbossxb/trunk/src/test/resources/xml/jbxb/characters/schema1.xsd
jbossxb/trunk/src/test/resources/xml/jbxb/characters/testSchema1.xml
jbossxb/trunk/src/test/resources/xml/jbxb/defaults/
jbossxb/trunk/src/test/resources/xml/jbxb/defaults/schema1.xsd
jbossxb/trunk/src/test/resources/xml/jbxb/defaults/schema2.xsd
jbossxb/trunk/src/test/resources/xml/jbxb/defaults/testSchema1.xml
jbossxb/trunk/src/test/resources/xml/jbxb/defaults/testSchema2.xml
jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/
jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/schema1.xsd
jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/schema1v2.xsd
jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/testSchema1.xml
jbossxb/trunk/src/test/resources/xml/loginconfig/
jbossxb/trunk/src/test/resources/xml/loginconfig/config.xml
jbossxb/trunk/src/test/resources/xml/loginconfig/jaspi-config.xml
jbossxb/trunk/src/test/resources/xml/loginconfig/security-config_4_1.xsd
jbossxb/trunk/src/test/resources/xml/loginconfig/security-config_5_0.xsd
jbossxb/trunk/src/test/resources/xml/loginconfig/user-roles_1_0.xsd
jbossxb/trunk/src/test/resources/xml/maps.xml
jbossxb/trunk/src/test/resources/xml/maps.xsd
jbossxb/trunk/src/test/resources/xml/multispaced/
jbossxb/trunk/src/test/resources/xml/multispaced/jdbcpm.xsd
jbossxb/trunk/src/test/resources/xml/multispaced/xmbean-localns.xml
jbossxb/trunk/src/test/resources/xml/multispaced/xmbean.xml
jbossxb/trunk/src/test/resources/xml/multispaced/xmbean.xsd
jbossxb/trunk/src/test/resources/xml/naming/
jbossxb/trunk/src/test/resources/xml/naming/custom-object-binding.xsd
jbossxb/trunk/src/test/resources/xml/naming/jndi-binding-service_1_0.xsd
jbossxb/trunk/src/test/resources/xml/naming/testBindings.xml
jbossxb/trunk/src/test/resources/xml/newmetadata.xml
jbossxb/trunk/src/test/resources/xml/person.dtd
jbossxb/trunk/src/test/resources/xml/person.xml
jbossxb/trunk/src/test/resources/xml/person.xsd
jbossxb/trunk/src/test/resources/xml/po.xml
jbossxb/trunk/src/test/resources/xml/po.xsd
jbossxb/trunk/src/test/resources/xml/pojoserver/
jbossxb/trunk/src/test/resources/xml/pojoserver/ejb-cache_1_0.xsd
jbossxb/trunk/src/test/resources/xml/pojoserver/ejb-config_1_0.xsd
jbossxb/trunk/src/test/resources/xml/pojoserver/test1-ejb-deployment.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testAnnotations.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testAttributeDependency.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testAttributeDependencyDependentState.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testConfigure.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testConfigureNested.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testConstructorDependency.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testDemandSupply.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testDemandSupplyWhenRequired.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testFactoryDependency.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testGenericBeanFactory.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testSimpleCollection.xml
jbossxb/trunk/src/test/resources/xml/pojoserver/testStaticFactoryDependency.xml
jbossxb/trunk/src/test/resources/xml/sandbox.xml
jbossxb/trunk/src/test/resources/xml/sandbox.xsd
jbossxb/trunk/src/test/resources/xml/soapenc/
jbossxb/trunk/src/test/resources/xml/soapenc/soapenc.xsd
jbossxb/trunk/src/test/resources/xml/soapenc/test.xsd
jbossxb/trunk/src/test/resources/xml/valuebinding.xml
jbossxb/trunk/src/test/resources/xml/xerces-bug.xsd
Modified:
jbossxb/trunk/pom.xml
jbossxb/trunk/src/main/java/org/jboss/xb/binding/Util.java
Log:
ported functional tests from the testsuite of the AS
Modified: jbossxb/trunk/pom.xml
===================================================================
--- jbossxb/trunk/pom.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/pom.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -107,6 +107,11 @@
<configuration>
<printSummary>true</printSummary>
<disableXmlReport>false</disableXmlReport>
+ <testFailureIgnore>true</testFailureIgnore>
+ <includes>
+ <include>**/**TestCase.java</include>
+ </includes>
+ <forkMode>pertest</forkMode> <!-- required to correctly run the PojoServer tests -->
</configuration>
</plugin>
<plugin>
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/binding/Util.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/Util.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/Util.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -514,8 +514,7 @@
}
catch(Exception e)
{
- log.error("Failed to create schema loader.", e);
- throw new IllegalStateException("Failed to create schema loader: " + e.getMessage());
+ throw new IllegalStateException("Failed to create schema loader: " + e.getClass().getName() + " " + e.getMessage());
}
return impl;
}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/AnnotatedPojoServerUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/AnnotatedPojoServerUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/AnnotatedPojoServerUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,299 @@
+/*
+ * 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.xml;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37728 $</tt>
+ */
+public class AnnotatedPojoServerUnitTestCase
+ extends PojoServerTestBase
+{
+ public AnnotatedPojoServerUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ protected SchemaBinding getSchemaBinding()
+ {
+ SchemaBinding cursor = readXsd();
+/** TODO
+ TypeBinding namedValueType = cursor.getType(namedValueTypeQName);
+ TypeBinding valueWithClassType = cursor.getType(valueWithClassTypeQName);
+ TypeBinding listType = cursor.getType(listTypeQName);
+ TypeBinding mapType = cursor.getType(mapTypeQName);
+ TypeBinding propsType = cursor.getType(propsTypeQName);
+
+ //
+ // add handlers
+ //
+
+ namedValueType.setSimpleType(new CharactersHandler()
+ {
+ public Object unmarshal(QName qName,
+ TypeBinding typeBinding,
+ NamespaceContext nsCtx,
+ org.jboss.xb.binding.metadata.ValueMetaData valueMetaData,
+ String value)
+ {
+ return value == null ? null : new StringValueMetaData(value);
+ }
+
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)owner;
+ prop.setValue((ValueMetaData)value);
+ }
+ }
+ );
+
+ namedValueType.pushInterceptor(parameterQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ // todo how to add?
+ //AbstractPropertyMetaData prop = (AbstractPropertyMetaData)parent;
+ //AbstractParameterMetaData param = (AbstractParameterMetaData)child;
+ //prop.setValue(param.getType(), param);
+ }
+ }
+ );
+ namedValueType.pushInterceptor(propertyQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ // todo how to add?
+ AbstractPropertyMetaData propParent = (AbstractPropertyMetaData)parent;
+ AbstractPropertyMetaData propChild = (AbstractPropertyMetaData)child;
+ propParent.setValue(propChild.getName(), propChild);
+ }
+ }
+ );
+ namedValueType.pushInterceptor(dependencyQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)parent;
+ AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData)child;
+ prop.setValue(dependency);
+ }
+ }
+ );
+ namedValueType.pushInterceptor(beanQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ // todo how to add?
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)parent;
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)child;
+ prop.setValue(bean.getName(), bean);
+ }
+ }
+ );
+ namedValueType.pushInterceptor(listQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName qName)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)parent;
+ AbstractListMetaData list = (AbstractListMetaData)child;
+ prop.setValue(list);
+ }
+ }
+ );
+ namedValueType.pushInterceptor(setQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName qName)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)parent;
+ AbstractSetMetaData set = (AbstractSetMetaData)child;
+ prop.setValue(set);
+ }
+ }
+ );
+ namedValueType.pushInterceptor(mapQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName qName)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)parent;
+ AbstractMapMetaData map = (AbstractMapMetaData)child;
+ prop.setValue(map);
+ }
+ }
+ );
+ namedValueType.pushInterceptor(propsQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName qName)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)parent;
+ Map children = (Map)child;
+ for(Iterator i = children.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ prop.setValue((String)entry.getKey(), entry.getValue());
+ }
+ }
+ }
+ );
+
+ valueWithClassType.setSimpleType(new CharactersHandler()
+ {
+ public Object unmarshal(QName qName,
+ TypeBinding typeBinding,
+ NamespaceContext nsCtx,
+ org.jboss.xb.binding.metadata.ValueMetaData valueMetaData,
+ String value)
+ {
+ return value == null ? null : new StringValueMetaData(value);
+ }
+
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ AbstractParameterMetaData param = (AbstractParameterMetaData)owner;
+ param.setValue((ValueMetaData)value);
+ }
+ }
+ );
+ valueWithClassType.pushInterceptor(dependencyQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName qName)
+ {
+ AbstractParameterMetaData param = (AbstractParameterMetaData)parent;
+ AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData)child;
+ param.setValue(dependency);
+ }
+ }
+ );
+
+ listType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object root, QName qName, ElementBinding element)
+ {
+ AbstractCollectionMetaData col;
+ if("set".equals(qName.getLocalPart()))
+ {
+ col = new AbstractSetMetaData();
+ }
+ else
+ {
+ col = new AbstractListMetaData();
+ }
+ return col;
+ }
+
+ public void attributes(Object o, QName qName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractCollectionMetaData col = (AbstractCollectionMetaData)o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("class".equals(lName))
+ {
+ // todo what should I do with this?
+ }
+ }
+ }
+ }
+ );
+ listType.pushInterceptor(valueQName, new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName qName, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ AbstractCollectionMetaData col = (AbstractCollectionMetaData)o;
+ col.add(text);
+ }
+ }
+ );
+
+ propsType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new HashMap();
+ }
+ }
+ );
+ propsType.pushInterceptor(propsEntryQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Map map = (Map)parent;
+ Object[] arr = (Object[])child;
+ map.put(arr[0], arr[1]);
+ }
+ }
+ );
+ propsType.pushInterceptor(propsEntryQName, new DefaultElementInterceptor()
+ {
+ public Object startElement(Object parent, QName qName, TypeBinding type)
+ {
+ return new Object[2];
+ }
+
+ public void attributes(Object o, QName name, TypeBinding type, Attributes attrs, NamespaceContext nsCtx)
+ {
+ Object[] arr = (Object[])o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ if("name".equals(attrs.getLocalName(i)))
+ {
+ arr[0] = attrs.getValue(i);
+ }
+ }
+ }
+
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Object[] arr = (Object[])o;
+ arr[1] = text;
+ }
+ }
+ );
+
+ mapType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractMapMetaData();
+ }
+ }
+ );
+ mapType.pushInterceptor(mapEntryQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractMapMetaData map = (AbstractMapMetaData)parent;
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)child;
+ map.put(prop.getName(), prop);
+ }
+ }
+ );
+*/
+ return cursor;
+ }
+
+ protected String getXsd()
+ {
+ return "xml/annotated-bean-deployer_1_0.xsd";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/AnnotationsUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/AnnotationsUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/AnnotationsUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,72 @@
+/*
+ * 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.xml;
+
+import org.jboss.test.xml.book.Book;
+import org.jboss.test.BaseTestCase;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 38201 $</tt>
+ */
+public class AnnotationsUnitTestCase
+ extends BaseTestCase
+{
+ public AnnotationsUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+/*
+ public void configureLogging()
+ {
+ enableTrace("org.jboss.xb");
+ }
+*/
+
+ public void testMain() throws Exception
+ {
+ String url = getPath("xml/book/annotated_books.xsd");
+ SchemaBinding schemaBinding = XsdBinder.bind(url);
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Book book = (Book)unmarshaller.unmarshal(getPath("xml/book/book-xs.xml"), schemaBinding);
+ assertEquals(Book.getInstance(), book);
+ }
+
+ // Private
+
+ public String getPath(String path)
+ {
+ java.net.URL url = Thread.currentThread().getContextClassLoader().getResource(path);
+ if(url == null)
+ {
+ fail("URL not found: " + path);
+ }
+ return url.toString();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/AnyUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/AnyUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/AnyUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,120 @@
+/*
+ * 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.xml;
+
+import java.io.FileReader;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import org.jboss.test.xml.collections.Collections;
+import org.jboss.test.xml.any.Container;
+import org.jboss.test.BaseTestCase;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.w3c.dom.ls.LSInput;
+
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 38057 $</tt>
+ */
+public class AnyUnitTestCase
+ extends BaseTestCase
+{
+ public AnyUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+/*
+ public void configureLogging()
+ {
+ enableTrace("org.jboss.xb");
+ }
+*/
+
+ public void testMain() throws Exception
+ {
+ String xsd = getFullPath("xml/any.xsd");
+ SchemaBinding schema = XsdBinder.bind(xsd);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+ schema.setSchemaResolver(new SchemaBindingResolver()
+ {
+ public String getBaseURI()
+ {
+ throw new UnsupportedOperationException("getBaseURI is not implemented.");
+ }
+
+ public void setBaseURI(String baseURI)
+ {
+ throw new UnsupportedOperationException("setBaseURI is not implemented.");
+ }
+
+ public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation)
+ {
+ SchemaBinding schema = null;
+ String ns = "http://www.jboss.org/test/xml/collections";
+ if(ns.equals(nsUri))
+ {
+ String xsd = getFullPath("xml/collections.xsd");
+ schema = XsdBinder.bind(xsd);
+ QName rootQName = new QName(ns, "collections");
+ TypeBinding type = schema.getType(rootQName);
+ schema.addElement(rootQName, type);
+ }
+ return schema;
+ }
+
+ public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation)
+ {
+ throw new UnsupportedOperationException("resolveResource is not implemented.");
+ }
+ }
+ );
+
+ String xml = getFullPath("xml/any.xml");
+ FileReader xmlReader = new FileReader(xml);
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(xmlReader, schema);
+
+ Container container = new Container();
+ container.setId("any test");
+ container.setAnyContent(Collections.getInstance());
+ assertEquals(container, o);
+ }
+
+ // Private
+
+ private String getFullPath(String name)
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(name);
+ if(url == null)
+ {
+ fail("Resource not found: " + name);
+ }
+ return url.getFile();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/ArrayWrapperUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/ArrayWrapperUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/ArrayWrapperUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,347 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Arrays;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 57202 $</tt>
+ */
+public class ArrayWrapperUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String XSD =
+ "<xsd:schema" +
+ " targetNamespace='http://www.jboss.org/xml/test/arraywrapper'" +
+ " xmlns='http://www.jboss.org/xml/test/arraywrapper'" +
+ " xmlns:jbxb='" +
+ Constants.NS_JBXB +
+ "'" +
+ " elementFormDefault='qualified'" +
+ " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
+ " <xsd:complexType name='ArrayWrapper'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" +
+ ArrayWrapper.class.getName() +
+ "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:sequence>" +
+ " <xsd:element name='stringArray' type='StringArray' minOccurs='0'/>" +
+ " <xsd:element name='stringArrayArray' type='StringArrayArray' minOccurs='0'/>" +
+ " <xsd:element name='jbxb79' type='xsd:string' minOccurs='0' maxOccurs='unbounded'/>" +
+ " </xsd:sequence>" +
+ " </xsd:complexType>" +
+ " <xsd:complexType name='StringArray'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" + StringArray.class.getName() + "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:sequence>" +
+ " <xsd:element maxOccurs='unbounded' minOccurs='0' name='value' nillable='true' type='xsd:string'/>" +
+ " </xsd:sequence>" +
+ " </xsd:complexType>" +
+ " <xsd:complexType name='StringArrayArray'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" + StringArrayArray.class.getName() + "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:sequence>" +
+ " <xsd:element maxOccurs='unbounded' minOccurs='0' name='value' nillable='true' type='StringArray'/>" +
+ " </xsd:sequence>" +
+ " </xsd:complexType>" +
+ " <xsd:element name='arr' type='ArrayWrapper'/>" +
+ "</xsd:schema>";
+
+ private static SchemaBinding SCHEMA;// = XsdBinder.bind(new StringReader(XSD), null);
+
+ private static final String XML =
+ "<ns_arr:arr xmlns:ns_arr='http://www.jboss.org/xml/test/arraywrapper'>" +
+ " <ns_arr:stringArray>" +
+ " <ns_arr:value>item1</ns_arr:value>" +
+ " <ns_arr:value>item2</ns_arr:value>" +
+ " <ns_arr:value></ns_arr:value>" +
+ " <ns_arr:value xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='1'></ns_arr:value>" +
+ " </ns_arr:stringArray>" +
+ "</ns_arr:arr>";
+
+ private static final String XML_STRING_ARR_ARR =
+ "<arr xmlns='http://www.jboss.org/xml/test/arraywrapper'>" +
+ " <stringArrayArray>" +
+ " <value>" +
+ " <value>item1</value>" +
+ " </value>" +
+ " <value>" +
+ " <value/>" +
+ " </value>" +
+ " <value>" +
+ " <value xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='1'/>" +
+ " </value>" +
+ " <value xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='1'/>" +
+ " <value>" +
+ " <value>item1</value>" +
+ " <value>item2</value>" +
+ " <value/>" +
+ " <value xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='1'/>" +
+ " </value>" +
+ " </stringArrayArray>" +
+ "</arr>";
+
+ private static final String JBXB79_XML =
+ "<ns_arr:arr xmlns:ns_arr='http://www.jboss.org/xml/test/arraywrapper'>" +
+ " <ns_arr:jbxb79>item1</ns_arr:jbxb79>" +
+ " <ns_arr:jbxb79>item2</ns_arr:jbxb79>" +
+ " <ns_arr:jbxb79></ns_arr:jbxb79>" +
+ " <ns_arr:jbxb79 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='1'/>" +
+ "</ns_arr:arr>";
+
+ public ArrayWrapperUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void configureLogging()
+ {
+// enableTrace("org.jboss.xb.binding");
+
+ if(SCHEMA == null)
+ {
+ SCHEMA = XsdBinder.bind(new StringReader(XSD), null);
+ }
+ }
+
+ public void testMarshalStringArraySunday() throws Exception
+ {
+ MarshallerImpl marshaller = new MarshallerImpl();
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(SCHEMA, null, ArrayWrapper.STRING_ARR_INSTANCE, writer);
+ assertXmlEqual(XML, writer.getBuffer().toString());
+ }
+
+ public void testMarshalStringArrayXerces() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.mapClassToGlobalElement(ArrayWrapper.class, "arr", "http://www.jboss.org/xml/test/arraywrapper", null, null);
+
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+ provider.mapFieldToElement(ArrayWrapper.class, "stringArray", "http://www.jboss.org/xml/test/arraywrapper", "stringArray", null);
+
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), provider, ArrayWrapper.STRING_ARR_INSTANCE, writer);
+ assertXmlEqual(XML, writer.getBuffer().toString());
+ }
+
+ public void testUnmarshalStringArray() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML), SCHEMA);
+ assertNotNull(o);
+ assertTrue(o instanceof ArrayWrapper);
+ ArrayWrapper aw = (ArrayWrapper)o;
+ assertNotNull(aw.stringArray);
+ assertTrue(Arrays.equals(ArrayWrapper.STRING_ARR_INSTANCE.stringArray.getValue(), aw.stringArray.getValue()));
+ }
+
+ public void testMarshalStringArrayArraySunday() throws Exception
+ {
+ MarshallerImpl marshaller = new MarshallerImpl();
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(SCHEMA, null, ArrayWrapper.STRING_ARR_ARR_INSTANCE, writer);
+ assertXmlEqual(XML_STRING_ARR_ARR, writer.getBuffer().toString());
+ }
+
+ public void testMarshalStringArrayArrayXerces() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.mapClassToGlobalElement(ArrayWrapper.class, "arr", "http://www.jboss.org/xml/test/arraywrapper", null, null);
+
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), provider, ArrayWrapper.STRING_ARR_ARR_INSTANCE, writer);
+ assertXmlEqual(XML_STRING_ARR_ARR, writer.getBuffer().toString());
+ }
+
+ public void testUnmarshalStringArrayArray() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML_STRING_ARR_ARR), SCHEMA);
+
+ assertNotNull(o);
+ assertTrue(o instanceof ArrayWrapper);
+ ArrayWrapper aw = (ArrayWrapper)o;
+ assertNotNull(aw.stringArrayArray);
+ StringArray[] wasArr = aw.stringArrayArray.getValue();
+ assertNotNull(wasArr);
+
+ StringArray[] expArr = ArrayWrapper.STRING_ARR_ARR_INSTANCE.stringArrayArray.getValue();
+ assertEquals(expArr.length, wasArr.length);
+
+ for(int i = 0; i < expArr.length; ++i)
+ {
+ StringArray expSA = expArr[i];
+ StringArray wasSA = wasArr[i];
+
+ if(expSA == null)
+ {
+ assertNull(wasSA);
+ }
+ else
+ {
+ assertNotNull(wasSA);
+ String[] exp = expSA.getValue();
+ String[] was = wasSA.getValue();
+ if(exp == null)
+ {
+ assertNull(was);
+ }
+ else
+ {
+ assertEquals(exp, was);
+ }
+ }
+ }
+ }
+
+ public void testUnmarshalJBXB79StringArray() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(JBXB79_XML), SCHEMA);
+ assertNotNull(o);
+ assertTrue(o instanceof ArrayWrapper);
+ ArrayWrapper aw = (ArrayWrapper)o;
+ assertNotNull(aw.jbxb79);
+ assertEquals(4, aw.jbxb79.length);
+ assertTrue(Arrays.equals(ArrayWrapper.JBXB79_STRING_ARR_INSTANCE.jbxb79, aw.jbxb79));
+ }
+
+ // Inner
+
+ public static class ArrayWrapper
+ {
+ public static final ArrayWrapper STRING_ARR_INSTANCE;
+ public static final ArrayWrapper STRING_ARR_ARR_INSTANCE;
+ public static final ArrayWrapper JBXB79_STRING_ARR_INSTANCE;
+
+ static
+ {
+ STRING_ARR_INSTANCE = new ArrayWrapper();
+ STRING_ARR_INSTANCE.stringArray = new StringArray(new String[]{"item1", "item2", "", null});
+
+ STRING_ARR_ARR_INSTANCE = new ArrayWrapper();
+ STRING_ARR_ARR_INSTANCE.stringArrayArray = new StringArrayArray(
+ new StringArray[]
+ {
+ new StringArray(new String[]{"item1"}),
+ new StringArray(new String[]{""}),
+ new StringArray(new String[]{null}),
+ null,
+ STRING_ARR_INSTANCE.stringArray
+ }
+ );
+
+ JBXB79_STRING_ARR_INSTANCE = new ArrayWrapper();
+ JBXB79_STRING_ARR_INSTANCE.jbxb79 = new String[]{"item1", "item2", "", null};
+}
+
+ public StringArray stringArray;
+ public StringArrayArray stringArrayArray;
+ public String[] jbxb79 = new String[10];
+
+ public String toString()
+ {
+ return "stringArray=" + stringArray + "; stringArrayArray=" + stringArrayArray;
+ }
+ }
+
+ public static class StringArray
+ {
+ private String[] value;
+
+ public StringArray()
+ {
+ }
+
+ public StringArray(final String[] value)
+ {
+ this.value = value;
+ }
+
+ public String[] getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(final String[] value)
+ {
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ return (value != null ? Arrays.asList(value).toString() : null);
+ }
+ }
+
+ public static class StringArrayArray
+ {
+ private StringArray[] value;
+
+ public StringArrayArray()
+ {
+ }
+
+ public StringArrayArray(final StringArray[] value)
+ {
+ this.value = value;
+ }
+
+ public StringArray[] getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(final StringArray[] value)
+ {
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ return (value != null ? Arrays.asList(value).toString() : null);
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/AttributesUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/AttributesUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/AttributesUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,265 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Collection;
+import javax.xml.namespace.QName;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.LSInputAdaptor;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.w3c.dom.ls.LSInput;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45337 $</tt>
+ */
+public class AttributesUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String NS_1 = "http://www.jboss.org/test/xml/attrs";
+ private static final String NS_2 = "http://www.jboss.org/test/xml/attrs2";
+ private static final String UNQUALIFIED_NAME = "unqualified";
+ private static final String MATE_NAME = "mate";
+ private static final String FOREIGNER_NAME = "foreigner";
+ private static final QName UNQUALIFIED_QNAME = new QName(UNQUALIFIED_NAME);
+ private static final QName MATE_QNAME = new QName(NS_1, MATE_NAME);
+ private static final QName FOREIGNER_QNAME = new QName(NS_2, FOREIGNER_NAME);
+
+ private static final String XSD =
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='" +
+ NS_1 +
+ "'" +
+ " xmlns='" +
+ NS_1 +
+ "'" +
+ " xmlns:attrs2='" +
+ NS_2 +
+ "'" +
+ " xmlns:jbxb='" +
+ Constants.NS_JBXB +
+ "'" +
+ " attributeFormDefault='unqualified'" +
+ " version='1.0'>" +
+ "<xsd:import namespace='" +
+ NS_2 +
+ "'/>" +
+ "<xsd:element name='e'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" +
+ E.class.getName() +
+ "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:complexType>" +
+ " <xsd:attribute name='" +
+ UNQUALIFIED_NAME +
+ "' type='xsd:string'/>" +
+ " <xsd:attribute form='qualified' name='" +
+ MATE_NAME +
+ "' type='xsd:string'/>" +
+ " <xsd:attribute ref='attrs2:" +
+ FOREIGNER_NAME +
+ "'/>" +
+ " </xsd:complexType>" +
+ "</xsd:element>" +
+ "</xsd:schema>";
+
+ private static final String XSD_2 =
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='" +
+ NS_2 +
+ "'" +
+ " xmlns='" +
+ NS_2 +
+ "'" +
+ " attributeFormDefault='qualified'" +
+ " version='1.0'>" +
+ " <xsd:attribute name='" +
+ FOREIGNER_NAME +
+ "' type='xsd:string'/>" +
+ "</xsd:schema>";
+
+ private static final SchemaBindingResolver SCHEMA_RESOLVER = new SchemaBindingResolver()
+ {
+ public String getBaseURI()
+ {
+ throw new UnsupportedOperationException("getBaseURI is not implemented.");
+ }
+
+ public void setBaseURI(String baseURI)
+ {
+ throw new UnsupportedOperationException("setBaseURI is not implemented.");
+ }
+
+ public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation)
+ {
+ throw new UnsupportedOperationException("resolve is not implemented.");
+ }
+
+ public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation)
+ {
+ return new LSInputAdaptor(new StringReader(XSD_2), null);
+ }
+ };
+
+ private static SchemaBinding SCHEMA;
+
+ private static final String XML =
+ "<attrs:e xmlns:attrs='" +
+ NS_1 +
+ "' xmlns:attrs2='" +
+ NS_2 +
+ "' " +
+ "attrs:" +
+ MATE_NAME +
+ "='m' attrs2:" +
+ FOREIGNER_NAME +
+ "='f' " +
+ UNQUALIFIED_NAME + "='u'/>";
+
+ public AttributesUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void configureLogging()
+ {
+ if(SCHEMA == null)
+ {
+ SCHEMA = XsdBinder.bind(new StringReader(XSD), null, SCHEMA_RESOLVER);
+ SCHEMA.setIgnoreUnresolvedFieldOrClass(false);
+ }
+ }
+
+ public void testAttributesInSchema()
+ {
+ ElementBinding eBinding = SCHEMA.getElement(new QName(NS_1, "e"));
+ TypeBinding eType = eBinding.getType();
+ Collection attributes = eType.getAttributes();
+ assertNotNull(attributes);
+ assertEquals(3, attributes.size());
+ assertNotNull(eType.getAttribute(UNQUALIFIED_QNAME));
+ assertNotNull(eType.getAttribute(MATE_QNAME));
+ assertNotNull(eType.getAttribute(FOREIGNER_QNAME));
+ }
+
+ public void testUnmarshalling() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML), SCHEMA);
+ assertTrue(o instanceof E);
+ assertEquals(E.INSTANCE, o);
+ }
+
+ public void testMarshallingXerces() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller(); //new MarshallerImpl();
+ marshaller.setSchemaResolver(SCHEMA_RESOLVER);
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), new MappingObjectModelProvider(), E.INSTANCE, writer);
+ assertXmlEqual(XML, writer.getBuffer().toString());
+ }
+
+ public void testMarshallingSunday() throws Exception
+ {
+ MarshallerImpl marshaller = new MarshallerImpl();
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(SCHEMA, null, E.INSTANCE, writer);
+ assertXmlEqual(XML, writer.getBuffer().toString());
+ }
+
+ // Inner
+
+ public static final class E
+ {
+ public static final E INSTANCE;
+
+ static
+ {
+ E e = new E();
+ e.unqualified = "u";
+ e.mate = "m";
+ e.foreigner = "f";
+ INSTANCE = e;
+ }
+
+ public String unqualified;
+ public String mate;
+ public String foreigner;
+
+ public String toString()
+ {
+ return "[unqualified=" + unqualified + ", mate=" + mate + ", foreigner=" + foreigner + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof E))
+ {
+ return false;
+ }
+
+ final E e = (E)o;
+
+ if(foreigner != null ? !foreigner.equals(e.foreigner) : e.foreigner != null)
+ {
+ return false;
+ }
+ if(mate != null ? !mate.equals(e.mate) : e.mate != null)
+ {
+ return false;
+ }
+ if(unqualified != null ? !unqualified.equals(e.unqualified) : e.unqualified != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (unqualified != null ? unqualified.hashCode() : 0);
+ result = 29 * result + (mate != null ? mate.hashCode() : 0);
+ result = 29 * result + (foreigner != null ? foreigner.hashCode() : 0);
+ return result;
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/BasicArraysUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/BasicArraysUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/BasicArraysUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,558 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import javax.xml.namespace.QName;
+import org.jboss.xb.binding.AbstractMarshaller;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.ObjectModelProvider;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 46059 $</tt>
+ */
+public class BasicArraysUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String NS = "http://www.jboss.org/test/xml/longarr";
+
+ private static final long[] PRIMITIVES = new long[]{-1, 0, 1};
+ private static final String PRIMITIVES_XML =
+ "<longArray xmlns='" +
+ NS +
+ "'>" +
+ " <item>-1</item>" +
+ " <item>0</item>" +
+ " <item>1</item>" +
+ "</longArray>";
+
+ private static final Long[] WRAPPERS = new Long[]{new Long(-1), new Long(0), new Long(1), null};
+ private static final String WRAPPERS_XML =
+ "<longArray xmlns='" +
+ NS +
+ "'>" +
+ " <item>-1</item>" +
+ " <item>0</item>" +
+ " <item>1</item>" +
+ " <item xmlns:xsi='" +
+ Constants.NS_XML_SCHEMA_INSTANCE +
+ "' xsi:nil='1'/>" +
+ "</longArray>";
+
+ private static final String WRAPPERS_NULL_ITEM_XML =
+ "<longArray xmlns='" +
+ NS +
+ "'>" +
+ " <item xmlns:xsi='" +
+ Constants.NS_XML_SCHEMA_INSTANCE +
+ "' xsi:nil='1'/>" +
+ "</longArray>";
+
+ private static final String EMPTY_ARRAY_XML = "<longArray xmlns='" + NS + "'/>";
+
+ public BasicArraysUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testUnmarshalEmptyPrimitiveArray() throws Exception
+ {
+ String xsd = getArrayOfLongXsd(false, false);
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object unmarshalled = unmarshaller.unmarshal(new StringReader(EMPTY_ARRAY_XML), schema);
+ assertNotNull(unmarshalled);
+ assertTrue(unmarshalled instanceof long[]);
+ long[] arr = (long[])unmarshalled;
+ assertEquals(0, arr.length);
+ }
+
+ public void testMarshalEmptyPrimitiveArrayXerces() throws Exception
+ {
+ marshallingTest(new XercesXsMarshaller(),
+ getProvider(),
+ getArrayOfLongXsd(false, false),
+ new long[0],
+ EMPTY_ARRAY_XML
+ );
+ }
+
+ public void testMarshalEmptyPrimitiveArraySunday() throws Exception
+ {
+ marshallingTest(new MarshallerImpl(), null, getArrayOfLongXsd(false, false), new long[0], EMPTY_ARRAY_XML);
+ }
+
+ public void testUnmarshalEmptyArrayOfWrappers() throws Exception
+ {
+ String xsd = getArrayOfLongXsd(true, false);
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object unmarshalled = unmarshaller.unmarshal(new StringReader(EMPTY_ARRAY_XML), schema);
+ assertNotNull(unmarshalled);
+ assertTrue(unmarshalled instanceof Long[]);
+ Long[] arr = (Long[])unmarshalled;
+ assertEquals(0, arr.length);
+ }
+
+ public void testMarshalEmptyArrayOfWrappersXerces() throws Exception
+ {
+ marshallingTest(new XercesXsMarshaller(),
+ getProvider(),
+ getArrayOfLongXsd(true, false),
+ new Long[0],
+ EMPTY_ARRAY_XML
+ );
+ }
+
+ public void testMarshalEmptyArrayOfWrappersSunday() throws Exception
+ {
+ marshallingTest(new MarshallerImpl(), null, getArrayOfLongXsd(true, false), new Long[0], EMPTY_ARRAY_XML);
+ }
+
+ public void testUnmarshalEmptyAnnotatedPrimitiveArray() throws Exception
+ {
+ String xsd = getArrayOfLongXsd(false, true);
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object unmarshalled = unmarshaller.unmarshal(new StringReader(EMPTY_ARRAY_XML), schema);
+ assertNotNull(unmarshalled);
+ assertTrue(unmarshalled instanceof ArrayWrapper);
+ long[] arr = ((ArrayWrapper)unmarshalled).primitives;
+ assertNotNull(arr);
+ assertEquals(0, arr.length);
+ }
+
+ public void testMarshalEmptyAnnotatedPrimitiveArrayXerces() throws Exception
+ {
+ MappingObjectModelProvider provider = getProvider();
+ provider.mapClassToElement(ArrayWrapper.class, NS, "longArray", null);
+ provider.mapFieldToElement(ArrayWrapper.class, "primitives", NS, "item", null);
+ marshallingTest(new XercesXsMarshaller(),
+ provider,
+ getArrayOfLongXsd(false, true),
+ new ArrayWrapper(new long[0]),
+ EMPTY_ARRAY_XML
+ );
+ }
+
+ public void testMarshalEmptyAnnotatedPrimitiveArraySunday() throws Exception
+ {
+ marshallingTest(new MarshallerImpl(), null, getArrayOfLongXsd(false, true), new ArrayWrapper(new long[0]), EMPTY_ARRAY_XML);
+ }
+
+ public void testUnmarshalEmptyAnnotatedArrayOfWrappers() throws Exception
+ {
+ String xsd = getArrayOfLongXsd(true, true);
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object unmarshalled = unmarshaller.unmarshal(new StringReader(EMPTY_ARRAY_XML), schema);
+ assertNotNull(unmarshalled);
+ assertTrue(unmarshalled instanceof ArrayWrapper);
+ Long[] arr = ((ArrayWrapper)unmarshalled).wrappers;
+ assertNotNull(arr);
+ assertEquals(0, arr.length);
+ }
+
+ public void testMarshalEmptyAnnotatedArrayOfWrappersXerces() throws Exception
+ {
+ MappingObjectModelProvider provider = getProvider();
+ provider.mapClassToElement(ArrayWrapper.class, NS, "longArray", null);
+ provider.mapFieldToElement(ArrayWrapper.class, "wrappers", NS, "item", null);
+ marshallingTest(new XercesXsMarshaller(),
+ provider,
+ getArrayOfLongXsd(true, true),
+ new ArrayWrapper(new Long[0]),
+ EMPTY_ARRAY_XML
+ );
+ }
+
+ public void testMarshalEmptyAnnotatedArrayOfWrappersSunday() throws Exception
+ {
+ marshallingTest(new MarshallerImpl(), null, getArrayOfLongXsd(true, true), new ArrayWrapper(new Long[0]), EMPTY_ARRAY_XML);
+ }
+
+ public void testUnmarshalPrimitiveArray() throws Exception
+ {
+ String xsd = getArrayOfLongXsd(false, false);
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object unmarshalled = unmarshaller.unmarshal(new StringReader(PRIMITIVES_XML), schema);
+ assertNotNull(unmarshalled);
+ assertTrue(unmarshalled instanceof long[]);
+ long[] arr = (long[])unmarshalled;
+ assertPrimitiveArray(arr);
+ }
+
+ public void testMarshalPrimitiveArrayXerces() throws Exception
+ {
+ marshallingTest(new XercesXsMarshaller(),
+ getProvider(),
+ getArrayOfLongXsd(false, false),
+ PRIMITIVES,
+ PRIMITIVES_XML
+ );
+ }
+
+ public void testMarshalPrimitiveArraySunday() throws Exception
+ {
+ marshallingTest(new MarshallerImpl(), null, getArrayOfLongXsd(false, false), PRIMITIVES, PRIMITIVES_XML);
+ }
+
+ public void testUnmarshalAnnotatedPrimtiveArray() throws Exception
+ {
+ String xsd = getArrayOfLongXsd(false, true);
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object unmarshalled = unmarshaller.unmarshal(new StringReader(PRIMITIVES_XML), schema);
+ assertNotNull(unmarshalled);
+ assertTrue(unmarshalled instanceof ArrayWrapper);
+ long[] arr = ((ArrayWrapper)unmarshalled).primitives;
+ assertPrimitiveArray(arr);
+ }
+
+ public void testMarshalAnnotatedPrimtiveArrayXerces() throws Exception
+ {
+ MappingObjectModelProvider provider = getProvider();
+ provider.mapClassToElement(ArrayWrapper.class, NS, "longArray", null);
+ provider.mapFieldToElement(ArrayWrapper.class, "primitives", NS, "item", null);
+ marshallingTest(new XercesXsMarshaller(),
+ provider,
+ getArrayOfLongXsd(false, true),
+ new ArrayWrapper(PRIMITIVES),
+ PRIMITIVES_XML
+ );
+ }
+
+ public void testMarshalAnnotatedPrimtiveArraySunday() throws Exception
+ {
+ marshallingTest(new MarshallerImpl(),
+ null,
+ getArrayOfLongXsd(false, true),
+ new ArrayWrapper(PRIMITIVES),
+ PRIMITIVES_XML
+ );
+ }
+
+ public void testArrayOfWrappersXerces() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ arrayOfWrappersTest(marshaller);
+ }
+
+ public void testArrayOfWrappersSunday() throws Exception
+ {
+ MarshallerImpl marshaller = new MarshallerImpl();
+ arrayOfWrappersTest(marshaller);
+ }
+
+ public void testQNameArrayWithPrefixesXerces() throws Exception
+ {
+ qNameArrayWithPrefixesTest(new XercesXsMarshaller());
+ }
+
+ public void testQNameArrayWithPrefixesSunday() throws Exception
+ {
+ qNameArrayWithPrefixesTest(new MarshallerImpl());
+ }
+
+ public void testQNameArrayWithoutPrefixesXerces() throws Exception
+ {
+ qNameArrayWithoutPrefixesTest(new XercesXsMarshaller());
+ }
+
+ public void testQNameArrayWithoutPrefixesSunday() throws Exception
+ {
+ qNameArrayWithoutPrefixesTest(new MarshallerImpl());
+ }
+
+ // Private
+
+ private MappingObjectModelProvider getProvider()
+ {
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+ provider.setIgnoreNotFoundField(false);
+ return provider;
+ }
+
+ private void marshallingTest(AbstractMarshaller marshaller,
+ ObjectModelProvider provider,
+ String xsd,
+ Object o,
+ String expectedXml)
+ throws Exception
+ {
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(xsd), provider, o, writer);
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(expectedXml, marshalled);
+ }
+
+ private void assertPrimitiveArray(long[] arr)
+ {
+ assertEquals(3, arr.length);
+ assertEquals(-1, arr[0]);
+ assertEquals(0, arr[1]);
+ assertEquals(1, arr[2]);
+ }
+
+ private void arrayOfWrappersTest(AbstractMarshaller marshaller) throws Exception
+ {
+ String xsd = getArrayOfLongXsd(true, false);
+ arrayOfWrappersTest(xsd, WRAPPERS_XML, WRAPPERS, marshaller);
+ arrayOfWrappersTest(xsd, WRAPPERS_NULL_ITEM_XML, new Long[]{null}, marshaller);
+ }
+
+ private void arrayOfWrappersTest(String xsd, String xml, Object[] expected, AbstractMarshaller marshaller)
+ throws Exception
+ {
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object unmarshalled = unmarshaller.unmarshal(new StringReader(xml), schema);
+ assertNotNull(unmarshalled);
+ assertTrue(unmarshalled instanceof Long[]);
+ Long[] arr = (Long[])unmarshalled;
+ if(expected != null)
+ {
+ assertNotNull(arr);
+ assertEquals(expected.length, arr.length);
+ for(int i = 0; i < expected.length; ++i)
+ {
+ if(expected[i] != null)
+ {
+ assertEquals(expected[i], arr[i]);
+ }
+ else
+ {
+ assertNull(arr[i]);
+ }
+ }
+ }
+ else
+ {
+ assertNull(arr);
+ }
+
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(xsd), getProvider(), unmarshalled, writer);
+
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(xml, marshalled);
+ }
+
+ private String getArrayOfLongXsd(boolean nillableItems, boolean annotations)
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append("<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'")
+ .append(" targetNamespace='").append(NS).append("'")
+ .append(" xmlns='").append(NS).append("'")
+ .append(" xmlns:jbxb='" + Constants.NS_JBXB + "'")
+ .append(" elementFormDefault='qualified'")
+ .append(" attributeFormDefault='unqualified'")
+ .append(" version='1.0'>")
+ .append("<xsd:complexType name='LongArray'>");
+
+ if(annotations)
+ {
+ buf.append("<xsd:annotation>")
+ .append(" <xsd:appinfo>")
+ .append(" <jbxb:class impl='").append(ArrayWrapper.class.getName()).append("'/>")
+ .append(" </xsd:appinfo>")
+ .append("</xsd:annotation>");
+ }
+
+ buf.append(" <xsd:sequence>")
+ .append(" <xsd:element name='item' type='xsd:long' minOccurs='0' maxOccurs='unbounded' nillable='")
+ .append(nillableItems)
+ .append(" '>");
+
+ if(annotations)
+ {
+ buf.append("<xsd:annotation>")
+ .append(" <xsd:appinfo>")
+ .append(" <jbxb:property name='")
+ .append(nillableItems ? "wrappers" : "primitives")
+ .append("'/>")
+ .append(" </xsd:appinfo>")
+ .append("</xsd:annotation>");
+ }
+
+ buf.append(" </xsd:element>")
+ .append(" </xsd:sequence>")
+ .append("</xsd:complexType>")
+ .append("<xsd:element name='longArray' type='LongArray'/>")
+ .append("</xsd:schema>");
+ return buf.toString();
+ }
+
+ private void qNameArrayWithoutPrefixesTest(AbstractMarshaller marshaller) throws Exception
+ {
+ QName[] arr = new QName[]{
+ new QName("http://some-ns1", "lp1"),
+ new QName("http://some-ns2", "lp2"),
+ new QName("http://some-ns3", "lp3")
+ };
+
+ String xsd = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/qname'" +
+ " xmlns='http://www.jboss.org/test/xml/qname'" +
+ " elementFormDefault='qualified'" +
+ " attributeFormDefault='unqualified'" +
+ " version='1.0'>" +
+ "<xsd:element name='qnameArray'>" +
+ "<xsd:complexType>" +
+ "<xsd:sequence>" +
+ "<xsd:element name='item' type='xsd:QName' minOccurs='0' maxOccurs='unbounded'/>" +
+ "</xsd:sequence>" +
+ "</xsd:complexType>" +
+ "</xsd:element>" +
+ "</xsd:schema>";
+
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+
+ String xml = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<qnameArray xmlns='http://www.jboss.org/test/xml/qname'>";
+ for(int i = 0; i < arr.length; ++i)
+ {
+ String prefix = arr[i].getLocalPart() + "_ns";
+ xml += "<item xmlns:" + prefix + "='" +
+ arr[i].getNamespaceURI() +
+ "'>" + prefix + ":" +
+ arr[i].getLocalPart() +
+ "</item>";
+ }
+ xml += "</qnameArray>";
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ QName[] unmarshalled = (QName[])unmarshaller.unmarshal(new StringReader(xml), schema);
+
+ assertNotNull(unmarshalled);
+ assertEquals(arr.length, unmarshalled.length);
+ for(int i = 0; i < arr.length; ++i)
+ {
+ assertEquals(arr[i], unmarshalled[i]);
+ }
+
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ marshaller.declareNamespace("", "http://www.jboss.org/test/xml/qname");
+ MappingObjectModelProvider provider = getProvider();
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(xsd), provider, arr, writer);
+
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(xml, marshalled);
+ }
+
+ private void qNameArrayWithPrefixesTest(AbstractMarshaller marshaller) throws Exception
+ {
+ QName[] arr = new QName[]{
+ new QName("http://some-ns1", "lp1", "ns1"),
+ new QName("http://some-ns2", "lp2", "ns2"),
+ new QName("http://some-ns3", "lp3", "ns3")
+ };
+
+ String xsd = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/qname'" +
+ " xmlns='http://www.jboss.org/test/xml/qname'" +
+ " elementFormDefault='qualified'" +
+ " attributeFormDefault='unqualified'" +
+ " version='1.0'>" +
+ "<xsd:element name='qnameArray'>" +
+ "<xsd:complexType>" +
+ "<xsd:sequence>" +
+ "<xsd:element name='item' type='xsd:QName' minOccurs='0' maxOccurs='unbounded'/>" +
+ "</xsd:sequence>" +
+ "</xsd:complexType>" +
+ "</xsd:element>" +
+ "</xsd:schema>";
+
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+
+ String xml = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<qnameArray xmlns='http://www.jboss.org/test/xml/qname'>";
+ for(int i = 0; i < arr.length; ++i)
+ {
+ xml += "<item xmlns:" +
+ arr[i].getPrefix() +
+ "='" +
+ arr[i].getNamespaceURI() +
+ "'>" +
+ arr[i].getPrefix() +
+ ":" +
+ arr[i].getLocalPart() +
+ "</item>";
+ }
+ xml += "</qnameArray>";
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ QName[] unmarshalled = (QName[])unmarshaller.unmarshal(new StringReader(xml), schema);
+
+ assertNotNull(unmarshalled);
+ assertEquals(arr.length, unmarshalled.length);
+ for(int i = 0; i < arr.length; ++i)
+ {
+ assertEquals(arr[i], unmarshalled[i]);
+ }
+
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ marshaller.declareNamespace(null, "http://www.jboss.org/test/xml/qname");
+ MappingObjectModelProvider provider = getProvider();
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(xsd), provider, unmarshalled, writer);
+
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(xml, marshalled);
+ }
+
+ // Inner
+
+ public static class ArrayWrapper
+ {
+ public long[] primitives;
+ public Long[] wrappers;
+
+ public ArrayWrapper()
+ {
+ }
+
+ public ArrayWrapper(long[] primitives)
+ {
+ this.primitives = primitives;
+ }
+
+ public ArrayWrapper(Long[] wrappers)
+ {
+ this.wrappers = wrappers;
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/BooleanPatternUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/BooleanPatternUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/BooleanPatternUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,170 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45337 $</tt>
+ */
+public class BooleanPatternUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String XSD = "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/patterns'" +
+ " xmlns='http://www.jboss.org/test/xml/patterns'" +
+ " elementFormDefault='qualified'" +
+ " xmlns:jbxb='" +
+ Constants.NS_JBXB +
+ "'" +
+ " version='1.0'>" +
+ "<xsd:element name='e'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" +
+ E.class.getName() +
+ "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:complexType>" +
+ " <xsd:sequence>" +
+ " <xsd:element name='eTrue10' type='bool10'/>" +
+ " <xsd:element name='eFalse10' type='bool10'/>" +
+ " <xsd:element name='eTrueTF' type='boolTrueFalse'/>" +
+ " <xsd:element name='eFalseTF' type='boolTrueFalse'/>" +
+ " </xsd:sequence>" +
+ " <xsd:attribute name='aTrueTF' type='boolTrueFalse'/>" +
+ " <xsd:attribute name='aFalseTF' type='boolTrueFalse'/>" +
+ " <xsd:attribute name='aTrue10' type='bool10'/>" +
+ " <xsd:attribute name='aFalse10' type='bool10'/>" +
+ " </xsd:complexType>" +
+ "</xsd:element>" +
+ "<xsd:simpleType name='bool10'>" +
+ " <xsd:restriction base='xsd:boolean'>" +
+ " <xsd:pattern value='0|1'/>" +
+ " </xsd:restriction>" +
+ "</xsd:simpleType>" +
+ "<xsd:simpleType name='boolTrueFalse'>" +
+ " <xsd:restriction base='xsd:boolean'>" +
+ " <xsd:pattern value='true|false'/>" +
+ " </xsd:restriction>" +
+ "</xsd:simpleType>" +
+ "</xsd:schema>";
+
+ private static SchemaBinding SCHEMA;
+
+ private static final String XML =
+ "<e xmlns='http://www.jboss.org/test/xml/patterns' aTrueTF='true' aFalseTF='false' aTrue10='1' aFalse10='0'>" +
+ "<eTrue10>1</eTrue10>" +
+ "<eFalse10>0</eFalse10>" +
+ "<eTrueTF>true</eTrueTF>" +
+ "<eFalseTF>false</eFalseTF>" +
+ "</e>";
+
+ public BooleanPatternUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void configureLogging()
+ {
+ if(SCHEMA == null)
+ {
+ SCHEMA = XsdBinder.bind(new StringReader(XSD), null);
+ SCHEMA.setIgnoreUnresolvedFieldOrClass(false);
+ }
+ }
+
+ public void testUnmarshalling() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML), SCHEMA);
+ assertNotNull(o);
+ assertTrue(o instanceof E);
+ E e = (E)o;
+ assertTrue(e.aTrue10);
+ assertFalse(e.aFalse10);
+ assertTrue(e.aTrueTF);
+ assertFalse(e.aFalseTF);
+ assertTrue(e.eTrue10);
+ assertFalse(e.eFalse10);
+ assertTrue(e.eTrueTF);
+ assertFalse(e.eFalseTF);
+ }
+
+ public void testMarshallingXerces() throws Exception
+ {
+ StringWriter writer = new StringWriter();
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ marshaller.marshal(new StringReader(XSD), new MappingObjectModelProvider(), E.INSTANCE, writer);
+ String xml = writer.getBuffer().toString();
+ assertXmlEqual(XML, xml);
+ }
+
+ public void testMarshallingSunday() throws Exception
+ {
+ StringWriter writer = new StringWriter();
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ marshaller.marshal(SCHEMA, null, E.INSTANCE, writer);
+ String xml = writer.getBuffer().toString();
+ assertXmlEqual(XML, xml);
+ }
+
+ // Inner
+
+ public static final class E
+ {
+ public static final E INSTANCE;
+
+ static
+ {
+ E e = new E();
+ e.aTrue10 = true;
+ e.aTrueTF = true;
+ e.eTrue10 = true;
+ e.eTrueTF = true;
+ INSTANCE = e;
+ }
+
+ public boolean aTrue10;
+ public boolean aFalse10;
+ public boolean aTrueTF;
+ public boolean aFalseTF;
+ public boolean eTrue10;
+ public boolean eFalse10;
+ public boolean eTrueTF;
+ public boolean eFalseTF;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/CollectionsUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/CollectionsUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/CollectionsUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,437 @@
+/*
+ * 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.xml;
+
+import java.io.FileReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+import javax.xml.namespace.QName;
+import org.jboss.test.xml.collections.Collections;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 56874 $</tt>
+ */
+public class CollectionsUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String LIST_TYPE_XSD = "<xsd:schema xmlns:xsd='" +
+ Constants.NS_XML_SCHEMA +
+ "'" +
+ " targetNamespace='http://jboss.org/test/xml/list'" +
+ " xmlns='http://jboss.org/test/xml/list'" +
+ " xmlns:jbxb='" +
+ Constants.NS_JBXB +
+ "'>" +
+ " <xsd:element name='e'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" +
+ ListWrapper.class.getName() +
+ "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:complexType>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:characters>" +
+ " <jbxb:property name='field2'/>" +
+ " </jbxb:characters>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:simpleContent>" +
+ " <xsd:extension base='booleanList'>" +
+ " <xsd:attribute name='field1'>" +
+ " <xsd:simpleType>" +
+ " <xsd:list itemType='xsd:string'/>" +
+ " </xsd:simpleType>" +
+ " </xsd:attribute>" +
+ " <xsd:attribute name='field3'>" +
+ " <xsd:simpleType>" +
+ " <xsd:list itemType='xsd:QName'/>" +
+ " </xsd:simpleType>" +
+ " </xsd:attribute>" +
+ " </xsd:extension>" +
+ " </xsd:simpleContent>" +
+ " </xsd:complexType>" +
+ " </xsd:element>" +
+ " <xsd:simpleType name='booleanList'>" +
+ " <xsd:list itemType='xsd:boolean'/>" +
+ " </xsd:simpleType>" +
+ "</xsd:schema>";
+
+ private static final String LIST_TYPE_XML = "<e xmlns='http://jboss.org/test/xml/list'" +
+ " field1='str1 str2 str3'>true false true</e>";
+
+ private static final String LIST_TYPE_QNAME_ARR_XML = "<e xmlns='http://jboss.org/test/xml/list'" +
+ " xmlns:ns1='http://ns1' xmlns:ns2='http://ns2' xmlns:ns3='http://ns3'" +
+ " field3='ns1:name1 ns2:name2 ns3:name3'/>";
+
+ private static final String MULTIDIM_ARR_XML = "<arr xmlns='http://www.jboss.org/test/xml/arr' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
+ " <item>" +
+ " <item>s1</item>" +
+ " </item>" +
+ " <item>" +
+ " <item>s2</item>" +
+ " <item>s3</item>" +
+ " </item>" +
+ " <item>" +
+ " <item xsi:nil='1'/>" +
+ " </item>" +
+ " <item xsi:nil='1'/>" +
+ "</arr>";
+
+ private static final String[][] MULTIDIM_ARR = new String[][]
+ {
+ new String[]{"s1"},
+ new String[]{"s2", "s3"},
+ new String[]{null},
+ null
+ };
+
+ public CollectionsUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+/*
+ protected void configureLogging()
+ {
+ enableTrace("org.jboss.xb.binding");
+ }
+*/
+
+ public void testUnmarshalling() throws Exception
+ {
+ String xml = getFullPath("xml/collections.xml");
+ Reader xmlReader = new FileReader(xml);
+ unmarshalCollections(xmlReader);
+ }
+
+ public void testMarshalling() throws Exception
+ {
+ String ns = "http://www.jboss.org/test/xml/collections";
+
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.addRootElement(new QName(ns, "collections"));
+ marshaller.setRootTypeQName(new QName(ns, "collections"));
+ marshaller.declareNamespace(null, ns);
+
+ String xsd = getFullPath("xml/collections.xsd");
+ StringWriter xml = new StringWriter();
+ marshaller.marshal(xsd, new MappingObjectModelProvider(), Collections.getInstance(), xml);
+
+ String marshalled = xml.getBuffer().toString();
+ try
+ {
+ unmarshalCollections(new StringReader(marshalled));
+ }
+ catch(Throwable t)
+ {
+ fail("Failed to unmarshal:\n" + marshalled + "\n" + t.getMessage());
+ }
+ }
+
+ public void testMultidimArrMarshallingXerces() throws Exception
+ {
+ StringWriter writer = new StringWriter();
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.marshal(new StringReader(getMultiDimArrayXsd(false)),
+ new MappingObjectModelProvider(),
+ MULTIDIM_ARR,
+ writer
+ );
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(MULTIDIM_ARR_XML, marshalled);
+ }
+
+ public void testMultidimArrMarshallingSunday() throws Exception
+ {
+ StringWriter writer = new StringWriter();
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.marshal(new StringReader(getMultiDimArrayXsd(false)), null, MULTIDIM_ARR, writer);
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(MULTIDIM_ARR_XML, marshalled);
+ }
+
+ public void testMultidimArrayUnmarshalling() throws Exception
+ {
+ Object o = unmarshalMDArray(false);
+ assertTrue(o instanceof String[][]);
+ String[][] arr = (String[][])o;
+ assertMultidimArray(arr);
+ }
+
+ public void testAnnotatedMultiDimArray() throws Exception
+ {
+ Object o = unmarshalMDArray(true);
+ assertTrue(o instanceof ArrayWrapper);
+ String[][] arr = ((ArrayWrapper)o).arr;
+ assertMultidimArray(arr);
+ }
+
+ public void testUnmarshalListType() throws Exception
+ {
+ SchemaBinding schema = XsdBinder.bind(new StringReader(LIST_TYPE_XSD), null);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(LIST_TYPE_XML), schema);
+ assertNotNull(o);
+ assertTrue(o instanceof ListWrapper);
+ ListWrapper lists = (ListWrapper)o;
+ assertEquals(Arrays.asList(new String[]{"str1", "str2", "str3"}), lists.field1);
+ assertEquals(Arrays.asList(new Boolean[]{Boolean.TRUE, Boolean.FALSE, Boolean.TRUE}), lists.field2);
+ }
+
+ public void testMarshallingListTypeXerces() throws Exception
+ {
+ ListWrapper lists = new ListWrapper();
+ lists.field1 = Arrays.asList(new String[]{"str1", "str2", "str3"});
+ lists.field2 = Arrays.asList(new Boolean[]{Boolean.TRUE, Boolean.FALSE, Boolean.TRUE});
+
+ StringWriter writer = new StringWriter();
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+ provider.mapFieldToElement(ListWrapper.class, "field2", "http://jboss.org/test/xml/list", "e", null);
+ marshaller.marshal(new StringReader(LIST_TYPE_XSD), provider, lists, writer);
+
+ String xml = writer.getBuffer().toString();
+ assertXmlEqual(LIST_TYPE_XML, xml);
+ }
+
+ public void testMarshallingListTypeSunday() throws Exception
+ {
+ ListWrapper lists = new ListWrapper();
+ lists.field1 = Arrays.asList(new String[]{"str1", "str2", "str3"});
+ lists.field2 = Arrays.asList(new Boolean[]{Boolean.TRUE, Boolean.FALSE, Boolean.TRUE});
+
+ SchemaBinding schema = XsdBinder.bind(new StringReader(LIST_TYPE_XSD), null);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+
+ StringWriter writer = new StringWriter();
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.marshal(schema, null, lists, writer);
+
+ String xml = writer.getBuffer().toString();
+ assertXmlEqual(LIST_TYPE_XML, xml);
+ }
+
+ public void testUnmarshalListTypeToArrayField() throws Exception
+ {
+ String xml = LIST_TYPE_QNAME_ARR_XML;
+ unmarshalQNameArray(xml);
+
+ }
+
+ public void testMarshallingListTypeArrayToListXerces() throws Exception
+ {
+ ListWrapper lists = new ListWrapper();
+ lists.field3 =
+ new QName[]{new QName("http://ns1", "name1"),
+ new QName("http://ns2", "name2"),
+ new QName("http://ns3", "name3")
+ };
+
+ StringWriter writer = new StringWriter();
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+ marshaller.marshal(new StringReader(LIST_TYPE_XSD), provider, lists, writer);
+
+ String xml = writer.getBuffer().toString();
+ unmarshalQNameArray(xml);
+ }
+
+ public void testMarshallingListTypeArrayToListSunday() throws Exception
+ {
+ ListWrapper lists = new ListWrapper();
+ lists.field3 =
+ new QName[]{new QName("http://ns1", "name1"),
+ new QName("http://ns2", "name2"),
+ new QName("http://ns3", "name3")
+ };
+
+ SchemaBinding schema = XsdBinder.bind(new StringReader(LIST_TYPE_XSD), null);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+
+ StringWriter writer = new StringWriter();
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.marshal(schema, null, lists, writer);
+
+ String xml = writer.getBuffer().toString();
+ unmarshalQNameArray(xml);
+ }
+
+ // Private
+
+ private void unmarshalQNameArray(String xml)
+ throws JBossXBException
+ {
+ SchemaBinding schema = XsdBinder.bind(new StringReader(LIST_TYPE_XSD), null);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(xml), schema);
+ assertNotNull(o);
+ assertTrue(o instanceof ListWrapper);
+ ListWrapper lists = (ListWrapper)o;
+ assertNotNull(lists.field3);
+ assertEquals(3, lists.field3.length);
+ assertEquals(new QName("http://ns1", "name1"), lists.field3[0]);
+ assertEquals(new QName("http://ns2", "name2"), lists.field3[1]);
+ assertEquals(new QName("http://ns3", "name3"), lists.field3[2]);
+ }
+
+ private Object unmarshalMDArray(boolean annotations)
+ throws JBossXBException
+ {
+ String xsd = getMultiDimArrayXsd(annotations);
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ return unmarshaller.unmarshal(new StringReader(MULTIDIM_ARR_XML), schema);
+ }
+
+ private String getMultiDimArrayXsd(boolean annotations)
+ {
+ StringBuffer xsdBuf = new StringBuffer()
+ .append("<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'\n")
+ .append(" targetNamespace='http://www.jboss.org/test/xml/arr'\n")
+ .append(" xmlns='http://www.jboss.org/test/xml/arr'\n")
+ .append(" xmlns:jbxb='http://www.jboss.org/xml/ns/jbxb'\n")
+ .append(" elementFormDefault='qualified'\n")
+ .append(" version='1.0'>\n")
+ .append(" <xsd:complexType name='strArr'>\n")
+ .append(" <xsd:sequence>\n")
+ .append(
+ " <xsd:element name='item' type='xsd:string' minOccurs='0' maxOccurs='unbounded' nillable='1'/>\n"
+ )
+ .append(" </xsd:sequence>\n")
+ .append(" </xsd:complexType>\n")
+ .append(" <xsd:complexType name='mdStrArr'>\n");
+
+ if(annotations)
+ {
+ xsdBuf
+ .append(" <xsd:annotation>\n")
+ .append(" <xsd:appinfo>\n")
+ .append(" <jbxb:class impl='" + ArrayWrapper.class.getName() + "'/>\n")
+ .append(" </xsd:appinfo>\n")
+ .append(" </xsd:annotation>\n");
+ }
+
+ xsdBuf
+ .append(" <xsd:sequence>\n")
+ .append(" <xsd:element name='item' type='strArr' minOccurs='0' maxOccurs='unbounded' nillable='1'>\n");
+
+ if(annotations)
+ {
+ xsdBuf
+ .append(" <xsd:annotation>\n")
+ .append(" <xsd:appinfo>\n")
+ .append(" <jbxb:property name='arr'/>\n")
+ .append(" </xsd:appinfo>\n")
+ .append(" </xsd:annotation>\n");
+ }
+
+ xsdBuf
+ .append(" </xsd:element>\n")
+ .append(" </xsd:sequence>\n")
+ .append(" </xsd:complexType>\n")
+ .append(" <xsd:element name='arr' type='mdStrArr'/>\n")
+ .append("</xsd:schema>");
+
+ String xsd = xsdBuf.toString();
+ return xsd;
+ }
+
+ private void assertMultidimArray(String[][] arr)
+ {
+ assertNotNull(arr);
+ assertEquals(4, arr.length);
+ assertTrue(arr[0] instanceof String[]);
+ assertEquals(1, arr[0].length);
+ assertEquals("s1", arr[0][0]);
+ assertEquals(2, arr[1].length);
+ assertEquals("s2", arr[1][0]);
+ assertEquals("s3", arr[1][1]);
+ assertTrue(arr[2] instanceof String[]);
+ assertEquals(1, arr[2].length);
+ assertNull(arr[2][0]);
+ assertNull(arr[3]);
+ }
+
+ private void unmarshalCollections(Reader xmlReader) throws JBossXBException
+ {
+ String xsd = getFullPath("xml/collections.xsd");
+ SchemaBinding schema = XsdBinder.bind(xsd);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+ String ns = "http://www.jboss.org/test/xml/collections";
+ QName rootQName = new QName(ns, "collections");
+ TypeBinding type = schema.getType(rootQName);
+ assertNotNull(type);
+ schema.addElement(rootQName, type);
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Collections collections;
+ collections = (Collections)unmarshaller.unmarshal(xmlReader, schema);
+ assertEquals(Collections.getInstance(), collections);
+ }
+
+ private String getFullPath(String name)
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(name);
+ if(url == null)
+ {
+ fail("Resource not found: " + name);
+ }
+ return url.getFile();
+ }
+
+ // Inner
+
+ public static final class ArrayWrapper
+ {
+ public String[][] arr;
+ }
+
+ public static final class ListWrapper
+ {
+ public List field1;
+ public List field2;
+ public QName[] field3;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/Dom2SaxUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/Dom2SaxUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/Dom2SaxUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,90 @@
+/*
+ * 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.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.jboss.xb.util.Dom2Sax;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 41882 $</tt>
+ */
+public class Dom2SaxUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String XML =
+ "<e1 xmlns='http://ns1'" +
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
+ "e text content" +
+ " <ns2:e2 xmlns:ns2='http://ns2'/>" +
+ " <e3 xmlns='http://ns3' e3_attr1='e3a1 value'>" +
+ " <ns4:e4 xmlns:ns4='http://ns4'>e4 text content</ns4:e4>" +
+ " </e3>" +
+ "</e1>";
+
+ public Dom2SaxUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testMain() throws Exception
+ {
+ Element e1 = parse();
+
+ StringWriter writer = new StringWriter();
+ XMLSerializer ser = new XMLSerializer(writer, null);
+ ser.setNamespaces(true);
+
+ OutputFormat of = new OutputFormat();
+ of.setOmitXMLDeclaration(true);
+ ser.setOutputFormat(of);
+
+ final ContentHandler serCh = ser.asContentHandler();
+ Dom2Sax.dom2sax(e1, serCh);
+
+ assertXmlEqual(XML, writer.getBuffer().toString());
+ }
+
+ private Element parse()
+ throws ParserConfigurationException, SAXException, IOException
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+
+ Document doc = builder.parse(new ByteArrayInputStream(XML.getBytes()));
+ return (Element)doc.getFirstChild();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/EnumUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/EnumUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/EnumUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,395 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Arrays;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.Marshaller;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45337 $</tt>
+ */
+public class EnumUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private final String XSD = "<xsd:schema xmlns='http://jboss.org/ns/enum' targetNamespace='http://jboss.org/ns/enum'" +
+ " xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " xmlns:jbxb='http://www.jboss.org/xml/ns/jbxb'" +
+ " elementFormDefault='qualified'>" +
+ "<xsd:simpleType name='color'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" + Color.class.getName() + "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:restriction base='xsd:string'>" +
+ " <xsd:enumeration value='red'/>" +
+ " <xsd:enumeration value='gree'/>" +
+ " <xsd:enumeration value='blue'/>" +
+ " </xsd:restriction>" +
+ "</xsd:simpleType>" +
+ "<xsd:simpleType name='number'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" + Nmbr.class.getName() + "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:restriction base='xsd:int'>" +
+ " <xsd:enumeration value='1'/>" +
+ " <xsd:enumeration value='2'/>" +
+ " <xsd:enumeration value='3'/>" +
+ " </xsd:restriction>" +
+ "</xsd:simpleType>" +
+ "<xsd:element name='global'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" + Global.class.getName() + "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:complexType>" +
+ " <xsd:sequence>" +
+ " <xsd:element name='color' type='color' minOccurs='0'/>" +
+ " <xsd:element name='number' type='number' minOccurs='0'/>" +
+ " <xsd:element name='all' minOccurs='0' maxOccurs='unbounded'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:skip/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:complexType>" +
+ " <xsd:all>" +
+ " <xsd:element name='color' type='color' minOccurs='0'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:property name='all'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " </xsd:element>" +
+ " <xsd:element name='number' type='number' minOccurs='0'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:property name='all'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " </xsd:element>" +
+ " </xsd:all>" +
+ " </xsd:complexType>" +
+ " </xsd:element>" +
+ " </xsd:sequence>" +
+ " </xsd:complexType>" +
+ "</xsd:element>" +
+ "</xsd:schema>";
+
+ private final String XML_SIMPLE =
+ "<global xmlns='http://jboss.org/ns/enum'>" +
+ "<color>red</color>" +
+ "<number>1</number>" +
+ "</global>";
+
+ private static final Global GLOBAL_SIMPLE;
+ static
+ {
+ Global simple = new Global();
+ simple.color = Color.RED;
+ simple.number = Nmbr.ONE;
+ GLOBAL_SIMPLE = simple;
+ }
+
+ private final String XML_ALL =
+ "<global xmlns='http://jboss.org/ns/enum'>" +
+ " <all>" +
+ " <number>3</number>" +
+ " <color>green</color>" +
+ " </all>" +
+ " <all>" +
+ " <color>blue</color>" +
+ " <number>1</number>" +
+ " </all>" +
+ " <all>" +
+ " <color>red</color>" +
+ " <number>2</number>" +
+ " </all>" +
+ "</global>";
+
+ private static final Global GLOBAL_ALL;
+
+ static
+ {
+ Global all = new Global();
+ all.all = Arrays.asList(new Object[]{Nmbr.THREE, Color.GREEN, Color.BLUE, Nmbr.ONE, Color.RED, Nmbr.TWO});
+ GLOBAL_ALL = all;
+ }
+
+ public EnumUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testSimpleUnmarshalling() throws Exception
+ {
+ SchemaBinding schema = XsdBinder.bind(new StringReader(XSD), null);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML_SIMPLE), schema);
+
+ assertEquals(GLOBAL_SIMPLE, o);
+ }
+
+ public void testSimpleMarshallingSunday() throws Exception
+ {
+ SchemaBinding schema = XsdBinder.bind(new StringReader(XSD), null);
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(schema, null, GLOBAL_SIMPLE, writer);
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(XML_SIMPLE, marshalled);
+ }
+
+ public void testSimpleMarshallingXerces() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), new MappingObjectModelProvider(), GLOBAL_SIMPLE, writer);
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(XML_SIMPLE, marshalled);
+ }
+
+ public void testAllUnmarshalling() throws Exception
+ {
+ SchemaBinding schema = XsdBinder.bind(new StringReader(XSD), null);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML_ALL), schema);
+
+ assertEquals(GLOBAL_ALL, o);
+ }
+
+ // Private
+
+ public static final class Global
+ {
+ public Color color;
+ public Nmbr number;
+ public List all;
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Global))
+ {
+ return false;
+ }
+
+ final Global global = (Global)o;
+
+ if(all != null ? !all.equals(global.all) : global.all != null)
+ {
+ return false;
+ }
+ if(color != null ? !color.equals(global.color) : global.color != null)
+ {
+ return false;
+ }
+ if(number != null ? !number.equals(global.number) : global.number != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (color != null ? color.hashCode() : 0);
+ result = 29 * result + (number != null ? number.hashCode() : 0);
+ result = 29 * result + (all != null ? all.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return color + " " + number + ", all=" + all;
+ }
+ }
+
+ public static final class Color
+ {
+ private static final String RED_VALUE = "red";
+ private static final String GREEN_VALUE = "green";
+ private static final String BLUE_VALUE = "blue";
+
+ public static final Color RED = new Color(RED_VALUE);
+ public static final Color GREEN = new Color(GREEN_VALUE);
+ public static final Color BLUE = new Color(BLUE_VALUE);
+
+ public static Color fromValue(String value)
+ {
+ Color color;
+ if(RED_VALUE.equals(value))
+ {
+ color = RED;
+ }
+ else if(GREEN_VALUE.equals(value))
+ {
+ color = GREEN;
+ }
+ else if(BLUE_VALUE.equals(value))
+ {
+ color = BLUE;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Not supported value: " + value);
+ }
+ return color;
+ }
+
+ private final String value;
+
+ private Color(String value)
+ {
+ this.value = value;
+ }
+
+ public String value()
+ {
+ return value;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Color))
+ {
+ return false;
+ }
+
+ final Color color = (Color)o;
+
+ if(!value.equals(color.value))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+
+ public String toString()
+ {
+ return "COLOR " + value;
+ }
+ }
+
+ public static final class Nmbr
+ {
+ public static final Nmbr ONE = new Nmbr(1);
+ public static final Nmbr TWO = new Nmbr(2);
+ public static final Nmbr THREE = new Nmbr(3);
+
+ public static Nmbr fromValue(int value)
+ {
+ Nmbr nmbr;
+ switch(value)
+ {
+ case 1:
+ nmbr = ONE;
+ break;
+ case 2:
+ nmbr = TWO;
+ break;
+ case 3:
+ nmbr = THREE;
+ break;
+ default:
+ throw new IllegalArgumentException("Not supported value: " + value);
+ }
+ return nmbr;
+ }
+
+ private final int value;
+
+ private Nmbr(int value)
+ {
+ this.value = value;
+ }
+
+ public int value()
+ {
+ return value;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Nmbr))
+ {
+ return false;
+ }
+
+ final Nmbr nmbr = (Nmbr)o;
+
+ if(value != nmbr.value)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return value;
+ }
+
+ public String toString()
+ {
+ return "NUMBER " + value;
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/ExceptionUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/ExceptionUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/ExceptionUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,160 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 41107 $</tt>
+ */
+public class ExceptionUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String XSD =
+ "<schema targetNamespace='http://jboss.org/xml/test/exc'" +
+ " elementFormDefault='qualified'" +
+ " xmlns:tns='http://jboss.org/xml/test/exc'" +
+ " xmlns:jbxb='" + Constants.NS_JBXB + "'" +
+ " xmlns='http://www.w3.org/2001/XMLSchema'>" +
+ " <complexType name='ExceptionType'>" +
+ " <annotation>" +
+ " <appinfo>" +
+ " <jbxb:class impl='" + Exception.class.getName() + "'/>" +
+ " </appinfo>" +
+ " </annotation>" +
+ " <sequence>" +
+ " <element name='message' type='string' minOccurs='0' maxOccurs='1'/>" +
+ " <element name='cause' type='tns:ExceptionType' minOccurs='0' maxOccurs='1'/>" +
+ " </sequence>" +
+ " </complexType>" +
+ " <element name='exc' type='tns:ExceptionType'/>" +
+ "</schema>";
+
+ private static final String EXC_XML =
+ "<exc xmlns='http://jboss.org/xml/test/exc'/>";
+
+ private static final String EXC_MSG_XML =
+ "<exc xmlns='http://jboss.org/xml/test/exc'>" +
+ " <message>didn't work</message>" +
+ "</exc>";
+
+ private static final String EXC_CAUSE_XML =
+ "<exc xmlns='http://jboss.org/xml/test/exc'>" +
+ " <cause>" +
+ " <message>didn't work</message>" +
+ " </cause>" +
+ "</exc>";
+
+ private static final String EXC_MSG_CAUSE_XML =
+ "<exc xmlns='http://jboss.org/xml/test/exc'>" +
+ " <message>see cause</message>" +
+ " <cause>" +
+ " <message>didn't work</message>" +
+ " </cause>" +
+ "</exc>";
+
+ private static SchemaBinding SCHEMA;
+
+ static
+ {
+/*
+ Validator.assertValidXml(XSD, EXC_XML);
+ Validator.assertValidXml(XSD, EXC_MSG_XML);
+ Validator.assertValidXml(XSD, EXC_CAUSE_XML);
+ Validator.assertValidXml(XSD, EXC_MSG_CAUSE_XML);
+*/
+ }
+
+ public ExceptionUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void configureLogging()
+ {
+ //enableTrace(XsdBinder.class.getName());
+ if(SCHEMA == null)
+ {
+ SCHEMA = XsdBinder.bind(new StringReader(XSD), null);
+ }
+ }
+
+ public void testUnmarshallingExcXml() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(EXC_XML), SCHEMA);
+
+ assertNotNull(o);
+ assertTrue(o instanceof Exception);
+ Exception e = (Exception)o;
+ assertNull(e.getMessage());
+ assertNull(e.getCause());
+ }
+
+ public void testUnmarshallingExcMsgXml() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(EXC_MSG_XML), SCHEMA);
+
+ assertNotNull(o);
+ assertTrue(o instanceof Exception);
+ Exception e = (Exception)o;
+ assertEquals("didn't work", e.getMessage());
+ assertNull(e.getCause());
+ }
+
+ public void testUnmarshallingExcCauseXml() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(EXC_CAUSE_XML), SCHEMA);
+
+ assertNotNull(o);
+ assertTrue(o instanceof Exception);
+ Exception e = (Exception)o;
+ assertEquals("java.lang.Exception: didn't work", e.getMessage());
+ assertNotNull(e.getCause());
+ e = (Exception)e.getCause();
+ assertEquals("didn't work", e.getMessage());
+ assertNull(e.getCause());
+ }
+
+ public void testUnmarshallingExcMsgCauseXml() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(EXC_MSG_CAUSE_XML), SCHEMA);
+
+ assertNotNull(o);
+ assertTrue(o instanceof Exception);
+ Exception e = (Exception)o;
+ assertEquals("see cause", e.getMessage());
+ assertNotNull(e.getCause());
+ e = (Exception)e.getCause();
+ assertEquals("didn't work", e.getMessage());
+ assertNull(e.getCause());
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/IntrospectionUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/IntrospectionUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/IntrospectionUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,161 @@
+/*
+ * 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.xml;
+
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+import java.beans.IntrospectionException;
+
+import org.jboss.xb.binding.introspection.ClassInfo;
+import org.jboss.xb.binding.introspection.ClassInfos;
+import org.jboss.xb.binding.introspection.FieldInfo;
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 56570 $</tt>
+ */
+public class IntrospectionUnitTestCase
+ extends TestCase
+{
+ public IntrospectionUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void testClassInfoNANonRequired() throws Exception
+ {
+ assertNull(ClassInfos.getClassInfo("na.package.A", false));
+ }
+
+ public void testClassInfoNARequired() throws Exception
+ {
+ try
+ {
+ ClassInfos.getClassInfo("na.package.B", true);
+ fail("Exception must be thrown for not available ClassInfo.");
+ }
+ catch(RuntimeException e)
+ {
+ }
+ }
+
+ public void testFieldInfoNANonRequired() throws Exception
+ {
+ ClassInfo classInfo = ClassInfos.getClassInfo(A.class);
+ assertNull(classInfo.getFieldInfo("field99", false));
+ }
+
+ public void testFieldInfoNARequired() throws Exception
+ {
+ ClassInfo classInfo = ClassInfos.getClassInfo(A.class);
+ try
+ {
+ classInfo.getFieldInfo("field99", true);
+ fail("Exception must be thrown for not availble FieldInfo.");
+ }
+ catch(RuntimeException e)
+ {
+ }
+ }
+
+ public void testGetterSetterAccess() throws Exception
+ {
+ FieldInfo fieldInfo = ClassInfos.getClassInfo(A.class).getFieldInfo("field1", true);
+ A a = new A();
+ assertNull(fieldInfo.getValue(a));
+ a.setField1("val1");
+ assertEquals("val1", fieldInfo.getValue(a));
+ fieldInfo.setValue(a, "val2");
+ assertEquals("val2", fieldInfo.getValue(a));
+ assertEquals("val2", a.getField1());
+ }
+
+ public void testFieldAccess() throws Exception
+ {
+ FieldInfo fieldInfo = ClassInfos.getClassInfo(A.class).getFieldInfo("field2", true);
+ A a = new A();
+ assertNull(fieldInfo.getValue(a));
+ a.field2 = "val1";
+ assertEquals("val1", fieldInfo.getValue(a));
+ fieldInfo.setValue(a, "val2");
+ assertEquals("val2", fieldInfo.getValue(a));
+ assertEquals("val2", a.field2);
+ }
+ public void testReadWriteMethodAccess() throws Exception
+ {
+ FieldInfo fieldInfo = ClassInfos.getClassInfo(A.class).getFieldInfo("field3", true);
+ A a = new A();
+ assertNull(fieldInfo.getValue(a));
+ a.writeField3("val1");
+ assertEquals("val1", fieldInfo.getValue(a));
+ fieldInfo.setValue(a, "val2");
+ assertEquals("val2", fieldInfo.getValue(a));
+ assertEquals("val2", a.readField3());
+ }
+
+ public static class A
+ {
+ private String field1;
+ public String field2;
+ private String field3;
+
+ public String getField1()
+ {
+ return field1;
+ }
+
+ public void setField1(String field1)
+ {
+ this.field1 = field1;
+ }
+
+ public String readField3()
+ {
+ return field3;
+ }
+
+ public void writeField3(String field3)
+ {
+ this.field3 = field3;
+ }
+ }
+
+ public static class ABeanInfo
+ extends SimpleBeanInfo
+ {
+ public PropertyDescriptor[] getPropertyDescriptors()
+ {
+ try
+ {
+ return new PropertyDescriptor[]
+ {
+ new PropertyDescriptor("field3", A.class, "readField3", "writeField3")
+ };
+ }
+ catch(IntrospectionException e)
+ {
+ throw new IllegalStateException("Failed to create property descriptors.");
+ }
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/JbxbCharactersUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/JbxbCharactersUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/JbxbCharactersUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,181 @@
+/*
+ * 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.xml;
+
+import java.io.FileReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import org.jboss.test.BaseTestCase;
+import org.jboss.test.xml.jbxb.characters.Binding;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+
+
+/**
+ * Test unmarshalling xml documents conforming to xml/jbxb/characters/schema1.xsd
+ * into org.jboss.test.xml.jbxb.characters.Binding.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 45337 $
+ */
+public class JbxbCharactersUnitTestCase
+ extends BaseTestCase
+{
+ private static final String XML_VALUE4 =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<ns_binding:binding xmlns:ns_binding=\"urn:jboss:jbxb-characters-schema1\" name=\"root\">" +
+ "<ns_binding:value4>val4</ns_binding:value4>" +
+ "</ns_binding:binding>";
+
+ public JbxbCharactersUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+/*
+ public void configureLogging()
+ {
+ enableTrace("org.jboss.xb");
+ }
+*/
+
+ public void testMainUnmarshalling() throws Exception
+ {
+ String res = getPath("xml/jbxb/characters/testSchema1.xml").getFile();
+ FileReader xmlReader = new FileReader(res);
+
+ Binding binding = unmarshal(xmlReader);
+
+ assertEquals("Binding.name = root ", "root", binding.getName());
+ assertEquals("Binding.text = value1 ", "value1", binding.getText());
+ }
+
+ public void testValue2Unmarshalling() throws Exception
+ {
+ StringReader xmlReader = new StringReader("<?xml version='1.0' encoding='UTF-8'?>" +
+ "<binding xmlns='urn:jboss:jbxb-characters-schema1'" +
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
+ " xsi:schemaLocation='urn:jboss:jbxb-characters-schema1 schema1.xsd'" +
+ " name='root'>" +
+ " <value2>value2</value2>" +
+ "</binding>"
+ );
+
+ Binding binding = unmarshal(xmlReader);
+
+ assertEquals("Binding.name = root ", "root", binding.getName());
+ Binding.Value2 value2 = binding.getValue2();
+ assertNotNull(value2);
+ assertEquals("Binding.text2 = value2 ", "value2", value2.text);
+ }
+
+ public void testValue3Unmarshalling() throws Exception
+ {
+ StringReader xmlReader = new StringReader("<?xml version='1.0' encoding='UTF-8'?>" +
+ "<binding xmlns='urn:jboss:jbxb-characters-schema1'" +
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
+ " xsi:schemaLocation='urn:jboss:jbxb-characters-schema1 schema1.xsd'" +
+ " name='root'>" +
+ " <value3 attr='attr'>value3</value3>" +
+ "</binding>"
+ );
+
+ Binding binding = unmarshal(xmlReader);
+
+ assertEquals("Binding.name = root ", "root", binding.getName());
+ Binding.Value3 value3 = binding.getValue3();
+ assertNotNull(value3);
+ assertEquals("value3", value3.chars);
+ assertEquals("attr", value3.attr);
+ }
+
+ public void testValue4Unmarshalling() throws Exception
+ {
+ Binding binding = unmarshal(new StringReader(XML_VALUE4));
+ assertEquals("Binding.name = root ", "root", binding.getName());
+ Binding.Value4 value4 = binding.value4;
+ assertNotNull(value4);
+ assertEquals("val4", value4.value);
+
+ }
+
+ public void testValue4MarshallingXerces() throws Exception
+ {
+ Binding binding = new Binding();
+ binding.setName("root");
+ binding.value4 = new Binding.Value4("val4");
+ StringWriter writer = new StringWriter();
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ String file = getPath("xml/jbxb/characters/schema1.xsd").getFile();
+ marshaller.marshal(new FileReader(file), new MappingObjectModelProvider(), binding, writer);
+ String xml = writer.getBuffer().toString();
+ assertEquals(XML_VALUE4, xml);
+ }
+
+ public void testValue4MarshallingSunday() throws Exception
+ {
+ Binding binding = new Binding();
+ binding.setName("root");
+ binding.value4 = new Binding.Value4("val4");
+ StringWriter writer = new StringWriter();
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ String file = getPath("xml/jbxb/characters/schema1.xsd").getFile();
+ marshaller.marshal(new FileReader(file), new MappingObjectModelProvider(), binding, writer);
+ String xml = writer.getBuffer().toString();
+ assertEquals(XML_VALUE4, xml);
+ }
+
+ // Private
+
+ private Binding unmarshal(Reader xmlReader)
+ throws JBossXBException
+ {
+ String url = getPath("xml/jbxb/characters/schema1.xsd").toExternalForm();
+ SchemaBinding schemaBinding = XsdBinder.bind(url);
+ schemaBinding.setIgnoreUnresolvedFieldOrClass(true);
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Binding binding = (Binding)unmarshaller.unmarshal(xmlReader, schemaBinding);
+ return binding;
+ }
+
+ private URL getPath(String path)
+ {
+ java.net.URL url = Thread.currentThread().getContextClassLoader().getResource(path);
+ if(url == null)
+ {
+ fail("URL not found: " + path);
+ }
+ return url;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/JbxbPojoServerUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/JbxbPojoServerUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/JbxbPojoServerUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,70 @@
+/*
+ * 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.xml;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37728 $</tt>
+ */
+public class JbxbPojoServerUnitTestCase
+ extends PojoServerTestBase
+{
+ public JbxbPojoServerUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ protected SchemaBinding getSchemaBinding()
+ {
+ SchemaBinding cursor = readXsd();
+/** TODO
+ TypeBinding namedValueType = cursor.getType(namedValueTypeQName);
+
+ //
+ // add handlers
+ //
+
+ namedValueType.pushInterceptor(propsQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName qName)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)parent;
+ Map children = (Map)child;
+ for(Iterator i = children.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ prop.setValue((String)entry.getKey(), entry.getValue());
+ }
+ }
+ }
+ );
+*/
+ return cursor;
+ }
+
+ protected String getXsd()
+ {
+ return "xml/jbxb-bean-deployer_1_0.xsd";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/MappingTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/MappingTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/MappingTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,295 @@
+/*
+ * 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.xml;
+
+import org.jboss.logging.Logger;
+import org.jboss.xb.binding.DtdMarshaller;
+import org.jboss.xb.binding.MappingObjectModelFactory;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.SimpleTypeBindings;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.jboss.test.xml.person.Address;
+import org.jboss.test.xml.person.Person;
+import org.jboss.test.xml.choice.Root;
+import org.jboss.test.xml.choice.Choice2;
+import org.jboss.test.xml.choice.Choice1;
+import org.jboss.test.xml.immutable.Child1;
+import org.jboss.test.xml.immutable.Child2;
+import org.jboss.test.xml.immutable.Child3;
+import org.jboss.test.xml.immutable.Parent;
+import org.jboss.test.xml.immutable.ImmutableChoice;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import junit.framework.TestCase;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.io.Reader;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.net.URL;
+
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 57179 $</tt>
+ */
+public class MappingTestCase
+ extends TestCase
+{
+ private static final Logger log = Logger.getLogger(MappingTestCase.class);
+
+ public MappingTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testUnmarshalling() throws Exception
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource("xml/person.xml");
+ if(url == null)
+ {
+ fail("the xml not found");
+ }
+
+ Reader xmlReader = new java.io.InputStreamReader(url.openStream());
+
+ Person person = unmarshalPerson(xmlReader);
+ xmlReader.close();
+
+ assertNotNull("Person is null", person);
+ assertEquals(person.getFirstName(), "Vasiliy");
+ assertEquals(person.getLastName(), "Poupkin");
+ assertEquals(person.getDateOfBirth(), SimpleTypeBindings.JAVA_UTIL_DATE.unmarshal("1980-01-01"));
+
+ assertEquals(person.getPhones(), Arrays.asList(new Object[]{"01", "02"}));
+
+ ArrayList list = new ArrayList();
+ Address addr1 = new Address();
+ addr1.setStreet("prosp. Rad. Ukr. 11A, 70");
+ list.add(addr1);
+ addr1 = new Address();
+ addr1.setStreet("Sky 7");
+ list.add(addr1);
+ assertEquals(person.getAddresses(), list);
+ }
+
+ public void testMarshalling() throws Exception
+ {
+ log.debug("<test-mapping-marshalling>");
+
+ final Person person = Person.newInstance();
+ StringWriter xmlOutput = new StringWriter();
+
+ InputStream is = getResource("xml/person.dtd");
+ Reader dtdReader = new InputStreamReader(is);
+
+ // create an instance of DTD marshaller
+ Marshaller marshaller = new DtdMarshaller();
+
+ // map publicId to systemId as it should appear in the resulting XML file
+ marshaller.mapPublicIdToSystemId("-//DTD Person//EN", "resources/xml/person.dtd");
+
+ // create an instance of ObjectModelProvider with the book instance to be marshalled
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+ provider.mapFieldToElement(Person.class, "dateOfBirth", "", "date-of-birth", SimpleTypeBindings.JAVA_UTIL_DATE);
+
+ // marshal the book
+ marshaller.marshal(dtdReader, provider, person, xmlOutput);
+
+ // close DTD reader
+ dtdReader.close();
+
+ final String xml = xmlOutput.getBuffer().toString();
+ log.debug("marshalled: " + xml);
+
+ // check unmarshalled person
+ Person unmarshalled = unmarshalPerson(new StringReader(xml));
+ assertEquals(person, unmarshalled);
+
+ log.debug("</test-mapping-marshalling>");
+ }
+
+ public void testChoice() throws Exception
+ {
+ log.debug("testChoice> started");
+ long startTime = System.currentTimeMillis();
+
+ String xsdUrl = getXsd("xml/choice.xsd");
+ Root root = newChoiceRoot();
+ String xml = marshalChoiceRoot(xsdUrl, root);
+
+ StringReader reader = new StringReader(xml);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Root unmarshalled = (Root)unmarshaller.unmarshal(reader, new MappingObjectModelFactory(), null);
+ log.info("unmarhalled:\n" + unmarshalled);
+
+ assertEquals(root, unmarshalled);
+
+ log.debug("testChoice> done in " + (System.currentTimeMillis() - startTime));
+ }
+
+ public void testImmutable() throws Exception
+ {
+ log.debug("testImmutable> started");
+ long startTime = System.currentTimeMillis();
+
+ String xsd = getXsd("xml/immutable.xsd");
+
+ Parent parent = newImmutableParent();
+ String xml = marshalImmutableParent(xsd, parent);
+
+ StringReader reader = new StringReader(xml);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Parent unmarshalled = (Parent)unmarshaller.unmarshal(reader, new MappingObjectModelFactory(), null);
+ log.info("unmarhalled:\n" + unmarshalled);
+
+ assertEquals(parent, unmarshalled);
+
+ log.debug("testImmutable> done in " + (System.currentTimeMillis() - startTime));
+ }
+
+ // Private
+
+ private String marshalImmutableParent(String xsd, Parent parent)
+ throws IOException, SAXException
+ {
+ StringWriter writer = new StringWriter();
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.declareNamespace("imm", "http://www.jboss.org/test/xml/immutable/");
+ marshaller.marshal(xsd,
+ new MappingObjectModelProvider(),
+ parent,
+ writer
+ );
+
+ log.info("parent:\n" + parent);
+ log.info("marshalled root:\n" + writer.getBuffer());
+ return writer.getBuffer().toString();
+ }
+
+ private Parent newImmutableParent()
+ {
+ Child1 child1 = new Child1("child1");
+ List child2 = Arrays.asList(new Object[]{new Child2("child2_1"), new Child2("child2_2")});
+ List others = Arrays.asList(new Object[]{new Child3("child3_1"), new Child3("child3_2"), new Child3("child3_3")});
+ List choice = Arrays.asList(
+ new Object[]{new ImmutableChoice("choice1"), new ImmutableChoice(new Child1("child1"))}
+ );
+ Parent parent = new Parent(child1, child2, others, choice);
+ return parent;
+ }
+
+ private static String getXsd(String path)
+ {
+ URL xsdUrl = Thread.currentThread().getContextClassLoader().getResource(path);
+ if(xsdUrl == null)
+ {
+ throw new IllegalStateException("XSD not found: " + path);
+ }
+ return xsdUrl.getFile();
+ }
+
+ private static String marshalChoiceRoot(String xsdUrl, Root root)
+ throws IOException, SAXException
+ {
+ StringWriter writer = new StringWriter();
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.declareNamespace("chs", "http://www.jboss.org/test/xml/choice/");
+ //marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ marshaller.marshal(xsdUrl,
+ new MappingObjectModelProvider(),
+ root,
+ writer
+ );
+
+ log.info("marshalled root:\n" + writer.getBuffer());
+ return writer.getBuffer().toString();
+ }
+
+ private static Root newChoiceRoot()
+ {
+ String a = "a";
+ String b = "b";
+ String c = "c";
+
+ List choice1 = Arrays.asList(new Choice1[]{new Choice1(a, null), new Choice1(null, b)});
+ List choice2 = Arrays.asList(new Choice2[]{new Choice2(a, b, null), new Choice2(a, null, c)});
+
+ Root root = new Root();
+ root.setChoice1(choice1);
+ root.setChoice2(choice2);
+ return root;
+ }
+
+ private Person unmarshalPerson(Reader xmlReader)
+ throws Exception
+ {
+ MappingObjectModelFactory factory = new MappingObjectModelFactory();
+ factory.mapElementToClass("person", Person.class);
+ factory.mapElementToField("date-of-birth", Person.class, "dateOfBirth", SimpleTypeBindings.JAVA_UTIL_DATE);
+ factory.mapElementToClass("phones", ArrayList.class);
+ factory.mapElementToClass("addresses", ArrayList.class);
+ factory.mapElementToClass("address", Address.class);
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ unmarshaller.setEntityResolver(
+ new EntityResolver()
+ {
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+ {
+ if(systemId.endsWith("person.dtd"))
+ {
+ InputStream dtdIs = Thread.currentThread().getContextClassLoader().getResourceAsStream("xml/person.dtd");
+ if(dtdIs == null)
+ {
+ fail("The person.dtd could not be found.");
+ }
+ return new InputSource(dtdIs);
+ }
+ return null;
+ }
+ }
+ );
+
+ return (Person)unmarshaller.unmarshal(xmlReader, factory, null);
+ }
+
+ private static InputStream getResource(String name)
+ {
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
+ if(is == null)
+ {
+ throw new IllegalStateException("Resource not found: " + name);
+ }
+ return is;
+ }
+}
\ No newline at end of file
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/MapsUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/MapsUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/MapsUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,390 @@
+/*
+ * 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.xml;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.CharactersHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementInterceptor;
+import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.ParticleHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SequenceBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.xml.sax.Attributes;
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class MapsUnitTestCase
+ extends TestCase
+{
+ private static final String NS = "http://www.jboss.org/test/xml/maps";
+ private static final QName QNAME_MAP = new QName(NS, "map");
+ private static final QName QNAME_SUBMAP = new QName(NS, "submap");
+ private static final QName QNAME_ENTRY1 = new QName(NS, "entry1");
+ private static final QName QNAME_ENTRY2 = new QName(NS, "entry2");
+ private static final QName QNAME_ENTRY3 = new QName(NS, "entry3");
+ private static final QName QNAME_ENTRY4 = new QName(NS, "entry4");
+ private static final QName QNAME_KEY1 = new QName(NS, "key1");
+ private static final QName QNAME_VALUE1 = new QName(NS, "value1");
+ private static final QName QNAME_VALUE2 = new QName(NS, "value2");
+
+ private static final Map EXPECTED;
+
+ static
+ {
+ Map expected = new HashMap();
+ expected.put("key1", "value1");
+ expected.put("key2", "value2");
+ expected.put("key3", "value3");
+ expected.put("key4", "value4");
+ expected.put("key_1", "value_1");
+ expected.put("key_2", "value_2");
+ expected.put("submap", Collections.singletonMap("submapKey", "submapValue"));
+ EXPECTED = expected;
+ }
+
+ public MapsUnitTestCase()
+ {
+ }
+
+ public MapsUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void testXsd() throws Exception
+ {
+ SchemaBinding schema = XsdBinder.bind(getFullPath("xml/maps.xsd"));
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object map = unmarshaller.unmarshal(getFullPath("xml/maps.xml"), schema);
+
+ assertNotNull(map);
+ assertTrue(map instanceof Map);
+
+ assertEquals(EXPECTED, map);
+ }
+
+ public void testManual() throws Exception
+ {
+ SchemaBinding schema = new SchemaBinding();
+
+ // Type declarations
+ TypeBinding mapType = new TypeBinding();
+ // default model group is all, we want sequence
+ mapType.setParticle(new ParticleBinding(new SequenceBinding(schema)));
+
+ TypeBinding entry1Type = new TypeBinding();
+ TypeBinding entry2Type = new TypeBinding();
+ TypeBinding entry3Type = new TypeBinding();
+ TypeBinding entry4Type = new TypeBinding();
+
+ // Schema assembling
+ mapType.addElement(QNAME_ENTRY1, entry1Type, 0, true);
+ mapType.addElement(QNAME_ENTRY2, entry2Type, 0, true);
+ mapType.addElement(QNAME_ENTRY3, entry3Type, 0, true);
+ mapType.addElement(QNAME_ENTRY4, entry4Type, 0, true);
+
+ // sequence as entry
+ SequenceBinding entrySeq = new SequenceBinding(schema);
+ ElementBinding keyElement = new ElementBinding(schema, new QName(NS, "key"), new TypeBinding());
+ entrySeq.addParticle(new ParticleBinding(keyElement));
+ ElementBinding valueElement = new ElementBinding(schema, new QName(NS, "value"), new TypeBinding());
+ entrySeq.addParticle(new ParticleBinding(valueElement));
+
+ ParticleBinding entryParticle = new ParticleBinding(entrySeq);
+ entryParticle.setMinOccurs(0);
+ entryParticle.setMaxOccursUnbounded(true);
+ mapType.addParticle(entryParticle);
+
+ mapType.addElement(QNAME_SUBMAP, mapType, 0, true);
+ schema.addElement(QNAME_MAP, mapType);
+
+ // Handler implementations
+ mapType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new HashMap();
+ }
+ }
+ );
+
+ ElementInterceptor addMapEntryInterceptor = new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Map map = (Map)parent;
+ Object[] arr = (Object[])child;
+ map.put(arr[0], arr[1]);
+ }
+ };
+ mapType.pushInterceptor(QNAME_ENTRY1, addMapEntryInterceptor);
+ mapType.pushInterceptor(QNAME_ENTRY2, addMapEntryInterceptor);
+ mapType.pushInterceptor(QNAME_ENTRY3, addMapEntryInterceptor);
+ mapType.pushInterceptor(QNAME_ENTRY4, addMapEntryInterceptor);
+ mapType.pushInterceptor(QNAME_SUBMAP, addMapEntryInterceptor);
+
+ entry1Type.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Object[2];
+ }
+ }
+ );
+ entry1Type.pushInterceptor(QNAME_KEY1, new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Object[] arr = (Object[])o;
+ arr[0] = text;
+ }
+ }
+ );
+ entry1Type.pushInterceptor(QNAME_VALUE1, new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Object[] arr = (Object[])o;
+ arr[1] = text;
+ }
+ }
+ );
+
+ entry2Type.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Object[2];
+ }
+
+ public void attributes(Object o,
+ QName elementName,
+ ElementBinding element,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Object[] arr = (Object[])o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("key2".equals(lName))
+ {
+ arr[0] = attrs.getValue(i);
+ }
+ }
+ }
+ }
+ );
+ entry2Type.pushInterceptor(QNAME_VALUE2, new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Object[] arr = (Object[])o;
+ arr[1] = text;
+ }
+ }
+ );
+
+ entry3Type.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Object[2];
+ }
+
+ public void attributes(Object o,
+ QName elementName,
+ ElementBinding element,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Object[] arr = (Object[])o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("key3".equals(lName))
+ {
+ arr[0] = attrs.getValue(i);
+ }
+ else if("value3".equals(lName))
+ {
+ arr[1] = attrs.getValue(i);
+ }
+ }
+ }
+ }
+ );
+
+ entry4Type.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Object[2];
+ }
+
+ public void attributes(Object o,
+ QName elementName,
+ ElementBinding element,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Object[] arr = (Object[])o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("key4".equals(lName))
+ {
+ arr[0] = attrs.getValue(i);
+ }
+ }
+ }
+
+ }
+ );
+ entry4Type.setSimpleType(new CharactersHandler()
+ {
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ Object[] arr = (Object[])owner;
+ arr[1] = value;
+ }
+ }
+ );
+
+ mapType.pushInterceptor(QNAME_SUBMAP, new DefaultElementInterceptor()
+ {
+ public Object startElement(Object parent, QName name, TypeBinding type)
+ {
+ return new Object[2];
+ }
+
+ public void attributes(Object o,
+ QName elementName,
+ TypeBinding type,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Object[] arr = (Object[])o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("key".equals(lName))
+ {
+ arr[0] = attrs.getValue(i);
+ }
+ }
+ }
+
+ public void add(Object parent, Object child, QName qName)
+ {
+ Object[] arr = (Object[])parent;
+ Map submap = (Map)child;
+ arr[1] = submap;
+ }
+ }
+ );
+
+ // sequence entry
+ entrySeq.setHandler(new ParticleHandler()
+ {
+ public Object startParticle(Object parent,
+ QName elementName,
+ ParticleBinding particle,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ return new Object[2];
+ }
+
+ public Object endParticle(Object o, QName elementName, ParticleBinding particle)
+ {
+ return o;
+ }
+
+ public void setParent(Object parent,
+ Object o,
+ QName elementName,
+ ParticleBinding particle,
+ ParticleBinding parentParticle)
+ {
+ Map map = (Map)parent;
+ Object[] arr = (Object[])o;
+ map.put(arr[0], arr[1]);
+ }
+ }
+ );
+
+ keyElement.pushInterceptor(new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Object[] arr = (Object[])o;
+ arr[0] = text;
+ }
+ });
+
+ valueElement.pushInterceptor(new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Object[] arr = (Object[])o;
+ arr[1] = text;
+ }
+ });
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object map = unmarshaller.unmarshal(getFullPath("xml/maps.xml"), schema);
+
+ assertNotNull(map);
+ assertTrue(map instanceof Map);
+
+ assertEquals(EXPECTED, map);
+ }
+
+ // Private
+
+ private String getFullPath(String name)
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(name);
+ if(url == null)
+ {
+ fail("Resource not found: " + name);
+ }
+ return url.getFile();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/MinOccurs0UnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/MinOccurs0UnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/MinOccurs0UnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,211 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45337 $</tt>
+ */
+public class MinOccurs0UnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String XSD =
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/minoccurs'" +
+ " xmlns='http://www.jboss.org/test/xml/minoccurs'" +
+ " elementFormDefault='qualified'" +
+ " xmlns:jbxb='" +
+ Constants.NS_JBXB +
+ "'" +
+ " version='1.0'>" +
+ "<xsd:element name='e'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" +
+ E.class.getName() +
+ "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:complexType>" +
+ " <xsd:sequence>" +
+ " <xsd:element name='value' type='xsd:string' minOccurs='0'/>" +
+ " </xsd:sequence>" +
+ " </xsd:complexType>" +
+ "</xsd:element>" +
+ "</xsd:schema>";
+
+ private static final String MBEAN_XSD =
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " xmlns:jbxb='" + Constants.NS_JBXB + "' version='1.0'>" +
+ "<xsd:element name='mbean'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" + ClassForMBean.class.getName() + "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:complexType>" +
+ " <xsd:sequence>" +
+ " <xsd:element minOccurs='0' ref='description'/>" +
+ " <xsd:element minOccurs='0' ref='descriptors'/>" +
+ " </xsd:sequence>" +
+ " </xsd:complexType>" +
+ "</xsd:element>" +
+ "<xsd:element name='description' type='xsd:string'/>" +
+ "<xsd:element name='descriptors' type='xsd:string'/>" +
+ "</xsd:schema>";
+
+ private static SchemaBinding SCHEMA;
+
+ private static final String XML_NO_VALUE =
+ "<e xmlns='http://www.jboss.org/test/xml/minoccurs'>" +
+ "</e>";
+
+ private static final String XML_WITH_VALUE =
+ "<e xmlns='http://www.jboss.org/test/xml/minoccurs'>" +
+ "<value>val</value>" +
+ "</e>";
+
+ public MinOccurs0UnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void configureLogging()
+ {
+ if(SCHEMA == null)
+ {
+ SCHEMA = XsdBinder.bind(new StringReader(XSD), null);
+ SCHEMA.setIgnoreUnresolvedFieldOrClass(false);
+ }
+ }
+
+ public void testUnmarshallingNoValue() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML_NO_VALUE), SCHEMA);
+ assertNotNull(o);
+ assertTrue(o instanceof E);
+ E e = (E)o;
+ assertNull(e.value);
+ }
+
+ public void testUnmarshallingWithValue() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML_WITH_VALUE), SCHEMA);
+ assertNotNull(o);
+ assertTrue(o instanceof E);
+ E e = (E)o;
+ assertEquals("val", e.value);
+ }
+
+ public void testMarshallingNoValueXerces() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), new MappingObjectModelProvider(), new E(), writer);
+ String xml = writer.getBuffer().toString();
+ assertXmlEqual(XML_NO_VALUE, xml);
+ }
+
+ public void testMarshallingWithValueXerces() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), new MappingObjectModelProvider(), new E("val"), writer);
+ String xml = writer.getBuffer().toString();
+ assertXmlEqual(XML_WITH_VALUE, xml);
+ }
+
+ public void testMarshallingNoValueSunday() throws Exception
+ {
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(SCHEMA, null, new E(), writer);
+ String xml = writer.getBuffer().toString();
+ assertXmlEqual(XML_NO_VALUE, xml);
+ }
+
+ public void testMarshallingWithValueSunday() throws Exception
+ {
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(SCHEMA, null, new E("val"), writer);
+ String xml = writer.getBuffer().toString();
+ assertXmlEqual(XML_WITH_VALUE, xml);
+ }
+
+ public void testMBeanUnmarshalling() throws Exception
+ {
+ SchemaBinding schema = XsdBinder.bind(new StringReader(MBEAN_XSD), null);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+
+ String xml = "<mbean><descriptors>descriptors</descriptors></mbean>";
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(xml), schema);
+
+ assertNotNull(o);
+ assertTrue(o instanceof ClassForMBean);
+ ClassForMBean mb = (ClassForMBean)o;
+ assertNull(mb.description);
+ assertEquals("descriptors", mb.descriptors);
+ }
+
+ // Inner
+
+ public static final class E
+ {
+ public String value;
+
+ public E()
+ {
+ }
+
+ public E(String value)
+ {
+ this.value = value;
+ }
+ }
+
+ public static final class ClassForMBean
+ {
+ public String description;
+ public String descriptors;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/MiscUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/MiscUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/MiscUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,383 @@
+/*
+ * 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.xml;
+
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.List;
+import org.jboss.test.xml.sandbox.Choice1;
+import org.jboss.test.xml.sandbox.Choice2;
+import org.jboss.test.xml.sandbox.Choice3;
+import org.jboss.test.xml.sandbox.Root;
+import org.jboss.test.xml.immutable.Child1;
+import org.jboss.test.xml.immutable.Child2;
+import org.jboss.test.xml.immutable.Child3;
+import org.jboss.test.xml.immutable.ImmutableChoice;
+import org.jboss.test.xml.immutable.Parent;
+import org.jboss.test.xml.person.Person;
+import org.jboss.xb.binding.MappingObjectModelFactory;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.AbstractMarshaller;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+
+
+/**
+ * Various tests that should later be categorized.
+ *
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45498 $</tt>
+ */
+public class MiscUnitTestCase
+ extends AbstractJBossXBTest
+{
+ //private static final Logger log = Logger.getLogger(MiscUnitTestCase.class);
+
+ public MiscUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void testStringNormalization() throws Exception
+ {
+ String xsd = "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/snorm'" +
+ " xmlns='http://www.jboss.org/test/xml/snorm'" +
+ " xmlns:jbxb='" + Constants.NS_JBXB + "'" +
+ " version='1.0'>" +
+ "<xsd:complexType name='ctype'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" + Person.class.getName() + "'/>" +
+ " <jbxb:characters>" +
+ " <jbxb:property name='lastName'/>" +
+ " </jbxb:characters>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:simpleContent>" +
+ " <xsd:extension base='xsd:string'>" +
+ " <xsd:attribute name='attr' type='xsd:string'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:property name='firstName'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " </xsd:attribute>" +
+ " </xsd:extension>" +
+ " </xsd:simpleContent>" +
+ "</xsd:complexType>" +
+ "<xsd:element name='person' type='ctype'/>" +
+ "</xsd:schema>";
+
+ String xml = "<person" +
+ " xmlns='http://www.jboss.org/test/xml/snorm'" +
+ " attr=''"&><'><>&"'</person>";
+
+ String lastName = "<>&\"'";
+ String firstName = "'\"&><";
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object unmarshalled = unmarshaller.unmarshal(new StringReader(xml), schema);
+ assertNotNull(unmarshalled);
+ assertTrue(unmarshalled instanceof Person);
+ Person person = (Person)unmarshalled;
+ assertEquals(firstName, person.getFirstName());
+ assertEquals(lastName, person.getLastName());
+
+ StringWriter writer = new StringWriter();
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.marshal(schema, null, person, writer);
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(xml, marshalled);
+ }
+
+ public void testImmutableXerces() throws Exception
+ {
+ immutableTest(new XercesXsMarshaller());
+ }
+
+ public void testImmutableSunday() throws Exception
+ {
+ immutableTest(new MarshallerImpl());
+ }
+
+ public void testEmptyElements() throws Exception
+ {
+ String xsd = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/empty'" +
+ " xmlns='http://www.jboss.org/test/xml/empty'" +
+ " xmlns:jbxb='" + Constants.NS_JBXB + "'" +
+ " elementFormDefault='qualified'" +
+ " attributeFormDefault='unqualified'" +
+ " version='1.0'>" +
+ "<xsd:complexType name='emptyType'>" +
+ "<xsd:annotation>" +
+ "<xsd:appinfo>" +
+ "<jbxb:class impl='" + java.util.Date.class.getName() + "'/>" +
+ "</xsd:appinfo>" +
+ "</xsd:annotation>" +
+ "<xsd:sequence/>" +
+ "</xsd:complexType>" +
+ "<xsd:element name='empty' type='emptyType'/>" +
+ "</xsd:schema>";
+
+ String xml = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<empty xmlns='http://www.jboss.org/test/xml/empty'/>";
+
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object unmarshalled = unmarshaller.unmarshal(new StringReader(xml), schema);
+ assertNotNull(unmarshalled);
+ assertTrue(unmarshalled instanceof java.util.Date);
+ }
+
+ public void testBase64BinaryUnmarshalling() throws Exception
+ {
+ String xsd = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/base64'" +
+ " xmlns='http://www.jboss.org/test/xml/collections'" +
+ " elementFormDefault='qualified'" +
+ " attributeFormDefault='unqualified'" +
+ " version='1.0'>" +
+ " <xsd:element name='base64' type='xsd:base64Binary' nillable='1'/>" +
+ "</xsd:schema>";
+
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+
+ String xml = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<base64 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
+ " xmlns='http://www.jboss.org/test/xml/base64'" +
+ " xsi:nil='1'/>";
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object result = unmarshaller.unmarshal(new StringReader(xml), schema);
+ assertNull(result);
+
+ xml = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<base64 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
+ " xmlns='http://www.jboss.org/test/xml/base64'/>";
+ byte[] bytes = (byte[])unmarshaller.unmarshal(new StringReader(xml), schema);
+ assertNotNull(bytes);
+ assertEquals(0, bytes.length);
+ }
+
+ public void testEmptyStringUnmarshalling() throws Exception
+ {
+ String xsd = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/emptystring'" +
+ " xmlns='http://www.jboss.org/test/xml/emptystring'" +
+ " elementFormDefault='qualified'" +
+ " attributeFormDefault='unqualified'" +
+ " version='1.0'>" +
+ " <xsd:element name='str' type='xsd:string' nillable='1'/>" +
+ "</xsd:schema>";
+
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+
+ String xml = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<str xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
+ " xmlns='http://www.jboss.org/test/xml/emptystring'/>";
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ String result = (String)unmarshaller.unmarshal(new StringReader(xml), schema);
+ assertEquals("", result);
+ }
+
+ public void testNullStringUnmarshalling() throws Exception
+ {
+ String xsd = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/emptystring'" +
+ " xmlns='http://www.jboss.org/test/xml/emptystring'" +
+ " elementFormDefault='qualified'" +
+ " attributeFormDefault='unqualified'" +
+ " version='1.0'>" +
+ " <xsd:element name='str' type='xsd:string' nillable='1'/>" +
+ "</xsd:schema>";
+
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+
+ String xml = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<str xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
+ " xmlns='http://www.jboss.org/test/xml/emptystring'" +
+ " xsi:nil='1'/>";
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object result = unmarshaller.unmarshal(new StringReader(xml), schema);
+ assertNull(result);
+ }
+
+ public void testDateTimeXerces() throws Exception
+ {
+ dateTimeTest(new XercesXsMarshaller());
+ }
+
+ public void testDateTimeSunday() throws Exception
+ {
+ dateTimeTest(new MarshallerImpl());
+ }
+
+ public void testJavaUtilDateXerces() throws Exception
+ {
+ javaUtilDateTest(new XercesXsMarshaller());
+ }
+
+ public void testJavaUtilDateSunday() throws Exception
+ {
+ javaUtilDateTest(new MarshallerImpl());
+ }
+
+ // Private
+
+ private void javaUtilDateTest(AbstractMarshaller marshaller) throws Exception
+ {
+ String xsd = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/datetime'" +
+ " xmlns='http://www.jboss.org/test/xml/datetime'" +
+ " elementFormDefault='qualified'" +
+ " attributeFormDefault='unqualified'" +
+ " version='1.0'>" +
+ " <xsd:element name='date' type='xsd:dateTime' nillable='1'/>" +
+ "</xsd:schema>";
+
+ java.util.Date date = java.util.Calendar.getInstance().getTime();
+
+ marshaller.declareNamespace(null, "http://www.jboss.org/test/xml/datetime");
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(xsd), provider, date, writer);
+
+ String marshalled = writer.getBuffer().toString();
+
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Calendar cal = (Calendar)unmarshaller.unmarshal(new StringReader(marshalled), schema);
+
+ assertEquals(date, cal.getTime());
+ }
+
+ private void dateTimeTest(AbstractMarshaller marshaller) throws Exception
+ {
+ String xsd = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/datetime'" +
+ " xmlns='http://www.jboss.org/test/xml/datetime'" +
+ " elementFormDefault='qualified'" +
+ " attributeFormDefault='unqualified'" +
+ " version='1.0'>" +
+ " <xsd:element name='date' type='xsd:dateTime' nillable='1'/>" +
+ "</xsd:schema>";
+
+ SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null);
+
+ String xml = "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<date xmlns='http://www.jboss.org/test/xml/datetime'>" +
+ "2005-06-24T12:24:43.555+01:00</date>";
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object result = unmarshaller.unmarshal(new StringReader(xml), schema);
+
+ marshaller.declareNamespace(null, "http://www.jboss.org/test/xml/datetime");
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(xsd), provider, result, writer);
+
+ assertXmlEqual(xml, writer.getBuffer().toString());
+ }
+
+ private void immutableTest(AbstractMarshaller marshaller) throws Exception
+ {
+ final URL xsdUrl = getUrl("xml/immutable.xsd");
+
+ Child1 child1 = new Child1("child1");
+ List child2 = Arrays.asList(new Object[]{new Child2("child2_1"), new Child2("child2_2")});
+ List others = Arrays.asList(new Object[]{new Child3("child3_1"), new Child3("child3_2"), new Child3("child3_3")});
+ List choice = Arrays.asList(
+ new Object[]{new ImmutableChoice("choice1"), new ImmutableChoice(new Child1("child1"))}
+ );
+ Parent parent = new Parent(child1, child2, others, choice);
+
+ StringWriter writer = new StringWriter();
+ marshaller.declareNamespace("imm", "http://www.jboss.org/test/xml/immutable/");
+ //marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ marshaller.marshal(xsdUrl.toExternalForm(),
+ new MappingObjectModelProvider(),
+ parent,
+ writer
+ );
+ String xml = writer.getBuffer().toString();
+
+ SchemaBinding schema = XsdBinder.bind(xsdUrl.openStream(), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(xml), schema);
+ assertEquals(parent, o);
+ }
+
+ private void assertUnmarshalled(Root unmarshalled)
+ {
+ Root root = new Root();
+ root.setChoiceCollection1(
+ Arrays.asList(new Object[]{new Choice1("choice1_a", null), new Choice1(null, "choice1_b")})
+ );
+ root.setChoice2(Arrays.asList(new Object[]{new Choice2("choice2_c", "choice2_d", null),
+ new Choice2(null, "choice2_d", "choice2_e")
+ }
+ )
+ );
+ root.setChoice3(Arrays.asList(new Object[]{
+ new Choice3(Arrays.asList(new Integer[]{new Integer(1), new Integer(2), new Integer(3)}), null),
+ new Choice3(null, Arrays.asList(new String[]{"1", "2", "3"}))
+ }
+ )
+ );
+
+ assertEquals(root, unmarshalled);
+ }
+
+ private static String getXmlUrl(String name)
+ {
+ return getUrl(name).getFile();
+ }
+
+ private static URL getUrl(String name)
+ {
+ URL xmlUrl = Thread.currentThread().getContextClassLoader().getResource(name);
+ if(xmlUrl == null)
+ {
+ throw new IllegalStateException(name + " not found");
+ }
+ return xmlUrl;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/ModelGroupBindingUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/ModelGroupBindingUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/ModelGroupBindingUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,393 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import org.jboss.xb.binding.AbstractMarshaller;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45337 $</tt>
+ */
+public class ModelGroupBindingUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String XSD =
+ "<xsd:schema targetNamespace='http://jboss.org/ns/mg'" +
+ " xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " xmlns:jbxb='http://www.jboss.org/xml/ns/jbxb'" +
+ " elementFormDefault='qualified'>" +
+ "<xsd:element name='global'>" +
+ "<xsd:annotation>" +
+ "<xsd:appinfo>" +
+ "<jbxb:class impl='" +
+ GlobalElement.class.getName() +
+ "'/>" +
+ "</xsd:appinfo>" +
+ "</xsd:annotation>" +
+ " <xsd:complexType>" +
+ " <xsd:sequence>" +
+ " <xsd:sequence minOccurs='0' maxOccurs='unbounded'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" +
+ GlobalElement.Sequence.class.getName() +
+ "' collectionType='java.util.ArrayList'/>" +
+ " <jbxb:property name='sequences'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:element name='item1' type='xsd:string'/>" +
+ " <xsd:element name='item2' type='xsd:string'/>" +
+ " <xsd:element name='item3' type='xsd:string'/>" +
+ " </xsd:sequence>" +
+ " <xsd:choice minOccurs='0' maxOccurs='unbounded'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" +
+ GlobalElement.Choice.class.getName() +
+ "' collectionType='java.util.ArrayList'/>" +
+ " <jbxb:property name='choices'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:element name='choice1' type='xsd:string'/>" +
+ " <xsd:element name='choice2' type='xsd:string'/>" +
+ " <xsd:element name='choice3' type='xsd:string'/>" +
+ " </xsd:choice>" +
+ " <xsd:sequence minOccurs='0' maxOccurs='unbounded'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" +
+ java.util.ArrayList.class.getName() +
+ "' collectionType='java.util.ArrayList'/>" +
+ " <jbxb:property name='listOfLists'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:element name='item_1' type='xsd:string'/>" +
+ " <xsd:element name='item_2' type='xsd:string'/>" +
+ " </xsd:sequence>" +
+ " </xsd:sequence>" +
+ " </xsd:complexType>" +
+ "</xsd:element>" +
+ "</xsd:schema>";
+
+ private static SchemaBinding SCHEMA;
+
+ private static final String XML =
+ "<global xmlns='http://jboss.org/ns/mg'>" +
+ "<item1>item11</item1>" +
+ "<item2>item12</item2>" +
+ "<item3>item13</item3>" +
+ "<item1>item21</item1>" +
+ "<item2>item22</item2>" +
+ "<item3>item23</item3>" +
+ "<choice1>choice1</choice1>" +
+ "<choice3>choice3</choice3>" +
+ "</global>";
+
+ private static final String LIST_OF_LISTS_XML = "<global xmlns='http://jboss.org/ns/mg'>" +
+ "<item_1>item11</item_1>" +
+ "<item_2>item12</item_2>" +
+ "<item_1>item21</item_1>" +
+ "<item_2>item22</item_2>" +
+ "<item_1>item31</item_1>" +
+ "<item_2>item32</item_2>" +
+ "</global>";
+
+ private static final List LIST_OF_LISTS = Arrays.asList(new Object[]{
+ Arrays.asList(new String[]{"item11", "item12"}),
+ Arrays.asList(new String[]{"item21", "item22"}),
+ Arrays.asList(new String[]{"item31", "item32"})
+ }
+ );
+
+ public ModelGroupBindingUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void configureLogging()
+ {
+ if(SCHEMA == null)
+ {
+ SCHEMA = XsdBinder.bind(new StringReader(XSD), null);
+ SCHEMA.setIgnoreUnresolvedFieldOrClass(false);
+ }
+ }
+
+ public void testUnmarshalling() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ GlobalElement global = (GlobalElement)unmarshaller.unmarshal(new StringReader(XML), SCHEMA);
+ assertEquals(GlobalElement.INSTANCE, global);
+ }
+
+ /**
+ * XercesXsMarshaller does not support marshalling of model groups since
+ * it is not based on annotations
+ */
+ public void testMarshallingSunday() throws Exception
+ {
+ marshallingTest(new MarshallerImpl());
+ }
+
+ public void testListOfListsUnmarshalling() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ GlobalElement global = (GlobalElement)unmarshaller.unmarshal(new StringReader(LIST_OF_LISTS_XML), SCHEMA);
+ assertNull(global.choices);
+ assertNull(global.sequences);
+ assertEquals(LIST_OF_LISTS, global.listOfLists);
+ }
+
+ public void testListOfListsMarshalling() throws Exception
+ {
+ GlobalElement global = new GlobalElement();
+ global.listOfLists = LIST_OF_LISTS;
+
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(SCHEMA, null, global, writer);
+
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(LIST_OF_LISTS_XML, marshalled);
+ }
+
+ // Private
+
+ private void marshallingTest(AbstractMarshaller marshaller) throws Exception
+ {
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), new MappingObjectModelProvider(), GlobalElement.INSTANCE, writer);
+
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(XML, marshalled);
+ }
+
+ // Inner
+
+ public static class GlobalElement
+ {
+ public static final GlobalElement INSTANCE;
+
+ static
+ {
+ GlobalElement global = new GlobalElement();
+ global.sequences = Arrays.asList(new Object[]{
+ new Sequence("item11", "item12", "item13"),
+ new Sequence("item21", "item22", "item23")
+ }
+ );
+ global.choices = Arrays.asList(new Object[]{
+ new Choice("choice1", null, null),
+ new Choice(null, null, "choice3")
+ }
+ );
+ INSTANCE = global;
+ }
+
+ public Collection sequences;
+ public Collection choices;
+ public Collection listOfLists;
+
+ public String toString()
+ {
+ return "[global sequences=" + sequences + ", choices=" + choices + ", listOfLists=" + listOfLists + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof GlobalElement))
+ {
+ return false;
+ }
+
+ final GlobalElement globalElement = (GlobalElement)o;
+
+ if(choices != null ? !choices.equals(globalElement.choices) : globalElement.choices != null)
+ {
+ return false;
+ }
+ if(sequences != null ? !sequences.equals(globalElement.sequences) : globalElement.sequences != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (sequences != null ? sequences.hashCode() : 0);
+ result = 29 * result + (choices != null ? choices.hashCode() : 0);
+ return result;
+ }
+ // Inner
+
+ public static class Sequence
+ {
+ public String item1;
+ public String item2;
+ public String item3;
+
+ public Sequence()
+ {
+ }
+
+ public Sequence(String item1, String item2, String item3)
+ {
+ this.item1 = item1;
+ this.item2 = item2;
+ this.item3 = item3;
+ }
+
+ public String toString()
+ {
+ return "[sequence item1=" +
+ item1 +
+ ", item2=" +
+ item2 +
+ ", item3=" + item3 + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Sequence))
+ {
+ return false;
+ }
+
+ final Sequence sequence = (Sequence)o;
+
+ if(item1 != null ? !item1.equals(sequence.item1) : sequence.item1 != null)
+ {
+ return false;
+ }
+ if(item2 != null ? !item2.equals(sequence.item2) : sequence.item2 != null)
+ {
+ return false;
+ }
+ if(item3 != null ? !item3.equals(sequence.item3) : sequence.item3 != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (item1 != null ? item1.hashCode() : 0);
+ result = 29 * result + (item2 != null ? item2.hashCode() : 0);
+ result = 29 * result + (item3 != null ? item3.hashCode() : 0);
+ return result;
+ }
+ }
+
+ public static class Choice
+ {
+ public String choice1;
+ public String choice2;
+ public String choice3;
+
+ public Choice()
+ {
+ }
+
+ public Choice(String choice1, String choice2, String choice3)
+ {
+ this.choice1 = choice1;
+ this.choice2 = choice2;
+ this.choice3 = choice3;
+ }
+
+ public String toString()
+ {
+ return "[choice choice1=" +
+ choice1 +
+ ", choice2=" +
+ choice2 +
+ ", choice3=" + choice3 + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Choice))
+ {
+ return false;
+ }
+
+ final Choice choice = (Choice)o;
+
+ if(choice1 != null ? !choice1.equals(choice.choice1) : choice.choice1 != null)
+ {
+ return false;
+ }
+ if(choice2 != null ? !choice2.equals(choice.choice2) : choice.choice2 != null)
+ {
+ return false;
+ }
+ if(choice3 != null ? !choice3.equals(choice.choice3) : choice.choice3 != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (choice1 != null ? choice1.hashCode() : 0);
+ result = 29 * result + (choice2 != null ? choice2.hashCode() : 0);
+ result = 29 * result + (choice3 != null ? choice3.hashCode() : 0);
+ return result;
+ }
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/MultispacedUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/MultispacedUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/MultispacedUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,267 @@
+/*
+ * 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.xml;
+
+import junit.framework.TestCase;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.io.StringReader;
+import java.util.List;
+import java.net.URL;
+
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.ObjectModelProvider;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.AbstractMarshaller;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.jboss.test.xml.multispaced.pm.jdbc.JDBCPmMetaDataFactory;
+import org.jboss.test.xml.multispaced.pm.jdbc.JDBCPm;
+import org.jboss.test.xml.multispaced.pm.jdbc.JDBCPmMetaDataProvider;
+import org.jboss.test.xml.multispaced.XMBeanMetaData;
+import org.jboss.test.xml.multispaced.XMBeanMetaDataFactory;
+import org.jboss.test.xml.multispaced.XMBeanMetaDataProvider;
+import org.jboss.test.xml.multispaced.XMBeanOperationMetaData;
+import org.jboss.test.xml.multispaced.XMBeanAttributeMetaData;
+import org.jboss.test.xml.multispaced.XMBeanConstructorMetaData;
+import org.jboss.test.xml.multispaced.XMBeanNotificationMetaData;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45336 $</tt>
+ */
+public class MultispacedUnitTestCase
+ extends TestCase
+{
+ private static final Logger log = Logger.getLogger(MultispacedUnitTestCase.class);
+
+ public MultispacedUnitTestCase()
+ {
+ }
+
+ public MultispacedUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testMultispacedUnmarshalling() throws Exception
+ {
+ log.debug("--- " + getName());
+
+ InputStream xmlIs = getResource("xml/multispaced/xmbean.xml");
+ InputStreamReader xmlReader = new InputStreamReader(xmlIs);
+
+ XMBeanMetaData xmbean = unmarshalXMBean(xmlReader);
+
+ xmlReader.close();
+
+ checkUnmarshalledXMBean(xmbean);
+ }
+
+ public void testMultispacedUnmarshalling2() throws Exception
+ {
+ log.debug("--- " + getName());
+
+ InputStream xmlIs = getResource("xml/multispaced/xmbean-localns.xml");
+ InputStreamReader xmlReader = new InputStreamReader(xmlIs);
+
+ XMBeanMetaData xmbean = unmarshalXMBean(xmlReader);
+
+ xmlReader.close();
+
+ checkUnmarshalledXMBean(xmbean);
+ }
+
+ public void testMarshallingXerces() throws Exception
+ {
+ log.debug("--- " + getName());
+
+ System.setProperty(Marshaller.PROP_MARSHALLER, XercesXsMarshaller.class.getName());
+ marshallingTest();
+ }
+
+ public void testMarshallingSunday() throws Exception
+ {
+ log.debug("--- " + getName());
+
+ System.setProperty(Marshaller.PROP_MARSHALLER, MarshallerImpl.class.getName());
+ marshallingTest();
+ }
+
+ // Private
+
+ private void marshallingTest()
+ throws Exception
+ {
+ StringWriter strWriter = new StringWriter();
+
+ AbstractMarshaller marshaller = (AbstractMarshaller)Marshaller.FACTORY.getInstance();
+ marshaller.addRootElement("http://jboss.org/xmbean", "xmbean", "mbean");
+ marshaller.declareNamespace("xmbean", "http://jboss.org/xmbean");
+ marshaller.declareNamespace("jdbcpm", "http://jboss.org/xmbean/persistence/jdbc");
+
+ XMBeanMetaData xmbean = createXMBeanMetaData();
+ ObjectModelProvider provider = XMBeanMetaDataProvider.INSTANCE;
+
+ ObjectModelProvider jdbcPmProvider = new JDBCPmMetaDataProvider((JDBCPm)xmbean.getPersistenceManager());
+ marshaller.mapClassToGlobalElement(JDBCPm.class,
+ "persistence-manager",
+ "http://jboss.org/xmbean/persistence/jdbc",
+ getResourceUrl("xml/multispaced/jdbcpm.xsd").toString(),
+ jdbcPmProvider
+ );
+
+ marshaller.marshal(getResourceUrl("xml/multispaced/xmbean.xsd").toString(), provider, xmbean, strWriter);
+
+ final String xml = strWriter.getBuffer().toString();
+ log.debug("marshalled with " + marshaller.getClass().getName() + ": " + xml);
+
+ StringReader xmlReader = new StringReader(xml);
+ XMBeanMetaData unmarshalled = unmarshalXMBean(xmlReader);
+
+ assertEquals(xmbean, unmarshalled);
+ }
+
+ private XMBeanMetaData unmarshalXMBean(Reader xmlReader)
+ throws Exception
+ {
+ XMBeanMetaData xmbean = new XMBeanMetaData();
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ unmarshaller.mapFactoryToNamespace(JDBCPmMetaDataFactory.INSTANCE, "http://jboss.org/xmbean/persistence/jdbc");
+ unmarshaller.unmarshal(xmlReader, XMBeanMetaDataFactory.INSTANCE, xmbean);
+
+ return xmbean;
+ }
+
+ private void checkUnmarshalledXMBean(XMBeanMetaData xmbean)
+ {
+ log.debug("xmbean: " + xmbean);
+
+ assertEquals("The JBoss XMBean version of the monitor server", xmbean.getDescription());
+ assertEquals("monitor.MonitorPOJO", xmbean.getMbeanClass());
+
+ final List constructors = xmbean.getConstructors();
+ assertEquals(1, constructors.size());
+ XMBeanConstructorMetaData constructor = (XMBeanConstructorMetaData)constructors.get(0);
+ assertEquals("The no-arg constructor", constructor.getDescription());
+ assertEquals("monitor.MonitorPOJO", constructor.getName());
+
+ final List attributes = xmbean.getAttributes();
+ assertEquals(1, attributes.size());
+ XMBeanAttributeMetaData attribute = (XMBeanAttributeMetaData)attributes.get(0);
+ assertEquals("read-write", attribute.getAccess());
+ assertEquals("getInterval", attribute.getGetMethod());
+ assertEquals("setInterval", attribute.getSetMethod());
+ assertEquals("The interval in milliseconds between checks of VM memory and threads", attribute.getDescription());
+ assertEquals("Interval", attribute.getName());
+ assertEquals("int", attribute.getType());
+
+ final List operations = xmbean.getOperations();
+ assertEquals(1, operations.size());
+ XMBeanOperationMetaData operation = (XMBeanOperationMetaData)operations.get(0);
+ assertEquals("Access the last HistoryLength monitor reports", operation.getDescription());
+ assertEquals("history", operation.getName());
+ assertEquals("java.lang.String", operation.getReturnType());
+
+ final List notifications = xmbean.getNotifications();
+ assertEquals(1, notifications.size());
+ XMBeanNotificationMetaData notification = (XMBeanNotificationMetaData)notifications.get(0);
+ assertEquals("A notification sent when the monitor interval expires", notification.getDescription());
+ assertEquals("javax.management.Notification", notification.getName());
+ assertEquals("monitor.IntervalElapsed", notification.getNotificationType());
+
+ final JDBCPm pm = (JDBCPm)xmbean.getPersistenceManager();
+ if(pm == null)
+ {
+ fail("persistence-manager is null.");
+ }
+
+ assertEquals("java:/DefaultDS", pm.getDatasource());
+ assertEquals("xmbeans", pm.getTable());
+ }
+
+ private XMBeanMetaData createXMBeanMetaData()
+ {
+ XMBeanMetaData xmbean = new XMBeanMetaData();
+ xmbean.setDescription("The JBoss XMBean version of the monitor server");
+ xmbean.setMbeanClass("monitor.MonitorPOJO");
+
+ XMBeanConstructorMetaData constructor = new XMBeanConstructorMetaData();
+ constructor.setDescription("The no-arg constructor");
+ constructor.setName("monitor.MonitorPOJO");
+ xmbean.addConstructor(constructor);
+
+ XMBeanAttributeMetaData attribute = new XMBeanAttributeMetaData();
+ attribute.setAccess("read-write");
+ attribute.setGetMethod("getInterval");
+ attribute.setSetMethod("setInterval");
+ attribute.setDescription("The interval in milliseconds between checks of VM memory and threads");
+ attribute.setName("Interval");
+ attribute.setType("int");
+ xmbean.addAttribute(attribute);
+
+ XMBeanOperationMetaData operation = new XMBeanOperationMetaData();
+ operation.setDescription("Access the last HistoryLength monitor reports");
+ operation.setName("history");
+ operation.setReturnType("java.lang.String");
+ xmbean.addOperation(operation);
+
+ XMBeanNotificationMetaData notification = new XMBeanNotificationMetaData();
+ notification.setDescription("A notification sent when the monitor interval expires");
+ notification.setName("javax.management.Notification");
+ notification.setNotificationType("monitor.IntervalElapsed");
+ xmbean.addNotification(notification);
+
+ JDBCPm pm = new JDBCPm();
+ pm.setDatasource("java:/DefaultDS");
+ pm.setTable("xmbeans");
+ xmbean.setPersistenceManager(pm);
+
+ return xmbean;
+ }
+
+ private static InputStream getResource(String name)
+ {
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
+ if(is == null)
+ {
+ throw new IllegalStateException("Resource not found: " + name);
+ }
+ return is;
+ }
+
+ private static URL getResourceUrl(String name)
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(name);
+ if(url == null)
+ {
+ throw new IllegalStateException("Resource not found: " + name);
+ }
+ return url;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/NamespaceRegistryUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/NamespaceRegistryUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/NamespaceRegistryUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,97 @@
+/*
+ * 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.xml;
+
+import junit.framework.TestCase;
+
+import org.jboss.xb.binding.NamespaceRegistry;
+
+/**
+ *
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class NamespaceRegistryUnitTestCase
+ extends TestCase
+{
+ private String[] prefix = new String[]{"p1", "p2", "p3"};
+ private String[] uri = new String[]{"http://jboss.org/p1", "http://jboss.org/p2", "http://jboss.org/p3"};
+ private NamespaceRegistry ctx;
+
+ public NamespaceRegistryUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void setUp()
+ {
+ ctx = new NamespaceRegistry();
+ for(int i = 0; i < prefix.length; ++i)
+ {
+ ctx.addPrefixMapping(prefix[i], uri[i]);
+ }
+ }
+
+ public void testBasic()
+ {
+ for(int i = 0; i < prefix.length; ++i)
+ {
+ assertEquals(uri[i], ctx.getNamespaceURI(prefix[i]));
+ assertEquals(prefix[i], ctx.getPrefix(uri[i]));
+ }
+ }
+
+ public void testPrefixOverride()
+ {
+ String newUri1 = "http://jboss.org/new_uri_1";
+ ctx.addPrefixMapping(prefix[0], newUri1);
+ assertEquals(newUri1, ctx.getNamespaceURI(prefix[0]));
+
+ String newUri2 = "http://jboss.org/new_uri_2";
+ ctx.addPrefixMapping(prefix[0], newUri2);
+ assertEquals(newUri2, ctx.getNamespaceURI(prefix[0]));
+
+ ctx.removePrefixMapping(prefix[0]);
+ assertEquals(newUri1, ctx.getNamespaceURI(prefix[0]));
+
+ ctx.removePrefixMapping(prefix[0]);
+ for(int i = 0; i < prefix.length; ++i)
+ {
+ assertEquals(uri[i], ctx.getNamespaceURI(prefix[i]));
+ assertEquals(prefix[i], ctx.getPrefix(uri[i]));
+ }
+
+ ctx.removePrefixMapping(prefix[0]);
+ assertNull(ctx.getPrefix(prefix[0]));
+ }
+
+ public void testDuplicateURIs()
+ {
+ String newPrefix = "p4";
+ ctx.addPrefixMapping(newPrefix, uri[0]);
+ assertEquals(uri[0], ctx.getNamespaceURI(newPrefix));
+ for(int i = 0; i < prefix.length; ++i)
+ {
+ assertEquals(uri[i], ctx.getNamespaceURI(prefix[i]));
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/PoUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/PoUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/PoUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -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.xml;
+
+import java.net.URL;
+
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.test.xml.po.PurchaseOrder;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45813 $</tt>
+ */
+public class PoUnitTestCase
+ extends BaseTestCase
+{
+ public PoUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void testMain() throws Exception
+ {
+ String xsdName = "xml/po.xsd";
+ URL xsd = getURL(xsdName);
+ String xmlName = "xml/po.xml";
+ URL xml = getURL(xmlName);
+
+ SchemaBinding schema = XsdBinder.bind(xsd.toExternalForm());
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ PurchaseOrder po = (PurchaseOrder)unmarshaller.unmarshal(xml.toExternalForm(), schema);
+ assertEquals(PurchaseOrder.DEFAULT_INSTANCE, po);
+ }
+
+ private URL getURL(String name)
+ {
+ URL resource = Thread.currentThread().getContextClassLoader().getResource(name);
+ if(resource == null)
+ {
+ fail("resource not found: " + name);
+ }
+ return resource;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/PojoServerTestBase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/PojoServerTestBase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/PojoServerTestBase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,1002 @@
+/*
+ * 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.xml;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.test.BaseTestCase;
+import org.jboss.test.xml.pojoserver.deployment.AbstractKernelDeployment;
+import org.jboss.test.xml.pojoserver.metadata.AbstractBeanMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractCollectionMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractDemandMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractDependencyValueMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractListMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractMapMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractParameterMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractPropertyMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractSetMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractSupplyMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractValueMetaData;
+import org.jboss.test.xml.pojoserver.metadata.ConstructorMetaData;
+import org.jboss.test.xml.pojoserver.metadata.ControllerState;
+import org.jboss.test.xml.pojoserver.metadata.GenericBeanFactory;
+import org.jboss.test.xml.pojoserver.metadata.StringValueMetaData;
+import org.jboss.test.xml.pojoserver.metadata.ValueMetaData;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 57517 $</tt>
+ */
+public abstract class PojoServerTestBase extends BaseTestCase
+{
+ /** The schema name */
+ protected static final String SCHEMA_NAME = "/xml/bean-deployer_1_0.xsd";
+
+ /** The namespace */
+ protected static final String BEAN_DEPLOYER_NS = "urn:jboss:bean-deployer";
+
+ /** The deployment binding */
+ protected static final QName deploymentTypeQName = new QName(BEAN_DEPLOYER_NS, "deploymentType");
+
+ /** The bean binding */
+ protected static final QName beanTypeQName = new QName(BEAN_DEPLOYER_NS, "beanType");
+
+ /** The bean element name */
+ protected static final QName beanQName = new QName(BEAN_DEPLOYER_NS, "bean");
+
+ /** The beanfactory binding */
+ protected static final QName beanFactoryTypeQName = new QName(BEAN_DEPLOYER_NS, "beanfactoryType");
+
+ /** The beanfactory element name */
+ protected static final QName beanFactoryQName = new QName(BEAN_DEPLOYER_NS, "beanfactory");
+
+ /** The constructor binding */
+ protected static final QName constructorTypeQName = new QName(BEAN_DEPLOYER_NS, "constructorType");
+
+ /** The constructor element name */
+ protected static final QName constructorQName = new QName(BEAN_DEPLOYER_NS, "constructor");
+
+ /** The factory element name */
+ protected static final QName factoryQName = new QName(BEAN_DEPLOYER_NS, "factory");
+
+ /** The parameter binding */
+ protected static final QName parameterTypeQName = new QName(BEAN_DEPLOYER_NS, "parameterType");
+
+ /** The parameter element name */
+ protected static final QName parameterQName = new QName(BEAN_DEPLOYER_NS, "parameter");
+
+ /** The lifecycle binding */
+ protected static final QName lifecycleTypeQName = new QName(BEAN_DEPLOYER_NS, "lifecycleType");
+
+ /** The create element name */
+ protected static final QName createQName = new QName(BEAN_DEPLOYER_NS, "create");
+
+ /** The start element name */
+ protected static final QName startQName = new QName(BEAN_DEPLOYER_NS, "start");
+
+ /** The stop element name */
+ protected static final QName stopQName = new QName(BEAN_DEPLOYER_NS, "stop");
+
+ /** The destroy element name */
+ protected static final QName destroyQName = new QName(BEAN_DEPLOYER_NS, "destroy");
+
+ /** The property binding */
+ protected static final QName propertyTypeQName = new QName(BEAN_DEPLOYER_NS, "propertyType");
+
+ /** The property element name */
+ protected static final QName propertyQName = new QName(BEAN_DEPLOYER_NS, "property");
+
+ /** The depends binding */
+ protected static final QName dependsTypeQName = new QName(BEAN_DEPLOYER_NS, "dependsType");
+
+ /** The depends element name */
+ protected static final QName dependsQName = new QName(BEAN_DEPLOYER_NS, "depends");
+
+ /** The demand binding */
+ protected static final QName demandTypeQName = new QName(BEAN_DEPLOYER_NS, "demandType");
+
+ /** The demand element name */
+ protected static final QName demandQName = new QName(BEAN_DEPLOYER_NS, "demand");
+
+ /** The supply binding */
+ protected static final QName supplyTypeQName = new QName(BEAN_DEPLOYER_NS, "supplyType");
+
+ /** The supply element name */
+ protected static final QName supplyQName = new QName(BEAN_DEPLOYER_NS, "supply");
+
+ /** The dependency binding */
+ protected static final QName dependencyTypeQName = new QName(BEAN_DEPLOYER_NS, "dependencyType");
+
+ /** The inject element name */
+ protected static final QName injectQName = new QName(BEAN_DEPLOYER_NS, "inject");
+
+ /** The plain value binding */
+ protected static final QName plainValueTypeQName = new QName(BEAN_DEPLOYER_NS, "plainValueType");
+
+ /** The value binding */
+ protected static final QName valueTypeQName = new QName(BEAN_DEPLOYER_NS, "valueType");
+
+ /** The value element name */
+ protected static final QName valueQName = new QName(BEAN_DEPLOYER_NS, "value");
+
+ /** The null element name */
+ protected static final QName nullQName = new QName(BEAN_DEPLOYER_NS, "null");
+
+ /** The collection binding */
+ protected static final QName collectionTypeQName = new QName(BEAN_DEPLOYER_NS, "collectionType");
+
+ /** The collection element name */
+ protected static final QName collectionQName = new QName(BEAN_DEPLOYER_NS, "collection");
+
+ /** The list binding */
+ protected static final QName listTypeQName = new QName(BEAN_DEPLOYER_NS, "listType");
+
+ /** The list element name */
+ protected static final QName listQName = new QName(BEAN_DEPLOYER_NS, "list");
+
+ /** The set binding */
+ protected static final QName setTypeQName = new QName(BEAN_DEPLOYER_NS, "setType");
+
+ /** The set element name */
+ protected static final QName setQName = new QName(BEAN_DEPLOYER_NS, "set");
+
+ /** The array binding */
+ protected static final QName arrayTypeQName = new QName(BEAN_DEPLOYER_NS, "arrayType");
+
+ /** The array element name */
+ protected static final QName arrayQName = new QName(BEAN_DEPLOYER_NS, "array");
+
+ /** The map binding */
+ protected static final QName mapTypeQName = new QName(BEAN_DEPLOYER_NS, "mapType");
+
+ /** The map element name */
+ protected static final QName mapQName = new QName(BEAN_DEPLOYER_NS, "map");
+
+ /** The entry binding */
+ protected static final QName entryTypeQName = new QName(BEAN_DEPLOYER_NS, "entryType");
+
+ /** The entry element name */
+ protected static final QName entryQName = new QName(BEAN_DEPLOYER_NS, "entry");
+
+ /** The key element name */
+ protected static final QName keyQName = new QName(BEAN_DEPLOYER_NS, "key");
+
+ /** The valueGroup name */
+ protected static final QName valueGroupQName = new QName(BEAN_DEPLOYER_NS, "valueGroup");
+
+ /** The schema binding */
+ protected static SchemaBinding schemaBinding;
+
+ /** The value handler */
+ protected static ValueMetaDataElementInterceptor VALUES = new ValueMetaDataElementInterceptor();
+
+ /** The null handler */
+ protected static NullValueElementInterceptor NULLVALUES = new NullValueElementInterceptor();
+
+ public PojoServerTestBase(String localName)
+ {
+ super(localName);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ if (schemaBinding == null)
+ {
+ log.debug("================ Getting Schema Binding");
+ long start = System.currentTimeMillis();
+ schemaBinding = getSchemaBinding();
+ log.debug("================ Got Schema Binding in " + (System.currentTimeMillis() - start) + "ms");
+ /** TODO assertSchemaBinding(SCHEMA); */
+ }
+ }
+
+ public void configureLogging()
+ {
+ //enableTrace("org.jboss.xb");
+ }
+
+ public void testGenericBeanFactory() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment);
+ assertEquals(2, deployment.getBeans().size());
+
+ AbstractBeanMetaData genericBeanFactory = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertNotNull(genericBeanFactory);
+ assertEquals("GenericBeanFactory", genericBeanFactory.getName());
+ assertEquals(GenericBeanFactory.class.getName(), genericBeanFactory.getBean());
+ assertNotNull(genericBeanFactory.getProperties());
+ assertEquals(3, genericBeanFactory.getProperties().size());
+
+ AbstractPropertyMetaData beanProp = null;
+ AbstractPropertyMetaData ctorProp = null;
+ AbstractPropertyMetaData propsProp = null;
+
+ for(Iterator i = genericBeanFactory.getProperties().iterator(); i.hasNext();)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)i.next();
+ if("bean".equals(prop.getName()))
+ {
+ beanProp = prop;
+ }
+ else if("constructor".equals(prop.getName()))
+ {
+ ctorProp = prop;
+ }
+ else if("properties".equals(prop.getName()))
+ {
+ propsProp = prop;
+ }
+ else
+ {
+ fail("Unexpected property: " + prop.getName());
+ }
+ }
+
+ assertEquals("bean", beanProp.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", beanProp.getValue().getUnderlyingValue());
+
+ // todo validation of property/parameter
+ assertEquals("constructor", ctorProp.getName());
+
+ assertEquals("properties", propsProp.getName());
+ AbstractMapMetaData beanProps = (AbstractMapMetaData) propsProp.getValue();
+ assertNotNull(beanProps);
+ assertEquals(1, beanProps.size());
+ Map.Entry entry = (Map.Entry) beanProps.entrySet().iterator().next();
+ AbstractValueMetaData otherKey = (AbstractValueMetaData) entry.getKey();
+ assertNotNull(otherKey);
+ assertEquals("other", otherKey.getValue());
+ AbstractValueMetaData otherValue = (AbstractValueMetaData) entry.getValue();
+ assertNotNull(otherValue);
+ AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData)otherValue.getValue();
+ assertNotNull(dependency);
+ assertEquals("SimpleBean2", dependency.getValue());
+
+ AbstractBeanMetaData simpleBean2 = (AbstractBeanMetaData)deployment.getBeans().get(1);
+ assertEquals("SimpleBean2", simpleBean2.getName());
+ assertEquals("org.jboss.test.kernel.xml.support.SimpleBeanImpl", simpleBean2.getBean());
+ ConstructorMetaData ctor = simpleBean2.getConstructor();
+ assertNotNull(ctor);
+ assertNotNull(ctor.getParameters());
+ assertEquals(1, ctor.getParameters().size());
+ AbstractParameterMetaData param = (AbstractParameterMetaData)ctor.getParameters().get(0);
+ assertEquals(String.class.getName(), param.getType());
+ assertEquals("Bean2", param.getValue().getUnderlyingValue());
+ }
+
+ public void testAttributeDependency() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment.getBeans());
+ assertEquals(2, deployment.getBeans().size());
+
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertEquals("SimpleBean1", bean.getName());
+ assertEquals("org.jboss.test.kernel.xml.support.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getProperties());
+ assertEquals(1, bean.getProperties().size());
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)bean.getProperties().iterator().next();
+ assertNotNull(prop);
+ assertEquals("other", prop.getName());
+ assertTrue(prop.getValue() instanceof AbstractDependencyValueMetaData);
+ AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData)prop.getValue();
+ assertEquals("SimpleBean2", dependency.getValue());
+
+ bean = (AbstractBeanMetaData)deployment.getBeans().get(1);
+ assertEquals("SimpleBean2", bean.getName());
+ assertEquals("org.jboss.test.kernel.xml.support.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getConstructor());
+ ConstructorMetaData ctor = bean.getConstructor();
+ assertNotNull(ctor.getParameters());
+ assertEquals(1, ctor.getParameters().size());
+ AbstractParameterMetaData param = (AbstractParameterMetaData)ctor.getParameters().get(0);
+ assertEquals("java.lang.String", param.getType());
+ assertEquals("Bean2", param.getValue().getUnderlyingValue());
+ }
+
+ public void testAttributeDependencyDependentState() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment.getBeans());
+ assertEquals(2, deployment.getBeans().size());
+
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertEquals("SimpleBean1", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getProperties());
+ assertEquals(1, bean.getProperties().size());
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)bean.getProperties().iterator().next();
+ assertNotNull(prop);
+ assertEquals("other", prop.getName());
+ assertTrue(prop.getValue() instanceof AbstractDependencyValueMetaData);
+ AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData)prop.getValue();
+ assertEquals("SimpleBean2", dependency.getValue());
+
+ bean = (AbstractBeanMetaData)deployment.getBeans().get(1);
+ assertEquals("SimpleBean2", bean.getName());
+ assertEquals("org.jboss.test.kernel.xml.support.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getConstructor());
+ ConstructorMetaData ctor = bean.getConstructor();
+ assertNotNull(ctor.getParameters());
+ assertEquals(1, ctor.getParameters().size());
+ AbstractParameterMetaData param = (AbstractParameterMetaData)ctor.getParameters().get(0);
+ assertEquals("java.lang.String", param.getType());
+ assertEquals("Bean2", param.getValue().getUnderlyingValue());
+ }
+
+ public void testConfigure() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment.getBeans());
+ assertEquals(1, deployment.getBeans().size());
+
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertEquals("SimpleBean1", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getProperties());
+ assertEquals(18, bean.getProperties().size());
+
+ for(Iterator i = bean.getProperties().iterator(); i.hasNext();)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)i.next();
+ String name = prop.getName();
+ Object value = prop.getValue().getUnderlyingValue();
+ assertConfigureProperty(name, value);
+ }
+ }
+
+ public void testConfigureNested() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment.getBeans());
+ assertEquals(1, deployment.getBeans().size());
+
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertEquals("SimpleBean1", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getProperties());
+ assertEquals(19, bean.getProperties().size());
+
+ for(Iterator i = bean.getProperties().iterator(); i.hasNext();)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)i.next();
+ String name = prop.getName();
+ if("other".equals(name))
+ {
+ /** TODO AbstractBeanMetaData nested = (AbstractBeanMetaData)prop.getValue("NestedSimpleBean1");
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(nested);
+ assertNotNull(bean.getProperties());
+ assertEquals(19, bean.getProperties().size());
+ for(Iterator j = nested.getProperties().iterator(); j.hasNext();)
+ {
+ AbstractPropertyMetaData nestedProp = (AbstractPropertyMetaData)j.next();
+ String nestedName = nestedProp.getName();
+ if("other".equals(nestedName))
+ {
+ assertNull(nestedProp.getValue());
+ }
+ else
+ {
+ Object value = nestedProp.getValue().getUnderlyingValue();
+ assertConfigureProperty(nestedName, value);
+ }
+ } */
+ }
+ else
+ {
+ Object value = prop.getValue().getUnderlyingValue();
+ assertConfigureProperty(name, value);
+ }
+ }
+ }
+
+ public void testConstructorDependency() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment.getBeans());
+ assertEquals(2, deployment.getBeans().size());
+
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertEquals("SimpleBean1", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getConstructor());
+ ConstructorMetaData ctor = bean.getConstructor();
+ assertNotNull(ctor.getParameters());
+ assertEquals(1, ctor.getParameters().size());
+ Object obj = ctor.getParameters().get(0);
+ assertNotNull(obj);
+ assertTrue(obj instanceof AbstractParameterMetaData);
+ AbstractParameterMetaData param = (AbstractParameterMetaData) obj;
+ assertEquals("org.jboss.test.kernel.xml.support.SimpleBean", param.getType());
+ assertTrue(param.getValue() instanceof AbstractDependencyValueMetaData);
+ AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData)param.getValue();
+ assertEquals("SimpleBean2", dependency.getValue());
+
+ bean = (AbstractBeanMetaData)deployment.getBeans().get(1);
+ assertEquals("SimpleBean2", bean.getName());
+ assertEquals("org.jboss.test.kernel.xml.support.SimpleBeanImpl", bean.getBean());
+ }
+
+ public void testDemandSupply() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment);
+ assertNotNull(deployment.getBeans());
+ assertEquals(3, deployment.getBeans().size());
+
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertEquals("SimpleBean1", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getDemands());
+ assertEquals(2, bean.getDemands().size());
+ for(Iterator i = bean.getDemands().iterator(); i.hasNext();)
+ {
+ Object object = i.next();
+ assertTrue(object instanceof AbstractDemandMetaData);
+ AbstractDemandMetaData demand = (AbstractDemandMetaData) object;
+ Object value = demand.getDemand();
+ if(!"SimpleBean2".equals(value) && !"XYZZY".equals(value))
+ {
+ fail("expected SimpleBean2 or XYZZY but got " + value);
+ }
+ }
+
+ bean = (AbstractBeanMetaData)deployment.getBeans().get(1);
+ assertEquals("SimpleBean2", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+
+ bean = (AbstractBeanMetaData)deployment.getBeans().get(2);
+ assertEquals("SimpleBean3", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getSupplies());
+ assertEquals(1, bean.getSupplies().size());
+ AbstractSupplyMetaData supply = (AbstractSupplyMetaData)bean.getSupplies().iterator().next();
+ assertEquals("XYZZY", supply.getSupply());
+ }
+
+ public void testDemandSupplyWhenRequired() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment);
+ assertNotNull(deployment.getBeans());
+ assertEquals(2, deployment.getBeans().size());
+
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertEquals("SimpleBean1", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getDemands());
+ assertEquals(1, bean.getDemands().size());
+ Object object = bean.getDemands().iterator().next();
+ assertTrue(object instanceof AbstractDemandMetaData);
+ AbstractDemandMetaData demand = (AbstractDemandMetaData) object;
+ assertEquals("SimpleBean2", demand.getDemand());
+ /** TODO assertEquals(ControllerState.LIFECYCLE, demand.getWhenRequired()); */
+
+ bean = (AbstractBeanMetaData)deployment.getBeans().get(1);
+ assertEquals("SimpleBean2", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getConstructor());
+ ConstructorMetaData ctor = bean.getConstructor();
+ assertNotNull(ctor.getParameters());
+ assertEquals(1, ctor.getParameters().size());
+ AbstractParameterMetaData param = (AbstractParameterMetaData)ctor.getParameters().get(0);
+ assertEquals("java.lang.String", param.getType());
+ assertEquals("whenRequired", param.getValue().getUnderlyingValue());
+ }
+
+ public void testFactoryDependency() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment);
+ assertNotNull(deployment.getBeans());
+ assertEquals(3, deployment.getBeans().size());
+
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertEquals("SimpleBean1", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getConstructor());
+ ConstructorMetaData ctor = bean.getConstructor();
+ assertEquals("createSimpleBean", ctor.getFactoryMethod());
+ assertNotNull(ctor.getFactory());
+ assertEquals("SimpleBeanFactory", ctor.getFactory().getUnderlyingValue());
+ assertNotNull(ctor.getParameters());
+ assertEquals(1, ctor.getParameters().size());
+ AbstractParameterMetaData param = (AbstractParameterMetaData)ctor.getParameters().get(0);
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBean", param.getType());
+ assertTrue(param.getValue() instanceof AbstractDependencyValueMetaData);
+ AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData)param.getValue();
+ assertEquals("SimpleBean2", dependency.getValue());
+
+ bean = (AbstractBeanMetaData)deployment.getBeans().get(1);
+ assertEquals("SimpleBean2", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+
+ bean = (AbstractBeanMetaData)deployment.getBeans().get(2);
+ assertEquals("SimpleBeanFactory", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanFactory", bean.getBean());
+ }
+
+ public void testSimpleCollection() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment);
+ assertNotNull(deployment.getBeans());
+ assertEquals(1, deployment.getBeans().size());
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertEquals("SimpleBean1", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+
+ assertNotNull(bean.getProperties());
+ assertEquals(4, bean.getProperties().size());
+
+ for(Iterator i = bean.getProperties().iterator(); i.hasNext();)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData)i.next();
+ String name = prop.getName();
+ if("aList".equals(name))
+ {
+ AbstractListMetaData list = (AbstractListMetaData) prop.getValue();
+ assertNotNull(list);
+ assertEquals(2, list.size());
+ assertEquals("value0", ((StringValueMetaData) list.get(0)).getValue());
+ assertEquals("value1", ((StringValueMetaData) list.get(1)).getValue());
+ }
+ else if("aSet".equals(name))
+ {
+ AbstractSetMetaData set = (AbstractSetMetaData) prop.getValue();
+ assertNotNull(set);
+ assertEquals(2, set.size());
+ boolean found0 = false;
+ boolean found1 = false;
+ for (Iterator j = set.iterator(); j.hasNext();)
+ {
+ StringValueMetaData value = (StringValueMetaData) j.next();
+ assertNull(value.getType());
+ String stringValue = (String) value.getValue();
+ if ("value0".equals(stringValue))
+ found0 = true;
+ else if ("value1".equals(stringValue))
+ found1 = true;
+ else
+ fail("Unexpected value " + stringValue);
+ }
+ assertTrue(found0);
+ assertTrue(found1);
+ }
+ else if("aMap".equals(name))
+ {
+ AbstractMapMetaData map = (AbstractMapMetaData) prop.getValue();
+ assertNotNull(map);
+ assertEquals("testMapClass", map.getType());
+ assertEquals("testKeyClass", map.getKeyType());
+ assertEquals("testValueClass", map.getValueType());
+ assertEquals(2, map.size());
+ for (Iterator j = map.entrySet().iterator(); j.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry) j.next();
+ Object key = entry.getKey();
+ assertTrue(key.getClass().getName(), key instanceof StringValueMetaData);
+ StringValueMetaData keyValue = (StringValueMetaData) key;
+ assertNull(keyValue.getType());
+ String realKey = (String) keyValue.getValue();
+ if ("nullKey".equals(realKey))
+ {
+ Object value = entry.getValue();
+ assertTrue(value instanceof AbstractValueMetaData);
+ AbstractValueMetaData valueValue = (AbstractValueMetaData) value;
+ assertNull(valueValue.getValue());
+ }
+ else if ("other".equals(realKey))
+ {
+ Object value = entry.getValue();
+ assertTrue(value instanceof AbstractDependencyValueMetaData);
+ AbstractDependencyValueMetaData valueValue = (AbstractDependencyValueMetaData) value;
+ assertEquals("SimpleBean2", valueValue.getValue());
+ assertEquals(ControllerState.INSTALLED, valueValue.getDependentState());
+ }
+ else
+ fail("Unexpected key " + realKey);
+ }
+ }
+ else if("props".equals(name))
+ {
+ AbstractMapMetaData map = (AbstractMapMetaData) prop.getValue();
+ assertNotNull(map);
+ assertEquals("java.util.Properties", map.getType());
+ assertEquals("java.lang.String", map.getKeyType());
+ assertEquals("java.lang.String", map.getValueType());
+ assertEquals(2, map.size());
+ for (Iterator j = map.entrySet().iterator(); j.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry) j.next();
+ Object key = entry.getKey();
+ assertTrue(key.getClass().getName(), key instanceof StringValueMetaData);
+ StringValueMetaData keyValue = (StringValueMetaData) key;
+ assertNull(keyValue.getType());
+ String realKey = (String) keyValue.getValue();
+ String expectedValue = null;
+ if ("prop0".equals(realKey))
+ expectedValue = "value0";
+ else if ("prop1".equals(realKey))
+ expectedValue = "value1";
+ else
+ fail("Unexpected key " + realKey);
+ Object value = entry.getValue();
+ assertTrue(value instanceof StringValueMetaData);
+ StringValueMetaData valueValue = (StringValueMetaData) value;
+ assertNull(valueValue.getType());
+ String realValue = (String) valueValue.getValue();
+ assertEquals(expectedValue, realValue);
+ }
+ }
+ else
+ {
+ fail("Unexpected property: expected aList, aSet, collection or props but got " + name);
+ }
+ }
+ }
+
+ public void testStaticFactoryDependency() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshal();
+
+ assertNotNull(deployment);
+ assertNotNull(deployment.getBeans());
+ assertEquals(2, deployment.getBeans().size());
+
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)deployment.getBeans().get(0);
+ assertEquals("SimpleBean1", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ assertNotNull(bean.getConstructor());
+ ConstructorMetaData ctor = bean.getConstructor();
+ assertEquals("org.jboss.test.kernel.xml.support.SimpleBeanFactory", ctor.getFactoryClass());
+ assertEquals("staticCreateSimpleBean", ctor.getFactoryMethod());
+ assertNotNull(ctor.getParameters());
+ assertEquals(1, ctor.getParameters().size());
+ AbstractParameterMetaData param = (AbstractParameterMetaData)ctor.getParameters().get(0);
+ assertNotNull(param);
+ assertEquals("org.jboss.test.kernel.xml.support.SimpleBean", param.getType());
+ assertNotNull(param.getValue());
+ assertTrue(param.getValue() instanceof AbstractDependencyValueMetaData);
+ AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData)param.getValue();
+ assertEquals("SimpleBean2", dependency.getValue());
+
+ bean = (AbstractBeanMetaData)deployment.getBeans().get(1);
+ assertEquals("SimpleBean2", bean.getName());
+ assertEquals("org.jboss.test.xml.pojoserver.SimpleBeanImpl", bean.getBean());
+ }
+
+ /** TODO
+ protected static void assertSchemaBinding(SchemaBinding doc)
+ {
+ // types
+ assertNotNull(doc.getType(classNameTypeQName));
+ assertNotNull(doc.getType(kernelControllerStateTypeQName));
+
+ TypeBinding deploymentType = doc.getType(deploymentTypeQName);
+ assertNotNull(deploymentType);
+ assertHasElement(deploymentType, beanQName, beanTypeQName);
+
+ TypeBinding valueType = doc.getType(valueTypeQName);
+ assertNotNull(valueType);
+ assertHasElement(valueType, beanQName, beanTypeQName);
+ assertValueGroupBinding(valueType);
+
+ TypeBinding mixedValueType = doc.getType(mixedValueTypeQName);
+ assertNotNull(mixedValueType);
+ assertHasElement(mixedValueType, beanQName, beanTypeQName);
+ assertValueGroupBinding(mixedValueType);
+
+ TypeBinding namedValueType = doc.getType(namedValueTypeQName);
+ assertNotNull(namedValueType);
+ assertHasElement(namedValueType, beanQName, beanTypeQName);
+ assertHasElement(namedValueType, annotationQName, annotationTypeQName);
+ assertHasAttribute(namedValueType, nameAttrQName, Constants.QNAME_STRING);
+ assertValueGroupBinding(namedValueType);
+
+ TypeBinding valueWithClassType = doc.getType(valueWithClassTypeQName);
+ assertNotNull(valueWithClassType);
+ assertHasElement(valueWithClassType, beanQName, beanTypeQName);
+ assertHasAttribute(valueWithClassType, classAttrQName, classNameTypeQName);
+ assertValueGroupBinding(valueWithClassType);
+
+ TypeBinding listType = doc.getType(listTypeQName);
+ assertNotNull(listType);
+ assertHasElement(listType, valueQName, mixedValueTypeQName);
+ assertHasAttribute(listType, classAttrQName, classNameTypeQName);
+
+ TypeBinding mapType = doc.getType(mapTypeQName);
+ assertNotNull(mapType);
+ assertHasElement(mapType, mapEntryQName, namedValueTypeQName);
+ assertHasAttribute(mapType, classAttrQName, classNameTypeQName);
+
+ TypeBinding propsType = doc.getType(propsTypeQName);
+ assertNotNull(propsType);
+ assertHasElement(propsType, propsEntryQName, null);
+ TypeBinding propsEntryType = propsType.getElement(propsEntryQName).getType();
+ assertHasAttribute(propsEntryType, nameAttrQName, Constants.QNAME_STRING);
+
+ TypeBinding constructorType = doc.getType(constructorTypeQName);
+ assertNotNull(constructorType);
+ assertHasElement(constructorType, annotationQName, annotationTypeQName);
+ assertHasElement(constructorType, factoryQName, factoryTypeQName);
+ assertHasElement(constructorType, parameterQName, valueWithClassTypeQName);
+ assertHasAttribute(constructorType, factoryClassAttrQName, classNameTypeQName);
+ assertHasAttribute(constructorType, factoryMethodAttrQName, Constants.QNAME_TOKEN);
+
+ TypeBinding factoryType = doc.getType(factoryTypeQName);
+ assertNotNull(factoryType);
+ assertHasAttribute(factoryType, beanAttrQName, Constants.QNAME_STRING);
+
+ TypeBinding demandType = doc.getType(demandTypeQName);
+ assertNotNull(demandType);
+ assertHasAttribute(demandType, whenRequiredAttrQName, kernelControllerStateTypeQName);
+
+ TypeBinding beanType = doc.getType(beanTypeQName);
+ assertNotNull(beanType);
+ assertHasElement(beanType, annotationQName, annotationTypeQName);
+ assertHasElement(beanType, constructorQName, constructorTypeQName);
+ assertHasElement(beanType, propertyQName, namedValueTypeQName);
+ assertHasElement(beanType, demandQName, demandTypeQName);
+ assertHasElement(beanType, supplyQName, Constants.QNAME_STRING);
+ assertHasAttribute(beanType, nameAttrQName, Constants.QNAME_STRING);
+ assertHasAttribute(beanType, classAttrQName, Constants.QNAME_TOKEN);
+
+ TypeBinding annotationType = doc.getType(annotationTypeQName);
+ assertNotNull(annotationType);
+ assertHasElement(annotationType, attributeQName, annotationAttributeTypeQName);
+ assertHasAttribute(annotationType, nameAttrQName, Constants.QNAME_STRING);
+
+ TypeBinding annotAttrType = doc.getType(annotationAttributeTypeQName);
+ assertNotNull(annotAttrType);
+ assertHasAttribute(annotAttrType, nameAttrQName, Constants.QNAME_STRING);
+ assertHasAttribute(annotAttrType, valueAttrQName, Constants.QNAME_STRING);
+
+ // elements
+ ElementBinding deployment = doc.getElement(deploymentQName);
+ assertNotNull(deployment);
+ assertNotNull(deployment.getType());
+ assertEquals(deploymentTypeQName, deployment.getType().getQName());
+ }
+
+ private static void assertHasElement(TypeBinding type, QName elementQName, QName typeQName)
+ {
+ ElementBinding element = type.getElement(elementQName);
+ assertNotNull(element);
+ assertNotNull(element.getType());
+ assertEquals(typeQName, element.getType().getQName());
+ }
+
+ private static void assertHasAttribute(TypeBinding type, QName attrQName, QName typeQName)
+ {
+ AttributeBinding attr = type.getAttribute(attrQName);
+ assertNotNull(attr);
+ assertNotNull(attr.getType());
+ assertEquals(typeQName, attr.getType().getQName());
+ }
+
+ private static void assertValueGroupBinding(TypeBinding valueType)
+ {
+ assertNotNull(valueType.getElement(listQName));
+ assertNotNull(valueType.getElement(setQName));
+ assertNotNull(valueType.getElement(mapQName));
+ assertNotNull(valueType.getElement(propsQName));
+ assertNotNull(valueType.getElement(nullQName));
+
+ ElementBinding dependency = valueType.getElement(dependencyQName);
+ assertNotNull(dependency);
+ TypeBinding dependencyType = dependency.getType();
+ assertNotNull(dependencyType);
+ assertHasAttribute(dependencyType, valueAttrQName, Constants.QNAME_STRING);
+ assertHasAttribute(dependencyType, stateAttrQName, kernelControllerStateTypeQName);
+
+ assertNotNull(valueType.getElement(parameterQName));
+ assertNotNull(valueType.getElement(propertyQName));
+ } */
+
+ private void assertConfigureProperty(String name, Object value)
+ {
+ if("aString".equals(name))
+ {
+ assertEquals("StringValue", value);
+ }
+ else if("aByte".equals(name))
+ {
+ assertEquals("12", value);
+ }
+ else if("aBoolean".equals(name))
+ {
+ assertEquals("true", value);
+ }
+ else if("aShort".equals(name))
+ {
+ assertEquals("123", value);
+ }
+ else if("anInt".equals(name))
+ {
+ assertEquals("1234", value);
+ }
+ else if("aLong".equals(name))
+ {
+ assertEquals("12345", value);
+ }
+ else if("aFloat".equals(name))
+ {
+ assertEquals("3.14", value);
+ }
+ else if("aDouble".equals(name))
+ {
+ assertEquals("3.14e12", value);
+ }
+ else if("aDate".equals(name))
+ {
+ assertEquals("12/12/12", value);
+ }
+ else if("aBigDecimal".equals(name))
+ {
+ assertEquals("12e4", value);
+ }
+ else if("aBigInteger".equals(name))
+ {
+ assertEquals("123456", value);
+ }
+ else if("abyte".equals(name))
+ {
+ assertEquals("12", value);
+ }
+ else if("aboolean".equals(name))
+ {
+ assertEquals("true", value);
+ }
+ else if("ashort".equals(name))
+ {
+ assertEquals("123", value);
+ }
+ else if("anint".equals(name))
+ {
+ assertEquals("1234", value);
+ }
+ else if("along".equals(name))
+ {
+ assertEquals("12345", value);
+ }
+ else if("afloat".equals(name))
+ {
+ assertEquals("3.14", value);
+ }
+ else if("adouble".equals(name))
+ {
+ assertEquals("3.14e12", value);
+ }
+ else
+ {
+ fail("Unexpected property: " + name + "=" + value);
+ }
+ }
+
+ private AbstractKernelDeployment unmarshal() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ return (AbstractKernelDeployment)unmarshaller.unmarshal(getXmlUrl("xml/pojoserver/" + getName() + ".xml"),
+ schemaBinding
+ );
+ }
+
+ protected abstract SchemaBinding getSchemaBinding();
+
+ protected abstract String getXsd();
+
+ protected SchemaBinding readXsd()
+ {
+ return XsdBinder.bind(getXmlUrl(getXsd()));
+ }
+
+ private static String getXmlUrl(String name)
+ {
+ URL xmlUrl = Thread.currentThread().getContextClassLoader().getResource(name);
+ if(xmlUrl == null)
+ {
+ throw new IllegalStateException(name + " not found");
+ }
+ return xmlUrl.getFile();
+ }
+
+ private static class NullValueElementInterceptor extends DefaultElementInterceptor
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ if (parent instanceof AbstractCollectionMetaData)
+ {
+ AbstractCollectionMetaData collection = (AbstractCollectionMetaData) parent;
+ collection.add(new AbstractValueMetaData());
+ }
+ else if (parent instanceof AbstractParameterMetaData)
+ {
+ AbstractParameterMetaData valueMetaData = (AbstractParameterMetaData) parent;
+ valueMetaData.setValue(new AbstractValueMetaData());
+ }
+ else if (parent instanceof AbstractPropertyMetaData)
+ {
+ AbstractPropertyMetaData valueMetaData = (AbstractPropertyMetaData) parent;
+ valueMetaData.setValue(new AbstractValueMetaData());
+ }
+ else
+ {
+ AbstractValueMetaData valueMetaData = (AbstractValueMetaData) parent;
+ valueMetaData.setValue(new AbstractValueMetaData());
+ }
+ }
+ }
+
+ private static class ValueMetaDataElementInterceptor extends DefaultElementInterceptor
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ if (parent instanceof AbstractCollectionMetaData)
+ {
+ AbstractCollectionMetaData collection = (AbstractCollectionMetaData) parent;
+ ValueMetaData value = (ValueMetaData) child;
+ collection.add(value);
+ }
+ else if (parent instanceof AbstractParameterMetaData)
+ {
+ AbstractParameterMetaData valueMetaData = (AbstractParameterMetaData) parent;
+ ValueMetaData value = (ValueMetaData) child;
+ valueMetaData.setValue(value);
+ }
+ else if (parent instanceof AbstractPropertyMetaData)
+ {
+ AbstractPropertyMetaData valueMetaData = (AbstractPropertyMetaData) parent;
+ ValueMetaData value = (ValueMetaData) child;
+ valueMetaData.setValue(value);
+ }
+ else
+ {
+ AbstractValueMetaData valueMetaData = (AbstractValueMetaData) parent;
+ ValueMetaData value = (ValueMetaData) child;
+ valueMetaData.setValue(value);
+ }
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/PojoServerUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/PojoServerUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/PojoServerUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,1062 @@
+/*
+ * 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.xml;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.test.xml.pojoserver.deployment.AbstractKernelDeployment;
+import org.jboss.test.xml.pojoserver.metadata.AbstractArrayMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractBeanMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractCollectionMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractConstructorMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractDemandMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractDependencyMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractDependencyValueMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractLifecycleMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractListMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractMapMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractParameterMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractPropertyMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractSetMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractSupplyMetaData;
+import org.jboss.test.xml.pojoserver.metadata.AbstractValueMetaData;
+import org.jboss.test.xml.pojoserver.metadata.ControllerMode;
+import org.jboss.test.xml.pojoserver.metadata.ControllerState;
+import org.jboss.test.xml.pojoserver.metadata.GenericBeanFactory;
+import org.jboss.test.xml.pojoserver.metadata.StringValueMetaData;
+import org.jboss.test.xml.pojoserver.metadata.ValueMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.CharactersHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.ModelGroupBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TermBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 57581 $</tt>
+ */
+public class PojoServerUnitTestCase
+ extends PojoServerTestBase
+{
+ public PojoServerUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void testXsdBinder() throws Exception
+ {
+ SchemaBinding doc = readXsd();
+ /* TODO assertSchemaBinding(doc); */
+ }
+
+ public void testManualBinding() throws Exception
+ {
+ SchemaBinding doc = createBinding();
+ /* TODO assertSchemaBinding(doc); */
+ }
+
+ protected SchemaBinding getSchemaBinding()
+ {
+ if (schemaBinding != null)
+ return schemaBinding;
+
+ long start = System.currentTimeMillis();
+
+ schemaBinding = readXsd();
+
+ long now = System.currentTimeMillis();
+ log.debug("Reading xsd took " + (now - start) + " milliseconds");
+
+ // deployment binding
+ TypeBinding deploymentType = schemaBinding.getType(deploymentTypeQName);
+ deploymentType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractKernelDeployment();
+ }
+ });
+
+ // deployment has a list beans
+ deploymentType.pushInterceptor(beanQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) child;
+ List beans = deployment.getBeans();
+ if (beans == null)
+ {
+ beans = new ArrayList();
+ deployment.setBeans(beans);
+ }
+ beans.add(bean);
+ }
+ });
+
+ // deployment has a list beanfactorys
+ deploymentType.pushInterceptor(beanFactoryQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) child;
+ List beans = deployment.getBeans();
+ if (beans == null)
+ {
+ beans = new ArrayList();
+ deployment.setBeans(beans);
+ }
+ beans.add(bean);
+ }
+ });
+
+ // bean binding
+ TypeBinding beanType = schemaBinding.getType(beanTypeQName);
+ beanType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractBeanMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("name".equals(localName))
+ bean.setName(attrs.getValue(i));
+ else if ("class".equals(localName))
+ bean.setBean(attrs.getValue(i));
+ else if ("mode".equals(localName))
+ bean.setMode(new ControllerMode(attrs.getValue(i)));
+ }
+ }
+ });
+
+ // beanfactory binding
+ TypeBinding beanFactoryType = schemaBinding.getType(beanFactoryTypeQName);
+ beanFactoryType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ AbstractBeanMetaData beanMetaData = new AbstractBeanMetaData();
+ beanMetaData.setBean(GenericBeanFactory.class.getName());
+ beanMetaData.setProperties(new HashSet());
+ return beanMetaData;
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) o;
+ Set properties = bean.getProperties();
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("name".equals(localName))
+ bean.setName(attrs.getValue(i));
+ else if ("class".equals(localName))
+ properties.add(new AbstractPropertyMetaData("bean", attrs.getValue(i)));
+ }
+ }
+ });
+
+ // bean has a constructor
+ beanType.pushInterceptor(constructorQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) child;
+ bean.setConstructor(constructor);
+ }
+ });
+
+ // beanfactory has a constructor
+ beanFactoryType.pushInterceptor(constructorQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) child;
+ Set properties = bean.getProperties();
+ properties.add(new AbstractPropertyMetaData("constructor", new AbstractValueMetaData(constructor)));
+ }
+ });
+
+ // constructor binding
+ TypeBinding constructorType = schemaBinding.getType(constructorTypeQName);
+ constructorType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractConstructorMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("factoryClass".equals(localName))
+ constructor.setFactoryClass(attrs.getValue(i));
+ else if ("factoryMethod".equals(localName))
+ constructor.setFactoryMethod(attrs.getValue(i));
+ }
+ }
+ });
+
+ // constructor has a factory
+ constructorType.pushInterceptor(factoryQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) parent;
+ AbstractDependencyValueMetaData factory = (AbstractDependencyValueMetaData) child;
+ constructor.setFactory(factory);
+ }
+ });
+
+ // constructor has a list parameters
+ constructorType.pushInterceptor(parameterQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) parent;
+ AbstractParameterMetaData parameter = (AbstractParameterMetaData) child;
+ List parameters = constructor.getParameters();
+ if (parameters == null)
+ {
+ parameters = new ArrayList();
+ constructor.setParameters(parameters);
+ }
+ parameters.add(parameter);
+ }
+ });
+
+ ModelGroupBinding valueGroup = schemaBinding.getGroup(valueGroupQName);
+ for(Iterator i = valueGroup.getParticles().iterator(); i.hasNext();)
+ {
+ TermBinding term = ((ParticleBinding)i.next()).getTerm();
+ if(!term.isWildcard())
+ {
+ ElementBinding e = (ElementBinding) term;
+ if(e.getQName().equals(nullQName))
+ {
+ e.pushInterceptor(NULLVALUES);
+ }
+ else
+ {
+ e.pushInterceptor(VALUES);
+ }
+ }
+ }
+
+ // parameter binding
+ TypeBinding parameterType = schemaBinding.getType(parameterTypeQName);
+ parameterType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractParameterMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractParameterMetaData parameter = (AbstractParameterMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("class".equals(localName))
+ parameter.setType(attrs.getValue(i));
+ }
+ }
+ });
+
+ // parameter can take a value
+ parameterType.setSimpleType(new CharactersHandler()
+ {
+ public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
+ {
+ return new StringValueMetaData(value);
+ }
+
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ AbstractParameterMetaData parameter = (AbstractParameterMetaData) owner;
+ parameter.setValue((StringValueMetaData) value);
+ }
+ });
+
+ // bean has a create
+ beanType.pushInterceptor(createQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
+ bean.setCreate(lifecycle);
+ }
+ });
+
+ // bean has a start
+ beanType.pushInterceptor(startQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
+ bean.setStart(lifecycle);
+ }
+ });
+
+ // bean has a stop
+ beanType.pushInterceptor(stopQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
+ bean.setStop(lifecycle);
+ }
+ });
+
+ // bean has a destroy
+ beanType.pushInterceptor(destroyQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) child;
+ bean.setDestroy(lifecycle);
+ }
+ });
+
+ // lifecycle binding
+ TypeBinding lifecycleType = schemaBinding.getType(lifecycleTypeQName);
+ lifecycleType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractLifecycleMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("method".equals(localName))
+ lifecycle.setMethodName(attrs.getValue(i));
+ }
+ }
+ });
+
+ // lifecycle has a list parameters
+ lifecycleType.pushInterceptor(parameterQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractLifecycleMetaData lifecycle = (AbstractLifecycleMetaData) parent;
+ AbstractParameterMetaData parameter = (AbstractParameterMetaData) child;
+ List parameters = lifecycle.getParameters();
+ if (parameters == null)
+ {
+ parameters = new ArrayList();
+ lifecycle.setParameters(parameters);
+ }
+ parameters.add(parameter);
+ }
+ });
+
+ // bean has a set of properties
+ beanType.pushInterceptor(propertyQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ AbstractPropertyMetaData property = (AbstractPropertyMetaData) child;
+ Set properties = bean.getProperties();
+ if (properties == null)
+ {
+ properties = new HashSet();
+ bean.setProperties(properties);
+ }
+ properties.add(property);
+ }
+ });
+
+ // beanfactory has a set of properties
+ beanFactoryType.pushInterceptor(propertyQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ Set properties = bean.getProperties();
+ AbstractPropertyMetaData props = null;
+ for (Iterator i = properties.iterator(); i.hasNext();)
+ {
+ AbstractPropertyMetaData prop = (AbstractPropertyMetaData) i.next();
+ if ("properties".equals(prop.getName()))
+ {
+ props = prop;
+ break;
+ }
+ }
+ AbstractMapMetaData map = null;
+ if (props == null)
+ {
+ map = new AbstractMapMetaData();
+ props = new AbstractPropertyMetaData("properties", map);
+ properties.add(props);
+ }
+ else
+ {
+ map = (AbstractMapMetaData) props.getValue();
+ }
+
+ AbstractPropertyMetaData property = (AbstractPropertyMetaData) child;
+ ValueMetaData valueMetaData = property.getValue();
+ valueMetaData = new AbstractValueMetaData(valueMetaData);
+ map.put(new AbstractValueMetaData(property.getName()), valueMetaData);
+ }
+ });
+
+ // bean has a set of depends
+ beanType.pushInterceptor(dependsQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ AbstractDependencyMetaData dependency = (AbstractDependencyMetaData) child;
+ Set demands = bean.getDemands();
+ if (demands == null)
+ {
+ demands = new HashSet();
+ bean.setDemands(demands);
+ }
+ demands.add(dependency);
+ }
+ });
+
+ // bean has a set of demands
+ beanType.pushInterceptor(demandQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ AbstractDemandMetaData demand = (AbstractDemandMetaData) child;
+ Set demands = bean.getDemands();
+ if (demands == null)
+ {
+ demands = new HashSet();
+ bean.setDemands(demands);
+ }
+ demands.add(demand);
+ }
+ });
+
+ // bean has a set of supplies
+ beanType.pushInterceptor(supplyQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+ AbstractSupplyMetaData supply = (AbstractSupplyMetaData) child;
+ Set supplies = bean.getSupplies();
+ if (supplies == null)
+ {
+ supplies = new HashSet();
+ bean.setSupplies(supplies);
+ }
+ supplies.add(supply);
+ }
+ });
+
+ // property binding
+ TypeBinding propertyType = schemaBinding.getType(propertyTypeQName);
+ propertyType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractPropertyMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractPropertyMetaData property = (AbstractPropertyMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("name".equals(localName))
+ property.setName(attrs.getValue(i));
+ else if ("class".equals(localName))
+ {
+ StringValueMetaData svmd = new StringValueMetaData();
+ svmd.setType(attrs.getValue(i));
+ property.setValue(svmd);
+ }
+ }
+ }
+
+ public Object endElement(Object o, QName qName, ElementBinding element)
+ {
+ AbstractPropertyMetaData x = (AbstractPropertyMetaData) o;
+ String name = x.getName();
+ if (name == null || name.trim().length() == 0)
+ throw new IllegalArgumentException("Null or empty property name.");
+ return o;
+ }
+ });
+
+ // property can take a value
+ propertyType.setSimpleType(new CharactersHandler()
+ {
+ public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
+ {
+ return new StringValueMetaData(value);
+ }
+
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ AbstractPropertyMetaData property = (AbstractPropertyMetaData) owner;
+ StringValueMetaData svmd = (StringValueMetaData) value;
+ ValueMetaData vmd = property.getValue();
+ if (vmd != null && vmd instanceof StringValueMetaData)
+ {
+ StringValueMetaData previous = (StringValueMetaData) vmd;
+ String type = previous.getType();
+ if (type != null)
+ svmd.setType(type);
+ }
+ property.setValue(svmd);
+ }
+ });
+
+ // dependency binding
+ TypeBinding dependsType = schemaBinding.getType(dependsTypeQName);
+ dependsType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractDependencyMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ }
+
+ public Object endElement(Object o, QName qName, ElementBinding element)
+ {
+ AbstractDependencyMetaData x = (AbstractDependencyMetaData) o;
+ String name = (String) x.getDependency();
+ if (name == null || name.trim().length() == 0)
+ throw new IllegalArgumentException("Null or empty dependency.");
+ return o;
+ }
+ });
+
+ // depends can take a value
+ dependsType.setSimpleType(new CharactersHandler()
+ {
+ public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
+ {
+ return value;
+ }
+
+ public void setValue(QName qname, ElementBinding element, Object owner, Object value)
+ {
+ AbstractDependencyMetaData depends = (AbstractDependencyMetaData) owner;
+ depends.setDependency(value);
+ }
+ });
+
+ // demand binding
+ TypeBinding demandType = schemaBinding.getType(demandTypeQName);
+ demandType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractDemandMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractDemandMetaData demand = (AbstractDemandMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("state".equals(localName))
+ demand.setWhenRequired(new ControllerState(attrs.getValue(i)));
+ }
+ }
+
+ public Object endElement(Object o, QName qName, ElementBinding element)
+ {
+ AbstractDemandMetaData x = (AbstractDemandMetaData) o;
+ String name = (String) x.getDemand();
+ if (name == null || name.trim().length() == 0)
+ throw new IllegalArgumentException("Null or empty demand.");
+ return o;
+ }
+ });
+
+ // demand can take a value
+ demandType.setSimpleType(new CharactersHandler()
+ {
+ public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
+ {
+ return value;
+ }
+
+ public void setValue(QName qname, ElementBinding element, Object owner, Object value)
+ {
+ AbstractDemandMetaData demand = (AbstractDemandMetaData) owner;
+ demand.setDemand(value);
+ }
+ });
+
+ // supply binding
+ TypeBinding supplyType = schemaBinding.getType(supplyTypeQName);
+ supplyType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractSupplyMetaData();
+ }
+
+ public Object endElement(Object o, QName qName, ElementBinding element)
+ {
+ AbstractSupplyMetaData x = (AbstractSupplyMetaData) o;
+ String name = (String) x.getSupply();
+ if (name == null || name.trim().length() == 0)
+ throw new IllegalArgumentException("Null or empty supply.");
+ return o;
+ }
+ });
+
+ // supply can take a value
+ supplyType.setSimpleType(new CharactersHandler()
+ {
+ public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
+ {
+ return value;
+ }
+
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ AbstractSupplyMetaData supply = (AbstractSupplyMetaData) owner;
+ supply.setSupply(value);
+ }
+ });
+
+ // dependency binding
+ TypeBinding dependencyType = schemaBinding.getType(dependencyTypeQName);
+ dependencyType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractDependencyValueMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("bean".equals(localName))
+ dependency.setValue(attrs.getValue(i));
+ else if ("property".equals(localName))
+ dependency.setProperty(attrs.getValue(i));
+ else if ("state".equals(localName))
+ dependency.setDependentState(new ControllerState(attrs.getValue(i)));
+ }
+ }
+
+ public Object endElement(Object o, QName qName, ElementBinding element)
+ {
+ AbstractDependencyValueMetaData x = (AbstractDependencyValueMetaData) o;
+ String name = (String) x.getUnderlyingValue();
+ if (name == null || name.trim().length() == 0)
+ throw new IllegalArgumentException("Null or empty bean in injection/factory.");
+ return o;
+ }
+ });
+
+ // value binding
+ TypeBinding plainValueType = schemaBinding.getType(plainValueTypeQName);
+ plainValueType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new StringValueMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ StringValueMetaData value = (StringValueMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("class".equals(localName))
+ value.setType(attrs.getValue(i));
+ }
+ }
+ });
+
+ // value can take a value
+ plainValueType.setSimpleType(new CharactersHandler()
+ {
+ public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
+ {
+ return value;
+ }
+
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ StringValueMetaData valueMetaData = (StringValueMetaData) owner;
+ valueMetaData.setValue(value);
+ }
+ });
+
+ // value binding
+ TypeBinding valueType = schemaBinding.getType(valueTypeQName);
+ valueType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractValueMetaData(new StringValueMetaData());
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractValueMetaData value = (AbstractValueMetaData) o;
+ StringValueMetaData string = (StringValueMetaData) value.getValue();
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("class".equals(localName))
+ string.setType(attrs.getValue(i));
+ }
+ }
+ });
+
+ // value can take a value
+ valueType.setSimpleType(new CharactersHandler()
+ {
+ public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
+ {
+ return value;
+ }
+
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ AbstractValueMetaData valueMetaData = (AbstractValueMetaData) owner;
+ StringValueMetaData string = (StringValueMetaData) valueMetaData.getValue();
+ string.setValue(value);
+ }
+ });
+
+ // collection binding
+ configureCollection(collectionTypeQName);
+
+ // list binding
+ configureCollection(listTypeQName);
+
+ // set binding
+ configureCollection(setTypeQName);
+
+ // array binding
+ configureCollection(arrayTypeQName);
+
+ // map binding
+ TypeBinding mapType = schemaBinding.getType(mapTypeQName);
+ mapType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new AbstractMapMetaData();
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractMapMetaData collection = (AbstractMapMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("class".equals(localName))
+ collection.setType(attrs.getValue(i));
+ else if ("keyClass".equals(localName))
+ collection.setKeyType(attrs.getValue(i));
+ else if ("valueClass".equals(localName))
+ collection.setValueType(attrs.getValue(i));
+ }
+ }
+ });
+
+ // map has a map entries
+ mapType.pushInterceptor(entryQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractMapMetaData map = (AbstractMapMetaData) parent;
+ MapEntry entry = (MapEntry) child;
+ AbstractValueMetaData entryKey = (AbstractValueMetaData) entry.key;
+ if (entryKey == null)
+ throw new IllegalArgumentException("No key in map entry");
+ AbstractValueMetaData entryValue = (AbstractValueMetaData) entry.value;
+ if (entryValue == null)
+ throw new IllegalArgumentException("No value in map entry");
+ map.put(entryKey.getValue(), entryValue.getValue());
+ }
+ });
+
+ // entry binding
+ TypeBinding entryType = schemaBinding.getType(entryTypeQName);
+ entryType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new MapEntry();
+ }
+ });
+
+ // entry has a key
+ entryType.pushInterceptor(keyQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ MapEntry entry = (MapEntry) parent;
+ ValueMetaData value = (ValueMetaData) child;
+ entry.key = value;
+ }
+ });
+
+ // entry has a value
+ entryType.pushInterceptor(valueQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ MapEntry entry = (MapEntry) parent;
+ ValueMetaData value = (ValueMetaData) child;
+ entry.value = value;
+ }
+ });
+
+ now = System.currentTimeMillis();
+
+ log.debug("Creating schema binding took " + (now - start) + " milliseconds");
+
+ return schemaBinding;
+ }
+
+ protected String getXsd()
+ {
+ return "xml/bean-deployer_1_0.xsd";
+ }
+
+ // Private
+
+ private static SchemaBinding createBinding()
+ {
+ SchemaBinding cursor = new SchemaBinding();
+
+ //
+ // Declare all the types
+ //
+/* TODO
+ TypeBinding kernelControllerStateType = new TypeBinding(kernelControllerStateTypeQName);
+ cursor.addType(kernelControllerStateType);
+ TypeBinding classNameType = new TypeBinding(classNameTypeQName);
+ cursor.addType(classNameType);
+ TypeBinding deploymentType = new TypeBinding(deploymentTypeQName);
+ cursor.addType(deploymentType);
+ TypeBinding beanType = new TypeBinding(beanTypeQName);
+ cursor.addType(beanType);
+ TypeBinding annotationType = new TypeBinding(annotationTypeQName);
+ cursor.addType(annotationType);
+ TypeBinding constructorType = new TypeBinding(constructorTypeQName);
+ cursor.addType(constructorType);
+ TypeBinding namedValueType = new TypeBinding(namedValueTypeQName);
+ cursor.addType(namedValueType);
+ TypeBinding demandType = new TypeBinding(demandTypeQName);
+ cursor.addType(demandType);
+ TypeBinding stringType = new TypeBinding(Constants.QNAME_STRING);
+ cursor.addType(stringType);
+ TypeBinding tokenType = new TypeBinding(Constants.QNAME_TOKEN);
+ cursor.addType(tokenType);
+ TypeBinding factoryType = new TypeBinding(factoryTypeQName);
+ cursor.addType(factoryType);
+ TypeBinding valueWithClassType = new TypeBinding(valueWithClassTypeQName);
+ cursor.addType(valueWithClassType);
+ TypeBinding dependencyType = new TypeBinding();
+ TypeBinding listType = new TypeBinding(listTypeQName);
+ cursor.addType(listType);
+ TypeBinding mapType = new TypeBinding(mapTypeQName);
+ cursor.addType(mapType);
+ TypeBinding propsType = new TypeBinding(propsTypeQName);
+ cursor.addType(propsType);
+ TypeBinding mixedValueType = new TypeBinding(mixedValueTypeQName);
+ cursor.addType(mixedValueType);
+ TypeBinding valueType = new TypeBinding(valueTypeQName);
+ cursor.addType(valueType);
+ TypeBinding nullType = new TypeBinding();
+ TypeBinding annotationAttributeType = new TypeBinding(annotationAttributeTypeQName);
+ cursor.addType(annotationAttributeType);
+
+ //
+ // Assemble schema
+ //
+
+ deploymentType.addElement(beanQName, beanType);
+
+ beanType.addElement(annotationQName, annotationType);
+ beanType.addElement(constructorQName, constructorType);
+ beanType.addElement(propertyQName, namedValueType);
+ beanType.addElement(demandQName, demandType);
+ beanType.addElement(supplyQName, stringType);
+ beanType.addAttribute(nameAttrQName, stringType, AttributeHandler.NOOP);
+ beanType.addAttribute(classAttrQName, tokenType, AttributeHandler.NOOP);
+
+ constructorType.addElement(annotationQName, annotationType);
+ constructorType.addElement(factoryQName, factoryType);
+ constructorType.addElement(parameterQName, valueWithClassType);
+ constructorType.addAttribute(factoryClassAttrQName, classNameType, AttributeHandler.NOOP);
+ constructorType.addAttribute(factoryMethodAttrQName, tokenType, AttributeHandler.NOOP);
+
+ // valueGroup
+ Map valueGroup = new HashMap();
+ valueGroup.put(listQName, listType);
+ valueGroup.put(setQName, listType);
+ valueGroup.put(listQName, listType);
+ valueGroup.put(mapQName, mapType);
+ valueGroup.put(propsQName, propsType);
+ valueGroup.put(dependencyQName, dependencyType);
+ valueGroup.put(parameterQName, valueWithClassType);
+ valueGroup.put(propertyQName, namedValueType);
+ valueGroup.put(nullQName, nullType);
+
+ mixedValueType.addGroup(valueGroup);
+ mixedValueType.addElement(beanQName, beanType);
+
+ // todo type extensions
+ namedValueType.addGroup(valueGroup);
+ namedValueType.addElement(beanQName, beanType);
+ namedValueType.addElement(annotationQName, annotationType);
+ namedValueType.addAttribute(nameAttrQName, stringType, AttributeHandler.NOOP);
+
+ valueType.addGroup(valueGroup);
+ valueType.addElement(beanQName, beanType);
+
+ valueWithClassType.addGroup(valueGroup);
+ valueWithClassType.addElement(beanQName, beanType);
+ valueWithClassType.addAttribute(classAttrQName, classNameType, AttributeHandler.NOOP);
+
+ listType.addElement(valueQName, mixedValueType);
+ listType.addAttribute(classAttrQName, classNameType, AttributeHandler.NOOP);
+
+ mapType.addElement(mapEntryQName, namedValueType);
+ mapType.addAttribute(classAttrQName, classNameType, AttributeHandler.NOOP);
+
+ TypeBinding propsEntryType = new TypeBinding();
+ propsType.addElement(propsEntryQName, propsEntryType);
+ propsEntryType.addAttribute(nameAttrQName, stringType, AttributeHandler.NOOP);
+
+ factoryType.addAttribute(beanAttrQName, stringType, AttributeHandler.NOOP);
+
+ demandType.addAttribute(whenRequiredAttrQName, kernelControllerStateType, AttributeHandler.NOOP);
+
+ annotationType.addElement(attributeQName, annotationAttributeType);
+ annotationType.addAttribute(nameAttrQName, stringType, AttributeHandler.NOOP);
+
+ annotationAttributeType.addAttribute(nameAttrQName, stringType, AttributeHandler.NOOP);
+ annotationAttributeType.addAttribute(valueAttrQName, stringType, AttributeHandler.NOOP);
+
+ dependencyType.addAttribute(valueAttrQName, stringType, AttributeHandler.NOOP);
+ dependencyType.addAttribute(stateAttrQName, kernelControllerStateType, AttributeHandler.NOOP);
+
+ // global elements
+ cursor.addElement(deploymentQName, deploymentType);
+*/
+ return cursor;
+ }
+
+ /**
+ * Configure a collection.
+ */
+ private static void configureCollection(QName qname)
+ {
+ TypeBinding collectionType = schemaBinding.getType(qname);
+ collectionType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ if (collectionQName.equals(name))
+ return new AbstractCollectionMetaData();
+ else if (listQName.equals(name))
+ return new AbstractListMetaData();
+ else if (setQName.equals(name))
+ return new AbstractSetMetaData();
+ else if (arrayQName.equals(name))
+ return new AbstractArrayMetaData();
+ else
+ throw new IllegalArgumentException("Unknown collection qname=" + name);
+ }
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ AbstractCollectionMetaData collection = (AbstractCollectionMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("class".equals(localName))
+ collection.setType(attrs.getValue(i));
+ else if ("elementClass".equals(localName))
+ collection.setElementType(attrs.getValue(i));
+ }
+ }
+ });
+ }
+
+ private static class MapEntry
+ {
+ public Object key;
+ public Object value;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/QNameAttributesUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/QNameAttributesUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/QNameAttributesUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,190 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.IOException;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.AbstractMarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 46059 $</tt>
+ */
+public class QNameAttributesUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String XSD =
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
+ " targetNamespace='http://www.jboss.org/test/xml/qnameattr'" +
+ " xmlns='http://www.jboss.org/test/xml/qnameattr'" +
+ " xmlns:jbxb='" +
+ Constants.NS_JBXB +
+ "'" +
+ " elementFormDefault='qualified' version='1.0'>" +
+ " <xsd:complexType name='UserType'>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='" +
+ UserType.class.getName() +
+ "'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:sequence>" +
+ " <xsd:element name='arr' type='xsd:QName' minOccurs='0' maxOccurs='unbounded'/>" +
+ " </xsd:sequence>" +
+ " <xsd:attribute name='qname' type='xsd:QName'/>" +
+ " <xsd:attribute name='qname2' type='xsd:QName'/>" +
+ " <xsd:attribute name='qname3' type='xsd:QName'/>" +
+ " </xsd:complexType>" +
+ " <xsd:element name='ut' type='UserType'/>" +
+ "</xsd:schema>";
+
+ private static final String XML =
+ "<ns_ut:ut xmlns:ns_ut='http://www.jboss.org/test/xml/qnameattr'" +
+ " xmlns:ns_local1='http://ns1' qname='ns_local1:local1' qname2='local2'" +
+ " xmlns:x='http://x' qname3='x:local3'>" +
+ "</ns_ut:ut>";
+
+ private static final String ARR_XML =
+ "<ut xmlns='http://www.jboss.org/test/xml/qnameattr'>" +
+ " <arr xmlns:local2_ns='http://ns2'>local2_ns:local2</arr>" +
+ " <arr xmlns:ns3='http://ns3'>ns3:local3</arr>" +
+ " <arr xmlns:ns4='http://ns4'>ns4:local4</arr>" +
+ "</ut>";
+
+ private static final MappingObjectModelProvider OM_PROVIDER = new MappingObjectModelProvider();
+
+ public QNameAttributesUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ // Tests
+
+ public void testMarshallingXerces() throws Exception
+ {
+ assertMarshalling(new XercesXsMarshaller());
+ }
+
+ public void testMarshallingSunday() throws Exception
+ {
+ assertMarshalling(new MarshallerImpl());
+ }
+
+ public void testUnmarshalling() throws Exception
+ {
+ SchemaBinding schema = XsdBinder.bind(new StringReader(XSD), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML), schema);
+ assertNotNull(o);
+ assertTrue(o instanceof UserType);
+ UserType ut = (UserType)o;
+ assertNotNull(ut.qname);
+ assertEquals("local1", ut.qname.getLocalPart());
+ assertEquals("http://ns1", ut.qname.getNamespaceURI());
+ assertNotNull(ut.qname2);
+ assertEquals("local2", ut.qname2.getLocalPart());
+ assertEquals("", ut.qname2.getNamespaceURI());
+ assertNotNull(ut.qname3);
+ assertEquals("local3", ut.qname3.getLocalPart());
+ assertEquals("http://x", ut.qname3.getNamespaceURI());
+ }
+
+ public void testUnmarshallingArray() throws Exception
+ {
+ SchemaBinding schema = XsdBinder.bind(new StringReader(XSD), null);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(ARR_XML), schema);
+ assertNotNull(o);
+ assertTrue(o instanceof UserType);
+ UserType ut = (UserType)o;
+ assertNull(ut.qname);
+ assertNull(ut.qname2);
+ assertNull(ut.qname3);
+ assertNotNull(ut.arr);
+ assertEquals(3, ut.arr.length);
+ assertEquals(new QName("http://ns2", "local2"), ut.arr[0]);
+ assertEquals(new QName("http://ns3", "local3"), ut.arr[1]);
+ assertEquals(new QName("http://ns4", "local4"), ut.arr[2]);
+ }
+
+ public void testMarshallingArrayXerces() throws Exception
+ {
+ assertMarshallingArray(new XercesXsMarshaller());
+ }
+
+ public void testMarshallingArraySunday() throws Exception
+ {
+ assertMarshallingArray(new MarshallerImpl());
+ }
+
+ // Private
+
+ private void assertMarshallingArray(AbstractMarshaller marshaller)
+ throws IOException, SAXException, ParserConfigurationException
+ {
+ UserType ut = new UserType();
+ ut.arr = new QName[]{
+ new QName("http://ns2", "local2"),
+ new QName("http://ns3", "local3", "ns3"),
+ new QName("http://ns4", "local4", "ns4")
+ };
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), OM_PROVIDER, ut, writer);
+ assertXmlEqual(ARR_XML, writer.getBuffer().toString());
+ }
+
+ private void assertMarshalling(AbstractMarshaller marshaller)
+ throws IOException, SAXException, ParserConfigurationException
+ {
+ UserType ut = new UserType();
+ ut.qname = new QName("http://ns1", "local1");
+ ut.qname2 = new QName("local2");
+ ut.qname3 = new QName("http://x", "local3");
+
+ StringWriter writer = new StringWriter();
+ marshaller.declareNamespace("x", "http://x");
+ marshaller.marshal(new StringReader(XSD), OM_PROVIDER, ut, writer);
+
+ assertXmlEqual(XML, writer.getBuffer().toString());
+ }
+
+ public static final class UserType
+ {
+ public QName qname;
+ public QName qname2;
+ public QName qname3;
+ public QName[] arr;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaBindingInitializerUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaBindingInitializerUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaBindingInitializerUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,140 @@
+/*
+* 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.xml;
+
+import junit.framework.Test;
+
+import org.jboss.test.xml.initializer.Container;
+import org.jboss.test.xml.initializer.ContainerInitializer;
+import org.jboss.test.xml.initializer.Simple;
+import org.jboss.test.xml.initializer.SimpleInitializer;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+
+/**
+ * SchemaBindingInitializerUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 40498 $
+ */
+public class SchemaBindingInitializerUnitTestCase extends AbstractJBossXBTest
+{
+ public static SchemaBindingResolver initResolver() throws Exception
+ {
+ Class clazz = SchemaBindingInitializerUnitTestCase.class;
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ resolver.addSchemaInitializer(SimpleInitializer.NS, SimpleInitializer.class.getName());
+ String location = getSchemaLocation(clazz, "SchemaBindingInitializerUnitTestCaseSimple.xsd");
+ resolver.addSchemaLocation(SimpleInitializer.NS, location);
+ resolver.addSchemaInitializer(ContainerInitializer.NS, ContainerInitializer.class.getName());
+ location = getSchemaLocation(clazz, "SchemaBindingInitializerUnitTestCaseContainer.xsd");
+ resolver.addSchemaLocation(ContainerInitializer.NS, location);
+ return resolver;
+ }
+
+ public void testSimple() throws Exception
+ {
+ Simple simple = (Simple) unmarshal(rootName + "Simple.xml", Simple.class);
+ assertEquals("SimpleTest", simple.getValue());
+ }
+
+ public void testContainer() throws Exception
+ {
+ Container container = (Container) unmarshal(rootName + "Container.xml", Container.class);
+ assertNull(container.getValue());
+ }
+
+ public void testContainerStrictSimple() throws Exception
+ {
+ Container container = (Container) unmarshal(rootName + "ContainerStrictSimple.xml", Container.class);
+ Object value = container.getValue();
+ assertNotNull("Should have a value", value);
+ assertTrue("Should be a simple", value instanceof Simple);
+ Simple simple = (Simple) value;
+ assertEquals("ContainerStrict", simple.getValue());
+ }
+
+ public void testContainerStrictNotSimple() throws Exception
+ {
+ try
+ {
+ unmarshal(rootName + "ContainerStrictNotSimple.xml");
+ fail("Should not be here!");
+ }
+ catch (Exception e)
+ {
+ checkThrowable(JBossXBException.class, e);
+ }
+ }
+
+ public void testContainerLaxSimple() throws Exception
+ {
+ Container container = (Container) unmarshal(rootName + "ContainerLaxSimple.xml", Container.class);
+ Object value = container.getValue();
+ assertNotNull("Should have a value", value);
+ assertTrue("Should be a simple", value instanceof Simple);
+ Simple simple = (Simple) value;
+ assertEquals("ContainerLax", simple.getValue());
+ }
+
+ public void testContainerLaxNotSimple() throws Exception
+ {
+ Container container = (Container) unmarshal(rootName + "ContainerLaxNotSimple.xml", Container.class);
+ Object value = container.getValue();
+ assertNull("Should NOT have a value", value);
+ }
+
+ public void testContainerSkipSimple() throws Exception
+ {
+ Container container = (Container) unmarshal(rootName + "ContainerSkipSimple.xml", Container.class);
+ Object value = container.getValue();
+ assertNull("Should NOT have a value", value);
+ }
+
+ public void testContainerSkipNotSimple() throws Exception
+ {
+ Container container = (Container) unmarshal(rootName + "ContainerSkipNotSimple.xml", Container.class);
+ Object value = container.getValue();
+ assertNull("Should NOT have a value", value);
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(SchemaBindingInitializerUnitTestCase.class);
+ }
+
+ /**
+ * Create a new SchemaBindingInitializerUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public SchemaBindingInitializerUnitTestCase(String name)
+ {
+ super(name);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaImportUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaImportUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaImportUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,187 @@
+/*
+ * 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.xml;
+
+import java.util.List;
+import java.util.Collections;
+import java.io.StringReader;
+import java.io.StringWriter;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.LSInputAdaptor;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.AbstractMarshaller;
+import org.jboss.test.xml.book.Book;
+import org.w3c.dom.ls.LSInput;
+
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45336 $</tt>
+ */
+public class SchemaImportUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String NS = "http://www.jboss.org/test/xml/schema-import";
+ private static final String XSD = "<xsd:schema" +
+ " targetNamespace='" + NS + "'" +
+ " xmlns='" + NS + "'" +
+ " xmlns:bk='http://example.org/ns/books/'" +
+ " xmlns:jbxb='" + Constants.NS_JBXB + "'" +
+ " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
+ " <xsd:import namespace='http://example.org/ns/books/'/>" +
+ " <xsd:element name='root'>" +
+ " <xsd:complexType>" +
+ " <xsd:annotation>" +
+ " <xsd:appinfo>" +
+ " <jbxb:class impl='java.util.ArrayList'/>" +
+ " </xsd:appinfo>" +
+ " </xsd:annotation>" +
+ " <xsd:sequence>" +
+ " <xsd:element ref='bk:book' maxOccurs='unbounded'/>" +
+ " </xsd:sequence>" +
+ " </xsd:complexType>" +
+ " </xsd:element>" +
+ "</xsd:schema>";
+
+ private static final String XML = "<root xmlns='" + NS + "'" +
+ " xmlns:bk='http://example.org/ns/books/'>" +
+ "<bk:book isbn='123'>" +
+ "<bk:title>Ti t le</bk:title>" +
+ "<bk:author>A.U.Thor</bk:author>" +
+ "</bk:book>" +
+ "</root>";
+
+ private static final SchemaBindingResolver SCHEMA_RESOLVER = new SchemaBindingResolver()
+ {
+ public String getBaseURI()
+ {
+ throw new UnsupportedOperationException("getBaseURI is not implemented.");
+ }
+
+ public void setBaseURI(String baseURI)
+ {
+ throw new UnsupportedOperationException("setBaseURI is not implemented.");
+ }
+
+ public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation)
+ {
+ throw new UnsupportedOperationException("resolve is not implemented.");
+ }
+
+ public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation)
+ {
+ if("http://example.org/ns/books/".equals(nsUri))
+ {
+ return new LSInputAdaptor(
+ Thread.currentThread().getContextClassLoader().
+ getResourceAsStream("xml/book/annotated_books.xsd"), null);
+ }
+ return null;
+ }
+ };
+
+ public SchemaImportUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testUnmarshalling() throws Exception
+ {
+ SchemaBinding schema = XsdBinder.bind(new StringReader(XSD), null, SCHEMA_RESOLVER);
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML), schema);
+ assertNotNull(o);
+ assertTrue(o instanceof List);
+ List list = (List)o;
+ assertEquals(1, list.size());
+ o = list.get(0);
+ assertTrue(o instanceof Book);
+ Book book = (Book)o;
+ assertEquals("123", book.getIsbn());
+ assertEquals("Ti t le", book.getTitle());
+ assertEquals("A.U.Thor", book.getAuthor());
+ }
+
+ public void testMarshallingXerces() throws Exception
+ {
+ Book book = new Book();
+ book.setIsbn("123");
+ book.setTitle("Ti t le");
+ book.setAuthor("A.U.Thor");
+
+ String marshalled = marshalXerces(book);
+
+ assertXmlEqual(XML, marshalled);
+ }
+
+ public void testMarshallingSunday() throws Exception
+ {
+ Book book = new Book();
+ book.setIsbn("123");
+ book.setTitle("Ti t le");
+ book.setAuthor("A.U.Thor");
+
+ String marshalled = marshalSunday(book);
+
+ assertXmlEqual(XML, marshalled);
+ }
+
+ private String marshalXerces(Book book)
+ throws Exception
+ {
+ StringWriter writer = new StringWriter();
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ initMarshaller(marshaller);
+ marshaller.setSchemaResolver(SCHEMA_RESOLVER);
+ marshaller.marshal(new StringReader(XSD), new MappingObjectModelProvider(), Collections.singleton(book), writer);
+ return writer.getBuffer().toString();
+ }
+
+ private String marshalSunday(Book book)
+ throws Exception
+ {
+ StringWriter writer = new StringWriter();
+ MarshallerImpl marshaller = new MarshallerImpl();
+ initMarshaller(marshaller);
+ marshaller.setSchemaResolver(SCHEMA_RESOLVER);
+ marshaller.marshal(new StringReader(XSD), new MappingObjectModelProvider(), Collections.singleton(book), writer);
+ return writer.getBuffer().toString();
+ }
+
+ private void initMarshaller(AbstractMarshaller marshaller)
+ {
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_XML_VERSION, "false");
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ marshaller.declareNamespace("", NS);
+ marshaller.declareNamespace("bk", "http://example.org/ns/books/");
+ marshaller.addRootElement(NS, "", "root");
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaIncludeUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaIncludeUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemaIncludeUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,59 @@
+/*
+* 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.xml;
+
+import java.net.URL;
+
+import org.jboss.test.BaseTestCase;
+import org.jboss.xb.binding.Util;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+
+/**
+ * SchemaIncludeUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 42856 $
+ */
+public class SchemaIncludeUnitTestCase extends BaseTestCase
+{
+ public void testSimpleInclude() throws Exception
+ {
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ URL url = getClass().getResource("/xml/SchemaIncludeUnitTestCase.xsd");
+ assertNotNull(url);
+ Util.loadSchema(url.toString(), resolver);
+ }
+
+ public void testComplexInclude() throws Exception
+ {
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ URL url = getClass().getResource("/xml/SchemaIncludeUnitTestCase.xsd");
+ assertNotNull(url);
+ resolver.addSchemaLocation("urn:jbosstest:schemainclude", url.toString());
+ Util.loadSchema(url.toString(), resolver);
+ }
+
+ public SchemaIncludeUnitTestCase(String name)
+ {
+ super(name);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemalessTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemalessTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/SchemalessTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,72 @@
+/*
+ * 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.xml;
+
+import junit.framework.TestCase;
+import org.jboss.test.xml.person.Person;
+import org.jboss.xb.binding.SchemalessMarshaller;
+import org.jboss.xb.binding.SchemalessObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.logging.Logger;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class SchemalessTestCase
+ extends TestCase
+{
+ private static final Logger log = Logger.getLogger(SchemalessTestCase.class);
+
+ public SchemalessTestCase()
+ {
+ }
+
+ public SchemalessTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void testSchemalessMarshalling() throws Exception
+ {
+ Person person = Person.newInstance();
+ StringWriter writer = new StringWriter();
+
+ SchemalessMarshaller marshaller = new SchemalessMarshaller();
+ marshaller.marshal(person, writer);
+
+ log.info("marshalled:\n" + writer.getBuffer());
+
+ StringReader reader = new StringReader(writer.getBuffer().toString());
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ SchemalessObjectModelFactory factory = new SchemalessObjectModelFactory();
+ Person unmarshalled = (Person)unmarshaller.unmarshal(reader, factory, null);
+
+ log.info("unmarshalled: " + unmarshalled);
+ assertEquals(person, unmarshalled);
+ }
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/SimpleTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/SimpleTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/SimpleTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,349 @@
+/*
+ * 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.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Iterator;
+import org.jboss.logging.Logger;
+import org.jboss.test.xml.book.Book;
+import org.jboss.test.xml.book.BookCharacter;
+import org.jboss.test.xml.book.BookGenericObjectModelFactory;
+import org.jboss.test.xml.book.BookGenericObjectModelProvider;
+import org.jboss.test.xml.book.BookObjectFactory;
+import org.jboss.test.xml.book.BookObjectProvider;
+import org.jboss.xb.binding.AbstractMarshaller;
+import org.jboss.xb.binding.DtdMarshaller;
+import org.jboss.xb.binding.GenericObjectModelFactory;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.ObjectModelProvider;
+import org.jboss.xb.binding.SimpleTypeBindings;
+import org.jboss.xb.binding.TypeBinding;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 43309 $</tt>
+ */
+public class SimpleTestCase
+ extends TestCase
+{
+ private static final Logger log = Logger.getLogger(SimpleTestCase.class);
+
+ public SimpleTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testUnmarshalBookDtd() throws Exception
+ {
+ // create an object model factory
+ ObjectModelFactory factory = new BookObjectFactory();
+ unmarshalBook("book-dtd.xml", factory);
+ }
+
+ public void testUnmarshalBookXs() throws Exception
+ {
+ // create an object model factory
+ ObjectModelFactory factory = new BookObjectFactory();
+ unmarshalBook("book-xs.xml", factory);
+ }
+
+ public void testUnmarshalBookXsGenericFactory() throws Exception
+ {
+ // create an object model factory
+ GenericObjectModelFactory factory = new BookGenericObjectModelFactory();
+ unmarshalBook("book-xs.xml", factory);
+ }
+
+ public void testMarshallBookDtd() throws Exception
+ {
+ log.debug("--- " + getName());
+
+ // obtain an instance of Book to marshal
+ Book book = createBook();
+
+ // get the output writter to write the XML content
+ StringWriter xmlOutput = new StringWriter();
+
+ // get the DTD source
+ InputStream is = getResource("xml/book/books.dtd");
+ Reader dtdReader = new InputStreamReader(is);
+
+ // create an instance of DTD marshaller
+ DtdMarshaller marshaller = new DtdMarshaller();
+ marshaller.addBinding("since", new TypeBinding()
+ {
+ public Object unmarshal(String value)
+ {
+ // todo: implement unmarshal
+ throw new UnsupportedOperationException("unmarshal is not implemented.");
+ }
+
+ public String marshal(Object value)
+ {
+ return SimpleTypeBindings.marshalDate((Calendar)value);
+ }
+ }
+ );
+
+ // map publicId to systemId as it should appear in the resulting XML file
+ marshaller.mapPublicIdToSystemId("-//DTD Books//EN", "resources/xml/book/books.dtd");
+
+ // create an instance of ObjectModelProvider with the book instance to be marshalled
+ ObjectModelProvider provider = new BookObjectProvider();
+
+ // marshal the book
+ marshaller.marshal(dtdReader, provider, book, xmlOutput);
+
+ // close DTD reader
+ dtdReader.close();
+
+ String xml = xmlOutput.getBuffer().toString();
+ checkMarshalledBook(xml, book);
+ }
+
+ public void testMarshallBookXercesXs() throws Exception
+ {
+ log.debug("--- " + getName());
+
+ System.setProperty(Marshaller.PROP_MARSHALLER, XercesXsMarshaller.class.getName());
+ marshallingTest();
+ }
+
+ public void testMarshallBookDtdGeneric() throws Exception
+ {
+ log.debug("--- " + getName());
+
+ // obtain an instance of Book to marshal
+ Book book = createBook();
+
+ // get the output writter to write the XML content
+ StringWriter xmlOutput = new StringWriter();
+
+ // get the DTD source
+ InputStream is = getResource("xml/book/books.dtd");
+ Reader dtdReader = new InputStreamReader(is);
+
+ // create an instance of DTD marshaller
+ Marshaller marshaller = new DtdMarshaller();
+
+ // map publicId to systemId as it should appear in the resulting XML file
+ marshaller.mapPublicIdToSystemId("-//DTD Books//EN", "resources/xml/book/books.dtd");
+
+ // create an instance of ObjectModelProvider with the book instance to be marshalled
+ ObjectModelProvider provider = new BookGenericObjectModelProvider();
+
+ // marshal the book
+ marshaller.marshal(dtdReader, provider, book, xmlOutput);
+
+ // close DTD reader
+ dtdReader.close();
+
+ String xml = xmlOutput.getBuffer().toString();
+ if(log.isTraceEnabled())
+ {
+ log.trace("marshalled with dtd: " + xml);
+ }
+ checkMarshalledBook(xml, book);
+ }
+
+ // Private
+
+ private void marshallingTest()
+ throws Exception
+ {
+ // obtain an instance of Book to marshal
+ Book book = createBook();
+
+ // get the output writter to write the XML content
+ StringWriter xmlOutput = new StringWriter();
+
+ // create an instance of XML Schema marshaller
+ AbstractMarshaller marshaller = (AbstractMarshaller)Marshaller.FACTORY.getInstance();
+
+ // we need to specify what elements are top most (roots) providing namespace URI, prefix and local name
+ marshaller.addRootElement("http://example.org/ns/books/", "", "book");
+
+ // declare default namespace
+ marshaller.declareNamespace(null, "http://example.org/ns/books/");
+
+ // add schema location by declaring xsi namespace and adding xsi:schemaReader attribute
+ marshaller.declareNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
+ marshaller.addAttribute("xsi",
+ "schemaReader",
+ "string",
+ "http://example.org/ns/books/ resources/book/books.xsd"
+ );
+
+ // create an instance of Object Model Provider with no book
+ ObjectModelProvider provider = new BookObjectProvider();
+
+ // marshall Book instance passing it as an argument instead of using the one that is returned by the BookObjectProvider
+ marshaller.marshal(getResourceUrl("xml/book/books.xsd").toString(), provider, book, xmlOutput);
+
+ String xml = xmlOutput.getBuffer().toString();
+ if(log.isTraceEnabled())
+ {
+ log.debug("marshalled with " + marshaller.getClass().getName() + ": " + xml);
+ }
+ checkMarshalledBook(xml, book);
+ }
+
+ private void unmarshalBook(String xmlSource, ObjectModelFactory factory) throws Exception
+ {
+ log.debug("<test-unmarshal-" + xmlSource + '>');
+
+ // get the XML stream
+ URL xmlUrl = getResourceUrl("xml/book/" + xmlSource);
+
+ // create unmarshaller
+ Unmarshaller unmarshaller = getBookUnmarshaller();
+
+ // let the object model factory to create an instance of Book and populate it with data from XML
+ Book book = (Book)unmarshaller.unmarshal(xmlUrl.openStream(), factory, null);
+
+ checkUnmarshalledBook(book);
+
+ log.debug("</test-unmarshal-" + xmlSource + '>');
+ }
+
+ private void checkMarshalledBook(String content, Book book)
+ throws Exception
+ {
+ Book unmarshalled = new Book();
+ ObjectModelFactory factory = new BookObjectFactory();
+
+ Unmarshaller unmarshaller = getBookUnmarshaller();
+
+ StringReader strReader = new StringReader(content);
+ unmarshaller.unmarshal(strReader, factory, unmarshalled);
+ strReader.close();
+
+ assertEquals(book, unmarshalled);
+ }
+
+ private void checkUnmarshalledBook(Book book)
+ {
+ log.debug("unmarshalled book: " + book);
+
+ assertEquals("Being a Dog Is a Full-Time Job", book.getTitle());
+ assertEquals("Charles M. Schulz", book.getAuthor());
+ assertEquals("0836217462", book.getIsbn());
+ assertEquals(book.getCharactersTotal(), 2);
+
+ for(Iterator iter = book.getCharacters().iterator(); iter.hasNext();)
+ {
+ BookCharacter character = (BookCharacter)iter.next();
+ final String name = character.getName();
+ if(name.equals("Snoopy"))
+ {
+ assertEquals(character.getFriendOf(), "Peppermint Patty");
+ assertEquals(character.getSince(), "1950-10-04");
+ assertEquals(character.getQualification(), "extroverted beagle");
+ }
+ else if(name.equals("Peppermint Patty"))
+ {
+ assertEquals(character.getFriendOf(), null);
+ assertEquals(character.getSince(), "1966-08-22");
+ assertEquals(character.getQualification(), "bold, brash and tomboyish");
+ }
+ }
+ }
+
+ private static Unmarshaller getBookUnmarshaller() throws JBossXBException
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ unmarshaller.setEntityResolver(
+ new EntityResolver()
+ {
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+ {
+ if(systemId.endsWith("books.dtd"))
+ {
+ return new InputSource(getResource("xml/book/books.dtd"));
+ }
+ return null;
+ }
+ }
+ );
+ return unmarshaller;
+ }
+
+ private static Book createBook()
+ {
+ Book book = new Book();
+ book.setIsbn("0836217462");
+ book.setTitle("Being a Dog Is a Full-Time Job");
+ book.setAuthor("Charles M. Schulz");
+
+ BookCharacter character = new BookCharacter();
+ character.setName("Snoopy");
+ character.setFriendOf("Peppermint Patty");
+ character.setSince("1950-10-04");
+ character.setQualification("extroverted beagle");
+ book.addCharacter(character);
+
+ character = new BookCharacter();
+ character.setName("Peppermint Patty");
+ character.setSince("1966-08-22");
+ character.setQualification("bold, brash and tomboyish");
+ book.addCharacter(character);
+
+ return book;
+ }
+
+ private static InputStream getResource(String name)
+ {
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
+ if(is == null)
+ {
+ throw new IllegalStateException("Resource not found: " + name);
+ }
+ return is;
+ }
+
+ private static URL getResourceUrl(String name)
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(name);
+ if(url == null)
+ {
+ throw new IllegalStateException("Resource not found: " + name);
+ }
+ return url;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/SimpleTypeBindingUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/SimpleTypeBindingUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/SimpleTypeBindingUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,491 @@
+/*
+ * 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.xml;
+
+import junit.framework.TestCase;
+
+import org.jboss.xb.binding.SimpleTypeBindings;
+
+import javax.xml.namespace.QName;
+import javax.xml.namespace.NamespaceContext;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.Collections;
+import java.util.List;
+import java.util.Arrays;
+import java.math.BigInteger;
+import java.math.BigDecimal;
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 40286 $</tt>
+ */
+public class SimpleTypeBindingUnitTestCase
+ extends TestCase
+{
+ public SimpleTypeBindingUnitTestCase()
+ {
+ }
+
+ public SimpleTypeBindingUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void testIntUnmarshalling() throws Exception
+ {
+ assertEquals(Integer.MAX_VALUE,
+ ((Integer)SimpleTypeBindings.unmarshal("int", Integer.toString(Integer.MAX_VALUE), null)).intValue()
+ );
+ assertEquals(Integer.MIN_VALUE,
+ ((Integer)SimpleTypeBindings.unmarshal("int", Integer.toString(Integer.MIN_VALUE), null)).intValue()
+ );
+ }
+
+ public void testLongUnmarshalling() throws Exception
+ {
+ assertEquals(Long.MAX_VALUE,
+ ((Long)SimpleTypeBindings.unmarshal("long", Long.toString(Long.MAX_VALUE), null)).longValue()
+ );
+ assertEquals(Long.MIN_VALUE,
+ ((Long)SimpleTypeBindings.unmarshal("long", Long.toString(Long.MIN_VALUE), null)).longValue()
+ );
+ }
+
+ public void testShortUnmarshalling() throws Exception
+ {
+ assertEquals(Short.MAX_VALUE,
+ ((Short)SimpleTypeBindings.unmarshal("short", Short.toString(Short.MAX_VALUE), null)).shortValue()
+ );
+ assertEquals(Short.MIN_VALUE,
+ ((Short)SimpleTypeBindings.unmarshal("short", Short.toString(Short.MIN_VALUE), null)).shortValue()
+ );
+ }
+
+ public void testByteUnmarshalling() throws Exception
+ {
+ assertEquals(Byte.MAX_VALUE,
+ ((Byte)SimpleTypeBindings.unmarshal("byte", Byte.toString(Byte.MAX_VALUE), null)).byteValue()
+ );
+ assertEquals(Byte.MIN_VALUE,
+ ((Byte)SimpleTypeBindings.unmarshal("byte", Byte.toString(Byte.MIN_VALUE), null)).byteValue()
+ );
+ }
+
+ public void testFloatUnmarshalling() throws Exception
+ {
+ assertEquals(Float.MAX_VALUE,
+ ((Float)SimpleTypeBindings.unmarshal("float", Float.toString(Float.MAX_VALUE), null)).floatValue(),
+ 0
+ );
+ assertEquals(Float.MIN_VALUE,
+ ((Float)SimpleTypeBindings.unmarshal("float", Float.toString(Float.MIN_VALUE), null)).floatValue(),
+ 0
+ );
+ assertEquals(-1E4, ((Float)SimpleTypeBindings.unmarshal("float", "-1E4", null)).floatValue(), 0);
+ assertEquals(1267.43233E12,
+ ((Float)SimpleTypeBindings.unmarshal("float", "1267.43233E12", null)).floatValue(),
+ 1.267432366800896E15 - 1.26743233E15
+ );
+ assertEquals(12.78e-2,
+ ((Float)SimpleTypeBindings.unmarshal("float", "12.78e-2", null)).floatValue(),
+ 0.12780000269412994 - 0.1278
+ );
+ assertEquals(-0, ((Float)SimpleTypeBindings.unmarshal("float", "-0", null)).floatValue(), 0);
+ assertEquals(Float.POSITIVE_INFINITY,
+ ((Float)SimpleTypeBindings.unmarshal("float", "INF", null)).floatValue(),
+ 0
+ );
+ }
+
+ public void testDoubleUnmarshalling() throws Exception
+ {
+ assertEquals(Double.MAX_VALUE,
+ ((Double)SimpleTypeBindings.unmarshal("double", Double.toString(Double.MAX_VALUE), null)).doubleValue(),
+ 0
+ );
+ assertEquals(Double.MIN_VALUE,
+ ((Double)SimpleTypeBindings.unmarshal("double", Double.toString(Double.MIN_VALUE), null)).doubleValue(),
+ 0
+ );
+ assertEquals(-1E4, ((Double)SimpleTypeBindings.unmarshal("double", "-1E4", null)).doubleValue(), 0);
+ assertEquals(1267.43233E12,
+ ((Double)SimpleTypeBindings.unmarshal("double", "1267.43233E12", null)).doubleValue(),
+ 1.267432366800896E15 - 1.26743233E15
+ );
+ assertEquals(12.78e-2,
+ ((Double)SimpleTypeBindings.unmarshal("double", "12.78e-2", null)).doubleValue(),
+ 0.12780000269412994 - 0.1278
+ );
+ assertEquals(-0, ((Double)SimpleTypeBindings.unmarshal("double", "-0", null)).doubleValue(), 0);
+ assertEquals(Double.POSITIVE_INFINITY,
+ ((Double)SimpleTypeBindings.unmarshal("double", "INF", null)).doubleValue(),
+ 0
+ );
+ }
+
+ public void testBooleanUnmarshalling() throws Exception
+ {
+ assertEquals(Boolean.TRUE, SimpleTypeBindings.unmarshal("boolean", "true", null));
+ assertEquals(Boolean.TRUE, SimpleTypeBindings.unmarshal("boolean", "1", null));
+ assertEquals(Boolean.FALSE, SimpleTypeBindings.unmarshal("boolean", "false", null));
+ assertEquals(Boolean.FALSE, SimpleTypeBindings.unmarshal("boolean", "0", null));
+ }
+
+ public void testIntegerUnmarshalling() throws Exception
+ {
+ assertEquals(new BigInteger("-1"), SimpleTypeBindings.unmarshal("integer", "-1", null));
+ assertEquals(new BigInteger("0"), SimpleTypeBindings.unmarshal("integer", "0", null));
+ assertEquals(new BigInteger("12678967543233"), SimpleTypeBindings.unmarshal("integer", "12678967543233", null));
+ }
+
+ public void testDecimalUnmarshalling() throws Exception
+ {
+ assertEquals(new BigDecimal("-1.23"), SimpleTypeBindings.unmarshal("decimal", "-1.23", null));
+ assertEquals(new BigDecimal("12678967.543233"),
+ SimpleTypeBindings.unmarshal("decimal", "12678967.543233", null)
+ );
+ }
+
+ public void testAnyUriUnmarshalling() throws Exception
+ {
+ assertEquals(new URI("http://jboss.org"), SimpleTypeBindings.unmarshal("anyURI", "http://jboss.org", null));
+ }
+
+ public void testUnsignedLongUnmarshalling() throws Exception
+ {
+ assertEquals(new BigInteger("18446744073709551615"),
+ SimpleTypeBindings.unmarshal("unsignedLong", "18446744073709551615", null)
+ );
+ }
+
+ public void testUnsignedIntUnmarshalling() throws Exception
+ {
+ assertEquals(new Long(4294967295L), SimpleTypeBindings.unmarshal("unsignedInt", "4294967295", null));
+ }
+
+ public void testUnsignedShortUnmarshalling() throws Exception
+ {
+ assertEquals(new Integer(65535), SimpleTypeBindings.unmarshal("unsignedShort", "65535", null));
+ }
+
+ public void testUnsignedByteUnmarshalling() throws Exception
+ {
+ assertEquals(Short.valueOf("255"), SimpleTypeBindings.unmarshal("unsignedByte", "255", null));
+ }
+
+ public void testNonPositiveIntegerUnmarshalling() throws Exception
+ {
+ assertEquals(new BigInteger("0"), SimpleTypeBindings.unmarshal("nonPositiveInteger", "0", null));
+ assertEquals(new BigInteger("-12678967543233"),
+ SimpleTypeBindings.unmarshal("nonPositiveInteger", "-12678967543233", null)
+ );
+ }
+
+ public void testPositiveIntegerUnmarshalling() throws Exception
+ {
+ assertEquals(new BigInteger("12678967543233"),
+ SimpleTypeBindings.unmarshal("positiveInteger", "12678967543233", null)
+ );
+ }
+
+ public void testNonNegativeIntegerUnmarshalling() throws Exception
+ {
+ assertEquals(new BigInteger("0"), SimpleTypeBindings.unmarshal("nonNegativeInteger", "0", null));
+ assertEquals(new BigInteger("12678967543233"),
+ SimpleTypeBindings.unmarshal("nonNegativeInteger", "12678967543233", null)
+ );
+ }
+
+ public void testNegativeIntegerUnmarshalling() throws Exception
+ {
+ assertEquals(new BigInteger("-12678967543233"),
+ SimpleTypeBindings.unmarshal("negativeInteger", "-12678967543233", null)
+ );
+ }
+
+ public void testNMTokensUnmarshalling() throws Exception
+ {
+ String[] tokens = SimpleTypeBindings.unmarshalNMTokens("1\n2\n3\n");
+ assertEquals(3, tokens.length);
+ assertEquals("1", tokens[0]);
+ assertEquals("2", tokens[1]);
+ assertEquals("3", tokens[2]);
+ }
+
+ public void testGMonthDayUnmarshalling() throws Exception
+ {
+ Calendar cal = SimpleTypeBindings.unmarshalGMonthDay("--12-31-02:00");
+ assertEquals(1970, cal.get(Calendar.YEAR));
+ assertEquals(11, cal.get(Calendar.MONTH));
+ assertEquals(31, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+ assertEquals("GMT-02:00", cal.getTimeZone().getDisplayName());
+
+ cal = SimpleTypeBindings.unmarshalGMonthDay("--12-31");
+ assertEquals(1970, cal.get(Calendar.YEAR));
+ assertEquals(11, cal.get(Calendar.MONTH));
+ assertEquals(31, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+ }
+
+ public void testGMonthUnmarshalling() throws Exception
+ {
+ Calendar cal = SimpleTypeBindings.unmarshalGMonth("--12+03:00");
+ assertEquals(1970, cal.get(Calendar.YEAR));
+ assertEquals(11, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+ assertEquals("GMT+03:00", cal.getTimeZone().getDisplayName());
+
+ cal = SimpleTypeBindings.unmarshalGMonth("--12");
+ assertEquals(1970, cal.get(Calendar.YEAR));
+ assertEquals(11, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+ }
+
+ public void testGYearUnmarshalling() throws Exception
+ {
+ Calendar cal = SimpleTypeBindings.unmarshalGYear("1997-03:00");
+ assertEquals(1997, cal.get(Calendar.YEAR));
+ assertEquals(0, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+ assertEquals("GMT-03:00", cal.getTimeZone().getDisplayName());
+
+ cal = SimpleTypeBindings.unmarshalGYear("1997");
+ assertEquals(1997, cal.get(Calendar.YEAR));
+ assertEquals(0, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+ }
+
+ public void testGYearMonthUnmarshalling() throws Exception
+ {
+ Calendar cal = SimpleTypeBindings.unmarshalGYearMonth("1995-04+01:00");
+ assertEquals(1995, cal.get(Calendar.YEAR));
+ assertEquals(3, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+ assertEquals("GMT+01:00", cal.getTimeZone().getDisplayName());
+
+ cal = SimpleTypeBindings.unmarshalGYearMonth("1995-04");
+ assertEquals(1995, cal.get(Calendar.YEAR));
+ assertEquals(3, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+ }
+
+ public void testDatetimeUnmarshalling() throws Exception
+ {
+ Calendar cal = SimpleTypeBindings.unmarshalDateTime("1980-02-19T03:22:17.333+02:00");
+ assertEquals(1980, cal.get(Calendar.YEAR));
+ assertEquals(1, cal.get(Calendar.MONTH));
+ assertEquals(19, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(3, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(22, cal.get(Calendar.MINUTE));
+ assertEquals(17, cal.get(Calendar.SECOND));
+ assertEquals(333, cal.get(Calendar.MILLISECOND));
+ assertEquals("GMT+02:00", cal.getTimeZone().getDisplayName());
+ }
+
+ public void testTimeUnmarshalling() throws Exception
+ {
+ String value = "23:32:28.123+01:00";
+ Calendar cal = SimpleTypeBindings.unmarshalTime(value);
+ assertEquals(1970, cal.get(Calendar.YEAR));
+ assertEquals(0, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals("GMT+01:00", cal.getTimeZone().getDisplayName());
+ assertEquals(23, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(32, cal.get(Calendar.MINUTE));
+ assertEquals(28, cal.get(Calendar.SECOND));
+ assertEquals(123, cal.get(Calendar.MILLISECOND));
+
+ value = "23:32:28.123+01:00";
+ cal = SimpleTypeBindings.unmarshalTime(value);
+ assertEquals(1970, cal.get(Calendar.YEAR));
+ assertEquals(0, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(23, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(32, cal.get(Calendar.MINUTE));
+ assertEquals(28, cal.get(Calendar.SECOND));
+ assertEquals(123, cal.get(Calendar.MILLISECOND));
+ }
+
+ public void testDateUnmarshalling() throws Exception
+ {
+ String value = "2004-12-01+01:00";
+ Calendar cal = SimpleTypeBindings.unmarshalDate(value);
+ assertEquals(2004, cal.get(Calendar.YEAR));
+ assertEquals(11, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals("GMT+01:00", cal.getTimeZone().getDisplayName());
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+
+ value = "2004-12-01";
+ cal = SimpleTypeBindings.unmarshalDate(value);
+ assertEquals(2004, cal.get(Calendar.YEAR));
+ assertEquals(11, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+
+ value = "-2004-12-01+01:00";
+ cal = SimpleTypeBindings.unmarshalDate(value);
+ assertEquals(2004, cal.get(Calendar.YEAR));
+ assertEquals(11, cal.get(Calendar.MONTH));
+ assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals("GMT+01:00", cal.getTimeZone().getDisplayName());
+ assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
+ assertEquals(0, cal.get(Calendar.MINUTE));
+ assertEquals(0, cal.get(Calendar.SECOND));
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+ }
+
+ public void testHexBinary() throws Exception
+ {
+ String s = "kloop";
+ String marshalled = SimpleTypeBindings.marshal("hexBinary", s.getBytes(), null);
+ byte[] bytes = (byte[])SimpleTypeBindings.unmarshal("hexBinary", marshalled, null);
+ String unmarshalled = new String(bytes);
+ assertEquals(s, unmarshalled);
+ }
+
+ public void testQName() throws Exception
+ {
+ final String ns = "http://jboss.org/test/simple/bindings";
+ String local = "test1";
+ final String prefix = "p1";
+ QName qName = new QName(ns, local, prefix);
+
+ NamespaceContext nsCtx = new NamespaceContext()
+ {
+ public String getNamespaceURI(String p)
+ {
+ if(!prefix.equals(p))
+ {
+ throw new IllegalStateException("The only supported prefix is " + prefix + " but got " + p);
+ }
+ return ns;
+ }
+
+ public String getPrefix(String namespaceURI)
+ {
+ if(!ns.equals(namespaceURI))
+ {
+ throw new IllegalStateException("The only supported uri is " + ns + " but got " + namespaceURI);
+ }
+ return prefix;
+ }
+
+ public Iterator getPrefixes(String namespaceURI)
+ {
+ if(!ns.equals(namespaceURI))
+ {
+ throw new IllegalStateException("The only supported uri is " + ns + " but got " + namespaceURI);
+ }
+ return Collections.singletonList(prefix).iterator();
+ }
+ };
+
+ String marshalled = SimpleTypeBindings.marshal(SimpleTypeBindings.XS_QNAME_NAME, qName, nsCtx);
+ assertEquals(prefix + ":" + local, marshalled);
+
+ QName unmarshalled = (QName)SimpleTypeBindings.unmarshal(SimpleTypeBindings.XS_QNAME_NAME, marshalled, nsCtx);
+
+ assertEquals(qName.getPrefix(), unmarshalled.getPrefix());
+ assertEquals(qName.getNamespaceURI(), unmarshalled.getNamespaceURI());
+ assertEquals(qName.getLocalPart(), unmarshalled.getLocalPart());
+ }
+
+ public void testBooleanListUnmarshalling() throws Exception
+ {
+ List booleans = SimpleTypeBindings.unmarshalList(
+ SimpleTypeBindings.XS_BOOLEAN_NAME, " 1 1 0 true true false ", null
+ );
+ assertNotNull(booleans);
+ assertEquals(6, booleans.size());
+
+ int i = 0;
+ Boolean item = (Boolean)booleans.get(i++);
+ assertNotNull(item);
+ assertTrue(item.booleanValue());
+ item = (Boolean)booleans.get(i++);
+ assertNotNull(item);
+ assertTrue(item.booleanValue());
+ item = (Boolean)booleans.get(i++);
+ assertNotNull(item);
+ assertFalse(item.booleanValue());
+ item = (Boolean)booleans.get(i++);
+ assertNotNull(item);
+ assertTrue(item.booleanValue());
+ item = (Boolean)booleans.get(i++);
+ assertNotNull(item);
+ assertTrue(item.booleanValue());
+ item = (Boolean)booleans.get(i++);
+ assertNotNull(item);
+ assertFalse(item.booleanValue());
+ }
+
+ public void testBooleanListMarshalling() throws Exception
+ {
+ String marshalled = SimpleTypeBindings.marshalList(
+ SimpleTypeBindings.XS_BOOLEAN_NAME,
+ Arrays.asList(new Boolean[]{Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE}),
+ null
+ );
+ assertNotNull(marshalled);
+ assertEquals("true true false true", marshalled);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/SoapEncUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/SoapEncUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/SoapEncUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,729 @@
+/*
+ * 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.xml;
+
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.io.StringReader;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Arrays;
+import java.util.TimeZone;
+import java.lang.reflect.Array;
+import javax.xml.namespace.QName;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.Marshaller;
+import org.jboss.xb.binding.AbstractMarshaller;
+import org.jboss.xb.binding.sunday.unmarshalling.LSInputAdaptor;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.w3c.dom.ls.LSInput;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45337 $</tt>
+ */
+public class SoapEncUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final SchemaBindingResolver RESOLVER = new SchemaBindingResolver()
+ {
+ public String getBaseURI()
+ {
+ throw new UnsupportedOperationException("getBaseURI is not implemented.");
+ }
+
+ public void setBaseURI(String baseURI)
+ {
+ throw new UnsupportedOperationException("setBaseURI is not implemented.");
+ }
+
+ public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation)
+ {
+ throw new UnsupportedOperationException("resolve is not implemented.");
+ }
+
+ public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation)
+ {
+ if("http://schemas.xmlsoap.org/soap/encoding/".equals(nsUri))
+ {
+ InputStream is = getStream("xml/soapenc/soapenc.xsd");
+ return new LSInputAdaptor(is, null);
+ }
+
+ throw new IllegalStateException("Unexpected nsUri: " + nsUri);
+ }
+ };
+
+ private static final String XML =
+ "<ns_allStruct:allStruct xmlns:ns_allStruct=\"http://ParameterModeTest.org/xsd\">" +
+ "<varString>String1</varString>" +
+ "<varInteger>3512359</varInteger>" +
+ "<varInt>-2147483648</varInt>" +
+ "<varLong>-9223372036854775808</varLong>" +
+ "<varShort>-32768</varShort>" +
+ "<varDecimal>3512359.1456</varDecimal>" +
+ "<varFloat>1.4E-45</varFloat>" +
+ "<varDouble>4.9E-324</varDouble>" +
+ "<varBoolean>false</varBoolean>" +
+ "<varByte>-128</varByte>" +
+ "<varQName xmlns=\"\">String2</varQName>" +
+ "<varDateTime>0096-05-31T23:00:00.000Z</varDateTime>" +
+ "<varSoapString>String3</varSoapString>" +
+ "<varSoapBoolean>false</varSoapBoolean>" +
+ "<varSoapFloat>1.4E-45</varSoapFloat>" +
+ "<varSoapDouble>4.9E-324</varSoapDouble>" +
+ "<varSoapDecimal>3512359.1111</varSoapDecimal>" +
+ "<varSoapInt>-2147483648</varSoapInt>" +
+ "<varSoapShort>-32768</varSoapShort>" +
+ "<varSoapByte>-128</varSoapByte>" +
+ "<varBase64Binary>gAB/</varBase64Binary>" +
+ "<varHexBinary>80007f</varHexBinary>" +
+ "<varSoapBase64>gAB/</varSoapBase64>" +
+ "</ns_allStruct:allStruct>";
+
+ public SoapEncUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testMarshallingXerces() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.setSchemaResolver(RESOLVER);
+ assertMarshalling(marshaller);
+ }
+
+ public void testMarshallingSunday() throws Exception
+ {
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.setSchemaResolver(RESOLVER);
+ assertMarshalling(marshaller);
+ }
+
+ public void testUnmarshalling() throws Exception
+ {
+ String xsdPath = getUrl("xml/soapenc/test.xsd").toExternalForm();
+ SchemaBinding schema = XsdBinder.bind(xsdPath, RESOLVER);
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML), schema);
+ assertNotNull(o);
+ assertTrue(o instanceof AllStruct);
+ assertEquals(AllStruct.INSTANCE, o);
+ }
+
+ // private
+
+ private void assertMarshalling(AbstractMarshaller marshaller)
+ throws Exception
+ {
+ StringWriter writer = new StringWriter();
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_XML_VERSION, "false");
+ marshaller.setProperty(Marshaller.PROP_OUTPUT_INDENTATION, "false");
+ marshaller.marshal(new FileReader(getUrl("xml/soapenc/test.xsd").getFile()),
+ new MappingObjectModelProvider(),
+ AllStruct.INSTANCE,
+ writer
+ );
+
+ String xml = writer.getBuffer().toString();
+ assertXmlEqual(XML, xml);
+ }
+
+ private static URL getUrl(String path)
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(path);
+ if(url == null)
+ {
+ fail("resource not found: " + path);
+ }
+ return url;
+ }
+
+ private static InputStream getStream(String path)
+ {
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
+ if(is == null)
+ {
+ fail("resource not found: " + path);
+ }
+ return is;
+ }
+
+ // inner
+
+ public static class AllStruct
+ {
+ public static final AllStruct INSTANCE;
+
+ static
+ {
+ byte[] bytes = new byte[]{Byte.MIN_VALUE, 0, Byte.MAX_VALUE};
+
+ AllStruct struct = new AllStruct();
+ struct = new AllStruct();
+ struct.setVarString(new String("String1"));
+ struct.setVarInteger(new BigInteger("3512359"));
+ struct.setVarInt((int)Integer.MIN_VALUE);
+ struct.setVarLong((long)Long.MIN_VALUE);
+ struct.setVarShort((short)Short.MIN_VALUE);
+ struct.setVarDecimal(new BigDecimal("3512359.1456"));
+ struct.setVarFloat((float)Float.MIN_VALUE);
+ struct.setVarDouble((double)Double.MIN_VALUE);
+ struct.setVarBoolean(false);
+ struct.setVarByte((byte)Byte.MIN_VALUE);
+ struct.setVarQName(new QName("String2"));
+
+ Calendar varDateTime = (Calendar)new GregorianCalendar(96, 5, 1);
+ int offset = varDateTime.get(Calendar.ZONE_OFFSET) + varDateTime.get(Calendar.DST_OFFSET);
+ StringBuffer buf = new StringBuffer();
+ buf.append("GMT");
+ if(offset > 0)
+ {
+ buf.append('+');
+ }
+ buf.append(offset);
+ varDateTime.setTimeZone(TimeZone.getTimeZone(buf.toString()));
+ struct.setVarDateTime(varDateTime);
+
+ struct.setVarSoapString("String3");
+ struct.setVarSoapBoolean(new Boolean(false));
+ struct.setVarSoapFloat(new Float(Float.MIN_VALUE));
+ struct.setVarSoapDouble(new Double(Double.MIN_VALUE));
+ struct.setVarSoapDecimal(new BigDecimal("3512359.1111"));
+ struct.setVarSoapInt(new Integer(Integer.MIN_VALUE));
+ struct.setVarSoapShort(new Short(Short.MIN_VALUE));
+ struct.setVarSoapByte(new Byte(Byte.MIN_VALUE));
+ struct.setVarBase64Binary(bytes);
+ struct.setVarHexBinary(bytes);
+ struct.setVarSoapBase64(bytes);
+
+ INSTANCE = struct;
+ }
+
+ private java.lang.String varString;
+ private java.math.BigInteger varInteger;
+ private int varInt;
+ private long varLong;
+ private short varShort;
+ private java.math.BigDecimal varDecimal;
+ private float varFloat;
+ private double varDouble;
+ private boolean varBoolean;
+ private byte varByte;
+ private javax.xml.namespace.QName varQName;
+ private java.util.Calendar varDateTime;
+ private java.lang.String varSoapString;
+ private java.lang.Boolean varSoapBoolean;
+ private java.lang.Float varSoapFloat;
+ private java.lang.Double varSoapDouble;
+ private java.math.BigDecimal varSoapDecimal;
+ private java.lang.Integer varSoapInt;
+ private java.lang.Short varSoapShort;
+ private java.lang.Byte varSoapByte;
+ private byte[] varBase64Binary;
+ private byte[] varHexBinary;
+ private byte[] varSoapBase64;
+
+ public AllStruct()
+ {
+ }
+
+ public AllStruct(java.lang.String varString,
+ java.math.BigInteger varInteger,
+ int varInt,
+ long varLong,
+ short varShort,
+ java.math.BigDecimal varDecimal,
+ float varFloat,
+ double varDouble,
+ boolean varBoolean,
+ byte varByte,
+ javax.xml.namespace.QName varQName,
+ java.util.Calendar varDateTime,
+ java.lang.String varSoapString,
+ java.lang.Boolean varSoapBoolean,
+ java.lang.Float varSoapFloat,
+ java.lang.Double varSoapDouble,
+ java.math.BigDecimal varSoapDecimal,
+ java.lang.Integer varSoapInt,
+ java.lang.Short varSoapShort,
+ java.lang.Byte varSoapByte,
+ byte[] varBase64Binary,
+ byte[] varHexBinary,
+ byte[] varSoapBase64)
+ {
+ this.varString = varString;
+ this.varInteger = varInteger;
+ this.varInt = varInt;
+ this.varLong = varLong;
+ this.varShort = varShort;
+ this.varDecimal = varDecimal;
+ this.varFloat = varFloat;
+ this.varDouble = varDouble;
+ this.varBoolean = varBoolean;
+ this.varByte = varByte;
+ this.varQName = varQName;
+ this.varDateTime = varDateTime;
+ this.varSoapString = varSoapString;
+ this.varSoapBoolean = varSoapBoolean;
+ this.varSoapFloat = varSoapFloat;
+ this.varSoapDouble = varSoapDouble;
+ this.varSoapDecimal = varSoapDecimal;
+ this.varSoapInt = varSoapInt;
+ this.varSoapShort = varSoapShort;
+ this.varSoapByte = varSoapByte;
+ this.varBase64Binary = varBase64Binary;
+ this.varHexBinary = varHexBinary;
+ this.varSoapBase64 = varSoapBase64;
+ }
+
+ public java.lang.String getVarString()
+ {
+ return varString;
+ }
+
+ public void setVarString(java.lang.String varString)
+ {
+ this.varString = varString;
+ }
+
+ public java.math.BigInteger getVarInteger()
+ {
+ return varInteger;
+ }
+
+ public void setVarInteger(java.math.BigInteger varInteger)
+ {
+ this.varInteger = varInteger;
+ }
+
+ public int getVarInt()
+ {
+ return varInt;
+ }
+
+ public void setVarInt(int varInt)
+ {
+ this.varInt = varInt;
+ }
+
+ public long getVarLong()
+ {
+ return varLong;
+ }
+
+ public void setVarLong(long varLong)
+ {
+ this.varLong = varLong;
+ }
+
+ public short getVarShort()
+ {
+ return varShort;
+ }
+
+ public void setVarShort(short varShort)
+ {
+ this.varShort = varShort;
+ }
+
+ public java.math.BigDecimal getVarDecimal()
+ {
+ return varDecimal;
+ }
+
+ public void setVarDecimal(java.math.BigDecimal varDecimal)
+ {
+ this.varDecimal = varDecimal;
+ }
+
+ public float getVarFloat()
+ {
+ return varFloat;
+ }
+
+ public void setVarFloat(float varFloat)
+ {
+ this.varFloat = varFloat;
+ }
+
+ public double getVarDouble()
+ {
+ return varDouble;
+ }
+
+ public void setVarDouble(double varDouble)
+ {
+ this.varDouble = varDouble;
+ }
+
+ public boolean isVarBoolean()
+ {
+ return varBoolean;
+ }
+
+ public void setVarBoolean(boolean varBoolean)
+ {
+ this.varBoolean = varBoolean;
+ }
+
+ public byte getVarByte()
+ {
+ return varByte;
+ }
+
+ public void setVarByte(byte varByte)
+ {
+ this.varByte = varByte;
+ }
+
+ public javax.xml.namespace.QName getVarQName()
+ {
+ return varQName;
+ }
+
+ public void setVarQName(javax.xml.namespace.QName varQName)
+ {
+ this.varQName = varQName;
+ }
+
+ public java.util.Calendar getVarDateTime()
+ {
+ return varDateTime;
+ }
+
+ public void setVarDateTime(java.util.Calendar varDateTime)
+ {
+ this.varDateTime = varDateTime;
+ }
+
+ public java.lang.String getVarSoapString()
+ {
+ return varSoapString;
+ }
+
+ public void setVarSoapString(java.lang.String varSoapString)
+ {
+ this.varSoapString = varSoapString;
+ }
+
+ public java.lang.Boolean getVarSoapBoolean()
+ {
+ return varSoapBoolean;
+ }
+
+ public void setVarSoapBoolean(java.lang.Boolean varSoapBoolean)
+ {
+ this.varSoapBoolean = varSoapBoolean;
+ }
+
+ public java.lang.Float getVarSoapFloat()
+ {
+ return varSoapFloat;
+ }
+
+ public void setVarSoapFloat(java.lang.Float varSoapFloat)
+ {
+ this.varSoapFloat = varSoapFloat;
+ }
+
+ public java.lang.Double getVarSoapDouble()
+ {
+ return varSoapDouble;
+ }
+
+ public void setVarSoapDouble(java.lang.Double varSoapDouble)
+ {
+ this.varSoapDouble = varSoapDouble;
+ }
+
+ public java.math.BigDecimal getVarSoapDecimal()
+ {
+ return varSoapDecimal;
+ }
+
+ public void setVarSoapDecimal(java.math.BigDecimal varSoapDecimal)
+ {
+ this.varSoapDecimal = varSoapDecimal;
+ }
+
+ public java.lang.Integer getVarSoapInt()
+ {
+ return varSoapInt;
+ }
+
+ public void setVarSoapInt(java.lang.Integer varSoapInt)
+ {
+ this.varSoapInt = varSoapInt;
+ }
+
+ public java.lang.Short getVarSoapShort()
+ {
+ return varSoapShort;
+ }
+
+ public void setVarSoapShort(java.lang.Short varSoapShort)
+ {
+ this.varSoapShort = varSoapShort;
+ }
+
+ public java.lang.Byte getVarSoapByte()
+ {
+ return varSoapByte;
+ }
+
+ public void setVarSoapByte(java.lang.Byte varSoapByte)
+ {
+ this.varSoapByte = varSoapByte;
+ }
+
+ public byte[] getVarBase64Binary()
+ {
+ return varBase64Binary;
+ }
+
+ public void setVarBase64Binary(byte[] varBase64Binary)
+ {
+ this.varBase64Binary = varBase64Binary;
+ }
+
+ public byte[] getVarHexBinary()
+ {
+ return varHexBinary;
+ }
+
+ public void setVarHexBinary(byte[] varHexBinary)
+ {
+ this.varHexBinary = varHexBinary;
+ }
+
+ public byte[] getVarSoapBase64()
+ {
+ return varSoapBase64;
+ }
+
+ public void setVarSoapBase64(byte[] varSoapBase64)
+ {
+ this.varSoapBase64 = varSoapBase64;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof AllStruct))
+ {
+ return false;
+ }
+
+ final AllStruct struct = (AllStruct)o;
+
+ if(varBoolean != struct.varBoolean)
+ {
+ return false;
+ }
+ if(varByte != struct.varByte)
+ {
+ return false;
+ }
+ if(varDouble != struct.varDouble)
+ {
+ return false;
+ }
+ if(varFloat != struct.varFloat)
+ {
+ return false;
+ }
+ if(varInt != struct.varInt)
+ {
+ return false;
+ }
+ if(varLong != struct.varLong)
+ {
+ return false;
+ }
+ if(varShort != struct.varShort)
+ {
+ return false;
+ }
+ if(!Arrays.equals(varBase64Binary, struct.varBase64Binary))
+ {
+ return false;
+ }
+ if(varDateTime != null ? !varDateTime.equals(struct.varDateTime) : struct.varDateTime != null)
+ {
+ return false;
+ }
+ if(varDecimal != null ? !varDecimal.equals(struct.varDecimal) : struct.varDecimal != null)
+ {
+ return false;
+ }
+ if(!Arrays.equals(varHexBinary, struct.varHexBinary))
+ {
+ return false;
+ }
+ if(varInteger != null ? !varInteger.equals(struct.varInteger) : struct.varInteger != null)
+ {
+ return false;
+ }
+ if(varQName != null ? !varQName.equals(struct.varQName) : struct.varQName != null)
+ {
+ return false;
+ }
+ if(!Arrays.equals(varSoapBase64, struct.varSoapBase64))
+ {
+ return false;
+ }
+ if(varSoapBoolean != null ? !varSoapBoolean.equals(struct.varSoapBoolean) : struct.varSoapBoolean != null)
+ {
+ return false;
+ }
+ if(varSoapByte != null ? !varSoapByte.equals(struct.varSoapByte) : struct.varSoapByte != null)
+ {
+ return false;
+ }
+ if(varSoapDecimal != null ? !varSoapDecimal.equals(struct.varSoapDecimal) : struct.varSoapDecimal != null)
+ {
+ return false;
+ }
+ if(varSoapDouble != null ? !varSoapDouble.equals(struct.varSoapDouble) : struct.varSoapDouble != null)
+ {
+ return false;
+ }
+ if(varSoapFloat != null ? !varSoapFloat.equals(struct.varSoapFloat) : struct.varSoapFloat != null)
+ {
+ return false;
+ }
+ if(varSoapInt != null ? !varSoapInt.equals(struct.varSoapInt) : struct.varSoapInt != null)
+ {
+ return false;
+ }
+ if(varSoapShort != null ? !varSoapShort.equals(struct.varSoapShort) : struct.varSoapShort != null)
+ {
+ return false;
+ }
+ if(varSoapString != null ? !varSoapString.equals(struct.varSoapString) : struct.varSoapString != null)
+ {
+ return false;
+ }
+ if(varString != null ? !varString.equals(struct.varString) : struct.varString != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ long temp;
+ result = (varString != null ? varString.hashCode() : 0);
+ result = 29 * result + (varInteger != null ? varInteger.hashCode() : 0);
+ result = 29 * result + varInt;
+ result = 29 * result + (int)(varLong ^ (varLong >>> 32));
+ result = 29 * result + (int)varShort;
+ result = 29 * result + (varDecimal != null ? varDecimal.hashCode() : 0);
+ result = 29 * result + varFloat != +0.0f ? Float.floatToIntBits(varFloat) : 0;
+ temp = varDouble != +0.0d ? Double.doubleToLongBits(varDouble) : 0l;
+ result = 29 * result + (int)(temp ^ (temp >>> 32));
+ result = 29 * result + (varBoolean ? 1 : 0);
+ result = 29 * result + (int)varByte;
+ result = 29 * result + (varQName != null ? varQName.hashCode() : 0);
+ result = 29 * result + (varDateTime != null ? varDateTime.hashCode() : 0);
+ result = 29 * result + (varSoapString != null ? varSoapString.hashCode() : 0);
+ result = 29 * result + (varSoapBoolean != null ? varSoapBoolean.hashCode() : 0);
+ result = 29 * result + (varSoapFloat != null ? varSoapFloat.hashCode() : 0);
+ result = 29 * result + (varSoapDouble != null ? varSoapDouble.hashCode() : 0);
+ result = 29 * result + (varSoapDecimal != null ? varSoapDecimal.hashCode() : 0);
+ result = 29 * result + (varSoapInt != null ? varSoapInt.hashCode() : 0);
+ result = 29 * result + (varSoapShort != null ? varSoapShort.hashCode() : 0);
+ result = 29 * result + (varSoapByte != null ? varSoapByte.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return
+ "[varString=" + varString +
+ "\nvarInteger=" + varInteger +
+ "\nvarInt=" + varInt +
+ "\nvarLong=" + varLong +
+ "\nvarShort=" + varShort +
+ "\nvarDecimal=" + varDecimal +
+ "\nvarFloat=" + varFloat +
+ "\nvarDouble=" + varDouble +
+ "\nvarBoolean=" + varBoolean +
+ "\nvarByte=" + varByte +
+ "\nvarQName=" + varQName +
+ "\nvarDateTime=" + varDateTime +
+ "\nvarSoapString=" + varSoapString +
+ "\nvarSoapBoolean=" + varSoapBoolean +
+ "\nvarSoapFloat=" + varSoapFloat +
+ "\nvarSoapDouble=" + varSoapDouble +
+ "\nvarSoapDecimal=" + varSoapDecimal +
+ "\nvarSoapInt=" + varSoapInt +
+ "\nvarSoapShort=" + varSoapShort +
+ "\nvarSoapByte=" + varSoapByte +
+ "\nvarBase64Binary=" + arrayToString(varBase64Binary) +
+ "\nvarHexBinary=" + arrayToString(varHexBinary) +
+ "\nvarSoapBase64=" + arrayToString(varSoapBase64) + "]";
+ }
+ }
+
+ private static String arrayToString(Object arr)
+ {
+ String str;
+ if(arr == null)
+ {
+ str = "null";
+ }
+ else
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append('[');
+ for(int i = 0; i < Array.getLength(arr); ++i)
+ {
+ if(i > 0)
+ {
+ buf.append(", ");
+ }
+ buf.append(Array.get(arr, i));
+ }
+ buf.append(']');
+ str = buf.toString();
+ }
+ return str;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/SundayUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/SundayUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/SundayUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,613 @@
+/*
+ * 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.xml;
+
+import junit.framework.TestCase;
+
+import org.jboss.xb.binding.Immutable;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.CharactersHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementInterceptor;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+import org.jboss.test.xml.config.Config;
+import org.xml.sax.Attributes;
+
+import javax.xml.namespace.QName;
+import javax.xml.namespace.NamespaceContext;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 56873 $</tt>
+ */
+public class SundayUnitTestCase
+ extends TestCase
+{
+ public SundayUnitTestCase()
+ {
+ }
+
+ public SundayUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void testConfigUnmarshalling() throws Exception
+ {
+ //
+ // Type declarations
+ //
+
+ TypeBinding configType = new TypeBinding();
+ TypeBinding attributeType = new TypeBinding();
+ TypeBinding attributeValue1Type = new TypeBinding();
+ TypeBinding attributeValue2Type = new TypeBinding();
+
+ TypeBinding beansType = new TypeBinding();
+ TypeBinding beanType = new TypeBinding();
+
+ TypeBinding listType = new TypeBinding();
+ TypeBinding listValueType = new TypeBinding();
+ TypeBinding listDependsType = new TypeBinding();
+
+ TypeBinding mapType = new TypeBinding();
+ TypeBinding entry1Type = new TypeBinding();
+ TypeBinding entry2Type = new TypeBinding();
+ TypeBinding entry3Type = new TypeBinding();
+ TypeBinding entry4Type = new TypeBinding();
+
+ //
+ // Schema assembling
+ //
+
+ configType.addElement(new QName("attribute"), attributeType, 0, true);
+ configType.addElement(new QName("beans"), beansType);
+ configType.addElement(new QName("list"), listType);
+ configType.addElement(new QName("map"), mapType);
+
+ attributeType.addElement(new QName("value1"), attributeValue1Type);
+ attributeType.addElement(new QName("value2"), attributeValue2Type);
+
+ beansType.addElement(new QName("bean"), beanType, 0, true);
+
+ listType.addElement(new QName("value"), listValueType);
+ listType.addElement(new QName("depends"), listDependsType);
+ listType.addElement(new QName("list"), listType);
+
+ mapType.addElement(new QName("entry1"), entry1Type);
+ mapType.addElement(new QName("entry2"), entry2Type);
+ mapType.addElement(new QName("entry3"), entry3Type);
+ mapType.addElement(new QName("entry4"), entry4Type);
+ mapType.addElement(new QName("map"), mapType);
+
+ //
+ // Handler implementations
+ //
+
+ configType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Config();
+ }
+ }
+ );
+
+ configType.pushInterceptor(new QName("attribute"), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Config config = (Config)parent;
+ Config.ConfigAttr attr = (Config.ConfigAttr)child;
+ Collection attrs = config.getAttrs();
+ if(attrs == null)
+ {
+ attrs = new ArrayList();
+ config.setAttrs(attrs);
+ }
+ attrs.add(attr);
+ }
+ }
+ );
+
+ configType.pushInterceptor(new QName("beans"), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Config config = (Config)parent;
+ config.beans = (Collection)child;
+ }
+ }
+ );
+
+ configType.pushInterceptor(new QName("list"), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Config config = (Config)parent;
+ config.list = (Collection)child;
+ }
+ }
+ );
+
+ configType.pushInterceptor(new QName("map"), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Config config = (Config)parent;
+ config.map = (Map)child;
+ }
+ }
+ );
+
+ attributeType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Immutable(Config.ConfigAttr.class);
+ }
+
+ public Object endElement(Object o, QName name, ElementBinding element)
+ {
+ Immutable imm = (Immutable)o;
+ return imm.newInstance();
+ }
+ }
+ );
+ attributeType.setSimpleType(new CharactersHandler(){
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ Immutable imm = (Immutable)owner;
+ Config.ConfigAttr.ConfigAttrDataValue o = new Config.ConfigAttr.ConfigAttrDataValue();
+ o.setData((String)value);
+ imm.addChild(qName.getLocalPart(), o);
+ }
+ });
+
+ attributeType.pushInterceptor(new QName("value1"), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Immutable imm = (Immutable)parent;
+ Config.ConfigAttr.ConfigAttrValue1 value1 = (Config.ConfigAttr.ConfigAttrValue1)child;
+ imm.addChild(name.getLocalPart(), value1);
+ }
+ }
+ );
+
+ attributeType.pushInterceptor(new QName("value2"), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Immutable imm = (Immutable)parent;
+ Config.ConfigAttr.ConfigAttrValue2 value2 = (Config.ConfigAttr.ConfigAttrValue2)child;
+ imm.addChild(name.getLocalPart(), value2);
+ }
+ }
+ );
+
+ attributeValue1Type.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Config.ConfigAttr.ConfigAttrValue1();
+ }
+ }
+ );
+ attributeValue1Type.pushInterceptor(new QName("property"), new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Config.ConfigAttr.ConfigAttrValue1 value1 = (Config.ConfigAttr.ConfigAttrValue1)o;
+ value1.setProperty(text);
+ }
+ }
+ );
+
+ attributeValue2Type.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Config.ConfigAttr.ConfigAttrValue2();
+ }
+
+ }
+ );
+ attributeValue2Type.setSimpleType(new CharactersHandler(){
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ Config.ConfigAttr.ConfigAttrValue2 value2 = (Config.ConfigAttr.ConfigAttrValue2)owner;
+ value2.setValue2((String)value);
+ }
+ });
+
+ beansType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new ArrayList();
+ }
+ }
+ );
+ beansType.pushInterceptor(new QName("bean"), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Collection beans = (Collection)parent;
+ Config.Bean bean = (Config.Bean)child;
+ beans.add(bean);
+ }
+ }
+ );
+
+ beanType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Immutable(Config.Bean.class);
+ }
+
+ public Object endElement(Object o, QName name, ElementBinding element)
+ {
+ Immutable imm = (Immutable)o;
+ Config.Bean bean = (Config.Bean)imm.newInstance();
+ return bean;
+ }
+ }
+ );
+
+ beanType.pushInterceptor(new QName("name"), new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Immutable imm = (Immutable)o;
+ imm.addChild(name.getLocalPart(), text);
+ }
+ }
+ );
+
+ listType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new ArrayList();
+ }
+ }
+ );
+ listType.pushInterceptor(new QName("value"), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Collection list = (Collection)parent;
+ Config.ListValue value = (Config.ListValue)child;
+ list.add(value);
+ }
+ }
+ );
+ listType.pushInterceptor(new QName("depends"), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Collection list = (Collection)parent;
+ Config.Depends depends = (Config.Depends)child;
+ list.add(depends);
+ }
+ }
+ );
+ listType.pushInterceptor(new QName("list"), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Collection list = (Collection)parent;
+ Collection sublist = (Collection)child;
+ list.add(sublist);
+ }
+ }
+ );
+
+ listValueType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Immutable(Config.ListValue.class);
+ }
+
+ public void attributes(Object o,
+ QName elementName,
+ ElementBinding element,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Immutable imm = (Immutable)o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("type".equals(lName))
+ {
+ imm.addChild(lName, attrs.getValue(i));
+ }
+ }
+ }
+
+ public Object endElement(Object o, QName name, ElementBinding element)
+ {
+ Immutable imm = (Immutable)o;
+ Config.ListValue value = (Config.ListValue)imm.newInstance();
+ return value;
+ }
+ }
+ );
+ listValueType.setSimpleType(new CharactersHandler(){
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ Immutable imm = (Immutable)owner;
+ imm.addChild(qName.getLocalPart(), value);
+ }
+ });
+
+ listDependsType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Immutable(Config.Depends.class);
+ }
+
+ public void attributes(Object o,
+ QName elementName,
+ ElementBinding element,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Immutable imm = (Immutable)o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("value".equals(lName))
+ {
+ imm.addChild(lName, attrs.getValue(i));
+ }
+ }
+ }
+
+ public Object endElement(Object o, QName name, ElementBinding element)
+ {
+ Immutable imm = (Immutable)o;
+ Config.Depends depends = (Config.Depends)imm.newInstance();
+ return depends;
+ }
+ }
+ );
+
+ mapType.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new HashMap();
+ }
+ }
+ );
+
+ ElementInterceptor addMapEntryInterceptor = new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Map map = (Map)parent;
+ Object[] arr = (Object[])child;
+ map.put(arr[0], arr[1]);
+ }
+ };
+ mapType.pushInterceptor(new QName("entry1"), addMapEntryInterceptor);
+ mapType.pushInterceptor(new QName("entry2"), addMapEntryInterceptor);
+ mapType.pushInterceptor(new QName("entry3"), addMapEntryInterceptor);
+ mapType.pushInterceptor(new QName("entry4"), addMapEntryInterceptor);
+ mapType.pushInterceptor(new QName("map"), addMapEntryInterceptor);
+
+ entry1Type.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Object[2];
+ }
+ }
+ );
+ entry1Type.pushInterceptor(new QName("key1"), new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Object[] arr = (Object[])o;
+ arr[0] = text;
+ }
+ }
+ );
+ entry1Type.pushInterceptor(new QName("value1"), new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Object[] arr = (Object[])o;
+ arr[1] = text;
+ }
+ }
+ );
+
+ entry2Type.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Object[2];
+ }
+
+ public void attributes(Object o,
+ QName elementName,
+ ElementBinding element,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Object[] arr = (Object[])o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("key2".equals(lName))
+ {
+ arr[0] = attrs.getValue(i);
+ }
+ }
+ }
+ }
+ );
+ entry2Type.pushInterceptor(new QName("value2"), new DefaultElementInterceptor()
+ {
+ public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
+ {
+ Object[] arr = (Object[])o;
+ arr[1] = text;
+ }
+ }
+ );
+
+ entry3Type.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Object[2];
+ }
+
+ public void attributes(Object o,
+ QName elementName,
+ ElementBinding element,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Object[] arr = (Object[])o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("key3".equals(lName))
+ {
+ arr[0] = attrs.getValue(i);
+ }
+ else if("value3".equals(lName))
+ {
+ arr[1] = attrs.getValue(i);
+ }
+ }
+ }
+ }
+ );
+
+ entry4Type.setHandler(new DefaultElementHandler()
+ {
+ public Object startElement(Object parent, QName name, ElementBinding element)
+ {
+ return new Object[2];
+ }
+
+ public void attributes(Object o,
+ QName elementName,
+ ElementBinding element,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Object[] arr = (Object[])o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("key4".equals(lName))
+ {
+ arr[0] = attrs.getValue(i);
+ }
+ }
+ }
+
+ }
+ );
+ entry4Type.setSimpleType(new CharactersHandler(){
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ Object[] arr = (Object[])owner;
+ arr[1] = value;
+ }
+ });
+
+ mapType.pushInterceptor(new QName("map"), new DefaultElementInterceptor()
+ {
+ public Object startElement(Object parent, QName name, TypeBinding type)
+ {
+ return new Object[2];
+ }
+
+ public void attributes(Object o,
+ QName elementName,
+ TypeBinding type,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Object[] arr = (Object[])o;
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ String lName = attrs.getLocalName(i);
+ if("key".equals(lName))
+ {
+ arr[0] = attrs.getValue(i);
+ }
+ }
+ }
+
+ public void add(Object parent, Object child, QName qName)
+ {
+ Object[] arr = (Object[])parent;
+ Map submap = (Map)child;
+ arr[1] = submap;
+ }
+ }
+ );
+
+ SchemaBinding cursor = new SchemaBinding();
+ cursor.addElement(new QName("config"), configType);
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object config = unmarshaller.unmarshal(getXmlUrl("xml/newmetadata.xml"), cursor);
+
+ //log.debug("unmarshalled: " + config);
+ assertEquals(Config.getInstance(), config);
+ }
+
+ // Private
+
+ private static String getXmlUrl(String name)
+ {
+ URL xmlUrl = Thread.currentThread().getContextClassLoader().getResource(name);
+ if(xmlUrl == null)
+ {
+ throw new IllegalStateException(name + " not found");
+ }
+ return xmlUrl.getFile();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/Validator.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/Validator.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/Validator.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,120 @@
+/*
+ * 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.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringReader;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.parsers.SAXParser;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.InputSource;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.helpers.DefaultHandler;
+import org.jboss.xb.binding.JBossXBRuntimeException;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45119 $</tt>
+ */
+public class Validator
+{
+ public static void assertValidXml(final String xsd, String xml)
+ {
+ assertValidXml(xsd, xml, null);
+ }
+
+ public static void assertValidXml(String xml, final EntityResolver resolver)
+ {
+ assertValidXml(null, xml, resolver);
+ }
+
+ private static void assertValidXml(final String xsd, String xml, final EntityResolver resolver)
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(true);
+ factory.setNamespaceAware(true);
+ SAXParser parser = null;
+ try
+ {
+ parser = factory.newSAXParser();
+ }
+ catch(Exception e)
+ {
+ throw new IllegalStateException("Failed to instantiate a SAX parser: " + e.getMessage());
+ }
+
+ try
+ {
+ parser.getXMLReader().setFeature("http://apache.org/xml/features/validation/schema", true);
+ }
+ catch(SAXException e)
+ {
+ throw new IllegalStateException("Schema validation feature is not supported by the parser: " + e.getMessage());
+ }
+
+ try
+ {
+ parser.parse(new ByteArrayInputStream(xml.getBytes()),
+ new DefaultHandler()
+ {
+ public void warning(SAXParseException e)
+ {
+ }
+
+ public void error(SAXParseException e)
+ {
+ throw new JBossXBRuntimeException("Error", e);
+ }
+
+ public void fatalError(SAXParseException e)
+ {
+ throw new JBossXBRuntimeException("Fatal error", e);
+ }
+
+ public InputSource resolveEntity(String publicId, String systemId)
+ {
+ if(resolver != null)
+ {
+ try
+ {
+ return resolver.resolveEntity(publicId, systemId);
+ }
+ catch(Exception e)
+ {
+ throw new IllegalStateException("Failed to resolveEntity " + systemId + ": " + systemId);
+ }
+ }
+ else
+ {
+ return new InputSource(new StringReader(xsd));
+ }
+ }
+ }
+ );
+ }
+ catch(Exception e)
+ {
+ throw new JBossXBRuntimeException("Parsing failed.", e);
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/WildcardUnresolvedElementsUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/WildcardUnresolvedElementsUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/WildcardUnresolvedElementsUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,1024 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.jboss.xb.binding.AttributesImpl;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.JBossXBRuntimeException;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.MarshallingContext;
+import org.jboss.xb.binding.ObjectLocalMarshaller;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.AbstractMarshaller;
+import org.jboss.xb.binding.metadata.ClassMetaData;
+import org.jboss.xb.binding.metadata.PropertyMetaData;
+import org.jboss.xb.binding.metadata.ValueMetaData;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.jboss.xb.binding.sunday.unmarshalling.CharactersHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.ParticleHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.WildcardBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.unmarshalling.impl.runtime.RtElementHandler;
+import org.jboss.xb.util.Dom2Sax;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.w3c.dom.ls.LSInput;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 46112 $</tt>
+ */
+public class WildcardUnresolvedElementsUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String XSD =
+ "<schema targetNamespace='http://org.jboss.ws/jbws434/types'" +
+ " xmlns:tns='http://org.jboss.ws/jbws434/types'" +
+ " xmlns='http://www.w3.org/2001/XMLSchema'>" +
+ " <complexType name='ArrayOfAny'>" +
+ " <sequence>" +
+ " <any namespace='##other' processContents='lax' minOccurs='0' maxOccurs='unbounded'/>" +
+ " </sequence>" +
+ " </complexType>" +
+ " <element name='e' type='tns:ArrayOfAny'/>" +
+ "</schema>";
+
+ private static final String XML =
+ "<e xmlns='http://org.jboss.ws/jbws434/types'" +
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
+ " xsi:schemaLocation='http://org.jboss.ws/jbws434/types ns1.xsd'" +
+ ">" +
+ " <child1 xmlns='http://somens'>" +
+ " <child2 child2_attr1='attr1' child2_attr2='attr2'/>" +
+ " <child3>text content3</child3>" +
+ " <child4 child4_attr1='attr1'>" +
+ " <child5/>" +
+ " </child4>" +
+ " </child1>" +
+ " <child6 xmlns='http://anotherns'/>" +
+ " <ns:child7 xmlns:ns='http://child7ns'>" +
+ " <ns:child8 xmlns:ns='http://child8ns'/>" +
+ " </ns:child7>" +
+ "</e>";
+
+ static
+ {
+ Validator.assertValidXml(XSD, XML);
+ }
+
+ public WildcardUnresolvedElementsUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testUnmarshallingGenericElement() throws Exception
+ {
+ SchemaBinding schema = getSchemaBinding(true);
+
+ // unmarshal
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML), schema);
+
+ assertArrayOfAnyGenericElement(o);
+ }
+
+ public void testUnmarshallingDom() throws Exception
+ {
+ SchemaBinding schema = getSchemaBinding(false);
+
+ // unmarshal
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(XML), schema);
+
+ assertArrayOfAnyDom(o);
+ }
+
+ public void testMarshallingXercesGenericElement() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ setupGeMarshaller(marshaller);
+
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), provider, ArrayOfAny.GE_INSTANCE, writer);
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(XML, marshalled);
+ }
+
+ public void testMarshallingXercesDom() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ setupDomMarshaller(marshaller);
+
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), provider, ArrayOfAny.DOM_INSTANCE, writer);
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(XML, marshalled);
+ }
+
+ public void testMarshallingSundayGenericElement() throws Exception
+ {
+ MarshallerImpl marshaller = new MarshallerImpl();
+ setupGeMarshaller(marshaller);
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), null, ArrayOfAny.GE_INSTANCE, writer);
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(XML, marshalled);
+ }
+
+ public void testMarshallingSundayDom() throws Exception
+ {
+ MarshallerImpl marshaller = new MarshallerImpl();
+ setupDomMarshaller(marshaller);
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(XSD), null, ArrayOfAny.DOM_INSTANCE, writer);
+ String marshalled = writer.getBuffer().toString();
+ assertXmlEqual(XML, marshalled);
+ }
+
+ // Private
+
+ private void setupDomMarshaller(AbstractMarshaller marshaller)
+ {
+ marshaller.mapClassToGlobalElement(ArrayOfAny.class, "e", "http://org.jboss.ws/jbws434/types", null, null);
+ marshaller.mapFieldToWildcard(ArrayOfAny.class, "_any",
+ new ObjectLocalMarshaller()
+ {
+ public void marshal(MarshallingContext ctx, Object o)
+ {
+ Element e = (Element)o;
+
+ ContentHandler ch = ctx.getContentHandler();
+ try
+ {
+ Dom2Sax.dom2sax(e, ch);
+ }
+ catch (SAXException e1)
+ {
+ throw new JBossXBRuntimeException("Failed to SAX the DOM");
+ }
+ }
+ }
+ );
+ }
+
+ private void setupGeMarshaller(AbstractMarshaller marshaller)
+ {
+ marshaller.mapClassToGlobalElement(ArrayOfAny.class, "e", "http://org.jboss.ws/jbws434/types", null, null);
+ marshaller.mapFieldToWildcard(ArrayOfAny.class, "_any",
+ new ObjectLocalMarshaller()
+ {
+ public void marshal(MarshallingContext ctx, Object o)
+ {
+ ContentHandler ch = ctx.getContentHandler();
+ GenericElement ge = (GenericElement)o;
+
+ try
+ {
+ AttributesImpl attrs = null;
+ if(ge.getAttributesTotal() > 0)
+ {
+ attrs = new AttributesImpl(ge.getAttributesTotal() + 1);
+ Set attrNames = ge.getAttributeNames();
+ for(Iterator i = attrNames.iterator(); i.hasNext();)
+ {
+ String attrName = (String)i.next();
+ String attrValue = ge.getAttribute(attrName);
+ attrs.add(null, attrName, attrName, null, attrValue);
+ }
+ }
+ else
+ {
+ attrs = new AttributesImpl(1);
+ }
+
+ attrs.add(Constants.NS_XML_SCHEMA, "xmlns", "xmlns", null, ge.getNsUri());
+
+ ch.startElement(ge.getNsUri(), ge.getLocalName(), ge.getLocalName(), attrs);
+
+ String text = ge.getTextContent();
+ if(text != null && text.length() > 0)
+ {
+ ch.characters(text.toCharArray(), 0, text.length());
+ }
+
+ if(ge.getChildElementsTotal() > 0)
+ {
+ for(Iterator i = ge.getChildElements(); i.hasNext();)
+ {
+ GenericElement child = (GenericElement)i.next();
+ this.marshal(ctx, child);
+ }
+ }
+
+ ch.endElement(null, ge.getLocalName(), ge.getLocalName());
+ }
+ catch(Exception e)
+ {
+ throw new JBossXBRuntimeException(e);
+ }
+ }
+ }
+ );
+ }
+
+ private SchemaBinding getSchemaBinding(boolean genericElement)
+ {
+ // bind
+ SchemaBinding schema = XsdBinder.bind(new StringReader(XSD), null);
+
+ // get bound components
+ TypeBinding type = schema.getType(new QName("http://org.jboss.ws/jbws434/types", "ArrayOfAny"));
+ WildcardBinding wildcard = type.getWildcard();
+ ElementBinding e = schema.getElement(new QName("http://org.jboss.ws/jbws434/types", "e"));
+
+ // adjust binding
+ ParticleHandler unresolvedElementHandler;
+ CharactersHandler unresolvedCharactersHandler;
+ if(genericElement)
+ {
+ unresolvedElementHandler = new GenericElementHandler();
+ unresolvedCharactersHandler = new GenericCharactersHandler();
+ }
+ else
+ {
+ unresolvedElementHandler = new DomElementHandler();
+ unresolvedCharactersHandler = new DomCharactersHandler();
+ }
+
+ wildcard.setUnresolvedElementHandler(unresolvedElementHandler);
+ wildcard.setUnresolvedCharactersHandler(unresolvedCharactersHandler);
+ PropertyMetaData property = new PropertyMetaData();
+ property.setName("_any");
+ wildcard.setPropertyMetaData(property);
+
+ ClassMetaData clsBinding = new ClassMetaData();
+ clsBinding.setImpl(ArrayOfAny.class.getName());
+ e.setClassMetaData(clsBinding);
+
+ // to fail the resolution quickly
+ schema.setSchemaResolver(new SchemaBindingResolver()
+ {
+ public String getBaseURI()
+ {
+ return null;
+ }
+
+ public void setBaseURI(String baseURI)
+ {
+ }
+
+ public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation)
+ {
+ return null;
+ }
+
+ public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation)
+ {
+ return null;
+ }
+ });
+
+ return schema;
+ }
+
+ private static void assertArrayOfAnyGenericElement(Object o)
+ {
+ assertNotNull(o);
+ assertTrue(o instanceof ArrayOfAny);
+ ArrayOfAny arrayOfAny = (ArrayOfAny)o;
+ assertNotNull(arrayOfAny._any);
+ assertEquals(3, arrayOfAny._any.length);
+
+ // child1
+ GenericElement ge = (GenericElement)arrayOfAny._any[0];
+ assertEquals("child1", ge.getLocalName());
+ assertAttributesTotal(ge, 0);
+ assertNoTextContent(ge);
+ assertChildElementsTotal(ge, 3);
+
+ for(Iterator i = ge.getChildElements(); i.hasNext();)
+ {
+ ge = (GenericElement)i.next();
+ String localName = ge.getLocalName();
+ if("child2".equals(localName))
+ {
+ assertNoTextContent(ge);
+ assertChildElementsTotal(ge, 0);
+ assertAttributesTotal(ge, 2);
+ assertAttribute(ge, "child2_attr1", "attr1");
+ assertAttribute(ge, "child2_attr2", "attr2");
+ }
+ else if("child3".equals(localName))
+ {
+ assertTextContent(ge, "text content3");
+ assertChildElementsTotal(ge, 0);
+ assertAttributesTotal(ge, 0);
+ }
+ else if("child4".equals(localName))
+ {
+ assertNoTextContent(ge);
+ assertAttributesTotal(ge, 1);
+ assertAttribute(ge, "child4_attr1", "attr1");
+ assertChildElementsTotal(ge, 1);
+
+ ge = (GenericElement)ge.getChildElements().next();
+ assertEquals("child5", ge.getLocalName());
+ assertNoTextContent(ge);
+ assertAttributesTotal(ge, 0);
+ assertChildElementsTotal(ge, 0);
+ }
+ else
+ {
+ fail("child1 expected to have only child2, child3 and child4 as child elements but got: " + localName);
+ }
+ }
+
+ ge = (GenericElement)arrayOfAny._any[1];
+ assertEquals("child6", ge.getLocalName());
+ assertAttributesTotal(ge, 0);
+ assertNoTextContent(ge);
+ assertChildElementsTotal(ge, 0);
+
+ ge = (GenericElement)arrayOfAny._any[2];
+ assertEquals("child7", ge.getLocalName());
+ assertAttributesTotal(ge, 0);
+ assertNoTextContent(ge);
+ assertChildElementsTotal(ge, 1);
+
+ ge = (GenericElement)ge.getChildElements().next();
+ assertEquals("child8", ge.getLocalName());
+ assertAttributesTotal(ge, 0);
+ assertNoTextContent(ge);
+ assertChildElementsTotal(ge, 0);
+ }
+
+ private static void assertArrayOfAnyDom(Object o)
+ {
+ assertNotNull(o);
+ assertTrue(o instanceof ArrayOfAny);
+ ArrayOfAny arrayOfAny = (ArrayOfAny)o;
+ assertNotNull(arrayOfAny._any);
+ assertEquals(3, arrayOfAny._any.length);
+
+ // child1
+ String somens = "http://somens";
+ Element e = (Element)arrayOfAny._any[0];
+ assertEquals("child1", e.getLocalName());
+ assertEquals(somens, e.getNamespaceURI());
+ assertEquals(0, e.getAttributes().getLength());
+ assertNoTextContent(e);
+ assertChildElementsTotal(e, 3);
+
+ NodeList childNodes = e.getChildNodes();
+ for(int i = 0; i < childNodes.getLength(); ++i)
+ {
+ Node node = childNodes.item(i);
+ if(node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ e = (Element)node;
+ String localName = e.getLocalName();
+ if("child2".equals(localName))
+ {
+ assertEquals(somens, e.getNamespaceURI());
+ assertNoTextContent(e);
+ assertChildElementsTotal(e, 0);
+ assertAttributesTotal(e, e.getAttributes().getLength());
+ assertAttribute(e, "child2_attr1", "attr1");
+ assertAttribute(e, "child2_attr2", "attr2");
+ }
+ else if("child3".equals(localName))
+ {
+ assertEquals(somens, e.getNamespaceURI());
+ assertTextContent(e, "text content3");
+ assertChildElementsTotal(e, 0);
+ assertAttributesTotal(e, 0);
+ }
+ else if("child4".equals(localName))
+ {
+ assertEquals(somens, e.getNamespaceURI());
+ assertNoTextContent(e);
+ assertAttributesTotal(e, 1);
+ assertAttribute(e, "child4_attr1", "attr1");
+ assertChildElementsTotal(e, 1);
+
+ e = getChildElement(e, "child5");
+ if(e == null)
+ {
+ fail("Element child4 expected to have child element child5");
+ }
+ assertEquals(somens, e.getNamespaceURI());
+ assertEquals("child5", e.getLocalName());
+ assertNoTextContent(e);
+ assertAttributesTotal(e, 0);
+ assertChildElementsTotal(e, 0);
+ }
+ else
+ {
+ fail("child1 expected to have only child2, child3 and child4 as child elements but got: " + localName);
+ }
+ }
+ }
+
+ e = (Element)arrayOfAny._any[1];
+ assertEquals("child6", e.getLocalName());
+ assertEquals("http://anotherns", e.getNamespaceURI());
+ assertAttributesTotal(e, 0);
+ assertNoTextContent(e);
+ assertChildElementsTotal(e, 0);
+
+ e = (Element)arrayOfAny._any[2];
+ assertEquals("child7", e.getLocalName());
+ assertEquals("http://child7ns", e.getNamespaceURI());
+ assertAttributesTotal(e, 0);
+ assertNoTextContent(e);
+ assertChildElementsTotal(e, 1);
+
+ e = getChildElement(e, "child8");
+ assertNotNull(e);
+ assertEquals("http://child8ns", e.getNamespaceURI());
+ assertAttributesTotal(e, 0);
+ assertNoTextContent(e);
+ assertChildElementsTotal(e, 0);
+ }
+
+ private static void assertChildElementsTotal(GenericElement e, int total)
+ {
+ if(e.getChildElementsTotal() != total)
+ {
+ fail("element " +
+ e.getLocalName() +
+ " was expected to have " +
+ total +
+ " elements but got " +
+ e.getChildElementsTotal()
+ );
+ }
+ }
+
+ private static void assertChildElementsTotal(Element e, int total)
+ {
+ int was = 0;
+ NodeList childNodes = e.getChildNodes();
+ if(childNodes != null && childNodes.getLength() > 0)
+ {
+ for(int i = 0; i < childNodes.getLength(); ++i)
+ {
+ Node node = childNodes.item(i);
+ if(node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ ++was;
+ }
+ }
+ }
+
+ if(was != total)
+ {
+ fail("element " +
+ e.getLocalName() +
+ " was expected to have " +
+ total +
+ " elements but got " +
+ was
+ );
+ }
+ }
+
+ private static void assertAttribute(GenericElement e, String attrName, String attrValue)
+ {
+ assertEquals(attrValue, e.getAttribute(attrName));
+ }
+
+ private static void assertAttribute(Element e, String attrName, String attrValue)
+ {
+ assertEquals(attrValue, e.getAttribute(attrName));
+ }
+
+ private static void assertAttributesTotal(GenericElement e, int total)
+ {
+ if(e.getAttributesTotal() != total)
+ {
+ fail("element " +
+ e.getLocalName() +
+ " was expected to have " +
+ total +
+ " attributes but got " +
+ e.getAttributesTotal() + ": " + e.getAttributeNames()
+ );
+ }
+ }
+
+ private static void assertAttributesTotal(Element e, int total)
+ {
+ NamedNodeMap attributes = e.getAttributes();
+ int was = attributes == null ? 0 : attributes.getLength();
+ if(was != total)
+ {
+ fail("element " +
+ e.getLocalName() +
+ " was expected to have " +
+ total +
+ " attributes but got " +
+ was
+ );
+ }
+ }
+
+ private static void assertTextContent(GenericElement e, String text)
+ {
+ assertEquals(text, e.getTextContent());
+ }
+
+ private static void assertTextContent(Element e, String text)
+ {
+ NodeList childNodes = e.getChildNodes();
+ if(childNodes != null && childNodes.getLength() > 0)
+ {
+ for(int i = 0; i < childNodes.getLength(); ++i)
+ {
+ Node node = childNodes.item(i);
+ if(node.getNodeType() == Node.TEXT_NODE)
+ {
+ String value = node.getNodeValue().trim();
+ if(value.length() > 0)
+ {
+ assertEquals(text, value);
+ return;
+ }
+ }
+ }
+ }
+ fail("Element " + e.getLocalName() + " expected to have text content " + text);
+ }
+
+ private static void assertNoTextContent(GenericElement e)
+ {
+ if(e.getTextContent() != null)
+ {
+ fail("element " +
+ e.getLocalName() +
+ " was not expected to have text content but got " +
+ e.getTextContent()
+ );
+ }
+ }
+
+ private static void assertNoTextContent(Element e)
+ {
+ NodeList childNodes = e.getChildNodes();
+ if(childNodes != null && childNodes.getLength() > 0)
+ {
+ for(int i = 0; i < childNodes.getLength(); ++i)
+ {
+ Node child = childNodes.item(i);
+ if(child.getNodeType() == Node.TEXT_NODE)
+ {
+ fail("element " +
+ e.getLocalName() +
+ " was not expected to have text content but got " +
+ child.getNodeValue()
+ );
+ }
+ }
+ }
+ }
+
+ private static Element getChildElement(Element e, String name)
+ {
+ NodeList childNodes = e.getChildNodes();
+ if(childNodes != null && childNodes.getLength() > 0)
+ {
+ for(int i = 0; i < childNodes.getLength(); ++i)
+ {
+ Node node = childNodes.item(i);
+ if(node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ if(name.equals(node.getLocalName()))
+ {
+ return (Element)node;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ // Inner
+
+ public static class ArrayOfAny
+ {
+ public static final ArrayOfAny GE_INSTANCE;
+ public static final ArrayOfAny DOM_INSTANCE;
+
+ static
+ {
+ GE_INSTANCE = new ArrayOfAny();
+ GE_INSTANCE._any = new GenericElement[3];
+
+ GenericElement child1 = new GenericElement("http://somens", "child1");
+ GE_INSTANCE._any[0] = child1;
+
+ GenericElement child2 = new GenericElement("http://somens", "child2");
+ child1.addChild(child2);
+ child2.setAttribute("child2_attr1", "attr1");
+ child2.setAttribute("child2_attr2", "attr2");
+
+ GenericElement child3 = new GenericElement("http://somens", "child3");
+ child1.addChild(child3);
+ child3.setTextContent("text content3");
+
+ GenericElement child4 = new GenericElement("http://somens", "child4");
+ child1.addChild(child4);
+ child4.setAttribute("child4_attr1", "attr1");
+
+ GenericElement child5 = new GenericElement("http://somens", "child5");
+ child4.addChild(child5);
+
+ GenericElement child6 = new GenericElement("http://anotherns", "child6");
+ GE_INSTANCE._any[1] = child6;
+
+ GenericElement child7 = new GenericElement("http://child7ns", "child7");
+ GE_INSTANCE._any[2] = child7;
+
+ GenericElement child8 = new GenericElement("http://child8ns", "child8");
+ child7.addChild(child8);
+
+ assertArrayOfAnyGenericElement(GE_INSTANCE);
+ }
+
+ static
+ {
+ DOM_INSTANCE = new ArrayOfAny();
+ DOM_INSTANCE._any = new Element[3];
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder domBuilder = null;
+ try
+ {
+ domBuilder = factory.newDocumentBuilder();
+ }
+ catch(ParserConfigurationException e)
+ {
+ throw new JBossXBRuntimeException("Failed to create document builder instance", e);
+ }
+ Document doc = domBuilder.newDocument();
+
+ Element child1 = doc.createElementNS("http://somens", "child1");
+ DOM_INSTANCE._any[0] = child1;
+
+ Element child2 = doc.createElementNS("http://somens", "child2");
+ child1.appendChild(child2);
+ child2.setAttribute("child2_attr1", "attr1");
+ child2.setAttribute("child2_attr2", "attr2");
+
+ Element child3 = doc.createElementNS("http://somens", "child3");
+ child1.appendChild(child3);
+ child3.appendChild(doc.createTextNode("text content3"));
+
+ Element child4 = doc.createElementNS("http://somens", "child4");
+ child1.appendChild(child4);
+ child4.setAttribute("child4_attr1", "attr1");
+
+ Element child5 = doc.createElementNS("http://somens", "child5");
+ child4.appendChild(child5);
+
+ Element child6 = doc.createElementNS("http://anotherns", "child6");
+ DOM_INSTANCE._any[1] = child6;
+
+ Element child7 = doc.createElementNS("http://child7ns", "child7");
+ DOM_INSTANCE._any[2] = child7;
+
+ Element child8 = doc.createElementNS("http://child8ns", "child8");
+ child7.appendChild(child8);
+
+ assertArrayOfAnyDom(DOM_INSTANCE);
+ }
+
+ private Object[] _any;
+
+ public Object[] get_any()
+ {
+ return _any;
+ }
+
+ public void set_any(Object[] _any)
+ {
+ this._any = _any;
+ }
+ }
+
+ public static class GenericElement
+ {
+ private String localName;
+ private String nsUri;
+ private Map attributes = Collections.EMPTY_MAP;
+ private Map childElements = Collections.EMPTY_MAP;
+ private String textContent;
+
+ public GenericElement(String localName)
+ {
+ this.localName = localName;
+ }
+
+ public GenericElement(String nsUri, String localName)
+ {
+ this.localName = localName;
+ this.nsUri = nsUri;
+ }
+
+ public String getLocalName()
+ {
+ return localName;
+ }
+
+ public String getNsUri()
+ {
+ return nsUri;
+ }
+
+ public String getTextContent()
+ {
+ return textContent;
+ }
+
+ public void setTextContent(String textContent)
+ {
+ this.textContent = textContent;
+ }
+
+ public void setAttribute(String name, String value)
+ {
+ switch(attributes.size())
+ {
+ case 0:
+ attributes = Collections.singletonMap(name, value);
+ break;
+ case 1:
+ attributes = new HashMap(attributes);
+ default:
+ attributes.put(name, value);
+ }
+ }
+
+ public String getAttribute(String name)
+ {
+ return (String)attributes.get(name);
+ }
+
+ public void addChild(GenericElement child)
+ {
+ switch(childElements.size())
+ {
+ case 0:
+ childElements = Collections.singletonMap(child.getLocalName(), child);
+ break;
+ case 1:
+ childElements = new LinkedHashMap(childElements);
+ default:
+ childElements.put(child.getLocalName(), child);
+ }
+ }
+
+ public GenericElement getChild(String name)
+ {
+ return (GenericElement)childElements.get(name);
+ }
+
+ public Iterator getChildElements()
+ {
+ return childElements.values().iterator();
+ }
+
+ public int getChildElementsTotal()
+ {
+ return childElements.size();
+ }
+
+ public Set getAttributeNames()
+ {
+ return attributes.keySet();
+ }
+
+ public int getAttributesTotal()
+ {
+ return attributes.size();
+ }
+ }
+
+ public static class GenericCharactersHandler
+ extends CharactersHandler
+ {
+ public Object unmarshalEmpty(QName qName,
+ TypeBinding typeBinding,
+ NamespaceContext nsCtx,
+ ValueMetaData valueMetaData)
+ {
+ return "";
+ }
+
+ public Object unmarshal(QName qName,
+ TypeBinding typeBinding,
+ NamespaceContext nsCtx,
+ ValueMetaData valueMetaData,
+ String value)
+ {
+ return value;
+ }
+
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ GenericElement e = (GenericElement)owner;
+ String text = (String)value;
+ e.setTextContent(text);
+ }
+ }
+
+ public static class GenericElementHandler
+ extends RtElementHandler
+ implements ParticleHandler
+ {
+ public Object startParticle(Object parent,
+ QName elementName,
+ ParticleBinding particle,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ GenericElement el = new GenericElement(elementName.getNamespaceURI(), elementName.getLocalPart());
+
+ if(attrs != null)
+ {
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ el.setAttribute(attrs.getLocalName(i), attrs.getValue(i));
+ }
+ }
+
+ return el;
+ }
+
+ public Object endParticle(Object o, QName elementName, ParticleBinding particle)
+ {
+ return o;
+ }
+
+ public void setParent(Object parent,
+ Object o,
+ QName elementName,
+ ParticleBinding particle,
+ ParticleBinding parentParticle)
+ {
+ if(parent instanceof GenericElement)
+ {
+ ((GenericElement)parent).addChild((GenericElement)o);
+ }
+ else
+ {
+ super.setParent(parent, o, elementName, particle, parentParticle);
+ }
+ }
+ }
+
+ public static class DomCharactersHandler
+ extends CharactersHandler
+ {
+ public Object unmarshalEmpty(QName qName,
+ TypeBinding typeBinding,
+ NamespaceContext nsCtx,
+ ValueMetaData valueMetaData)
+ {
+ return "";
+ }
+
+ public Object unmarshal(QName qName,
+ TypeBinding typeBinding,
+ NamespaceContext nsCtx,
+ ValueMetaData valueMetaData,
+ String value)
+ {
+ return value;
+ }
+
+ public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+ {
+ Element e = (Element)owner;
+ Text textNode = e.getOwnerDocument().createTextNode((String)value);
+ e.appendChild(textNode);
+ }
+ }
+
+ public static class DomElementHandler
+ extends RtElementHandler
+ implements ParticleHandler
+ {
+ private Document doc;
+
+ public Object startParticle(Object parent,
+ QName elementName,
+ ParticleBinding particle,
+ Attributes attrs,
+ NamespaceContext nsCtx)
+ {
+ Document doc = getDocument();
+ Element element = doc.createElementNS(elementName.getNamespaceURI(), elementName.getLocalPart());
+
+ if(attrs != null)
+ {
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ element.setAttribute(attrs.getLocalName(i), attrs.getValue(i));
+ }
+ }
+
+ return element;
+ }
+
+ public Object endParticle(Object o, QName elementName, ParticleBinding particle)
+ {
+ return o;
+ }
+
+ public void setParent(Object parent,
+ Object o,
+ QName elementName,
+ ParticleBinding particle,
+ ParticleBinding parentParticle)
+ {
+ if(parent instanceof Element)
+ {
+ ((Element)parent).appendChild((Element)o);
+ }
+ else
+ {
+ super.setParent(parent, o, elementName, particle, parentParticle);
+ }
+ }
+
+ private Document getDocument()
+ {
+ if(doc == null)
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder domBuilder = null;
+ try
+ {
+ domBuilder = factory.newDocumentBuilder();
+ }
+ catch(ParserConfigurationException e)
+ {
+ throw new JBossXBRuntimeException("Failed to create document builder instance", e);
+ }
+ doc = domBuilder.newDocument();
+ }
+ return doc;
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/WildcardWrapperUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/WildcardWrapperUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/WildcardWrapperUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -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.xml;
+
+import junit.framework.Test;
+
+import org.jboss.test.xml.initializer.Simple;
+import org.jboss.test.xml.initializer.SimpleInitializer;
+import org.jboss.test.xml.pojoserver.metadata.AbstractValueMetaData;
+import org.jboss.test.xml.pojoserver.metadata.PropertyInitializer;
+import org.jboss.test.xml.pojoserver.metadata.PropertyMetaData;
+import org.jboss.test.xml.pojoserver.metadata.StringValueMetaData;
+import org.jboss.test.xml.pojoserver.metadata.ValueMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+
+/**
+ * WildcardWrapperUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 40741 $
+ */
+public class WildcardWrapperUnitTestCase extends AbstractJBossXBTest
+{
+ public static SchemaBindingResolver initResolver() throws Exception
+ {
+ Class clazz = WildcardWrapperUnitTestCase.class;
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ resolver.addSchemaInitializer(PropertyInitializer.NS, PropertyInitializer.class.getName());
+ String location = getSchemaLocation(clazz, "WildcardWrapperUnitTestCase.xsd");
+ resolver.addSchemaLocation(PropertyInitializer.NS, location);
+ resolver.addSchemaInitializer(SimpleInitializer.NS, SimpleInitializer.class.getName());
+ location = getSchemaLocation(clazz, "SchemaBindingInitializerUnitTestCaseSimple.xsd");
+ resolver.addSchemaLocation(SimpleInitializer.NS, location);
+ return resolver;
+ }
+
+ public void testSimple() throws Exception
+ {
+ PropertyMetaData property = (PropertyMetaData) unmarshal(rootName + "Simple.xml", PropertyMetaData.class);
+ ValueMetaData value = property.getValue();
+ assertNotNull("Should have a value", value);
+ assertTrue(value instanceof StringValueMetaData);
+ StringValueMetaData stringValue = (StringValueMetaData) value;
+ assertEquals("testSimple", stringValue.getValue());
+ }
+
+ public void testWildcard() throws Exception
+ {
+ PropertyMetaData property = (PropertyMetaData) unmarshal(rootName + "Wildcard.xml", PropertyMetaData.class);
+ ValueMetaData value = property.getValue();
+ assertNotNull("Should have a value", value);
+ assertTrue(value instanceof AbstractValueMetaData);
+ AbstractValueMetaData abstractValue = (AbstractValueMetaData) value;
+ Object anyValue = abstractValue.getValue();
+ assertNotNull("AbstractValue should have a value", anyValue);
+ assertTrue(anyValue instanceof Simple);
+ Simple simple = (Simple) anyValue;
+ assertEquals("testWildcard", simple.getValue());
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(WildcardWrapperUnitTestCase.class);
+ }
+
+ /**
+ * Create a new WildcardWrapperUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public WildcardWrapperUnitTestCase(String name)
+ {
+ super(name);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/XMLNameToJavaIdentifierUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/XMLNameToJavaIdentifierUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/XMLNameToJavaIdentifierUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,160 @@
+/*
+ * 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.xml;
+
+import junit.framework.TestCase;
+
+import org.jboss.xb.binding.Util;
+
+/**
+ * Tests XML names to various Java identifiers conversion.
+ *
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37940 $</tt>
+ */
+public class XMLNameToJavaIdentifierUnitTestCase
+ extends TestCase
+{
+ private static final String[] xmlNames = new String[]
+ {
+ "mixedCaseName", "Answer42", "name-with-dashes", "other_punct-chars", "one2three", "__-invalids-at-the-end---",
+ "ID", "iD"
+ };
+
+ private static final String[] clsNames = new String[]
+ {
+ "MixedCaseName", "Answer42", "NameWithDashes", "OtherPunctChars", "One2Three", "InvalidsAtTheEnd", "ID", "ID"
+ };
+
+ private static final String[] clsNamesWithLowLines = new String[]
+ {
+ "MixedCaseName", "Answer42", "NameWithDashes", "Other_PunctChars", "One2Three", "__InvalidsAtTheEnd", "ID", "ID"
+ };
+
+ private static final String[] fieldNames = new String[]
+ {
+ "mixedCaseName", "answer42", "nameWithDashes", "otherPunctChars", "one2Three", "invalidsAtTheEnd", "ID", "iD"
+ };
+
+ private static final String[] getNames = new String[]
+ {
+ "getMixedCaseName", "getAnswer42", "getNameWithDashes", "getOtherPunctChars", "getOne2Three",
+ "getInvalidsAtTheEnd", "getID", "getID"
+ };
+
+ private static final String[] setNames = new String[]
+ {
+ "setMixedCaseName", "setAnswer42", "setNameWithDashes", "setOtherPunctChars", "setOne2Three",
+ "setInvalidsAtTheEnd", "setID", "setID"
+ };
+
+ private static final String[] constNames = new String[]
+ {
+ "MIXED_CASE_NAME", "ANSWER_42", "NAME_WITH_DASHES", "OTHER_PUNCT_CHARS", "ONE_2_THREE", "INVALIDS_AT_THE_END",
+ "ID", "I_D"
+ };
+
+ public XMLNameToJavaIdentifierUnitTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void testXmlNameToClassName() throws Exception
+ {
+ for(int i = 0; i < xmlNames.length; ++i)
+ {
+ String clsName = Util.xmlNameToClassName(xmlNames[i], true);
+ assertEquals(clsNames[i], clsName);
+ }
+ }
+
+ public void testXmlNameToClassNameWithLowLines() throws Exception
+ {
+ for(int i = 0; i < xmlNames.length; ++i)
+ {
+ String clsName = Util.xmlNameToClassName(xmlNames[i], false);
+ assertEquals(clsNamesWithLowLines[i], clsName);
+ }
+ }
+
+ public void testXmlNameToGetMethodName() throws Exception
+ {
+ for(int i = 0; i < xmlNames.length; ++i)
+ {
+ String clsName = Util.xmlNameToGetMethodName(xmlNames[i], true);
+ assertEquals(getNames[i], clsName);
+ }
+ }
+
+ public void testXmlNameToSetMethodName() throws Exception
+ {
+ for(int i = 0; i < xmlNames.length; ++i)
+ {
+ String clsName = Util.xmlNameToSetMethodName(xmlNames[i], true);
+ assertEquals(setNames[i], clsName);
+ }
+ }
+
+ public void testXmlNameToConstantName() throws Exception
+ {
+ for(int i = 0; i < xmlNames.length; ++i)
+ {
+ String constName = Util.xmlNameToConstantName(xmlNames[i]);
+ assertEquals(constNames[i], constName);
+ }
+ }
+
+ public void testXmlNameToFieldName() throws Exception
+ {
+ for(int i = 0; i < xmlNames.length; ++i)
+ {
+ String fieldName = Util.xmlNameToFieldName(xmlNames[i], true);
+ assertEquals(fieldNames[i], fieldName);
+ }
+ }
+
+ public void testXmlNamespaceToJavaPackage() throws Exception
+ {
+ String[] ns = new String[]{
+ "http://www.acme.com/go/espeak.xsd",
+ "http://example.org/ns/books/",
+ "http://www.w3.org/2001/XMLSchema",
+ "http://example.org/",
+ "http://example.org",
+ "http://www.kloop.com.ua/xsd-schemas/schema1.xsd"
+ };
+
+ String[] pkg = new String[]{
+ "com.acme.go.espeak",
+ "org.example.ns.books",
+ "org.w3._2001.xmlschema",
+ "org.example",
+ "org.example",
+ "ua.com.kloop.xsd_schemas.schema1"
+ };
+
+ for(int i = 0; i < ns.length; ++i)
+ {
+ assertEquals(pkg[i], Util.xmlNamespaceToJavaPackage(ns[i]));
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/XercesBugTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/XercesBugTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/XercesBugTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,174 @@
+/*
+ * 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.xml;
+
+import java.net.URL;
+
+import org.apache.xerces.xs.XSComplexTypeDefinition;
+import org.apache.xerces.xs.XSConstants;
+import org.apache.xerces.xs.XSImplementation;
+import org.apache.xerces.xs.XSLoader;
+import org.apache.xerces.xs.XSModel;
+import org.apache.xerces.xs.XSNamedMap;
+import org.apache.xerces.xs.XSObjectList;
+import org.apache.xerces.xs.XSTypeDefinition;
+import org.apache.xerces.xs.XSModelGroup;
+import org.jboss.test.BaseTestCase;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.Util;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinderTerminatingErrorHandler;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSResourceResolver;
+
+/**
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @version <tt>$Revision: 41616 $</tt>
+ */
+public class XercesBugTestCase extends BaseTestCase
+{
+ public XercesBugTestCase(String localName)
+ {
+ super(localName);
+ }
+
+ public void testXerces280Bug()
+ {
+ String xsd =
+ "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
+ " <xsd:complexType name='valueType'>" +
+ " <xsd:sequence>" +
+ " <xsd:element name='value' type='xsd:string'/>" +
+ " </xsd:sequence>" +
+ " </xsd:complexType>" +
+ " <xsd:complexType name='annotatedValueType'>" +
+ " <xsd:complexContent>" +
+ " <xsd:extension base='valueType'>" +
+ " <xsd:sequence>" +
+ " <xsd:element name='annotation' type='xsd:string'/>" +
+ " </xsd:sequence>" +
+ " </xsd:extension>" +
+ " </xsd:complexContent>" +
+ " </xsd:complexType>" +
+ "</xsd:schema>";
+
+ XSModel model = Util.loadSchema(xsd, (String)null);
+
+ XSComplexTypeDefinition type = (XSComplexTypeDefinition)model.getTypeDefinition("valueType", "");
+ XSModelGroup modelGroup = (XSModelGroup)type.getParticle().getTerm();
+ assertNull(modelGroup.getAnnotation());
+
+ type = (XSComplexTypeDefinition)model.getTypeDefinition("annotatedValueType", "");
+ modelGroup = (XSModelGroup)type.getParticle().getTerm();
+ assertNull(modelGroup.getAnnotation());
+ }
+
+ public void testXercesBug()
+ {
+ String name = "xml/xerces-bug.xsd";
+ URL xsdUrl = Thread.currentThread().getContextClassLoader().getResource(name);
+
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ resolver.setBaseURI(xsdUrl.toString());
+ XSImplementation impl = getXSImplementation();
+ XSLoader schemaLoader = impl.createXSLoader(null);
+ setResourceResolver(schemaLoader, resolver);
+ setDOMErrorHandler(schemaLoader);
+ XSModel model = schemaLoader.loadURI(xsdUrl.toString());
+
+ XSNamedMap types = model.getComponents(XSConstants.TYPE_DEFINITION);
+ for(int i = 0; i < types.getLength(); ++i)
+ {
+ XSTypeDefinition type = (XSTypeDefinition)types.item(i);
+ if(!Constants.NS_XML_SCHEMA.equals(type.getNamespace()))
+ {
+ if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)
+ {
+ XSComplexTypeDefinition typeDef = (XSComplexTypeDefinition) type;
+ XSObjectList annotations = typeDef.getAnnotations();
+ assertEquals(1, annotations.getLength());
+ }
+ }
+ }
+ }
+
+ private static void setResourceResolver(XSLoader schemaLoader, final SchemaBindingResolver schemaResolver)
+ {
+ DOMConfiguration config = schemaLoader.getConfig();
+ config.setParameter("resource-resolver", new LSResourceResolver()
+ {
+ public LSInput resolveResource(String type,
+ String namespaceURI,
+ String publicId,
+ String systemId,
+ String baseURI)
+ {
+ if(Constants.NS_XML_SCHEMA.equals(type))
+ {
+ return schemaResolver.resolveAsLSInput(namespaceURI, null, null);
+ }
+ return null;
+ }
+ }
+ );
+ }
+
+ private static void setDOMErrorHandler(XSLoader schemaLoader)
+ {
+ DOMConfiguration config = schemaLoader.getConfig();
+ config.setParameter("error-handler", XsdBinderTerminatingErrorHandler.newInstance());
+ }
+
+ private static XSImplementation getXSImplementation()
+ {
+ // Get DOM Implementation using DOM Registry
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ // Try the 2.6.2 version
+ String name = "org.apache.xerces.dom.DOMXSImplementationSourceImpl";
+ loader.loadClass(name);
+ System.setProperty(DOMImplementationRegistry.PROPERTY, name);
+ }
+ catch(ClassNotFoundException e)
+ {
+ // Try the 2.7.0 version
+ String name = "org.apache.xerces.dom.DOMXSImplementationSourceImpl";
+ System.setProperty(DOMImplementationRegistry.PROPERTY, name);
+ }
+
+ XSImplementation impl;
+ try
+ {
+ DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+ impl = (XSImplementation)registry.getDOMImplementation("XS-Loader");
+ }
+ catch(Exception e)
+ {
+ throw new IllegalStateException("Failed to create schema loader: " + e.getMessage());
+ }
+ return impl;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/XsiTypeUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/XsiTypeUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/XsiTypeUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,420 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import org.jboss.xb.binding.MappingObjectModelProvider;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.XercesXsMarshaller;
+import org.jboss.xb.binding.Constants;
+import org.jboss.xb.binding.sunday.unmarshalling.LSInputAdaptor;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
+import org.w3c.dom.ls.LSInput;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 45337 $</tt>
+ */
+public class XsiTypeUnitTestCase
+ extends AbstractJBossXBTest
+{
+ private static final String PO_NS = "http://www.example.com/IPO";
+
+ private static final String ADDRESS_XSD =
+ "<schema targetNamespace='" + PO_NS + "'" +
+ " xmlns='http://www.w3.org/2001/XMLSchema'" +
+ " xmlns:jbxb='" + Constants.NS_JBXB + "'" +
+ " xmlns:ipo='" + PO_NS + "'>" +
+ " <complexType name='Address'>" +
+ " <sequence>" +
+ " <element name='name' type='string'/>" +
+ " <element name='street' type='string'/>" +
+ " <element name='city' type='string'/>" +
+ " </sequence>" +
+ " </complexType>" +
+ " <complexType name='USAddress'>" +
+ " <annotation>" +
+ " <appinfo>" +
+ " <jbxb:class impl='" + USAddress.class.getName() + "'/>" +
+ " </appinfo>" +
+ " </annotation>" +
+ " <complexContent>" +
+ " <extension base='ipo:Address'>" +
+ " <sequence>" +
+ " <element name='state' type='string'/>" +
+ " <element name='zip' type='string'/>" +
+ " </sequence>" +
+ " </extension>" +
+ " </complexContent>" +
+ " </complexType>" +
+ " <complexType name='UKAddress'>" +
+ " <annotation>" +
+ " <appinfo>" +
+ " <jbxb:class impl='" + UKAddress.class.getName() + "'/>" +
+ " </appinfo>" +
+ " </annotation>" +
+ " <complexContent>" +
+ " <extension base='ipo:Address'>" +
+ " <sequence>" +
+ " <element name='postcode' type='string'/>" +
+ " </sequence>" +
+ " <attribute name='exportCode' type='string' fixed='1'/>" +
+ " </extension>" +
+ " </complexContent>" +
+ " </complexType>" +
+ "</schema>";
+
+ private static final String PO_XSD =
+ "<schema targetNamespace='" + PO_NS + "'" +
+ " xmlns='http://www.w3.org/2001/XMLSchema'" +
+ " xmlns:jbxb='" + Constants.NS_JBXB + "'" +
+ " xmlns:ipo='" + PO_NS + "'>" +
+ " <include schemaLocation='http://www.example.com/schemas/address.xsd'/>" +
+ " <complexType name='PurchaseOrderType'>" +
+ " <annotation>" +
+ " <appinfo>" +
+ " <jbxb:class impl='" + PurchaseOrder.class.getName() + "'/>" +
+ " </appinfo>" +
+ " </annotation>" +
+ " <sequence>" +
+ " <element name='shipTo' type='ipo:Address'/>" +
+ " <element name='billTo' type='ipo:Address'/>" +
+ " </sequence>" +
+ " </complexType>" +
+ " <element name='purchaseOrder' type='ipo:PurchaseOrderType'/>" +
+ "</schema>";
+
+ private static final String PO_XML =
+ "<ipo:purchaseOrder" +
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
+ " xmlns:ipo='" + PO_NS + "'>" +
+ " <shipTo exportCode='1' xsi:type='ipo:UKAddress'>" +
+ " <name>Helen Zoe</name>" +
+ " <street>47 Eden Street</street>" +
+ " <city>Cambridge</city>" +
+ " <postcode>CB1 1JR</postcode>" +
+ " </shipTo>" +
+ " <billTo xsi:type='ipo:USAddress'>" +
+ " <name>Robert Smith</name>" +
+ " <street>8 Oak Avenue</street>" +
+ " <city>Old Town</city>" +
+ " <state>PA</state>" +
+ " <zip>95819</zip>" +
+ " </billTo>" +
+ "</ipo:purchaseOrder>";
+
+ private static final SchemaBindingResolver SCHEMA_RESOLVER = new SchemaBindingResolver()
+ {
+ public String getBaseURI()
+ {
+ throw new UnsupportedOperationException("getBaseURI is not implemented.");
+ }
+
+ public void setBaseURI(String baseURI)
+ {
+ throw new UnsupportedOperationException("setBaseURI is not implemented.");
+ }
+
+ public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation)
+ {
+ throw new UnsupportedOperationException("resolve is not implemented.");
+ }
+
+ public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation)
+ {
+ if(schemaLocation.endsWith("address.xsd"))
+ {
+ return new LSInputAdaptor(new StringReader(ADDRESS_XSD), null);
+ }
+ return null;
+ }
+ };
+
+ private static SchemaBinding SCHEMA;
+
+ public XsiTypeUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void configureLogging()
+ {
+ if(SCHEMA == null)
+ {
+ SCHEMA = XsdBinder.bind(new StringReader(PO_XSD), null, SCHEMA_RESOLVER);
+ }
+ }
+
+ public void testUnmarshalling() throws Exception
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(new StringReader(PO_XML), SCHEMA);
+ assertEquals(PurchaseOrder.INSTANCE, o);
+ }
+
+ public void testMarshallingXerces() throws Exception
+ {
+ XercesXsMarshaller marshaller = new XercesXsMarshaller();
+ marshaller.setSchemaResolver(SCHEMA_RESOLVER);
+ marshaller.mapClassToXsiType(UKAddress.class, PO_NS, "UKAddress");
+ marshaller.mapClassToXsiType(USAddress.class, PO_NS, "USAddress");
+
+ MappingObjectModelProvider provider = new MappingObjectModelProvider();
+
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(new StringReader(PO_XSD), provider, PurchaseOrder.INSTANCE, writer);
+ assertXmlEqual(PO_XML, writer.getBuffer().toString());
+ }
+
+ public void testMarshallingSunday() throws Exception
+ {
+ MarshallerImpl marshaller = new MarshallerImpl();
+ marshaller.setSchemaResolver(SCHEMA_RESOLVER);
+ marshaller.mapClassToXsiType(UKAddress.class, PO_NS, "UKAddress");
+ marshaller.mapClassToXsiType(USAddress.class, PO_NS, "USAddress");
+
+ StringWriter writer = new StringWriter();
+
+ marshaller.marshal(SCHEMA, null, PurchaseOrder.INSTANCE, writer);
+ assertXmlEqual(PO_XML, writer.getBuffer().toString());
+ }
+
+ // Inner
+
+ public static final class PurchaseOrder
+ {
+ public static final PurchaseOrder INSTANCE = new PurchaseOrder();
+
+ static
+ {
+ UKAddress ukAddr = new UKAddress();
+ ukAddr.name = "Helen Zoe";
+ ukAddr.street = "47 Eden Street";
+ ukAddr.city = "Cambridge";
+ ukAddr.postcode = "CB1 1JR";
+ ukAddr.exportCode = "1";
+ INSTANCE.shipTo = ukAddr;
+
+ USAddress usAddr = new USAddress();
+ usAddr.name = "Robert Smith";
+ usAddr.street = "8 Oak Avenue";
+ usAddr.city = "Old Town";
+ usAddr.state = "PA";
+ usAddr.zip = "95819";
+ INSTANCE.billTo = usAddr;
+ }
+
+ public Address shipTo;
+ public Address billTo;
+
+ public String toString()
+ {
+ return "[shipTo=" + shipTo + ", billTo=" + billTo + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof PurchaseOrder))
+ {
+ return false;
+ }
+
+ final PurchaseOrder purchaseOrder = (PurchaseOrder)o;
+
+ if(billTo != null ? !billTo.equals(purchaseOrder.billTo) : purchaseOrder.billTo != null)
+ {
+ return false;
+ }
+ if(shipTo != null ? !shipTo.equals(purchaseOrder.shipTo) : purchaseOrder.shipTo != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (shipTo != null ? shipTo.hashCode() : 0);
+ result = 29 * result + (billTo != null ? billTo.hashCode() : 0);
+ return result;
+ }
+ }
+
+ public static class Address
+ {
+ public String name;
+ public String street;
+ public String city;
+
+ public String toString()
+ {
+ return "name=" + name + ", street=" + street + ", city=" + city;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Address))
+ {
+ return false;
+ }
+
+ final Address address = (Address)o;
+
+ if(city != null ? !city.equals(address.city) : address.city != null)
+ {
+ return false;
+ }
+ if(name != null ? !name.equals(address.name) : address.name != null)
+ {
+ return false;
+ }
+ if(street != null ? !street.equals(address.street) : address.street != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (name != null ? name.hashCode() : 0);
+ result = 29 * result + (street != null ? street.hashCode() : 0);
+ result = 29 * result + (city != null ? city.hashCode() : 0);
+ return result;
+ }
+ }
+
+ public static final class USAddress
+ extends Address
+ {
+ public String state;
+ public String zip;
+
+ public String toString()
+ {
+ return super.toString() + ", state=" + state + ", zip=" + zip;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof USAddress))
+ {
+ return false;
+ }
+ if(!super.equals(o))
+ {
+ return false;
+ }
+
+ final USAddress usAddress = (USAddress)o;
+
+ if(state != null ? !state.equals(usAddress.state) : usAddress.state != null)
+ {
+ return false;
+ }
+ if(zip != null ? !zip.equals(usAddress.zip) : usAddress.zip != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 29 * result + (state != null ? state.hashCode() : 0);
+ result = 29 * result + (zip != null ? zip.hashCode() : 0);
+ return result;
+ }
+ }
+
+ public static final class UKAddress
+ extends Address
+ {
+ public String postcode;
+ public String exportCode;
+
+ public String toString()
+ {
+ return super.toString() + ", postcode=" + postcode + ", exportCode=" + exportCode;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof UKAddress))
+ {
+ return false;
+ }
+ if(!super.equals(o))
+ {
+ return false;
+ }
+
+ final UKAddress ukAddress = (UKAddress)o;
+
+ if(exportCode != null ? !exportCode.equals(ukAddress.exportCode) : ukAddress.exportCode != null)
+ {
+ return false;
+ }
+ if(postcode != null ? !postcode.equals(ukAddress.postcode) : ukAddress.postcode != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 29 * result + (postcode != null ? postcode.hashCode() : 0);
+ result = 29 * result + (exportCode != null ? exportCode.hashCode() : 0);
+ return result;
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/any/Container.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/any/Container.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/any/Container.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,90 @@
+/*
+ * 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.xml.any;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Container
+{
+ private String id;
+ private Object anyContent;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public Object getAnyContent()
+ {
+ return anyContent;
+ }
+
+ public void setAnyContent(Object anyContent)
+ {
+ this.anyContent = anyContent;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Container))
+ {
+ return false;
+ }
+
+ final Container container = (Container)o;
+
+ if(anyContent != null ? !anyContent.equals(container.anyContent) : container.anyContent != null)
+ {
+ return false;
+ }
+ if(id != null ? !id.equals(container.id) : container.id != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 29 * result + (anyContent != null ? anyContent.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[container id=" + id + ", anyContent=" + anyContent + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/book/Book.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/book/Book.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/book/Book.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,149 @@
+/*
+ * 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.xml.book;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Book class that represents book element in XML content.
+ *
+ * @version <tt>$Revision: 37406 $</tt>
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public class Book
+{
+ public static Book getInstance()
+ {
+ Book book = new Book();
+ book.setIsbn("0836217462");
+ book.setTitle("Being a Dog Is a Full-Time Job");
+ book.setAuthor("Charles M. Schulz");
+
+ BookCharacter character = new BookCharacter();
+ character.setName("Snoopy");
+ character.setFriendOf("Peppermint Patty");
+ character.setSince("1950-10-04");
+ character.setQualification("extroverted beagle");
+ book.addCharacter(character);
+
+ character = new BookCharacter();
+ character.setName("Peppermint Patty");
+ character.setSince("1966-08-22");
+ character.setQualification("bold, brash and tomboyish");
+ book.addCharacter(character);
+
+ return book;
+ }
+
+ private String isbn;
+ private String title;
+ private String author;
+ private List characters = new ArrayList();
+
+ public String getIsbn()
+ {
+ return isbn;
+ }
+
+ public void setIsbn(String isbn)
+ {
+ this.isbn = isbn;
+ }
+
+ public String getAuthor()
+ {
+ return author;
+ }
+
+ public void setAuthor(String author)
+ {
+ this.author = author;
+ }
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
+
+ public List getCharacters()
+ {
+ return characters;
+ }
+
+ public void setCharacters(List characters)
+ {
+ this.characters = characters;
+ }
+
+ public void addCharacter(BookCharacter character)
+ {
+ characters.add(character);
+ }
+
+ public int getCharactersTotal()
+ {
+ return characters.size();
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append('[')
+ .append("isbn=").append(isbn)
+ .append(", title=").append(title)
+ .append(", author=").append(author)
+ .append(", characters=").append(characters)
+ .append(']');
+ return sb.toString();
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o) return true;
+ if(!(o instanceof Book)) return false;
+
+ final Book book = (Book)o;
+
+ if(author != null ? !author.equals(book.author) : book.author != null) return false;
+ if(characters != null ? !characters.equals(book.characters) : book.characters != null) return false;
+ if(isbn != null ? !isbn.equals(book.isbn) : book.isbn != null) return false;
+ if(title != null ? !title.equals(book.title) : book.title != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (isbn != null ? isbn.hashCode() : 0);
+ result = 29 * result + (title != null ? title.hashCode() : 0);
+ result = 29 * result + (author != null ? author.hashCode() : 0);
+ result = 29 * result + (characters != null ? characters.hashCode() : 0);
+ return result;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookCharacter.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookCharacter.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookCharacter.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,113 @@
+/*
+ * 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.xml.book;
+
+/**
+ * BookCharacter class that represents the character element in XML content.
+ *
+ * @version <tt>$Revision: 37406 $</tt>
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public class BookCharacter
+{
+ private String name;
+ private String friendOf;
+ private String since;
+ private String qualification;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getFriendOf()
+ {
+ return friendOf;
+ }
+
+ public void setFriendOf(String friendOf)
+ {
+ this.friendOf = friendOf;
+ }
+
+ public String getSince()
+ {
+ return since;
+ }
+
+ public void setSince(String since)
+ {
+ this.since = since;
+ }
+
+ public String getQualification()
+ {
+ return qualification;
+ }
+
+ public void setQualification(String qualification)
+ {
+ this.qualification = qualification;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o) return true;
+ if(!(o instanceof BookCharacter)) return false;
+
+ final BookCharacter bookCharacter = (BookCharacter)o;
+
+ if(friendOf != null ? !friendOf.equals(bookCharacter.friendOf) : bookCharacter.friendOf != null) return false;
+ if(name != null ? !name.equals(bookCharacter.name) : bookCharacter.name != null) return false;
+ if(qualification != null ? !qualification.equals(bookCharacter.qualification) : bookCharacter.qualification != null) return false;
+ if(since != null ? !since.equals(bookCharacter.since) : bookCharacter.since != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (name != null ? name.hashCode() : 0);
+ result = 29 * result + (friendOf != null ? friendOf.hashCode() : 0);
+ result = 29 * result + (since != null ? since.hashCode() : 0);
+ result = 29 * result + (qualification != null ? qualification.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(50);
+ sb.append('[')
+ .append("name=").append(name)
+ .append(", friend-of=").append(friendOf)
+ .append(", since=").append(since)
+ .append(", qualification=").append(qualification)
+ .append(']');
+ return sb.toString();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookGenericObjectModelFactory.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookGenericObjectModelFactory.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookGenericObjectModelFactory.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,138 @@
+/*
+ * 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.xml.book;
+
+import org.jboss.xb.binding.GenericObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class BookGenericObjectModelFactory
+ implements GenericObjectModelFactory
+{
+ public Object newRoot(Object root,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName,
+ Attributes attrs)
+ {
+ final Book book;
+ if(root == null)
+ {
+ root = book = new Book();
+ }
+ else
+ {
+ book = (Book) root;
+ }
+
+ if(attrs.getLength() > 0)
+ {
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ if(attrs.getLocalName(i).equals("isbn"))
+ {
+ book.setIsbn(attrs.getValue(i));
+ }
+ }
+ }
+
+ return root;
+ }
+
+ public Object newChild(Object parent,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName,
+ Attributes attrs)
+ {
+ Object child = null;
+ if(parent instanceof Book)
+ {
+ if("character".equals(localName))
+ {
+ child = new BookCharacter();
+ }
+ }
+ return child;
+ }
+
+ public void addChild(Object parent,
+ Object child,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName)
+ {
+ if(parent instanceof Book)
+ {
+ final Book book = (Book)parent;
+ if(child instanceof BookCharacter)
+ {
+ book.addCharacter((BookCharacter)child);
+ }
+ }
+ }
+
+ public void setValue(Object o, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+ {
+ if(o instanceof Book)
+ {
+ final Book book = (Book)o;
+ if("title".equals(localName))
+ {
+ book.setTitle(value);
+ }
+ else if("author".equals(localName))
+ {
+ book.setAuthor(value);
+ }
+ }
+ else if(o instanceof BookCharacter)
+ {
+ BookCharacter character = (BookCharacter)o;
+ if("name".equals(localName))
+ {
+ character.setName(value);
+ }
+ else if("friend-of".equals(localName))
+ {
+ character.setFriendOf(value);
+ }
+ else if("since".equals(localName))
+ {
+ character.setSince(value);
+ }
+ else if("qualification".equals(localName))
+ {
+ character.setQualification(value);
+ }
+ }
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ return root;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookGenericObjectModelProvider.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookGenericObjectModelProvider.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookGenericObjectModelProvider.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,108 @@
+/*
+ * 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.xml.book;
+
+import org.jboss.xb.binding.GenericObjectModelProvider;
+import org.jboss.xb.binding.MarshallingContext;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class BookGenericObjectModelProvider
+ implements GenericObjectModelProvider
+{
+ public Object getChildren(Object o, MarshallingContext ctx, String namespaceURI, String localName)
+ {
+ Object children = null;
+ if(o instanceof Book)
+ {
+ Book book = (Book)o;
+ if(localName.equals("character"))
+ {
+ children = book.getCharacters();
+ }
+ else if(localName.equals("book"))
+ {
+ children = book;
+ }
+ }
+ return children;
+ }
+
+ public Object getElementValue(Object o, MarshallingContext ctx, String namespaceURI, String localName)
+ {
+ Object value = null;
+ if(o instanceof Book)
+ {
+ Book book = (Book)o;
+ if("title".equals(localName))
+ {
+ value = book.getTitle();
+ }
+ else if("author".equals(localName))
+ {
+ value = book.getAuthor();
+ }
+ }
+ else if(o instanceof BookCharacter)
+ {
+ BookCharacter character = (BookCharacter)o;
+ if("name".equals(localName))
+ {
+ value = character.getName();
+ }
+ else if("friend-of".equals(localName))
+ {
+ value = character.getFriendOf();
+ }
+ else if("since".equals(localName))
+ {
+ value = character.getSince();
+ }
+ else if("qualification".equals(localName))
+ {
+ value = character.getQualification();
+ }
+ }
+ return value;
+ }
+
+ public Object getAttributeValue(Object o, MarshallingContext ctx, String namespaceURI, String localName)
+ {
+ Object value = null;
+ if(o instanceof Book)
+ {
+ Book book = (Book)o;
+ if("isbn".equals(localName))
+ {
+ value = book.getIsbn();
+ }
+ }
+ return value;
+ }
+
+ public Object getRoot(Object o, MarshallingContext ctx, String namespaceURI, String localName)
+ {
+ return o;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookObjectFactory.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookObjectFactory.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookObjectFactory.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,158 @@
+/*
+ * 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.xml.book;
+
+import org.xml.sax.Attributes;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+
+/**
+ * org.jboss.xb.binding.ObjectModelFactory implementation that accepts data chuncks from unmarshaller
+ * and assembles them into an instance Book.
+ *
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class BookObjectFactory
+ implements ObjectModelFactory
+{
+ // ObjectModelFactory implementation
+
+ /**
+ * Return the root.
+ */
+ public Object newRoot(Object root,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName,
+ Attributes attrs)
+ {
+ final Book book;
+ if(root == null)
+ {
+ root = book = new Book();
+ }
+ else
+ {
+ book = (Book) root;
+ }
+
+ if(attrs.getLength() > 0)
+ {
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ if(attrs.getLocalName(i).equals("isbn"))
+ {
+ book.setIsbn(attrs.getValue(i));
+ }
+ }
+ }
+
+ return root;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
+ {
+ return root;
+ }
+
+ // Methods discovered by introspection
+
+ /**
+ * Called when a child element with simple content is read for book.
+ */
+ public void setValue(Book book,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName,
+ String value)
+ {
+ if("title".equals(localName))
+ {
+ book.setTitle(value);
+ }
+ else if("author".equals(localName))
+ {
+ book.setAuthor(value);
+ }
+ }
+
+ /**
+ * Called when parsing of a new element started.
+ */
+ public Object newChild(Book book,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName,
+ Attributes attrs)
+ {
+ Object child = null;
+ if("character".equals(localName))
+ {
+ child = new BookCharacter();
+ }
+ return child;
+ }
+
+ /**
+ * Called when a child element with simple content is read for character.
+ */
+ public void setValue(BookCharacter character,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName,
+ String value)
+ {
+ if("name".equals(localName))
+ {
+ character.setName(value);
+ }
+ else if("friend-of".equals(localName))
+ {
+ character.setFriendOf(value);
+ }
+ else if("since".equals(localName))
+ {
+ if(value.endsWith("Z"))
+ {
+ value = value.substring(0, value.length() - 1);
+ }
+ character.setSince(value);
+ }
+ else if("qualification".equals(localName))
+ {
+ character.setQualification(value);
+ }
+ }
+
+ /**
+ * Called when parsing character is complete.
+ */
+ public void addChild(Book book,
+ BookCharacter character,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName)
+ {
+ book.addCharacter(character);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookObjectProvider.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookObjectProvider.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/book/BookObjectProvider.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,136 @@
+/*
+ * 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.xml.book;
+
+import java.text.SimpleDateFormat;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import org.jboss.xb.binding.MarshallingContext;
+import org.jboss.xb.binding.ObjectModelProvider;
+
+/**
+ * org.jboss.xb.binding.ObjectModelProvider implementation that provides data to marshaller given
+ * specific Book instance.
+ *
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class BookObjectProvider
+ implements ObjectModelProvider
+{
+ public Object getRoot(Object o, MarshallingContext ctx, String namespaceURI, String localName)
+ {
+ return o;
+ }
+
+ public Object getChildren(Book book, String namespaceUri, String localName)
+ {
+ Object children = null;
+ if(localName.equals("book"))
+ {
+ children = book;
+ }
+ else if(localName.equals("character"))
+ {
+ children = book.getCharacters();
+ }
+ return children;
+ }
+
+ public Object getAttributeValue(Book book, String namespaceUri, String localName)
+ {
+ Object value;
+ if("isbn".equals(localName))
+ {
+ value = book.getIsbn();
+ }
+ else
+ {
+ value = null;
+ }
+ return value;
+ }
+
+ public Object getElementValue(Book book, String namespaceUri, String localName)
+ {
+ Object value;
+ if("title".equals(localName))
+ {
+ value = book.getTitle();
+ }
+ else if("author".equals(localName))
+ {
+ value = book.getAuthor();
+ }
+ else
+ {
+ value = null;
+ }
+ return value;
+ }
+
+ public Object getElementValue(BookCharacter character, String namespaceUri, String localName)
+ {
+ Object value = null;
+ if("name".equals(localName))
+ {
+ value = character.getName();
+ }
+ else if("friend-of".equals(localName))
+ {
+ value = character.getFriendOf();
+ }
+ else if("since".equals(localName))
+ {
+ String since = character.getSince();
+ if(since == null)
+ {
+ value = null;
+ }
+ else
+ {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+ java.util.Date date = null;
+ try
+ {
+ date = dateFormat.parse(since);
+ }
+ catch(ParseException e)
+ {
+ throw new IllegalStateException("Failed to parse date " + since + ": " + e.getMessage());
+ }
+
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ cal.setTime(date);
+ value = cal;
+ }
+ }
+ else if("qualification".equals(localName))
+ {
+ value = character.getQualification();
+ }
+ return value;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/book/DateDatatypeConverter.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/book/DateDatatypeConverter.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/book/DateDatatypeConverter.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,37 @@
+/*
+ * 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.xml.book;
+
+import java.util.Date;
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class DateDatatypeConverter
+{
+ public static String unmarshal(String value, NamespaceContext ctx)
+ {
+ return value;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Choice1.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Choice1.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Choice1.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,100 @@
+/*
+ * 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.xml.choice;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Choice1
+{
+ private String a;
+ private String b;
+
+ public Choice1()
+ {
+ }
+
+ public Choice1(String a, String b)
+ {
+ this.a = a;
+ this.b = b;
+ }
+
+ public String getA()
+ {
+ return a;
+ }
+
+ public void setA(String a)
+ {
+ this.a = a;
+ }
+
+ public String getB()
+ {
+ return b;
+ }
+
+ public void setB(String b)
+ {
+ this.b = b;
+ }
+
+ public String toString()
+ {
+ return "[a=" + a + ", b=" + b + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Choice1))
+ {
+ return false;
+ }
+
+ final Choice1 choice1 = (Choice1)o;
+
+ if(a != null ? !a.equals(choice1.a) : choice1.a != null)
+ {
+ return false;
+ }
+ if(b != null ? !b.equals(choice1.b) : choice1.b != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (a != null ? a.hashCode() : 0);
+ result = 29 * result + (b != null ? b.hashCode() : 0);
+ return result;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Choice2.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Choice2.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Choice2.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,117 @@
+/*
+ * 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.xml.choice;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Choice2
+{
+ private String a;
+ private String b;
+ private String c;
+
+ public Choice2()
+ {
+ }
+
+ public Choice2(String a, String b, String c)
+ {
+ this.a = a;
+ this.b = b;
+ this.c = c;
+ }
+
+ public String getA()
+ {
+ return a;
+ }
+
+ public void setA(String a)
+ {
+ this.a = a;
+ }
+
+ public String getB()
+ {
+ return b;
+ }
+
+ public void setB(String b)
+ {
+ this.b = b;
+ }
+
+ public String getC()
+ {
+ return c;
+ }
+
+ public void setC(String c)
+ {
+ this.c = c;
+ }
+
+ public String toString()
+ {
+ return "[a=" + a + ", b=" + b + ", c=" + c + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Choice2))
+ {
+ return false;
+ }
+
+ final Choice2 choice2 = (Choice2)o;
+
+ if(a != null ? !a.equals(choice2.a) : choice2.a != null)
+ {
+ return false;
+ }
+ if(b != null ? !b.equals(choice2.b) : choice2.b != null)
+ {
+ return false;
+ }
+ if(c != null ? !c.equals(choice2.c) : choice2.c != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (a != null ? a.hashCode() : 0);
+ result = 29 * result + (b != null ? b.hashCode() : 0);
+ result = 29 * result + (c != null ? c.hashCode() : 0);
+ return result;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Root.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Root.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/choice/Root.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,92 @@
+/*
+ * 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.xml.choice;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Root
+{
+ private Collection choice1;
+ private Collection choice2;
+
+ public Collection getChoice1()
+ {
+ return choice1;
+ }
+
+ public void setChoice1(Collection choice1)
+ {
+ this.choice1 = choice1;
+ }
+
+ public Collection getChoice2()
+ {
+ return choice2;
+ }
+
+ public void setChoice2(Collection choice2)
+ {
+ this.choice2 = choice2;
+ }
+
+ public String toString()
+ {
+ return "[choice1=" + choice1 + ", choice2=" + choice2 + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Root))
+ {
+ return false;
+ }
+
+ final Root root = (Root)o;
+
+ if(choice1 != null ? !choice1.equals(root.choice1) : root.choice1 != null)
+ {
+ return false;
+ }
+ if(choice2 != null ? !choice2.equals(root.choice2) : root.choice2 != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (choice1 != null ? choice1.hashCode() : 0);
+ result = 29 * result + (choice2 != null ? choice2.hashCode() : 0);
+ return result;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/collections/Collections.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/collections/Collections.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/collections/Collections.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,170 @@
+/*
+ * 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.xml.collections;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Collections
+{
+ public static Collections getInstance()
+ {
+ Collections c = new Collections();
+ c.stringArray = new String[]{"str1", "str2", "str3"};
+ c.intCol = Arrays.asList(new Integer[]{new Integer(1), new Integer(2), new Integer(3)});
+ c.itemArray = new String[]{"item1", "item2", "item3"};
+ c.itemCol = Arrays.asList(new String[]{"item4", "item5", "item6"});
+ c.intArray = new int[3];
+ c.intArray[0] = 1;
+ c.intArray[1] = 0;
+ c.intArray[2] = -1;
+ return c;
+ }
+
+ private String[] stringArray;
+ private Collection intCol;
+ private String[] itemArray;
+ private Collection itemCol;
+ private int[] intArray;
+
+ public String[] getStringArray()
+ {
+ return stringArray;
+ }
+
+ public void setStringArray(String[] stringArray)
+ {
+ this.stringArray = stringArray;
+ }
+
+ public Collection getIntCol()
+ {
+ return intCol;
+ }
+
+ public void setIntCol(Collection intCol)
+ {
+ this.intCol = intCol;
+ }
+
+ public String[] getItemArray()
+ {
+ return itemArray;
+ }
+
+ public void setItemArray(String[] itemArray)
+ {
+ this.itemArray = itemArray;
+ }
+
+ public Collection getItemCol()
+ {
+ return itemCol;
+ }
+
+ public void setItemCol(Collection itemCol)
+ {
+ this.itemCol = itemCol;
+ }
+
+ public int[] getIntArray()
+ {
+ return intArray;
+ }
+
+ public void setIntArray(int[] intArray)
+ {
+ this.intArray = intArray;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Collections))
+ {
+ return false;
+ }
+
+ final Collections collections = (Collections)o;
+
+ if(!Arrays.equals(intArray, collections.intArray))
+ {
+ return false;
+ }
+ if(intCol != null ? !intCol.equals(collections.intCol) : collections.intCol != null)
+ {
+ return false;
+ }
+ if(!Arrays.equals(itemArray, collections.itemArray))
+ {
+ return false;
+ }
+ if(itemCol != null ? !itemCol.equals(collections.itemCol) : collections.itemCol != null)
+ {
+ return false;
+ }
+ if(!Arrays.equals(stringArray, collections.stringArray))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (intCol != null ? intCol.hashCode() : 0);
+ result = 29 * result + (itemCol != null ? itemCol.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ Integer[] ia = intArray == null ? null : new Integer[intArray.length];
+ if(ia != null)
+ {
+ for(int i = 0; i < intArray.length; ++i)
+ {
+ ia[i] = new Integer(intArray[i]);
+ }
+ }
+
+ return "[collections stringArray=" +
+ (stringArray == null ? "null" : Arrays.asList(stringArray).toString()) +
+ ", intCol=" +
+ intCol +
+ ", itemArray=" +
+ (itemArray == null ? "null" : Arrays.asList(itemArray).toString()) +
+ ", itemCol=" + itemCol +
+ ", intArray=" +
+ (ia == null ? "null" : Arrays.asList(ia).toString()) +
+ "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/config/Config.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/config/Config.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/config/Config.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,473 @@
+/*
+ * 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.xml.config;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Config
+{
+ public static Config getInstance()
+ {
+ Config config = new Config();
+
+ Config.ConfigAttr.ConfigAttrDataValue defValue = new Config.ConfigAttr.ConfigAttrDataValue();
+ defValue.setData("default value");
+ config.getAttrs().add(new Config.ConfigAttr(defValue));
+
+ Config.ConfigAttr.ConfigAttrValue1 value1 = new Config.ConfigAttr.ConfigAttrValue1();
+ value1.setProperty("value1");
+ config.getAttrs().add(new Config.ConfigAttr(value1));
+
+ Config.ConfigAttr.ConfigAttrValue2 value2 = new Config.ConfigAttr.ConfigAttrValue2();
+ value2.setValue2("value2");
+ config.getAttrs().add(new Config.ConfigAttr(value2));
+
+ config.beans = new ArrayList();
+ config.beans.add(new Config.Bean("A"));
+ config.beans.add(new Config.Bean("B"));
+
+ config.list = new LinkedList();
+ config.list.add(new Config.ListValue("some.type", "foo"));
+ config.list.add(new Config.Depends("SomeBean"));
+
+ List sublist = new LinkedList();
+ sublist.add(new Config.ListValue("another.type", "bar"));
+ sublist.add(new Config.Depends("AnotherBean"));
+ config.list.add(sublist);
+
+ config.map = new HashMap();
+ config.map.put("key1", "value1");
+ config.map.put("key2", "value2");
+ config.map.put("key3", "value3");
+ config.map.put("key4", "value4");
+
+ Map submap = new HashMap();
+ submap.put("submapKey3", "submapValue3");
+ config.map.put("submap", submap);
+
+ return config;
+ }
+
+ private Collection attrs = new ArrayList();
+ public Collection beans;
+ public Collection list;
+ public Map map;
+
+ public Collection getAttrs()
+ {
+ return attrs;
+ }
+
+ public void setAttrs(Collection attrs)
+ {
+ this.attrs = attrs;
+ }
+
+ public String toString()
+ {
+ return "[config attrs=" +
+ attrs +
+ (beans == null ? ", no beans" : ", beans{" + beans.getClass() + "}=" + beans) +
+ (list == null ? ", no list" : ", list{" + list.getClass() + "}=" + list) +
+ (map == null ? ", no map" : ", map{" + map.getClass() + "}=" + map) +
+ "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Config))
+ {
+ return false;
+ }
+
+ final Config config = (Config)o;
+
+ if(attrs != null ? !attrs.equals(config.attrs) : config.attrs != null)
+ {
+ return false;
+ }
+ if(beans != null ? !beans.equals(config.beans) : config.beans != null)
+ {
+ return false;
+ }
+ if(list != null ? !list.equals(config.list) : config.list != null)
+ {
+ return false;
+ }
+ if(map != null ? !map.equals(config.map) : config.map != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (attrs != null ? attrs.hashCode() : 0);
+ result = 29 * result + (beans != null ? beans.hashCode() : 0);
+ result = 29 * result + (list != null ? list.hashCode() : 0);
+ result = 29 * result + (map != null ? map.hashCode() : 0);
+ return result;
+ }
+
+ // Inner
+
+ public static class ListValue
+ {
+ public String type;
+ public String value;
+
+ public ListValue(String type, String value)
+ {
+ this.type = type;
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ return "[list-value type=" + type + ", value=" + value + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof ListValue))
+ {
+ return false;
+ }
+
+ final ListValue listValue = (ListValue)o;
+
+ if(type != null ? !type.equals(listValue.type) : listValue.type != null)
+ {
+ return false;
+ }
+ if(value != null ? !value.equals(listValue.value) : listValue.value != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (type != null ? type.hashCode() : 0);
+ result = 29 * result + (value != null ? value.hashCode() : 0);
+ return result;
+ }
+ }
+
+ public static class Depends
+ {
+ public String value;
+
+ public Depends(String value)
+ {
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ return "[depends value=" + value + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Depends))
+ {
+ return false;
+ }
+
+ final Depends depends = (Depends)o;
+
+ if(value != null ? !value.equals(depends.value) : depends.value != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (value != null ? value.hashCode() : 0);
+ }
+ }
+
+ public static class Bean
+ {
+ public String name;
+
+ public Bean(String name)
+ {
+ this.name = name;
+ }
+
+ public String toString()
+ {
+ return "[bean " + name + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Bean))
+ {
+ return false;
+ }
+
+ final Bean bean = (Bean)o;
+
+ if(name != null ? !name.equals(bean.name) : bean.name != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (name != null ? name.hashCode() : 0);
+ }
+ }
+
+ public static class ConfigAttr
+ {
+ private ConfigAttrValue value;
+
+ public ConfigAttr(ConfigAttrValue value)
+ {
+ this.value = value;
+ }
+
+ public ConfigAttrValue getValue()
+ {
+ return value;
+ }
+
+ public String toString()
+ {
+ return "[config-attr " + value + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof ConfigAttr))
+ {
+ return false;
+ }
+
+ final ConfigAttr configAttr = (ConfigAttr)o;
+
+ if(!value.equals(configAttr.value))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+
+ // Inner
+
+ public static abstract class ConfigAttrValue
+ {
+ }
+
+ public static class ConfigAttrDataValue
+ extends ConfigAttrValue
+ {
+ private String data;
+
+ public String getData()
+ {
+ return data;
+ }
+
+ public void setData(String data)
+ {
+ this.data = data;
+ }
+
+ public String toString()
+ {
+ return "[" + getClass().getName() + ": " + data + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof ConfigAttrDataValue))
+ {
+ return false;
+ }
+
+ final ConfigAttrDataValue configAttrDefaultValue = (ConfigAttrDataValue)o;
+
+ if(!data.equals(configAttrDefaultValue.data))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return data.hashCode();
+ }
+ }
+
+ public static class ConfigAttrValue1
+ extends ConfigAttrValue
+ {
+ private String property;
+
+ public String getProperty()
+ {
+ return property;
+ }
+
+ public void setProperty(String property)
+ {
+ this.property = property;
+ }
+
+ public String toString()
+ {
+ return "[" + getClass().getName() + ": " + property + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof ConfigAttrValue1))
+ {
+ return false;
+ }
+
+ final ConfigAttrValue1 configAttrValue1 = (ConfigAttrValue1)o;
+
+ if(!property.equals(configAttrValue1.property))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return property.hashCode();
+ }
+ }
+
+ public static class ConfigAttrValue2
+ extends ConfigAttrValue
+ {
+ private String value2;
+
+ public String getValue2()
+ {
+ return value2;
+ }
+
+ public void setValue2(String value2)
+ {
+ this.value2 = value2;
+ }
+
+ public String toString()
+ {
+ return "[" + getClass().getName() + ": " + value2 + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof ConfigAttrValue2))
+ {
+ return false;
+ }
+
+ final ConfigAttrValue2 configAttrValue2 = (ConfigAttrValue2)o;
+
+ if(!value2.equals(configAttrValue2.value2))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return value2.hashCode();
+ }
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child1.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child1.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child1.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,72 @@
+/*
+ * 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.xml.immutable;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Child1
+{
+ private final String name;
+
+ public Child1(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Child1))
+ {
+ return false;
+ }
+
+ final Child1 child1 = (Child1)o;
+
+ if(name != null ? !name.equals(child1.name) : child1.name != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (name != null ? name.hashCode() : 0);
+ }
+
+ public String toString()
+ {
+ return "[" + name + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child2.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child2.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child2.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,72 @@
+/*
+ * 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.xml.immutable;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Child2
+{
+ private final String name;
+
+ public Child2(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Child2))
+ {
+ return false;
+ }
+
+ final Child2 child2 = (Child2)o;
+
+ if(name != null ? !name.equals(child2.name) : child2.name != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (name != null ? name.hashCode() : 0);
+ }
+
+ public String toString()
+ {
+ return "[" + name + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child3.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child3.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Child3.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,72 @@
+/*
+ * 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.xml.immutable;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Child3
+{
+ private final String name;
+
+ public Child3(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Child3))
+ {
+ return false;
+ }
+
+ final Child3 child3 = (Child3)o;
+
+ if(name != null ? !name.equals(child3.name) : child3.name != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (name != null ? name.hashCode() : 0);
+ }
+
+ public String toString()
+ {
+ return "[" + name + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/ImmutableChoice.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/ImmutableChoice.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/ImmutableChoice.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,93 @@
+/*
+ * 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.xml.immutable;
+
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class ImmutableChoice
+{
+ private final String choice1;
+ private final Child1 child1;
+
+ public ImmutableChoice(String choice1)
+ {
+ this.choice1 = choice1;
+ this.child1 = null;
+ }
+
+ public ImmutableChoice(Child1 choice2)
+ {
+ this.choice1 = null;
+ this.child1 = choice2;
+ }
+
+ public String getChoice1()
+ {
+ return choice1;
+ }
+
+ public Child1 getChild1()
+ {
+ return child1;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof ImmutableChoice))
+ {
+ return false;
+ }
+
+ final ImmutableChoice immutableChoice = (ImmutableChoice)o;
+
+ if(choice1 != null ? !choice1.equals(immutableChoice.choice1) : immutableChoice.choice1 != null)
+ {
+ return false;
+ }
+ if(child1 != null ? !child1.equals(immutableChoice.child1) : immutableChoice.child1 != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (choice1 != null ? choice1.hashCode() : 0);
+ result = 29 * result + (child1 != null ? child1.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[choice1=" + choice1 + ", child1=" + child1 + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Parent.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Parent.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/immutable/Parent.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,120 @@
+/*
+ * 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.xml.immutable;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Parent
+{
+ private final Child1 child1;
+ private final Collection child2;
+ private final Collection otherChildren;
+ private final Collection immutableChoice;
+
+ public Parent(Child1 child1, Collection child2, Collection otherChildren, Collection immutableChoice)
+ {
+ this.child1 = child1;
+ this.child2 = child2;
+ this.otherChildren = otherChildren;
+ this.immutableChoice = immutableChoice;
+ }
+
+ public Child1 getChild1()
+ {
+ return child1;
+ }
+
+ public Collection getChild2()
+ {
+ return child2;
+ }
+
+ public Collection getOtherChildren()
+ {
+ return otherChildren;
+ }
+
+ public Collection getImmutableChoice()
+ {
+ return immutableChoice;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Parent))
+ {
+ return false;
+ }
+
+ final Parent parent = (Parent)o;
+
+ if(child1 != null ? !child1.equals(parent.child1) : parent.child1 != null)
+ {
+ return false;
+ }
+ if(child2 != null ? !child2.equals(parent.child2) : parent.child2 != null)
+ {
+ return false;
+ }
+ if(immutableChoice != null ? !immutableChoice.equals(parent.immutableChoice) : parent.immutableChoice != null)
+ {
+ return false;
+ }
+ if(otherChildren != null ? !otherChildren.equals(parent.otherChildren) : parent.otherChildren != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (child1 != null ? child1.hashCode() : 0);
+ result = 29 * result + (child2 != null ? child2.hashCode() : 0);
+ result = 29 * result + (otherChildren != null ? otherChildren.hashCode() : 0);
+ result = 29 * result + (immutableChoice != null ? immutableChoice.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[child1=" +
+ child1 +
+ ", child2=" +
+ child2 +
+ ", otherChildren=" +
+ otherChildren +
+ ", immutableChoice=" +
+ immutableChoice +
+ "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/Container.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/Container.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/Container.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,43 @@
+/*
+* 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.xml.initializer;
+
+/**
+ * Container.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 40495 $
+ */
+public class Container
+{
+ private Object value;
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/ContainerInitializer.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/ContainerInitializer.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/ContainerInitializer.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,78 @@
+/*
+* 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.xml.initializer;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.xb.binding.metadata.ClassMetaData;
+import org.jboss.xb.binding.metadata.PropertyMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultWildcardHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingInitializer;
+
+/**
+ * ContainerInitializer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 40741 $
+ */
+public class ContainerInitializer implements SchemaBindingInitializer
+{
+ public static final String NS = "dummy://www.jboss.org/container";
+
+ private static final QName containerStrictQName = new QName(NS, "containerStrict");
+ private static final QName containerLaxQName = new QName(NS, "containerLax");
+ private static final QName containerSkipQName = new QName(NS, "containerSkip");
+
+ private static final ContainerWildcardHandler wildcardHandler = new ContainerWildcardHandler();
+
+ public SchemaBinding init(SchemaBinding schema)
+ {
+ ClassMetaData classMetaData = new ClassMetaData();
+ classMetaData.setImpl(Container.class.getName());
+
+ PropertyMetaData property = new PropertyMetaData();
+ property.setName("value");
+
+ ElementBinding containerStrict = schema.getElement(containerStrictQName);
+ containerStrict.setClassMetaData(classMetaData);
+ containerStrict.getType().getWildcard().setWildcardHandler(wildcardHandler);
+ ElementBinding containerLax = schema.getElement(containerLaxQName);
+ containerLax.setClassMetaData(classMetaData);
+ containerStrict.getType().getWildcard().setWildcardHandler(wildcardHandler);
+ ElementBinding containerSkip = schema.getElement(containerSkipQName);
+ containerSkip.setClassMetaData(classMetaData);
+ containerStrict.getType().getWildcard().setWildcardHandler(wildcardHandler);
+
+ return schema;
+ }
+
+ private static class ContainerWildcardHandler extends DefaultWildcardHandler
+ {
+ public void setParent(Object parent, Object o, QName elementName, ElementBinding element, ElementBinding parentElement)
+ {
+ Container container = (Container) parent;
+ container.setValue(o);
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/Simple.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/Simple.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/Simple.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,43 @@
+/*
+* 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.xml.initializer;
+
+/**
+ * Simple.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 40492 $
+ */
+public class Simple
+{
+ private String value;
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/SimpleInitializer.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/SimpleInitializer.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/initializer/SimpleInitializer.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,57 @@
+/*
+* 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.xml.initializer;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.xb.binding.metadata.ClassMetaData;
+import org.jboss.xb.binding.metadata.PropertyMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingInitializer;
+
+/**
+ * SimpleInitializer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 41256 $
+ */
+public class SimpleInitializer implements SchemaBindingInitializer
+{
+ public static final String NS = "dummy://www.jboss.org/simple";
+
+ private static final QName testQName = new QName(NS, "test");
+
+ public SchemaBinding init(SchemaBinding schema)
+ {
+ ElementBinding test = schema.getElement(testQName);
+ ClassMetaData classMetaData = new ClassMetaData();
+ classMetaData.setImpl(Simple.class.getName());
+ test.setClassMetaData(classMetaData);
+
+ PropertyMetaData propMetaData = new PropertyMetaData();
+ propMetaData.setName("value");
+ test.setPropertyMetaData(propMetaData);
+
+ return schema;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/characters/Binding.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/characters/Binding.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/characters/Binding.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,128 @@
+/*
+ * 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.xml.jbxb.characters;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 38439 $
+ */
+public class Binding
+{
+ private String name;
+ private String type;
+ private String text;
+ private Value2 value2;
+ private Value3 value3;
+ public Value4 value4;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public String getText()
+ {
+ return text;
+ }
+
+ public void setText(String text)
+ {
+ this.text = text;
+ }
+
+ public Value2 getValue2()
+ {
+ return value2;
+ }
+
+ public void setValue2(Value2 value2)
+ {
+ this.value2 = value2;
+ }
+
+ public Value3 getValue3()
+ {
+ return value3;
+ }
+
+ public void setValue3(Value3 value3)
+ {
+ this.value3 = value3;
+ }
+
+ // Inner
+
+ public static final class Value2
+ {
+ public String text;
+
+ public String getText()
+ {
+ return text;
+ }
+
+ public void setText(String text)
+ {
+ this.text = text;
+ }
+ }
+
+ public static final class Value3
+ {
+ public static Object unmarshalChars(String chars)
+ {
+ return chars;
+ }
+
+ public Object chars;
+ public String attr;
+ }
+
+ public static final class Value4
+ {
+ public Value4(String value)
+ {
+ this.value = value;
+ }
+
+ public Value4()
+ {
+ }
+
+ public String value;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/defaults/DefaultsUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/defaults/DefaultsUnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/defaults/DefaultsUnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,87 @@
+/*
+ * 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.xml.jbxb.defaults;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public class DefaultsUnitTestCase
+ extends TestCase
+{
+ public void testSchema1() throws Exception
+ {
+ InputStream xsd = getResource("xml/jbxb/defaults/schema1.xsd");
+ SchemaBinding schemaBinding = XsdBinder.bind(xsd, "UTF-8");
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ InputStream is = getResource("xml/jbxb/defaults/testSchema1.xml");
+ JBean bean = (JBean) unmarshaller.unmarshal(is, schemaBinding);
+ is.close();
+ int attr2 = bean.getAttr2();
+ assertEquals("JBean.Attr2("+attr2+") == 123", 123, attr2);
+ String attr1 = bean.getAttr1();
+ assertEquals("JBean.Attr1("+attr1+") == DefaultVaue", "DefaultValue", attr1);
+
+ boolean attr3 = bean.getAttr3();
+ assertEquals("JBean.Attr3("+attr3+") == true", true, attr3);
+ }
+
+ public void testSchema2() throws Exception
+ {
+ InputStream xsd = getResource("xml/jbxb/defaults/schema2.xsd");
+ SchemaBinding schemaBinding = XsdBinder.bind(xsd, "UTF-8");
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ InputStream is = getResource("xml/jbxb/defaults/testSchema2.xml");
+ JBean bean = (JBean) unmarshaller.unmarshal(is, schemaBinding);
+ is.close();
+ int attr2 = bean.getAttr2();
+ assertEquals("JBean.Attr2("+attr2+") == 123", 123, attr2);
+ String attr1 = bean.getAttr1();
+ assertEquals("JBean.Attr1("+attr1+") == DefaultVaue", "DefaultValue", attr1);
+
+ boolean attr3 = bean.getAttr3();
+ assertEquals("JBean.Attr3("+attr3+") == true", true, attr3);
+ }
+
+ private InputStream getResource(String path)
+ throws IOException
+ {
+ java.net.URL url = Thread.currentThread().getContextClassLoader().getResource(path);
+ if(url == null)
+ {
+ fail("URL not found: " + path);
+ }
+ return url.openStream();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/defaults/JBean.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/defaults/JBean.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/defaults/JBean.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,60 @@
+/*
+ * 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.xml.jbxb.defaults;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public class JBean
+{
+ private String attr1;
+ private int attr2;
+ private boolean attr3;
+
+ public String getAttr1()
+ {
+ return attr1;
+ }
+ public void setAttr1(String attr1)
+ {
+ this.attr1 = attr1;
+ }
+
+ public int getAttr2()
+ {
+ return attr2;
+ }
+ public void setAttr2(int attr2)
+ {
+ this.attr2 = attr2;
+ }
+
+ public boolean getAttr3()
+ {
+ return attr3;
+ }
+ public void setAttr3(boolean attr3)
+ {
+ this.attr3 = attr3;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/minOccurs/Schema1UnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/minOccurs/Schema1UnitTestCase.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/jbxb/minOccurs/Schema1UnitTestCase.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,75 @@
+/*
+ * 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.xml.jbxb.minOccurs;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.test.xml.jbxb.defaults.JBean;
+import org.jboss.test.xml.AbstractJBossXBTest;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 41759 $
+ */
+public class Schema1UnitTestCase
+ extends AbstractJBossXBTest
+{
+ public Schema1UnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testSchema1() throws Exception
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ resolver.addSchemaLocation("urn:jboss:jbxb-minOccurs-schema1", "xml/jbxb/minOccurs/schema1.xsd");
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ URL testSchema1 = loader.getResource("xml/jbxb/minOccurs/testSchema1.xml");
+ Object root = unmarshaller.unmarshal(testSchema1.toString(), resolver);
+ }
+
+ public void testSchema1v2() throws Exception
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+ resolver.addSchemaLocation("urn:jboss:jbxb-minOccurs-schema1", "xml/jbxb/minOccurs/schema1v2.xsd");
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ URL testSchema1 = loader.getResource("xml/jbxb/minOccurs/testSchema1.xml");
+ Object root = unmarshaller.unmarshal(testSchema1.toString(), resolver);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanAttributeMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanAttributeMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanAttributeMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,136 @@
+/*
+ * 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.xml.multispaced;
+
+/**
+ * @version <tt>$Revision: 37406 $</tt>
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public class XMBeanAttributeMetaData
+{
+ private String access;
+ private String getMethod;
+ private String setMethod;
+ private String description;
+ private String name;
+ private String type;
+
+ public String getAccess()
+ {
+ return access;
+ }
+
+ public void setAccess(String access)
+ {
+ this.access = access;
+ }
+
+ public String getGetMethod()
+ {
+ return getMethod;
+ }
+
+ public void setGetMethod(String getMethod)
+ {
+ this.getMethod = getMethod;
+ }
+
+ public String getSetMethod()
+ {
+ return setMethod;
+ }
+
+ public void setSetMethod(String setMethod)
+ {
+ this.setMethod = setMethod;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public String toString()
+ {
+ return
+ "[description=" + description +
+ ", access=" + access +
+ ", getMethod=" + getMethod +
+ ", setMethod=" + setMethod +
+ ", name=" + name +
+ ", type=" + type + ']';
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o) return true;
+ if(!(o instanceof XMBeanAttributeMetaData)) return false;
+
+ final XMBeanAttributeMetaData mBeanAttributeMetaData = (XMBeanAttributeMetaData)o;
+
+ if(access != null ? !access.equals(mBeanAttributeMetaData.access) : mBeanAttributeMetaData.access != null) return false;
+ if(description != null ? !description.equals(mBeanAttributeMetaData.description) : mBeanAttributeMetaData.description != null) return false;
+ if(getMethod != null ? !getMethod.equals(mBeanAttributeMetaData.getMethod) : mBeanAttributeMetaData.getMethod != null) return false;
+ if(name != null ? !name.equals(mBeanAttributeMetaData.name) : mBeanAttributeMetaData.name != null) return false;
+ if(setMethod != null ? !setMethod.equals(mBeanAttributeMetaData.setMethod) : mBeanAttributeMetaData.setMethod != null) return false;
+ if(type != null ? !type.equals(mBeanAttributeMetaData.type) : mBeanAttributeMetaData.type != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (access != null ? access.hashCode() : 0);
+ result = 29 * result + (getMethod != null ? getMethod.hashCode() : 0);
+ result = 29 * result + (setMethod != null ? setMethod.hashCode() : 0);
+ result = 29 * result + (description != null ? description.hashCode() : 0);
+ result = 29 * result + (name != null ? name.hashCode() : 0);
+ result = 29 * result + (type != null ? type.hashCode() : 0);
+ return result;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanConstructorMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanConstructorMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanConstructorMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,78 @@
+/*
+ * 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.xml.multispaced;
+
+/**
+ * @version <tt>$Revision: 37406 $</tt>
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public class XMBeanConstructorMetaData
+{
+ private String description;
+ private String name;
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String toString()
+ {
+ return "[name=" + name + ", description=" + description + ']';
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o) return true;
+ if(!(o instanceof XMBeanConstructorMetaData)) return false;
+
+ final XMBeanConstructorMetaData mBeanConstructorMetaData = (XMBeanConstructorMetaData)o;
+
+ if(description != null ? !description.equals(mBeanConstructorMetaData.description) : mBeanConstructorMetaData.description != null) return false;
+ if(name != null ? !name.equals(mBeanConstructorMetaData.name) : mBeanConstructorMetaData.name != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (description != null ? description.hashCode() : 0);
+ result = 29 * result + (name != null ? name.hashCode() : 0);
+ return result;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,154 @@
+/*
+ * 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.xml.multispaced;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @version <tt>$Revision: 37406 $</tt>
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public class XMBeanMetaData
+{
+ private String description;
+ private String mbeanClass;
+ private List constructors = new ArrayList();
+ private List attributes = new ArrayList();
+ private List operations = new ArrayList();
+ private List notifications = new ArrayList();
+
+ private Object persistenceManager;
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public String getMbeanClass()
+ {
+ return mbeanClass;
+ }
+
+ public void setMbeanClass(String mbeanClass)
+ {
+ this.mbeanClass = mbeanClass;
+ }
+
+ public List getConstructors()
+ {
+ return constructors;
+ }
+
+ public void addConstructor(XMBeanConstructorMetaData constructor)
+ {
+ constructors.add(constructor);
+ }
+
+ public List getAttributes()
+ {
+ return attributes;
+ }
+
+ public void addAttribute(XMBeanAttributeMetaData attribute)
+ {
+ attributes.add(attribute);
+ }
+
+ public List getOperations()
+ {
+ return operations;
+ }
+
+ public void addOperation(XMBeanOperationMetaData operation)
+ {
+ operations.add(operation);
+ }
+
+ public List getNotifications()
+ {
+ return notifications;
+ }
+
+ public void addNotification(XMBeanNotificationMetaData notification)
+ {
+ notifications.add(notification);
+ }
+
+ public Object getPersistenceManager()
+ {
+ return persistenceManager;
+ }
+
+ public void setPersistenceManager(Object persistenceManager)
+ {
+ this.persistenceManager = persistenceManager;
+ }
+
+ public String toString()
+ {
+ return
+ "[description=" + description +
+ ", mbeanClass=" + mbeanClass +
+ ", constructors=" + constructors +
+ ", attributes=" + attributes +
+ ", operations=" + operations +
+ ", notifications=" + notifications +
+ ", persistence-manager=" + persistenceManager + ']';
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o) return true;
+ if(!(o instanceof XMBeanMetaData)) return false;
+
+ final XMBeanMetaData xmBeanMetaData = (XMBeanMetaData)o;
+
+ if(attributes != null ? !attributes.equals(xmBeanMetaData.attributes) : xmBeanMetaData.attributes != null) return false;
+ if(constructors != null ? !constructors.equals(xmBeanMetaData.constructors) : xmBeanMetaData.constructors != null) return false;
+ if(description != null ? !description.equals(xmBeanMetaData.description) : xmBeanMetaData.description != null) return false;
+ if(mbeanClass != null ? !mbeanClass.equals(xmBeanMetaData.mbeanClass) : xmBeanMetaData.mbeanClass != null) return false;
+ if(notifications != null ? !notifications.equals(xmBeanMetaData.notifications) : xmBeanMetaData.notifications != null) return false;
+ if(operations != null ? !operations.equals(xmBeanMetaData.operations) : xmBeanMetaData.operations != null) return false;
+ if(persistenceManager != null ? !persistenceManager.equals(xmBeanMetaData.persistenceManager) : xmBeanMetaData.persistenceManager != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (description != null ? description.hashCode() : 0);
+ result = 29 * result + (mbeanClass != null ? mbeanClass.hashCode() : 0);
+ result = 29 * result + (constructors != null ? constructors.hashCode() : 0);
+ result = 29 * result + (attributes != null ? attributes.hashCode() : 0);
+ result = 29 * result + (operations != null ? operations.hashCode() : 0);
+ result = 29 * result + (notifications != null ? notifications.hashCode() : 0);
+ result = 29 * result + (persistenceManager != null ? persistenceManager.hashCode() : 0);
+ return result;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaDataFactory.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaDataFactory.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaDataFactory.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,224 @@
+/*
+ * 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.xml.multispaced;
+
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.jboss.test.xml.multispaced.pm.jdbc.JDBCPm;
+import org.xml.sax.Attributes;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class XMBeanMetaDataFactory
+ implements ObjectModelFactory
+{
+ public static final XMBeanMetaDataFactory INSTANCE = new XMBeanMetaDataFactory();
+
+ private XMBeanMetaDataFactory()
+ {
+ }
+
+ public Object newRoot(Object root,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName,
+ Attributes attrs)
+ {
+ return root == null ? new XMBeanMetaData() : root;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
+ {
+ return root;
+ }
+
+ public void setValue(XMBeanMetaData xmbean,
+ UnmarshallingContext navigator,
+ String namespaceUri,
+ String localName,
+ String value)
+ {
+ if("description".equals(localName))
+ {
+ xmbean.setDescription(value);
+ }
+ else if("class".equals(localName))
+ {
+ xmbean.setMbeanClass(value);
+ }
+ }
+
+ public Object newChild(XMBeanMetaData xmbean,
+ UnmarshallingContext navigator,
+ String namespaceUri,
+ String localName,
+ Attributes attrs)
+ {
+ Object child;
+ if("constructor".equals(localName))
+ {
+ child = new XMBeanConstructorMetaData();
+ }
+ else if("attribute".equals(localName))
+ {
+ final XMBeanAttributeMetaData attribute = new XMBeanAttributeMetaData();
+ for(int i = 0; i < attrs.getLength(); ++i)
+ {
+ final String attrName = attrs.getLocalName(i);
+ if("access".equals(attrName))
+ {
+ attribute.setAccess(attrs.getValue(i));
+ }
+ else if("getMethod".equals(attrName))
+ {
+ attribute.setGetMethod(attrs.getValue(i));
+ }
+ else if("setMethod".equals(attrName))
+ {
+ attribute.setSetMethod(attrs.getValue(i));
+ }
+ }
+ child = attribute;
+ }
+ else if("operation".equals(localName))
+ {
+ child = new XMBeanOperationMetaData();
+ }
+ else if("notification".equals(localName))
+ {
+ child = new XMBeanNotificationMetaData();
+ }
+ else
+ {
+ child = null;
+ }
+
+ return child;
+ }
+
+ public void addChild(XMBeanMetaData xmbean, XMBeanConstructorMetaData constructor, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ xmbean.addConstructor(constructor);
+ }
+
+ public void addChild(XMBeanMetaData xmbean, XMBeanAttributeMetaData attribute, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ xmbean.addAttribute(attribute);
+ }
+
+ public void addChild(XMBeanMetaData xmbean, XMBeanOperationMetaData operation, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ xmbean.addOperation(operation);
+ }
+
+ public void addChild(XMBeanMetaData xmbean, XMBeanNotificationMetaData notification, UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ xmbean.addNotification(notification);
+ }
+
+ public void addChild(XMBeanMetaData xmbean,
+ Object pm,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName)
+ {
+ xmbean.setPersistenceManager(pm);
+ }
+
+ public void setValue(XMBeanConstructorMetaData constructor,
+ UnmarshallingContext navigator,
+ String namespaceUri,
+ String localName,
+ String value)
+ {
+ if("description".equals(localName))
+ {
+ constructor.setDescription(value);
+ }
+ else if("name".equals(localName))
+ {
+ constructor.setName(value);
+ }
+ }
+
+ public void setValue(XMBeanAttributeMetaData attribute,
+ UnmarshallingContext navigator,
+ String namespaceUri,
+ String localName,
+ String value)
+ {
+ if("description".equals(localName))
+ {
+ attribute.setDescription(value);
+ }
+ else if("name".equals(localName))
+ {
+ attribute.setName(value);
+ }
+ else if("type".equals(localName))
+ {
+ attribute.setType(value);
+ }
+ }
+
+ public void setValue(XMBeanOperationMetaData operation,
+ UnmarshallingContext navigator,
+ String namespaceUri,
+ String localName,
+ String value)
+ {
+ if("description".equals(localName))
+ {
+ operation.setDescription(value);
+ }
+ else if("name".equals(localName))
+ {
+ operation.setName(value);
+ }
+ else if("return-type".equals(localName))
+ {
+ operation.setReturnType(value);
+ }
+ }
+
+ public void setValue(XMBeanNotificationMetaData notification,
+ UnmarshallingContext navigator,
+ String namespaceUri,
+ String localName,
+ String value)
+ {
+ if("description".equals(localName))
+ {
+ notification.setDescription(value);
+ }
+ else if("name".equals(localName))
+ {
+ notification.setName(value);
+ }
+ else if("notification-type".equals(localName))
+ {
+ notification.setNotificationType(value);
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaDataProvider.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaDataProvider.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanMetaDataProvider.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,200 @@
+/*
+ * 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.xml.multispaced;
+
+import org.jboss.xb.binding.MarshallingContext;
+import org.jboss.xb.binding.ObjectModelProvider;
+
+/**
+ * @version <tt>$Revision: 37406 $</tt>
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public class XMBeanMetaDataProvider
+ implements ObjectModelProvider
+{
+ public static final XMBeanMetaDataProvider INSTANCE = new XMBeanMetaDataProvider();
+
+ private XMBeanMetaDataProvider() {}
+
+ public Object getRoot(Object o, MarshallingContext ctx, String namespaceURI, String localName)
+ {
+ return o;
+ }
+
+ public Object getChildren(XMBeanMetaData xmbean, String namespaceUri, String localName)
+ {
+ Object children;
+ if("mbean".equals(localName))
+ {
+ children = xmbean;
+ }
+ else if("constructor".equals(localName))
+ {
+ children = xmbean.getConstructors();
+ }
+ else if("attribute".equals(localName))
+ {
+ children = xmbean.getAttributes();
+ }
+ else if("operation".equals(localName))
+ {
+ children = xmbean.getOperations();
+ }
+ else if("notification".equals(localName))
+ {
+ children = xmbean.getNotifications();
+ }
+ else if("persistence".equals(localName))
+ {
+ children = xmbean.getPersistenceManager();
+ }
+ else
+ {
+ children = null;
+ }
+ return children;
+ }
+
+ public Object getElementValue(XMBeanMetaData xmbean, String namespaceUri, String localName)
+ {
+ Object value;
+ if("description".equals(localName))
+ {
+ value = xmbean.getDescription();
+ }
+ else if("class".equals(localName))
+ {
+ value = xmbean.getMbeanClass();
+ }
+ else
+ {
+ value = null;
+ }
+ return value;
+ }
+
+ public Object getElementValue(XMBeanConstructorMetaData constructor, String namespaceUri, String localName)
+ {
+ Object value;
+ if("description".equals(localName))
+ {
+ value = constructor.getDescription();
+ }
+ else if("name".equals(localName))
+ {
+ value = constructor.getName();
+ }
+ else
+ {
+ value = null;
+ }
+ return value;
+ }
+
+ public Object getAttributeValue(XMBeanAttributeMetaData attribute, String namespaceUri, String localName)
+ {
+ Object value;
+ if("access".equals(localName))
+ {
+ value = attribute.getAccess();
+ }
+ else if("getMethod".equals(localName))
+ {
+ value = attribute.getGetMethod();
+ }
+ else if("setMethod".equals(localName))
+ {
+ value = attribute.getSetMethod();
+ }
+ else
+ {
+ value = null;
+ }
+ return value;
+ }
+
+ public Object getElementValue(XMBeanAttributeMetaData attribute, String namespaceUri, String localName)
+ {
+ Object value;
+ if("description".equals(localName))
+ {
+ value = attribute.getDescription();
+ }
+ else if("name".equals(localName))
+ {
+ value = attribute.getName();
+ }
+ else if("type".equals(localName))
+ {
+ value = attribute.getType();
+ }
+ else
+ {
+ value = null;
+ }
+ return value;
+ }
+
+ public Object getElementValue(XMBeanOperationMetaData operation, String namespaceUri, String localName)
+ {
+ Object value;
+ if("description".equals(localName))
+ {
+ value = operation.getDescription();
+ }
+ else if("name".equals(localName))
+ {
+ value = operation.getName();
+ }
+ else if("return-type".equals(localName))
+ {
+ value = operation.getReturnType();
+ }
+ else
+ {
+ value = null;
+ }
+ return value;
+ }
+
+ public Object getElementValue(XMBeanNotificationMetaData notification, String namespaceUri, String localName)
+ {
+ Object value;
+ if("description".equals(localName))
+ {
+ value = notification.getDescription();
+ }
+ else if("name".equals(localName))
+ {
+ value = notification.getName();
+ }
+ else if("notification-type".equals(localName))
+ {
+ value = notification.getNotificationType();
+ }
+ else
+ {
+ value = null;
+ }
+ return value;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanNotificationMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanNotificationMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanNotificationMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,91 @@
+/*
+ * 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.xml.multispaced;
+
+/**
+ * @version <tt>$Revision: 37406 $</tt>
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public class XMBeanNotificationMetaData
+{
+ private String description;
+ private String name;
+ private String notificationType;
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getNotificationType()
+ {
+ return notificationType;
+ }
+
+ public void setNotificationType(String notificationType)
+ {
+ this.notificationType = notificationType;
+ }
+
+ public String toString()
+ {
+ return "[name=" + name + ", notification-type=" + notificationType + ", description=" + description + ']';
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o) return true;
+ if(!(o instanceof XMBeanNotificationMetaData)) return false;
+
+ final XMBeanNotificationMetaData mBeanNotificationMetaData = (XMBeanNotificationMetaData)o;
+
+ if(description != null ? !description.equals(mBeanNotificationMetaData.description) : mBeanNotificationMetaData.description != null) return false;
+ if(name != null ? !name.equals(mBeanNotificationMetaData.name) : mBeanNotificationMetaData.name != null) return false;
+ if(notificationType != null ? !notificationType.equals(mBeanNotificationMetaData.notificationType) : mBeanNotificationMetaData.notificationType != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (description != null ? description.hashCode() : 0);
+ result = 29 * result + (name != null ? name.hashCode() : 0);
+ result = 29 * result + (notificationType != null ? notificationType.hashCode() : 0);
+ return result;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanOperationMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanOperationMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/XMBeanOperationMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,91 @@
+/*
+ * 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.xml.multispaced;
+
+/**
+ * @version <tt>$Revision: 37406 $</tt>
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public class XMBeanOperationMetaData
+{
+ private String description;
+ private String name;
+ private String returnType;
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getReturnType()
+ {
+ return returnType;
+ }
+
+ public void setReturnType(String returnType)
+ {
+ this.returnType = returnType;
+ }
+
+ public String toString()
+ {
+ return "[name=" + name + ", return-type=" + returnType + ", description=" + description + ']';
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o) return true;
+ if(!(o instanceof XMBeanOperationMetaData)) return false;
+
+ final XMBeanOperationMetaData mBeanOperationMetaData = (XMBeanOperationMetaData)o;
+
+ if(description != null ? !description.equals(mBeanOperationMetaData.description) : mBeanOperationMetaData.description != null) return false;
+ if(name != null ? !name.equals(mBeanOperationMetaData.name) : mBeanOperationMetaData.name != null) return false;
+ if(returnType != null ? !returnType.equals(mBeanOperationMetaData.returnType) : mBeanOperationMetaData.returnType != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (description != null ? description.hashCode() : 0);
+ result = 29 * result + (name != null ? name.hashCode() : 0);
+ result = 29 * result + (returnType != null ? returnType.hashCode() : 0);
+ return result;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPm.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPm.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPm.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,78 @@
+/*
+ * 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.xml.multispaced.pm.jdbc;
+
+/**
+ * @version <tt>$Revision: 37406 $</tt>
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public class JDBCPm
+{
+ private String datasource;
+ private String table;
+
+ public String getDatasource()
+ {
+ return datasource;
+ }
+
+ public void setDatasource(String datasource)
+ {
+ this.datasource = datasource;
+ }
+
+ public String getTable()
+ {
+ return table;
+ }
+
+ public void setTable(String table)
+ {
+ this.table = table;
+ }
+
+ public String toString()
+ {
+ return "[datasource=" + datasource + ", table=" + table + ']';
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o) return true;
+ if(!(o instanceof JDBCPm)) return false;
+
+ final JDBCPm jdbcPm = (JDBCPm)o;
+
+ if(datasource != null ? !datasource.equals(jdbcPm.datasource) : jdbcPm.datasource != null) return false;
+ if(table != null ? !table.equals(jdbcPm.table) : jdbcPm.table != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (datasource != null ? datasource.hashCode() : 0);
+ result = 29 * result + (table != null ? table.hashCode() : 0);
+ return result;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPmMetaDataFactory.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPmMetaDataFactory.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPmMetaDataFactory.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -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.xml.multispaced.pm.jdbc;
+
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.jboss.test.xml.multispaced.XMBeanMetaData;
+import org.xml.sax.Attributes;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class JDBCPmMetaDataFactory
+ implements ObjectModelFactory
+{
+ public static final JDBCPmMetaDataFactory INSTANCE = new JDBCPmMetaDataFactory();
+
+ private JDBCPmMetaDataFactory()
+ {
+ }
+
+ public Object newRoot(Object root,
+ UnmarshallingContext navigator,
+ String namespaceURI,
+ String localName,
+ Attributes attrs)
+ {
+ return new JDBCPm();
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String name)
+ {
+ return root;
+ }
+
+ public void setValue(JDBCPm pm, UnmarshallingContext navigator, String namespaceUri, String localName, String value)
+ {
+ if("datasource".equals(localName))
+ {
+ pm.setDatasource(value);
+ }
+ else if("table".equals(localName))
+ {
+ pm.setTable(value);
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPmMetaDataProvider.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPmMetaDataProvider.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/multispaced/pm/jdbc/JDBCPmMetaDataProvider.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,70 @@
+/*
+ * 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.xml.multispaced.pm.jdbc;
+
+import org.jboss.xb.binding.MarshallingContext;
+import org.jboss.xb.binding.ObjectModelProvider;
+import org.jboss.logging.Logger;
+
+/**
+ * @version <tt>$Revision: 37406 $</tt>
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public class JDBCPmMetaDataProvider
+ implements ObjectModelProvider
+{
+ private static final Logger log = Logger.getLogger(JDBCPmMetaDataFactory.class);
+
+ private final JDBCPm pm;
+
+ public JDBCPmMetaDataProvider(JDBCPm pm)
+ {
+ this.pm = pm;
+ }
+
+ public Object getRoot(Object o, MarshallingContext ctx, String namespaceURI, String localName)
+ {
+ log.debug("getRoot(): o=" + o.getClass());
+ return pm;
+ }
+
+ public Object getChildren(JDBCPm pm, String namespaceUri, String localName)
+ {
+ log.debug("getChildren> ns=" + namespaceUri + ", localName=" + localName);
+ return null;
+ }
+
+ public Object getElementValue(JDBCPm pm, String namespaceUri, String localName)
+ {
+ log.debug("getValue> ns=" + namespaceUri + ", localName=" + localName);
+ Object child = null;
+ if("datasource".equals(localName))
+ {
+ child = pm.getDatasource();
+ }
+ else if("table".equals(localName))
+ {
+ child = pm.getTable();
+ }
+ return child;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/person/Address.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/person/Address.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/person/Address.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,63 @@
+/*
+ * 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.xml.person;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Address
+{
+ private String street;
+
+ public String getStreet()
+ {
+ return street;
+ }
+
+ public void setStreet(String street)
+ {
+ this.street = street;
+ }
+
+ public String toString()
+ {
+ return street;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o) return true;
+ if(!(o instanceof Address)) return false;
+
+ final Address address = (Address) o;
+
+ if(street != null ? !street.equals(address.street) : address.street != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (street != null ? street.hashCode() : 0);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/person/Person.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/person/Person.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/person/Person.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,148 @@
+/*
+ * 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.xml.person;
+
+import org.jboss.xb.binding.SimpleTypeBindings;
+import org.jboss.xb.binding.TypeBinding;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Person
+{
+ public static Person newInstance()
+ {
+ Person person = new Person();
+ person.setFirstName("Vasiliy");
+ person.setLastName("Poupkin");
+ person.setDateOfBirth((java.util.Date)SimpleTypeBindings.JAVA_UTIL_DATE.unmarshal("1980-01-01"));
+ person.setPhones(Arrays.asList(new Object[]{"01", "02"}));
+
+ ArrayList list = new ArrayList();
+ Address addr1 = new Address();
+ addr1.setStreet("prosp. Rad. Ukr. 11A, 70");
+ list.add(addr1);
+ addr1 = new Address();
+ addr1.setStreet("Sky 7");
+ list.add(addr1);
+ person.setAddresses(list);
+
+ return person;
+ }
+
+ private String firstName;
+ private String lastName;
+ private java.util.Date dateOfBirth;
+ private Collection phones = new ArrayList();
+ private Collection addresses = new ArrayList();
+
+ public String getFirstName()
+ {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName)
+ {
+ this.firstName = firstName;
+ }
+
+ public String getLastName()
+ {
+ return lastName;
+ }
+
+ public void setLastName(String lastName)
+ {
+ this.lastName = lastName;
+ }
+
+ public java.util.Date getDateOfBirth()
+ {
+ return dateOfBirth;
+ }
+
+ public void setDateOfBirth(java.util.Date dateOfBirth)
+ {
+ this.dateOfBirth = dateOfBirth;
+ }
+
+ public Collection getPhones()
+ {
+ return phones;
+ }
+
+ public void setPhones(Collection phones)
+ {
+ this.phones = phones;
+ }
+
+ public Collection getAddresses()
+ {
+ return addresses;
+ }
+
+ public void setAddresses(Collection addresses)
+ {
+ this.addresses = addresses;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o) return true;
+ if(!(o instanceof Person)) return false;
+
+ final Person person = (Person) o;
+
+ if(addresses != null ? !addresses.equals(person.addresses) : person.addresses != null) return false;
+ if(dateOfBirth != null ? !dateOfBirth.equals(person.dateOfBirth) : person.dateOfBirth != null) return false;
+ if(firstName != null ? !firstName.equals(person.firstName) : person.firstName != null) return false;
+ if(lastName != null ? !lastName.equals(person.lastName) : person.lastName != null) return false;
+ if(phones != null ? !phones.equals(person.phones) : person.phones != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (firstName != null ? firstName.hashCode() : 0);
+ result = 29 * result + (lastName != null ? lastName.hashCode() : 0);
+ result = 29 * result + (dateOfBirth != null ? dateOfBirth.hashCode() : 0);
+ result = 29 * result + (phones != null ? phones.hashCode() : 0);
+ result = 29 * result + (addresses != null ? addresses.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[firstName=" + firstName +
+ ", lastName=" + lastName +
+ ", dateOfBirth=" + dateOfBirth +
+ ", phones=" + phones +
+ ", addresses=" + addresses + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/po/Item.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/po/Item.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/po/Item.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,170 @@
+/*
+ * 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.xml.po;
+
+import java.math.BigInteger;
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.text.SimpleDateFormat;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Item
+{
+ private String productName;
+ private BigInteger quantity;
+ private BigDecimal USPrice;
+ private String comment;
+ private Calendar shipDate;
+ private String partNum;
+
+ public String getProductName()
+ {
+ return productName;
+ }
+
+ public void setProductName(String productName)
+ {
+ this.productName = productName;
+ }
+
+ public BigInteger getQuantity()
+ {
+ return quantity;
+ }
+
+ public void setQuantity(BigInteger quantity)
+ {
+ this.quantity = quantity;
+ }
+
+ public BigDecimal getUSPrice()
+ {
+ return USPrice;
+ }
+
+ public void setUSPrice(BigDecimal USPrice)
+ {
+ this.USPrice = USPrice;
+ }
+
+ public String getComment()
+ {
+ return comment;
+ }
+
+ public void setComment(String comment)
+ {
+ this.comment = comment;
+ }
+
+ public Calendar getShipDate()
+ {
+ return shipDate;
+ }
+
+ public void setShipDate(Calendar shipDate)
+ {
+ this.shipDate = shipDate;
+ }
+
+ public String getPartNum()
+ {
+ return partNum;
+ }
+
+ public void setPartNum(String partNum)
+ {
+ this.partNum = partNum;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Item))
+ {
+ return false;
+ }
+
+ final Item item = (Item)o;
+
+ if(USPrice != null ? !USPrice.equals(item.USPrice) : item.USPrice != null)
+ {
+ return false;
+ }
+ if(comment != null ? !comment.equals(item.comment) : item.comment != null)
+ {
+ return false;
+ }
+ if(partNum != null ? !partNum.equals(item.partNum) : item.partNum != null)
+ {
+ return false;
+ }
+ if(productName != null ? !productName.equals(item.productName) : item.productName != null)
+ {
+ return false;
+ }
+ if(quantity != null ? !quantity.equals(item.quantity) : item.quantity != null)
+ {
+ return false;
+ }
+ if(shipDate != null ? !shipDate.equals(item.shipDate) : item.shipDate != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (productName != null ? productName.hashCode() : 0);
+ result = 29 * result + (quantity != null ? quantity.hashCode() : 0);
+ result = 29 * result + (USPrice != null ? USPrice.hashCode() : 0);
+ result = 29 * result + (comment != null ? comment.hashCode() : 0);
+ result = 29 * result + (shipDate != null ? shipDate.hashCode() : 0);
+ result = 29 * result + (partNum != null ? partNum.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[Item productName=" +
+ productName +
+ ", quantity=" +
+ quantity +
+ ", USPrice=" +
+ USPrice +
+ ", comment=" +
+ comment +
+ ", shipDate=" + (shipDate == null ? "null" : new SimpleDateFormat("yyyy.MM.dd HH:mm:ss").format(
+ shipDate.getTime())
+ ) +
+ ", partNum=" + partNum + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/po/PurchaseOrder.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/po/PurchaseOrder.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/po/PurchaseOrder.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,181 @@
+/*
+ * 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.xml.po;
+
+import java.util.Collection;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.ArrayList;
+import java.text.SimpleDateFormat;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class PurchaseOrder
+{
+ public static final PurchaseOrder DEFAULT_INSTANCE = createDefaultInstance();
+
+ public static final PurchaseOrder createDefaultInstance()
+ {
+ PurchaseOrder po = new PurchaseOrder();
+ po.orderDate = new GregorianCalendar(1999, 9, 20);
+ po.shipTo = new USAddress();
+ po.shipTo.setName("Alice Smith");
+ po.shipTo.setStreet("123 Maple Street");
+ po.shipTo.setCity("Mill Valley");
+ po.shipTo.setState("CA");
+ po.shipTo.setZip(new BigDecimal((double)90952));
+ po.billTo = new USAddress();
+ po.billTo.setName("Robert Smith");
+ po.billTo.setStreet("8 Oak Avenue");
+ po.billTo.setCity("Old Town");
+ po.billTo.setState("PA");
+ po.billTo.setZip(new BigDecimal((double)95819));
+ po.comment = "Hurry, my lawn is going wild!";
+ po.items = new ArrayList();
+
+ Item item = new Item();
+ item.setPartNum("872-AA");
+ item.setProductName("Lawnmower");
+ item.setQuantity(BigInteger.valueOf(1));
+ item.setUSPrice(new BigDecimal("148.95"));
+ item.setComment("Confirm this is electric");
+ po.items.add(item);
+
+ item = new Item();
+ item.setPartNum("926-AA");
+ item.setProductName("Baby Monitor");
+ item.setQuantity(BigInteger.valueOf(1));
+ item.setUSPrice(new BigDecimal("39.98"));
+ item.setShipDate(new GregorianCalendar(1999, 4, 21));
+ po.items.add(item);
+
+ return po;
+ }
+
+ public USAddress shipTo;
+ private USAddress billTo;
+ private String comment;
+ private Collection items;
+ private Calendar orderDate;
+
+ public USAddress getBillTo()
+ {
+ return billTo;
+ }
+
+ public void setBillTo(USAddress billTo)
+ {
+ this.billTo = billTo;
+ }
+
+ public String getComment()
+ {
+ return comment;
+ }
+
+ public void setComment(String comment)
+ {
+ this.comment = comment;
+ }
+
+ public Collection getItems()
+ {
+ return items;
+ }
+
+ public void setItems(Collection items)
+ {
+ this.items = items;
+ }
+
+ public Calendar getOrderDate()
+ {
+ return orderDate;
+ }
+
+ public void setOrderDate(Calendar orderDate)
+ {
+ this.orderDate = orderDate;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof PurchaseOrder))
+ {
+ return false;
+ }
+
+ final PurchaseOrder purchaseOrder = (PurchaseOrder)o;
+
+ if(billTo != null ? !billTo.equals(purchaseOrder.billTo) : purchaseOrder.billTo != null)
+ {
+ return false;
+ }
+ if(comment != null ? !comment.equals(purchaseOrder.comment) : purchaseOrder.comment != null)
+ {
+ return false;
+ }
+ if(items != null ? !items.equals(purchaseOrder.items) : purchaseOrder.items != null)
+ {
+ return false;
+ }
+ if(orderDate != null ? !orderDate.equals(purchaseOrder.orderDate) : purchaseOrder.orderDate != null)
+ {
+ return false;
+ }
+ if(shipTo != null ? !shipTo.equals(purchaseOrder.shipTo) : purchaseOrder.shipTo != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (shipTo != null ? shipTo.hashCode() : 0);
+ result = 29 * result + (billTo != null ? billTo.hashCode() : 0);
+ result = 29 * result + (comment != null ? comment.hashCode() : 0);
+ result = 29 * result + (items != null ? items.hashCode() : 0);
+ result = 29 * result + (orderDate != null ? orderDate.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[purchaseOrder shipto=" + shipTo +
+ ", billTo=" + billTo +
+ ", comment=" + comment +
+ ", items=" + items +
+ ", orderDate=" + (orderDate == null ? "null" : new SimpleDateFormat("yyyy.MM.dd HH:mm:ss").format(
+ orderDate.getTime())) + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/po/USAddress.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/po/USAddress.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/po/USAddress.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,150 @@
+/*
+ * 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.xml.po;
+
+import java.math.BigDecimal;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class USAddress
+{
+ private final String country = "US";
+ private String name;
+ private String street;
+ private String city;
+ private String state;
+ private BigDecimal zip;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getStreet()
+ {
+ return street;
+ }
+
+ public void setStreet(String street)
+ {
+ this.street = street;
+ }
+
+ public String getCity()
+ {
+ return city;
+ }
+
+ public void setCity(String city)
+ {
+ this.city = city;
+ }
+
+ public String getState()
+ {
+ return state;
+ }
+
+ public void setState(String state)
+ {
+ this.state = state;
+ }
+
+ public BigDecimal getZip()
+ {
+ return zip;
+ }
+
+ public void setZip(BigDecimal zip)
+ {
+ this.zip = zip;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof USAddress))
+ {
+ return false;
+ }
+
+ final USAddress usAddress = (USAddress)o;
+
+ if(city != null ? !city.equals(usAddress.city) : usAddress.city != null)
+ {
+ return false;
+ }
+ if(country != null ? !country.equals(usAddress.country) : usAddress.country != null)
+ {
+ return false;
+ }
+ if(name != null ? !name.equals(usAddress.name) : usAddress.name != null)
+ {
+ return false;
+ }
+ if(state != null ? !state.equals(usAddress.state) : usAddress.state != null)
+ {
+ return false;
+ }
+ if(street != null ? !street.equals(usAddress.street) : usAddress.street != null)
+ {
+ return false;
+ }
+ if(zip != null ? !zip.equals(usAddress.zip) : usAddress.zip != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (country != null ? country.hashCode() : 0);
+ result = 29 * result + (name != null ? name.hashCode() : 0);
+ result = 29 * result + (street != null ? street.hashCode() : 0);
+ result = 29 * result + (city != null ? city.hashCode() : 0);
+ result = 29 * result + (state != null ? state.hashCode() : 0);
+ result = 29 * result + (zip != null ? zip.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[USAddress name=" + name +
+ ", street=" + street +
+ ", city=" + city +
+ ", state=" + state +
+ ", zip=" + zip + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBean.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBean.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBean.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,127 @@
+/*
+ * 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.xml.pojoserver;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+/**
+ * A SimpleBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public interface SimpleBean
+{
+ // Constants -----------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ String getConstructorUsed();
+
+ BigDecimal getABigDecimal();
+
+ void setABigDecimal(BigDecimal bigDecimal);
+
+ BigInteger getABigInteger();
+
+ void setABigInteger(BigInteger bigInteger);
+
+ boolean isAboolean();
+
+ void setAboolean(boolean aboolean);
+
+ Boolean getABoolean();
+
+ void setABoolean(Boolean boolean1);
+
+ byte getAbyte();
+
+ void setAbyte(byte abyte);
+
+ Byte getAByte();
+
+ void setAByte(Byte byte1);
+
+ char getAchar();
+
+ void setAchar(char achar);
+
+ Character getACharacter();
+
+ void setACharacter(Character character);
+
+ Date getADate();
+
+ void setADate(Date date);
+
+ double getAdouble();
+
+ void setAdouble(double adouble);
+
+ Double getADouble();
+
+ void setADouble(Double double1);
+
+ float getAfloat();
+
+ void setAfloat(float afloat);
+
+ Float getAFloat();
+
+ void setAFloat(Float float1);
+
+ long getAlong();
+
+ void setAlong(long along);
+
+ Long getALong();
+
+ void setALong(Long long1);
+
+ int getAnint();
+
+ void setAnint(int anint);
+
+ Integer getAnInt();
+
+ void setAnInt(Integer anInt);
+
+ short getAshort();
+
+ void setAshort(short ashort);
+
+ Short getAShort();
+
+ void setAShort(Short short1);
+
+ String getAString();
+
+ void setAString(String string);
+
+ SimpleBean getOther();
+
+ void setOther(SimpleBean other);
+
+ // Inner classes -------------------------------------------------
+}
\ No newline at end of file
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBeanFactory.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBeanFactory.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBeanFactory.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,86 @@
+/*
+ * 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.xml.pojoserver;
+
+/**
+ * A simple bean factory
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class SimpleBeanFactory
+{
+ // Constants -----------------------------------------------------
+
+ /** The method used */
+ private static String methodUsed;
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ public static String getMethodUsed()
+ {
+ return methodUsed;
+ }
+
+ public static SimpleBean staticCreateSimpleBean()
+ {
+ methodUsed = "staticCreateSimpleBean()";
+ return new SimpleBeanImpl();
+ }
+
+ public static SimpleBean staticCreateSimpleBean(SimpleBean other)
+ {
+ methodUsed = "staticCreateSimpleBean(SimpleBean)";
+ return new SimpleBeanImpl(other);
+ }
+
+ // Constructors --------------------------------------------------
+
+ public SimpleBeanFactory()
+ {
+ }
+
+ // Public --------------------------------------------------------
+
+ public SimpleBean createSimpleBean()
+ {
+ methodUsed = "createSimpleBean()";
+ return new SimpleBeanImpl();
+ }
+
+ public SimpleBean createSimpleBean(SimpleBean other)
+ {
+ methodUsed = "createSimpleBean(SimpleBean)";
+ return new SimpleBeanImpl(other);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
+
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBeanImpl.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBeanImpl.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/SimpleBeanImpl.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,413 @@
+/*
+ * 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.xml.pojoserver;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Collection;
+import java.util.Properties;
+import java.util.Set;
+import java.util.List;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * A simple bean
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:les.hazlewood at jboss.org">Les A. Hazlewood</a>
+ * @version $Revision: 37406 $
+ */
+public class SimpleBeanImpl implements Serializable, SimpleBean
+{
+ // Constants -----------------------------------------------------
+
+ private static final long serialVersionUID = 3762247526635353911L;
+
+ // Attributes ----------------------------------------------------
+
+ /** Constructor used */
+ private String constructorUsed;
+
+ /** A string */
+ private String aString;
+
+ /** Byte */
+ private Byte aByte;
+
+ /** Boolean */
+ private Boolean aBoolean;
+
+ /** Character */
+ private Character aCharacter;
+
+ /** Short */
+ private Short aShort;
+
+ /** Int */
+ private Integer anInt;
+
+ /** Long */
+ private Long aLong;
+
+ /** Float */
+ private Float aFloat;
+
+ /** Double */
+ private Double aDouble;
+
+ /** Date */
+ private Date aDate;
+
+ /** BigDecimal */
+ private BigDecimal aBigDecimal;
+
+ /** BigDecimal */
+ private BigInteger aBigInteger;
+
+ /** byte */
+ private byte abyte;
+
+ /** boolean */
+ private boolean aboolean;
+
+ /** char */
+ private char achar;
+
+ /** short */
+ private short ashort;
+
+ /** int */
+ private int anint;
+
+ /** long */
+ private long along;
+
+ /** float */
+ private float afloat;
+
+ /** double */
+ private double adouble;
+
+ /** a simple bean */
+ private SimpleBean other;
+
+ /** A collection */
+ private Collection collection;
+
+ /** A list */
+ private List aList;
+ /** A set */
+ private Set aSet;
+ /** A properties */
+ private Properties props;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public SimpleBeanImpl()
+ {
+ constructorUsed = "()";
+ }
+
+ public SimpleBeanImpl(String string)
+ {
+ constructorUsed = string;
+ }
+
+ public SimpleBeanImpl(SimpleBean other)
+ {
+ constructorUsed = SimpleBean.class.getName();
+ this.other = other;
+ }
+
+ // Public --------------------------------------------------------
+
+ public String getConstructorUsed()
+ {
+ return constructorUsed;
+ }
+
+ public BigDecimal getABigDecimal()
+ {
+ return aBigDecimal;
+ }
+
+ public void setABigDecimal(BigDecimal bigDecimal)
+ {
+ aBigDecimal = bigDecimal;
+ }
+
+ public BigInteger getABigInteger()
+ {
+ return aBigInteger;
+ }
+
+ public void setABigInteger(BigInteger bigInteger)
+ {
+ aBigInteger = bigInteger;
+ }
+
+ public boolean isAboolean()
+ {
+ return aboolean;
+ }
+
+ public void setAboolean(boolean aboolean)
+ {
+ this.aboolean = aboolean;
+ }
+
+ public Boolean getABoolean()
+ {
+ return aBoolean;
+ }
+
+ public void setABoolean(Boolean boolean1)
+ {
+ aBoolean = boolean1;
+ }
+
+ public byte getAbyte()
+ {
+ return abyte;
+ }
+
+ public void setAbyte(byte abyte)
+ {
+ this.abyte = abyte;
+ }
+
+ public Byte getAByte()
+ {
+ return aByte;
+ }
+
+ public void setAByte(Byte byte1)
+ {
+ aByte = byte1;
+ }
+
+ public char getAchar()
+ {
+ return achar;
+ }
+
+ public void setAchar(char achar)
+ {
+ this.achar = achar;
+ }
+
+ public Character getACharacter()
+ {
+ return aCharacter;
+ }
+
+ public void setACharacter(Character character)
+ {
+ aCharacter = character;
+ }
+
+ public Date getADate()
+ {
+ return aDate;
+ }
+
+ public void setADate(Date date)
+ {
+ aDate = date;
+ }
+
+ public double getAdouble()
+ {
+ return adouble;
+ }
+
+ public void setAdouble(double adouble)
+ {
+ this.adouble = adouble;
+ }
+
+ public Double getADouble()
+ {
+ return aDouble;
+ }
+
+ public void setADouble(Double double1)
+ {
+ aDouble = double1;
+ }
+
+ public float getAfloat()
+ {
+ return afloat;
+ }
+
+ public void setAfloat(float afloat)
+ {
+ this.afloat = afloat;
+ }
+
+ public Float getAFloat()
+ {
+ return aFloat;
+ }
+
+ public void setAFloat(Float float1)
+ {
+ aFloat = float1;
+ }
+
+ public long getAlong()
+ {
+ return along;
+ }
+
+ public void setAlong(long along)
+ {
+ this.along = along;
+ }
+
+ public Long getALong()
+ {
+ return aLong;
+ }
+
+ public void setALong(Long long1)
+ {
+ aLong = long1;
+ }
+
+ public int getAnint()
+ {
+ return anint;
+ }
+
+ public void setAnint(int anint)
+ {
+ this.anint = anint;
+ }
+
+ public Integer getAnInt()
+ {
+ return anInt;
+ }
+
+ public void setAnInt(Integer anInt)
+ {
+ this.anInt = anInt;
+ }
+
+ public short getAshort()
+ {
+ return ashort;
+ }
+
+ public void setAshort(short ashort)
+ {
+ this.ashort = ashort;
+ }
+
+ public Short getAShort()
+ {
+ return aShort;
+ }
+
+ public void setAShort(Short short1)
+ {
+ aShort = short1;
+ }
+
+ public String getAString()
+ {
+ return aString;
+ }
+
+ public void setAString(String string)
+ {
+ aString = string;
+ }
+
+ public SimpleBean getOther()
+ {
+ return other;
+ }
+
+ public void setOther(SimpleBean other)
+ {
+ /** TODO if (constructorUsed.equals("dependentState"))
+ {
+ if (other.getAString() != null)
+ throw new RuntimeException("Should not be configured: " + other.getAString());
+ } */
+ this.other = other;
+ }
+
+ public Collection getCollection()
+ {
+ return collection;
+ }
+
+ public void setCollection(Collection collection)
+ {
+ this.collection = collection;
+ }
+
+ public List getAList()
+ {
+ return aList;
+ }
+
+ public void setAList(List aList)
+ {
+ this.aList = aList;
+ }
+
+ public Set getASet()
+ {
+ return aSet;
+ }
+
+ public void setASet(Set aSet)
+ {
+ this.aSet = aSet;
+ }
+
+ public Properties getProps()
+ {
+ return props;
+ }
+
+ public void setProps(Properties props)
+ {
+ this.props = props;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/deployment/AbstractKernelDeployment.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/deployment/AbstractKernelDeployment.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/deployment/AbstractKernelDeployment.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,71 @@
+/*
+ * 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.xml.pojoserver.deployment;
+
+import java.util.List;
+
+/**
+ * An abstract kernel deployment.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractKernelDeployment
+{
+ /** The name of the deployment */
+ protected String name;
+
+ /** The beans List<BeanMetaData> */
+ protected List beans;
+
+ /**
+ * Create a new kernel deployment
+ */
+ public AbstractKernelDeployment()
+ {
+ }
+
+ /**
+ * Set the beans.
+ *
+ * @param beans a List<BeanMetaData>.
+ */
+ public void setBeans(List beans)
+ {
+ this.beans = beans;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public List getBeans()
+ {
+ return beans;
+ }
+}
\ No newline at end of file
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractAnnotationAttributeMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractAnnotationAttributeMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractAnnotationAttributeMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,131 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+
+/**
+ * Metadata for an annotation attribute.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 38009 $
+ */
+public class AbstractAnnotationAttributeMetaData implements AnnotationAttributeMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ /** The attribute name */
+ protected String name;
+
+ /** The attribute value */
+ protected ValueMetaData value;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Create a new annotation attribute meta data
+ */
+ public AbstractAnnotationAttributeMetaData()
+ {
+ }
+
+ /**
+ * Create a new annotation meta data
+ *
+ * @param name the name
+ * @param value the value
+ */
+ public AbstractAnnotationAttributeMetaData(String name, Object value)
+ {
+ this.name = name;
+ this.value = new AbstractValueMetaData(value);
+ }
+
+ /**
+ * Create a new annotation meta data
+ *
+ * @param name the name
+ * @param value the string value
+ */
+ public AbstractAnnotationAttributeMetaData(String name, String value)
+ {
+ this.name = name;
+ this.value = new StringValueMetaData(value);
+ }
+
+ /**
+ * Create a new annotation meta data
+ *
+ * @param name the name
+ * @param value the value meta data
+ */
+ public AbstractAnnotationAttributeMetaData(String name, ValueMetaData value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Set the name
+ *
+ * @param name the name
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Set the value
+ *
+ * @param value the value
+ */
+ public void setValue(ValueMetaData value)
+ {
+ this.value = value;
+ }
+
+ // AnnotationAttributeMetaData implementation --------------------
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public ValueMetaData getValue()
+ {
+ return value;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractAnnotationMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractAnnotationMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractAnnotationMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,97 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.Set;
+
+/**
+ * Metadata for an annotation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 38009 $
+ */
+public class AbstractAnnotationMetaData implements AnnotationMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ /** The annotation class name */
+ protected String name;
+
+ /** The attributes Set<AnnotationAttributeMetaData> */
+ protected Set attributes;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Create a new annotation meta data
+ */
+ public AbstractAnnotationMetaData()
+ {
+ super();
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Set the name.
+ *
+ * @param name The name to set.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Set the attributes.
+ *
+ * @param attributes Set<AnnotationAttributeMetaData>
+ */
+ public void setAttributes(Set attributes)
+ {
+ this.attributes = attributes;
+ }
+
+ // AnnotationMetaData implementation -----------------------------
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Set getAttributes()
+ {
+ return attributes;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractArrayMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractArrayMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractArrayMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,38 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * Array metadata.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractArrayMetaData extends AbstractListMetaData
+{
+ /**
+ * Create a new array value
+ */
+ public AbstractArrayMetaData()
+ {
+ }
+}
\ No newline at end of file
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractBeanMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractBeanMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractBeanMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,287 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * Metadata for a bean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractBeanMetaData extends AbstractFeatureMetaData implements BeanMetaData
+{
+ /** The bean class name */
+ protected String bean;
+
+ /** The name of this instance */
+ protected String name;
+
+ /** The mode */
+ protected ControllerMode mode = null;
+
+ /** The properties configuration Set<PropertyMetaData> */
+ protected Set properties;
+
+ /** The constructor */
+ protected ConstructorMetaData constructor;
+
+ /** The create lifecycle */
+ protected LifecycleMetaData create;
+
+ /** The start lifecycle */
+ protected LifecycleMetaData start;
+
+ /** The stop lifecycle */
+ protected LifecycleMetaData stop;
+
+ /** The destroy lifecycle */
+ protected LifecycleMetaData destroy;
+
+ /** What the bean demands Set<DemandMetaData> */
+ protected Set demands;
+
+ /** What the bean supplies Set<SupplyMetaData> */
+ protected Set supplies;
+
+ protected Map metaData;
+ /**
+ * Create a new bean meta data
+ */
+ public AbstractBeanMetaData()
+ {
+ super();
+ }
+
+ /**
+ * Create a new bean meta data
+ *
+ * @param bean the bean class name
+ */
+ public AbstractBeanMetaData(String bean)
+ {
+ this.bean = bean;
+ }
+ /**
+ * Create a new bean meta data
+ *
+ * @param name the name
+ * @param bean the bean class name
+ */
+ public AbstractBeanMetaData(String name, String bean)
+ {
+ this.name = name;
+ this.bean = bean;
+ }
+
+ /**
+ * Set the bean.
+ *
+ * @param bean The bean to set.
+ */
+ public void setBean(String bean)
+ {
+ this.bean = bean;
+ }
+
+ /**
+ * Set the propertiess.
+ *
+ * @param properties Set<PropertiesMetaData>
+ */
+ public void setProperties(Set properties)
+ {
+ this.properties = properties;
+ }
+
+ /**
+ * Set the constructor
+ *
+ * @param constructor the constructor metadata
+ */
+ public void setConstructor(ConstructorMetaData constructor)
+ {
+ this.constructor = constructor;
+ }
+
+ /**
+ * Set what the bean demands.
+ *
+ * @param demands Set<DemandMetaData>
+ */
+ public void setDemands(Set demands)
+ {
+ this.demands = demands;
+ }
+
+ /**
+ * Set what the bean supplies.
+ *
+ * @param supplies Set<SupplyMetaData>
+ */
+ public void setSupplies(Set supplies)
+ {
+ this.supplies = supplies;
+ }
+
+ public String getBean()
+ {
+ return bean;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Set the name.
+ *
+ * @param name The name to set.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public ControllerMode getMode()
+ {
+ return mode;
+ }
+
+ public void setMode(ControllerMode mode)
+ {
+ this.mode = mode;
+ }
+
+ public Set getProperties()
+ {
+ return properties;
+ }
+
+ public ConstructorMetaData getConstructor()
+ {
+ return constructor;
+ }
+
+ public LifecycleMetaData getCreate()
+ {
+ return create;
+ }
+
+ /**
+ * Set the lifecycle metadata
+ *
+ * @param lifecycle the lifecycle metadata
+ */
+ public void setCreate(LifecycleMetaData lifecycle)
+ {
+ lifecycle.setState(ControllerState.CREATE);
+ this.create = lifecycle;
+ }
+
+ public LifecycleMetaData getStart()
+ {
+ return start;
+ }
+
+ /**
+ * Set the start metadata
+ *
+ * @param lifecycle the lifecycle metadata
+ */
+ public void setStart(LifecycleMetaData lifecycle)
+ {
+ lifecycle.setState(ControllerState.START);
+ this.start = lifecycle;
+ }
+
+ public LifecycleMetaData getStop()
+ {
+ return stop;
+ }
+
+ /**
+ * Set the stop metadata
+ *
+ * @param lifecycle the lifecycle metadata
+ */
+ public void setStop(LifecycleMetaData lifecycle)
+ {
+ lifecycle.setState(ControllerState.START);
+ this.stop = lifecycle;
+ }
+
+ public LifecycleMetaData getDestroy()
+ {
+ return destroy;
+ }
+
+ /**
+ * Set the destroy metadata
+ *
+ * @param lifecycle the lifecycle metadata
+ */
+ public void setDestroy(LifecycleMetaData lifecycle)
+ {
+ lifecycle.setState(ControllerState.CREATE);
+ this.destroy = lifecycle;
+ }
+
+ public Set getDemands()
+ {
+ return demands;
+ }
+
+ public Set getSupplies()
+ {
+ return supplies;
+ }
+
+ public Iterator getChildren()
+ {
+ ArrayList list = new ArrayList();
+ if (constructor != null)
+ list.add(constructor);
+ if (properties != null)
+ list.addAll(properties);
+ if (create != null)
+ list.add(create);
+ if (start != null)
+ list.add(start);
+ if (stop != null)
+ list.add(stop);
+ if (destroy != null)
+ list.add(destroy);
+ if (demands != null)
+ list.addAll(demands);
+ if (supplies != null)
+ list.addAll(supplies);
+ if (metaData != null)
+ list.add(metaData);
+ return list.iterator();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractCollectionMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractCollectionMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractCollectionMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,133 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * Collection metadata.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractCollectionMetaData extends AbstractTypeMetaData implements Collection
+{
+ /** The collection */
+ protected ArrayList collection = new ArrayList();
+
+ /** The element type */
+ protected String elementType;
+
+ /**
+ * Create a new collection value
+ */
+ public AbstractCollectionMetaData()
+ {
+ }
+
+ /**
+ * Get the element type
+ *
+ * @return the element type
+ */
+ public String getElementType()
+ {
+ return elementType;
+ }
+
+ /**
+ * Set the element type
+ *
+ * @param elementType the element type
+ */
+ public void setElementType(String elementType)
+ {
+ this.elementType = elementType;
+ }
+
+ public boolean add(Object o)
+ {
+ return collection.add(o);
+ }
+
+ public boolean addAll(Collection c)
+ {
+ return collection.addAll(c);
+ }
+
+ public void clear()
+ {
+ collection.clear();
+ }
+
+ public boolean contains(Object o)
+ {
+ return collection.contains(o);
+ }
+
+ public boolean containsAll(Collection c)
+ {
+ return collection.containsAll(c);
+ }
+
+ public boolean isEmpty()
+ {
+ return collection.isEmpty();
+ }
+
+ public Iterator iterator()
+ {
+ return collection.iterator();
+ }
+
+ public boolean remove(Object o)
+ {
+ return collection.remove(o);
+ }
+
+ public boolean removeAll(Collection c)
+ {
+ return collection.removeAll(c);
+ }
+
+ public boolean retainAll(Collection c)
+ {
+ return collection.retainAll(c);
+ }
+
+ public int size()
+ {
+ return collection.size();
+ }
+
+ public Object[] toArray()
+ {
+ return collection.toArray();
+ }
+
+ public Object[] toArray(Object[] a)
+ {
+ return collection.toArray(a);
+ }
+}
\ No newline at end of file
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractConstructorMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractConstructorMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractConstructorMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,159 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public class AbstractConstructorMetaData extends AbstractFeatureMetaData
+ implements ConstructorMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ /** The paramaters List<ParameterMetaData> */
+ protected List parameters;
+
+ /** The factory */
+ protected ValueMetaData factory;
+
+ /** The factory class name */
+ protected String factoryClassName;
+
+ /** The factory method */
+ protected String factoryMethod;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Create a new constructor meta data
+ */
+ public AbstractConstructorMetaData()
+ {
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Set the parameters
+ *
+ * @param parameters List<ParameterMetaData>
+ */
+ public void setParameters(List parameters)
+ {
+ this.parameters = parameters;
+ }
+
+ /**
+ * Set the factory
+ *
+ * @param factory the factory
+ */
+ public void setFactory(ValueMetaData factory)
+ {
+ this.factory = factory;
+ }
+
+ /**
+ * Set the factory class name
+ *
+ * @param name the factory class name
+ */
+ public void setFactoryClass(String name)
+ {
+ this.factoryClassName = name;
+ }
+
+ /**
+ * Set the factory method
+ *
+ * @param name the factory method
+ */
+ public void setFactoryMethod(String name)
+ {
+ this.factoryMethod = name;
+ }
+
+ // ConstructorMetaData implementation ----------------------------
+
+ public List getParameters()
+ {
+ return parameters;
+ }
+
+ public ValueMetaData getFactory()
+ {
+ return factory;
+ }
+
+ public String getFactoryClass()
+ {
+ return factoryClassName;
+ }
+
+ public String getFactoryMethod()
+ {
+ return factoryMethod;
+ }
+
+ // MetaDataVisitorNode overrides ----------------------------------
+
+ public Iterator getChildren()
+ {
+ ArrayList list = new ArrayList();
+ if (parameters != null)
+ list.addAll(parameters);
+ if (factory != null)
+ list.add(factory);
+ return list.iterator();
+ }
+
+ // JBossObject overrides ------------------------------------------
+
+ public void toString(StringBuffer buffer)
+ {
+ buffer.append("parameters=").append(parameters);
+ if (factory != null)
+ buffer.append(" factory=").append(factory);
+ if (factoryClassName != null)
+ buffer.append(" factoryClass=").append(factoryClassName);
+ if (factoryMethod != null)
+ buffer.append(" factoryMethod=").append(factoryMethod);
+ super.toString(buffer);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDemandMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDemandMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDemandMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,117 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public class AbstractDemandMetaData extends AbstractFeatureMetaData
+ implements DemandMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ /** The demand */
+ protected Object demand;
+
+ /** When the dependency is required */
+ protected ControllerState whenRequired = ControllerState.DESCRIBED;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Create a new demand
+ */
+ public AbstractDemandMetaData()
+ {
+ }
+
+ /**
+ * Create a new demand
+ *
+ * @param demand the demand
+ */
+ public AbstractDemandMetaData(Object demand)
+ {
+ this.demand = demand;
+ }
+
+ /**
+ * Set the required state of the dependency
+ *
+ * @param whenRequired when the dependecy is required
+ */
+ public void setWhenRequired(ControllerState whenRequired)
+ {
+ this.whenRequired = whenRequired;
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Set the demand
+ *
+ * @param demand the demand
+ */
+ public void setDemand(Object demand)
+ {
+ this.demand = demand;
+ }
+
+ // DemandMetaData implementation ---------------------------------
+
+ public Object getDemand()
+ {
+ return demand;
+ }
+
+ public ControllerState getWhenRequired()
+ {
+ return whenRequired;
+ }
+
+ // JBossObject overrides -----------------------------------------
+
+ public void toString(StringBuffer buffer)
+ {
+ buffer.append("demand=").append(demand);
+ if (whenRequired != null)
+ buffer.append(" whenRequired").append(whenRequired.getStateString());
+ }
+
+ public void toShortString(StringBuffer buffer)
+ {
+ buffer.append(demand);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDependencyMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDependencyMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDependencyMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -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.xml.pojoserver.metadata;
+
+/**
+ * A dependency.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractDependencyMetaData implements DependencyMetaData
+{
+ /** The dependency */
+ protected Object dependency;
+
+ /**
+ * Create a new dependency
+ */
+ public AbstractDependencyMetaData()
+ {
+ }
+
+ /**
+ * Create a new dependency
+ *
+ * @param dependency the dependency
+ */
+ public AbstractDependencyMetaData(Object dependency)
+ {
+ this.dependency = dependency;
+ }
+
+ /**
+ * Set the dependency
+ *
+ * @param dependency the dependency
+ */
+ public void setDependency(Object dependency)
+ {
+ this.dependency = dependency;
+ }
+
+ public Object getDependency()
+ {
+ return dependency;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDependencyValueMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDependencyValueMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractDependencyValueMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,101 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * Dependency value.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractDependencyValueMetaData extends AbstractValueMetaData
+{
+ /** The property name */
+ protected String property;
+
+ /** The required state of the dependency or null to look in the registry */
+ protected ControllerState dependentState = ControllerState.INSTALLED;
+
+ /**
+ * Create a new dependency value
+ */
+ public AbstractDependencyValueMetaData()
+ {
+ }
+
+ /**
+ * Create a new dependency value
+ *
+ * @param value the value
+ */
+ public AbstractDependencyValueMetaData(Object value)
+ {
+ super(value);
+ }
+
+ /**
+ * Create a new dependency value
+ *
+ * @param value the value
+ * @param property the property
+ */
+ public AbstractDependencyValueMetaData(Object value, String property)
+ {
+ super(value);
+ this.property = property;
+ }
+
+ /**
+ * Set the value
+ *
+ * @param value the value
+ */
+ public void setValue(Object value)
+ {
+ super.setValue(value);
+ }
+
+ /**
+ * Set the property
+ *
+ * @param property the property name
+ */
+ public void setProperty(String property)
+ {
+ this.property = property;
+ }
+
+ /**
+ * Set the required state of the dependency
+ *
+ * @param dependentState the required state or null if it must be in the registry
+ */
+ public void setDependentState(ControllerState dependentState)
+ {
+ this.dependentState = dependentState;
+ }
+
+ public ControllerState getDependentState()
+ {
+ return dependentState;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractFeatureMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractFeatureMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractFeatureMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,119 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.Map;
+import java.util.Iterator;
+
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public class AbstractFeatureMetaData
+ implements FeatureMetaData
+{
+ /** The description */
+ protected String description;
+
+ /** The generic metadata */
+ protected Map values;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Create a new meta data
+ */
+ public AbstractFeatureMetaData()
+ {
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Set the description.
+ *
+ * @param description the description.
+ */
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param key the key to the value
+ * @param value The value to set.
+ */
+ public void setValue(String key, Object value)
+ {
+ if (values == null)
+ values = new ConcurrentReaderHashMap();
+ values.put(key, value);
+ }
+
+ // MetaData implementation ---------------------------------------
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public Object getValue(String key)
+ {
+ if (values == null)
+ return null;
+ return values.get(key);
+ }
+
+ // MetaDataVisitorNote overrides ----------------------------------
+
+ public void visit(MetaDataVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ public Iterator getChildren()
+ {
+ return null;
+ }
+
+ // JBossObject overrides ------------------------------------------
+
+ public void toString(StringBuffer buffer)
+ {
+ if (description != null)
+ buffer.append("description=").append(description);
+ if (values != null)
+ buffer.append(" values=").append(values);
+ }
+
+ public void toShortString(StringBuffer buffer)
+ {
+ buffer.append(description);
+ }
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractLifecycleMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractLifecycleMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractLifecycleMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,89 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.List;
+
+/**
+ * Metadata for lifecycle.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractLifecycleMetaData extends AbstractFeatureMetaData implements LifecycleMetaData
+{
+ /** The state */
+ protected ControllerState state;
+
+ /** The method name */
+ protected String methodName;
+
+ /** The paramaters List<ParameterMetaData> */
+ protected List parameters;
+
+ /**
+ * Create a new lifecycle meta data
+ */
+ public AbstractLifecycleMetaData()
+ {
+ }
+
+ public ControllerState getState()
+ {
+ return state;
+ }
+
+ public void setState(ControllerState state)
+ {
+ this.state = state;
+ }
+
+ public String getMethodName()
+ {
+ return methodName;
+ }
+
+ /**
+ * Set the method name
+ *
+ * @param name the factory method
+ */
+ public void setMethodName(String name)
+ {
+ this.methodName = name;
+ }
+
+ public List getParameters()
+ {
+ return parameters;
+ }
+
+ /**
+ * Set the parameters
+ *
+ * @param parameters List<ParameterMetaData>
+ */
+ public void setParameters(List parameters)
+ {
+ this.parameters = parameters;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractListMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractListMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractListMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,92 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * List metadata.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractListMetaData extends AbstractCollectionMetaData implements List
+{
+ /**
+ * Create a new list value
+ */
+ public AbstractListMetaData()
+ {
+ }
+
+ public void add(int index, Object element)
+ {
+ collection.add(index, element);
+ }
+
+ public boolean addAll(int index, Collection c)
+ {
+ return collection.addAll(index, c);
+ }
+
+ public Object get(int index)
+ {
+ return collection.get(index);
+ }
+
+ public int indexOf(Object o)
+ {
+ return collection.indexOf(o);
+ }
+
+ public int lastIndexOf(Object o)
+ {
+ return lastIndexOf(o);
+ }
+
+ public ListIterator listIterator()
+ {
+ return collection.listIterator();
+ }
+
+ public ListIterator listIterator(int index)
+ {
+ return collection.listIterator(index);
+ }
+
+ public Object remove(int index)
+ {
+ return collection.remove(index);
+ }
+
+ public Object set(int index, Object element)
+ {
+ return set(index, element);
+ }
+
+ public List subList(int fromIndex, int toIndex)
+ {
+ return subList(fromIndex, toIndex);
+ }
+}
\ No newline at end of file
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractMapMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractMapMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractMapMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,152 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Map metadata.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractMapMetaData extends AbstractTypeMetaData implements Map
+{
+ /** The map */
+ private HashMap map = new HashMap();
+
+ /** The key type */
+ protected String keyType;
+
+ /** The value type */
+ protected String valueType;
+
+ /**
+ * Create a new map value
+ */
+ public AbstractMapMetaData()
+ {
+ }
+
+ /**
+ * Get the key type
+ *
+ * @return the key type
+ */
+ public String getKeyType()
+ {
+ return keyType;
+ }
+
+ /**
+ * Set the key type
+ *
+ * @param keyType the key type
+ */
+ public void setKeyType(String keyType)
+ {
+ this.keyType = keyType;
+ }
+
+ /**
+ * Get the value type
+ *
+ * @return the value type
+ */
+ public String getValueType()
+ {
+ return valueType;
+ }
+
+ /**
+ * Set the value type
+ *
+ * @param valueType the value type
+ */
+ public void setValueType(String valueType)
+ {
+ this.valueType = valueType;
+ }
+
+ public void clear()
+ {
+ map.clear();
+ }
+
+ public boolean containsKey(Object key)
+ {
+ return map.containsKey(key);
+ }
+
+ public boolean containsValue(Object value)
+ {
+ return map.containsValue(value);
+ }
+
+ public Set entrySet()
+ {
+ return map.entrySet();
+ }
+
+ public Object get(Object key)
+ {
+ return map.get(key);
+ }
+
+ public boolean isEmpty()
+ {
+ return map.isEmpty();
+ }
+
+ public Set keySet()
+ {
+ return map.keySet();
+ }
+
+ public Object put(Object key, Object value)
+ {
+ return map.put(key, value);
+ }
+
+ public void putAll(Map t)
+ {
+ map.putAll(t);
+ }
+
+ public Object remove(Object key)
+ {
+ return map.remove(key);
+ }
+
+ public int size()
+ {
+ return map.size();
+ }
+
+ public Collection values()
+ {
+ return map.values();
+ }
+}
\ No newline at end of file
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractMapMetaDataEntry.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractMapMetaDataEntry.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractMapMetaDataEntry.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -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.xml.pojoserver.metadata;
+
+/**
+ * Map metadata.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 38013 $
+ */
+public class AbstractMapMetaDataEntry
+{
+ private AbstractValueMetaData key;
+
+ private AbstractValueMetaData value;
+
+ public Object getKey()
+ {
+ return key.getUnderlyingValue();
+ }
+
+ public void setKey(Object key)
+ {
+ this.key = (AbstractValueMetaData) key;
+ }
+
+ public Object getValue()
+ {
+ return value.getUnderlyingValue();
+ }
+
+ public void setValue(Object value)
+ {
+ this.value = (AbstractValueMetaData) value;
+ }
+
+ public String toString()
+ {
+ return "[map-entry key=" + key + ", value=" + value + "]";
+ }
+
+}
\ No newline at end of file
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractParameterMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractParameterMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractParameterMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,111 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * Metadata for a parameter.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractParameterMetaData extends AbstractFeatureMetaData implements ParameterMetaData
+{
+ /** The parameter type */
+ protected String type;
+
+ /** The parameter value */
+ protected ValueMetaData value;
+
+ /**
+ * Create a new parameter meta data
+ */
+ public AbstractParameterMetaData()
+ {
+ }
+
+ /**
+ * Create a new parameter meta data
+ *
+ * @param value the value
+ */
+ public AbstractParameterMetaData(Object value)
+ {
+ this.type = value.getClass().getName();
+ this.value = new AbstractValueMetaData(value);
+ }
+
+ /**
+ * Create a new parameter meta data
+ *
+ * @param type the type
+ * @param value the value
+ */
+ public AbstractParameterMetaData(String type, Object value)
+ {
+ this.type = type;
+ this.value = new AbstractValueMetaData(value);
+ }
+
+ /**
+ * Create a new parameter meta data
+ *
+ * @param type the type
+ * @param value the string value
+ */
+ public AbstractParameterMetaData(String type, String value)
+ {
+ this.type = type;
+ this.value = new StringValueMetaData(value);
+ }
+
+ /**
+ * Create a new parameter meta data
+ *
+ * @param type the type
+ * @param value the value meta data
+ */
+ public AbstractParameterMetaData(String type, ValueMetaData value)
+ {
+ this.type = type;
+ this.value = value;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public ValueMetaData getValue()
+ {
+ return value;
+ }
+
+ public void setValue(ValueMetaData value)
+ {
+ this.value = value;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractPropertyMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractPropertyMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractPropertyMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,139 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.Iterator;
+import java.util.Collections;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public class AbstractPropertyMetaData
+ extends AbstractFeatureMetaData implements PropertyMetaData
+ {
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ /** The property name */
+ protected String name;
+
+ /** The property value */
+ protected ValueMetaData value;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Create a new property meta data
+ */
+ public AbstractPropertyMetaData()
+ {
+ }
+
+ /**
+ * Create a new property meta data
+ *
+ * @param name the name
+ * @param value the value
+ */
+ public AbstractPropertyMetaData(String name, Object value)
+ {
+ this.name = name;
+ this.value = new AbstractValueMetaData(value);
+ }
+
+ /**
+ * Create a new property meta data
+ *
+ * @param name the name
+ * @param value the string value
+ */
+ public AbstractPropertyMetaData(String name, String value)
+ {
+ this.name = name;
+ this.value = new StringValueMetaData(value);
+ }
+
+ /**
+ * Create a new attribute meta data
+ *
+ * @param name the name
+ * @param value the value meta data
+ */
+ public AbstractPropertyMetaData(String name, ValueMetaData value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+
+ // Public --------------------------------------------------------
+
+ // PropertyMetaData implementation -------------------------------
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public ValueMetaData getValue()
+ {
+ return value;
+ }
+
+ public void setValue(ValueMetaData value)
+ {
+ this.value = value;
+ }
+
+ // MetaDataVisitorNode overrides ----------------------------------
+
+ public Iterator getChildren()
+ {
+ if (value != null)
+ return Collections.singletonList(value).iterator();
+ return null;
+ }
+
+ // JBossObject overrides ------------------------------------------
+
+ public void toString(StringBuffer buffer)
+ {
+ buffer.append("name=").append(name);
+ if (value != null)
+ buffer.append(" value=").append(value);
+ super.toString(buffer);
+ }
+
+ public void toShortString(StringBuffer buffer)
+ {
+ buffer.append(name);
+ }
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractSetMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractSetMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractSetMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -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.xml.pojoserver.metadata;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Set metadata.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractSetMetaData extends AbstractCollectionMetaData implements Set
+{
+ /**
+ * Create a new set value
+ */
+ public AbstractSetMetaData()
+ {
+ }
+
+ public boolean add(Object o)
+ {
+ if (collection.contains(o))
+ return false;
+ return super.add(o);
+ }
+
+ public boolean addAll(Collection c)
+ {
+ boolean changed = false;
+ if (c != null && c.size() > 0)
+ {
+ for (Iterator i = c.iterator(); i.hasNext(); )
+ {
+ Object o = i.next();
+ if (collection.contains(o) == false)
+ {
+ if (super.add(o))
+ changed = true;
+ }
+ }
+ }
+ return changed;
+ }
+}
\ No newline at end of file
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractSupplyMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractSupplyMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractSupplyMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,97 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public class AbstractSupplyMetaData extends AbstractFeatureMetaData
+ implements SupplyMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ /** The supply */
+ protected Object supply;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Create a new supply
+ */
+ public AbstractSupplyMetaData()
+ {
+ }
+
+ /**
+ * Create a new supply
+ *
+ * @param supply the supply
+ */
+ public AbstractSupplyMetaData(Object supply)
+ {
+ this.supply = supply;
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Set the supply
+ *
+ * @param supply the supply
+ */
+ public void setSupply(Object supply)
+ {
+ this.supply = supply;
+ }
+
+ // SupplyMetaData implementation ---------------------------------
+
+ public Object getSupply()
+ {
+ return supply;
+ }
+
+ // JBossObject overrides -----------------------------------------
+
+ public void toString(StringBuffer buffer)
+ {
+ buffer.append("supply=").append(supply);
+ }
+
+ public void toShortString(StringBuffer buffer)
+ {
+ buffer.append(supply);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractTypeMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractTypeMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractTypeMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,65 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * A typed value.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public abstract class AbstractTypeMetaData extends AbstractValueMetaData
+{
+ /** The type */
+ protected String type;
+ /**
+ * Create a new typed value
+ */
+ public AbstractTypeMetaData()
+ {
+ }
+
+ /**
+ * Create a new typed value
+ *
+ * @param value the value
+ */
+ public AbstractTypeMetaData(String value)
+ {
+ super(value);
+ }
+
+ /**
+ * Set the type
+ *
+ * @param type the type
+ */
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractValueMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractValueMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AbstractValueMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -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.xml.pojoserver.metadata;
+
+/**
+ * Plain value.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class AbstractValueMetaData implements ValueMetaData
+{
+ /** The value */
+ protected Object value;
+
+ /**
+ * Create a new plain value
+ */
+ public AbstractValueMetaData()
+ {
+ }
+
+ /**
+ * Create a new plain value
+ *
+ * @param value the value
+ */
+ public AbstractValueMetaData(Object value)
+ {
+ this.value = value;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+
+ public Object getUnderlyingValue()
+ {
+ return value;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AnnotationAttributeMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AnnotationAttributeMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AnnotationAttributeMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,52 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+
+/**
+ * Metadata about an annotation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public interface AnnotationAttributeMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Get the name
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * Get the value.
+ *
+ * @return the value.
+ */
+ ValueMetaData getValue();
+
+ // Inner classes -------------------------------------------------
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AnnotationMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AnnotationMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/AnnotationMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,53 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.Set;
+
+/**
+ * Metadata about an annotation attribute.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public interface AnnotationMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Get the name
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * Get the annotation attributes.
+ *
+ * @return Set<AnnotationAttributeMetaData>.
+ */
+ Set getAttributes();
+
+ // Inner classes -------------------------------------------------
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/BeanMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/BeanMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/BeanMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,84 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.Set;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public interface BeanMetaData extends FeatureMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Get the bean.
+ *
+ * @return the bean.
+ */
+ String getBean();
+
+ /**
+ * Get the name
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * Set the name
+ *
+ * @param name the name
+ */
+ void setName(String name);
+
+ /**
+ * Get the properties.
+ *
+ * @return List<PropertyMetaData>.
+ */
+ Set getProperties();
+
+ /**
+ * Get the constructor
+ *
+ * @return the constructor metadata
+ */
+ ConstructorMetaData getConstructor();
+
+ /**
+ * Get what this bean demands.
+ *
+ * @return Set<DemandMetaData>
+ */
+ Set getDemands();
+
+ /**
+ * Get what this bean supplies.
+ *
+ * @return Set<SupplyMetaData>
+ */
+ Set getSupplies();
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ConstructorMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ConstructorMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ConstructorMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,65 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.List;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public interface ConstructorMetaData extends FeatureMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Get the parameters.
+ *
+ * @return List<ParameterMetaData>.
+ */
+ List getParameters();
+
+ /**
+ * Get the factory.
+ *
+ * @return the factory.
+ */
+ ValueMetaData getFactory();
+
+ /**
+ * Get the factory class.
+ *
+ * @return the class name of the factory.
+ */
+ String getFactoryClass();
+
+ /**
+ * Get the factory method.
+ *
+ * @return the factory method.
+ */
+ String getFactoryMethod();
+
+ // Inner classes -------------------------------------------------
+ }
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerMode.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerMode.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerMode.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,81 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * Mode of the context.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class ControllerMode
+{
+ /** Automatic */
+ public static final ControllerMode AUTOMATIC = new ControllerMode("Automatic");
+
+ /** On demand */
+ public static final ControllerMode ON_DEMAND = new ControllerMode("On Demand");
+
+ /** Manual */
+ public static final ControllerMode MANUAL = new ControllerMode("Manual");
+
+ /** Disabled */
+ public static final ControllerMode DISABLED = new ControllerMode("Disabled");
+
+ /** The mode string */
+ protected final String modeString;
+
+ /**
+ * Create a new mode
+ *
+ * @param modeString the mode representation
+ */
+ public ControllerMode(String modeString)
+ {
+ if (modeString == null)
+ throw new IllegalArgumentException("Null mode string");
+ this.modeString = modeString;
+ }
+
+ /**
+ * Get the mode string
+ *
+ * @return the mdoe string
+ */
+ public String getModeString()
+ {
+ return modeString;
+ }
+
+ public boolean equals(Object object)
+ {
+ if (object == null || object instanceof ControllerMode == false)
+ return false;
+ ControllerMode other = (ControllerMode) object;
+ return modeString.equals(other.modeString);
+ }
+
+ public int hashCode()
+ {
+ return modeString.hashCode();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerState.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerState.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerState.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,93 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * Description of state.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class ControllerState
+{
+ /** Error */
+ public static final ControllerState ERROR = new ControllerState("**ERROR**");
+
+ /** Not installed state */
+ public static final ControllerState NOT_INSTALLED = new ControllerState("Not Installed");
+
+ /** Described state */
+ public static final ControllerState DESCRIBED = new ControllerState("Described");
+
+ /** Instantiated state */
+ public static final ControllerState INSTANTIATED = new ControllerState("Instantiated");
+
+ /** Configured state */
+ public static final ControllerState CONFIGURED = new ControllerState("Configured");
+
+ /** Create state */
+ public static final ControllerState CREATE = new ControllerState("Create");
+
+ /** Start state */
+ public static final ControllerState START = new ControllerState("Start");
+
+ /** Installed state */
+ public static final ControllerState INSTALLED = new ControllerState("Installed");
+
+ /** The state string */
+ protected final String stateString;
+
+ /**
+ * Create a new state
+ *
+ * @param stateString the string representation
+ */
+ public ControllerState(String stateString)
+ {
+ if (stateString == null)
+ throw new IllegalArgumentException("Null state string");
+ this.stateString = stateString;
+ }
+
+ /**
+ * Get the state string
+ *
+ * @return the state string
+ */
+ public String getStateString()
+ {
+ return stateString;
+ }
+
+ public boolean equals(Object object)
+ {
+ if (object == null || object instanceof ControllerState == false)
+ return false;
+ ControllerState other = (ControllerState) object;
+ return stateString.equals(other.stateString);
+ }
+
+ public int hashCode()
+ {
+ return stateString.hashCode();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerStateDataTypeConverter.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerStateDataTypeConverter.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ControllerStateDataTypeConverter.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,36 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class ControllerStateDataTypeConverter
+{
+ public static Object unmarshalStringValue(String text, NamespaceContext nsCtx)
+ {
+ return new ControllerState(text);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DataTypeConverter.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DataTypeConverter.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DataTypeConverter.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,36 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class DataTypeConverter
+{
+ public static Object unmarshalStringValue(String text, NamespaceContext nsCtx)
+ {
+ return text == null ? null : new StringValueMetaData(text);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DemandMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DemandMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DemandMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,47 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public interface DemandMetaData extends FeatureMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * What is demanded
+ *
+ * @return the demand
+ */
+ Object getDemand();
+
+ /**
+ * Get when the dependency is required
+ *
+ * @return when the dependency is required
+ */
+ ControllerState getWhenRequired();
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DependencyMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DependencyMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DependencyMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,38 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * Metadata about what a bean's dependency.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public interface DependencyMetaData
+{
+ /**
+ * What is the dependency
+ *
+ * @return the dependency
+ */
+ Object getDependency();
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DependencyValueMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DependencyValueMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/DependencyValueMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,49 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public interface DependencyValueMetaData extends ValueMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Set the controller
+ *
+ * @param controller the controller
+ */
+ void setController(Object controller);
+
+ /**
+ * Get the required state of the dependency
+ *
+ * @return the required state or null if it must be in the registry
+ */
+ ControllerState getDependentState();
+
+ // Inner classes -------------------------------------------------
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/FeatureMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/FeatureMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/FeatureMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,45 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public interface FeatureMetaData extends MetaDataVisitorNode
+{
+ /**
+ * Get the descrition.
+ *
+ * @return the description.
+ */
+ String getDescription();
+
+ /**
+ * Get the value.
+ *
+ * @param key the key to the value
+ * @return the value.
+ */
+ Object getValue(String key);
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/GenericBeanFactory.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/GenericBeanFactory.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/GenericBeanFactory.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,111 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.Map;
+
+/**
+ * Collection metadata.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class GenericBeanFactory
+{
+ /** The bean class name */
+ protected String bean;
+
+ /** The constructor metadata */
+ protected ConstructorMetaData constructor;
+
+ /** The properties Map<propertyName, ValueMetaData> */
+ protected Map properties;
+
+ /**
+ * Create a new generic bean factory
+ */
+ public GenericBeanFactory()
+ {
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Get the bean name
+ *
+ * @return the bean
+ */
+ public String getBean()
+ {
+ return bean;
+ }
+
+ /**
+ * Set the bean name
+ *
+ * @param bean the bean name
+ */
+ public void setBean(String bean)
+ {
+ this.bean = bean;
+ }
+
+ /**
+ * Get the constructor metadata
+ *
+ * @return the contructor metadata
+ */
+ public ConstructorMetaData getConstructor()
+ {
+ return constructor;
+ }
+
+ /**
+ * Set the constructor metadata
+ *
+ * @param constructor the constructor metadata
+ */
+ public void setConstructor(ConstructorMetaData constructor)
+ {
+ this.constructor = constructor;
+ }
+
+ /**
+ * Get the properties
+ *
+ * @return the properties Map<propertyName, ValueMetaData>
+ */
+ public Map getProperties()
+ {
+ return properties;
+ }
+
+ /**
+ * Set the properties
+ *
+ * @param properties the properties Map<propertyName, ValueMetaData>
+ */
+ public void setProperties(Map properties)
+ {
+ this.properties = properties;
+ }
+}
\ No newline at end of file
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/LifecycleMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/LifecycleMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/LifecycleMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -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.xml.pojoserver.metadata;
+
+import java.util.List;
+
+/**
+ * Metadata about a lifecycle method.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public interface LifecycleMetaData extends FeatureMetaData
+{
+ /**
+ * Get the state
+ *
+ * @return the state
+ */
+ ControllerState getState();
+
+ /**
+ * Set the state
+ *
+ * @param state the state
+ */
+ void setState(ControllerState state);
+
+ /**
+ * Get the method name.
+ *
+ * @return the method name.
+ */
+ String getMethodName();
+
+ /**
+ * Get the parameters.
+ *
+ * @return List<ParameterMetaData>.
+ */
+ List getParameters();
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/MetaDataVisitor.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/MetaDataVisitor.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/MetaDataVisitor.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,31 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public interface MetaDataVisitor
+{
+ public void visit(MetaDataVisitorNode node);
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/MetaDataVisitorNode.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/MetaDataVisitorNode.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/MetaDataVisitorNode.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,50 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+import java.util.Iterator;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public interface MetaDataVisitorNode
+{
+ // Constants -----------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Visit the node
+ *
+ * @param vistor the visitor
+ */
+ public void visit(MetaDataVisitor vistor);
+
+ /**
+ * Return the child nodes
+ *
+ * @return Iterator<MetaDataVistorNode> or null if there aren't any
+ */
+ public Iterator getChildren();
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ParameterMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ParameterMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ParameterMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,50 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public interface ParameterMetaData extends FeatureMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Get the type.
+ *
+ * @return the type.
+ */
+ String getType();
+
+ /**
+ * Get the value.
+ *
+ * @return the value.
+ */
+ ValueMetaData getValue();
+
+ // Inner classes -------------------------------------------------
+}
+
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/PropertyInitializer.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/PropertyInitializer.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/PropertyInitializer.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,69 @@
+/*
+* 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.xml.pojoserver.metadata;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.xb.binding.metadata.ClassMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultWildcardHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingInitializer;
+
+/**
+ * ContainerInitializer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 40741 $
+ */
+public class PropertyInitializer implements SchemaBindingInitializer
+{
+ public static final String NS = "dummy://www.jboss.org/property";
+
+ private static final QName propertyQName = new QName(NS, "property");
+ private static final QName valueQName = new QName(NS, "value");
+
+ public SchemaBinding init(SchemaBinding schema)
+ {
+ ElementBinding element = schema.getElement(propertyQName);
+ ClassMetaData classMetaData = new ClassMetaData();
+ classMetaData.setImpl(AbstractPropertyMetaData.class.getName());
+ element.setClassMetaData(classMetaData);
+ element.getType().getWildcard().setWildcardHandler(new DefaultWildcardHandler()
+ {
+ public void setParent(Object parent, Object o, QName elementName, ElementBinding element, ElementBinding parentElement)
+ {
+ AbstractPropertyMetaData property = (AbstractPropertyMetaData) parent;
+ if (o instanceof ValueMetaData == false)
+ o = new AbstractValueMetaData(o);
+ property.setValue((ValueMetaData) o);
+ }
+ });
+
+ element = schema.getElement(valueQName);
+ classMetaData = new ClassMetaData();
+ classMetaData.setImpl(StringValueMetaData.class.getName());
+ element.setClassMetaData(classMetaData);
+
+ return schema;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/PropertyMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/PropertyMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/PropertyMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,43 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public interface PropertyMetaData extends FeatureMetaData
+{
+ /**
+ * Get the name.
+ *
+ * @return the name.
+ */
+ String getName();
+
+ /**
+ * Get the value.
+ *
+ * @return the value.
+ */
+ ValueMetaData getValue();
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/StringValueMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/StringValueMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/StringValueMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,65 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * String value.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public class StringValueMetaData extends AbstractTypeMetaData
+{
+ /**
+ * Create a new string value
+ */
+ public StringValueMetaData()
+ {
+ }
+
+ /**
+ * Create a new string value
+ *
+ * @param value the value
+ */
+ public StringValueMetaData(String value)
+ {
+ super(value);
+ }
+
+ /**
+ * Set the value
+ *
+ * @param value the value
+ */
+ public void setValue(String value)
+ {
+ super.setValue(value);
+ }
+
+ public void setValue(Object value)
+ {
+ if (value != null && value instanceof String == false)
+ throw new ClassCastException("value is not a String: " + value);
+ super.setValue(value);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/SupplyMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/SupplyMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/SupplyMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,42 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 37406 $
+ */
+public interface SupplyMetaData extends FeatureMetaData
+{
+ // Constants -----------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Get what is supplied
+ *
+ * @return the supply
+ */
+ Object getSupply();
+
+ // Inner classes -------------------------------------------------
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ValueMetaData.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ValueMetaData.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/pojoserver/metadata/ValueMetaData.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,38 @@
+/*
+ * 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.xml.pojoserver.metadata;
+
+/**
+ * Metadata about a value.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+public interface ValueMetaData
+{
+ /**
+ * Get the underlying value
+ *
+ * @return the underlying value
+ */
+ public Object getUnderlyingValue();
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice1.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice1.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice1.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,100 @@
+/*
+ * 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.xml.sandbox;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Choice1
+{
+ private String a;
+ private String b;
+
+ public Choice1()
+ {
+ }
+
+ public Choice1(String a, String b)
+ {
+ this.a = a;
+ this.b = b;
+ }
+
+ public String getA()
+ {
+ return a;
+ }
+
+ public void setA(String a)
+ {
+ this.a = a;
+ }
+
+ public String getB()
+ {
+ return b;
+ }
+
+ public void setB(String b)
+ {
+ this.b = b;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Choice1))
+ {
+ return false;
+ }
+
+ final Choice1 choice1 = (Choice1)o;
+
+ if(a != null ? !a.equals(choice1.a) : choice1.a != null)
+ {
+ return false;
+ }
+ if(b != null ? !b.equals(choice1.b) : choice1.b != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (a != null ? a.hashCode() : 0);
+ result = 29 * result + (b != null ? b.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[a=" + a + ", b=" + b + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice2.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice2.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice2.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,117 @@
+/*
+ * 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.xml.sandbox;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Choice2
+{
+ private String c;
+ private String d;
+ private String e;
+
+ public Choice2()
+ {
+ }
+
+ public Choice2(String c, String d, String e)
+ {
+ this.c = c;
+ this.d = d;
+ this.e = e;
+ }
+
+ public String getC()
+ {
+ return c;
+ }
+
+ public void setC(String c)
+ {
+ this.c = c;
+ }
+
+ public String getD()
+ {
+ return d;
+ }
+
+ public void setD(String d)
+ {
+ this.d = d;
+ }
+
+ public String getE()
+ {
+ return e;
+ }
+
+ public void setE(String e)
+ {
+ this.e = e;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Choice2))
+ {
+ return false;
+ }
+
+ final Choice2 choice2 = (Choice2)o;
+
+ if(c != null ? !c.equals(choice2.c) : choice2.c != null)
+ {
+ return false;
+ }
+ if(d != null ? !d.equals(choice2.d) : choice2.d != null)
+ {
+ return false;
+ }
+ if(e != null ? !e.equals(choice2.e) : choice2.e != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (c != null ? c.hashCode() : 0);
+ result = 29 * result + (d != null ? d.hashCode() : 0);
+ result = 29 * result + (e != null ? e.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[c=" + c + ", d=" + d + ", e=" + e + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice3.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice3.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Choice3.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,102 @@
+/*
+ * 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.xml.sandbox;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Choice3
+{
+ private Collection listOfIntegers;
+ private Collection listOfStrings;
+
+ public Choice3()
+ {
+ }
+
+ public Choice3(Collection listOfIntegers, Collection listOfStrings)
+ {
+ this.listOfIntegers = listOfIntegers;
+ this.listOfStrings = listOfStrings;
+ }
+
+ public Collection getListOfIntegers()
+ {
+ return listOfIntegers;
+ }
+
+ public void setListOfIntegers(Collection listOfIntegers)
+ {
+ this.listOfIntegers = listOfIntegers;
+ }
+
+ public Collection getListOfStrings()
+ {
+ return listOfStrings;
+ }
+
+ public void setListOfStrings(Collection listOfStrings)
+ {
+ this.listOfStrings = listOfStrings;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Choice3))
+ {
+ return false;
+ }
+
+ final Choice3 choice3 = (Choice3)o;
+
+ if(listOfIntegers != null ? !listOfIntegers.equals(choice3.listOfIntegers) : choice3.listOfIntegers != null)
+ {
+ return false;
+ }
+ if(listOfStrings != null ? !listOfStrings.equals(choice3.listOfStrings) : choice3.listOfStrings != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (listOfIntegers != null ? listOfIntegers.hashCode() : 0);
+ result = 29 * result + (listOfStrings != null ? listOfStrings.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[listOfIntegers=" + listOfIntegers + ", listOfStrigns=" + listOfStrings + "]";
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Root.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Root.java 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/sandbox/Root.java 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,108 @@
+/*
+ * 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.xml.sandbox;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 37406 $</tt>
+ */
+public class Root
+{
+ private Collection choiceCollection1;
+ private Collection choice2;
+ private Collection choice3;
+
+ public Collection getChoice3()
+ {
+ return choice3;
+ }
+
+ public void setChoice3(Collection choice3)
+ {
+ this.choice3 = choice3;
+ }
+
+ public Collection getChoiceCollection1()
+ {
+ return choiceCollection1;
+ }
+
+ public void setChoiceCollection1(Collection choiceCollection1)
+ {
+ this.choiceCollection1 = choiceCollection1;
+ }
+
+ public Collection getChoice2()
+ {
+ return choice2;
+ }
+
+ public void setChoice2(Collection choice2)
+ {
+ this.choice2 = choice2;
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Root))
+ {
+ return false;
+ }
+
+ final Root root = (Root)o;
+
+ if(choice2 != null ? !choice2.equals(root.choice2) : root.choice2 != null)
+ {
+ return false;
+ }
+ if(choice3 != null ? !choice3.equals(root.choice3) : root.choice3 != null)
+ {
+ return false;
+ }
+ if(choiceCollection1 != null ? !choiceCollection1.equals(root.choiceCollection1) : root.choiceCollection1 != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (choiceCollection1 != null ? choiceCollection1.hashCode() : 0);
+ result = 29 * result + (choice2 != null ? choice2.hashCode() : 0);
+ result = 29 * result + (choice3 != null ? choice3.hashCode() : 0);
+ return result;
+ }
+
+ public String toString()
+ {
+ return "[choiceCollection1=" + choiceCollection1 + ", choice2=" + choice2 + ", choice3=" + choice3 + "]";
+ }
+}
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<containerStrict
+xmlns="dummy://www.jboss.org/container"
+/>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="dummy://www.jboss.org/container"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0"
+>
+ <element name="containerStrict">
+ <complexType>
+ <sequence>
+ <xsd:any namespace="##other" processContents="strict"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="containerLax">
+ <complexType>
+ <sequence>
+ <xsd:any namespace="##other" processContents="lax"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="containerSkip">
+ <complexType>
+ <sequence>
+ <xsd:any namespace="##other" processContents="skip"/>
+ </sequence>
+ </complexType>
+ </element>
+
+</schema>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxNotSimple.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxNotSimple.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxNotSimple.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<containerLax
+xmlns="dummy://www.jboss.org/container"
+>
+ <simple:test
+ xmlns:simple="dummy://www.jboss.org/notsimple"
+ >Should ignore this</simple:test>
+</containerLax>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxSimple.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxSimple.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxSimple.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<containerLax
+xmlns="dummy://www.jboss.org/container"
+>
+ <simple:test
+ xmlns:simple="dummy://www.jboss.org/simple"
+ >ContainerLax</simple:test>
+</containerLax>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipNotSimple.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipNotSimple.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipNotSimple.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<containerSkip
+xmlns="dummy://www.jboss.org/container"
+>
+ <simple:test
+ xmlns:simple="dummy://www.jboss.org/notsimple"
+ >Should ignore this</simple:test>
+</containerSkip>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipSimple.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipSimple.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipSimple.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<containerSkip
+xmlns="dummy://www.jboss.org/container"
+>
+ <simple:test
+ xmlns:simple="dummy://www.jboss.org/simple"
+ >ContainerSkip</simple:test>
+</containerSkip>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictNotSimple.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictNotSimple.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictNotSimple.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<containerStrict
+xmlns="dummy://www.jboss.org/container"
+>
+ <simple:test
+ xmlns:simple="dummy://www.jboss.org/notsimple"
+ >This should cause an error</simple:test>
+</containerStrict>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictSimple.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictSimple.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictSimple.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<containerStrict
+xmlns="dummy://www.jboss.org/container"
+>
+ <simple:test
+ xmlns:simple="dummy://www.jboss.org/simple"
+ >ContainerStrict</simple:test>
+</containerStrict>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<test
+xmlns="dummy://www.jboss.org/simple"
+>SimpleTest</test>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="dummy://www.jboss.org/simple"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0"
+>
+ <element name="test"/>
+
+</schema>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCase.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCase.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCase.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="dummy://www.jboss.org/property"
+ targetNamespace="dummy://www.jboss.org/property"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0"
+>
+ <xsd:element name="value" type="valueType"/>
+
+ <xsd:group name="values">
+ <xsd:choice>
+ <xsd:element ref="value"/>
+ <xsd:any namespace="##other" processContents="strict"/>
+ </xsd:choice>
+ </xsd:group>
+
+ <xsd:complexType name="valueType" mixed="true"/>
+
+ <xsd:element name="property">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="values"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseSimple.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseSimple.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseSimple.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<property xmlns="dummy://www.jboss.org/property">
+ <value>testSimple</value>
+</property>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseWildcard.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseWildcard.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseWildcard.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<property xmlns="dummy://www.jboss.org/property">
+ <simple:test xmlns:simple="dummy://www.jboss.org/simple">testWildcard</simple:test>
+</property>
Added: jbossxb/trunk/src/test/resources/xml/SchemaIncludeUnitTestCase.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/SchemaIncludeUnitTestCase.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/SchemaIncludeUnitTestCase.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A prototype xsd schema for the pojoserver xml deployer
+$Id: SchemaIncludeUnitTestCase.xsd 43382 2006-04-04 13:54:01Z adrian $
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:bean-deployer:2.0"
+ xmlns="urn:jboss:bean-deployer:2.0"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="2.0">
+
+ <xsd:include schemaLocation="SchemaIncludeUnitTestCaseIncluded.xsd"/>
+
+ <xsd:complexType name="deploymentType">
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/SchemaIncludeUnitTestCaseIncluded.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/SchemaIncludeUnitTestCaseIncluded.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/SchemaIncludeUnitTestCaseIncluded.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A prototype xsd schema for the pojoserver xml deployer
+$Id: SchemaIncludeUnitTestCaseIncluded.xsd 43382 2006-04-04 13:54:01Z adrian $
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:bean-deployer:2.0"
+ xmlns="urn:jboss:bean-deployer:2.0"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="2.0">
+
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/annotated-bean-deployer_1_0.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/annotated-bean-deployer_1_0.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/annotated-bean-deployer_1_0.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,898 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A prototype xsd schema for the pojoserver xml deployer
+$Id: annotated-bean-deployer_1_0.xsd 39207 2005-12-21 22:49:56Z adrian $
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:bean-deployer"
+ xmlns="urn:jboss:bean-deployer"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0"
+>
+
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The xml deployer schema. The deployment document instance
+ root element should reference the schema in the root
+ deployment element using something like:
+
+ <deployment
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ ...
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:schemaBindings>
+ <jaxb:package name="org.jboss.test.xml.pojoserver.metadata"/>
+ </jaxb:schemaBindings>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:element name="deployment" type="deploymentType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The root of the xml deployer instance document
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+
+ <xsd:complexType name="deploymentType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The deployment contains a number of beans and bean factories.
+
+ e.g.
+ <deployment ...>
+ <bean .../>
+ <bean .../>
+ <beanfactory .../>
+ </deployment>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.deployment.AbstractKernelDeployment"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="bean" type="beanType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="beans" collectionType="java.util.ArrayList"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="beanfactory" type="beanfactoryType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="beans" collectionType="java.util.ArrayList"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+
+ <xsd:complexType name="beanType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The bean is an instance of a pojo.
+
+ e.g.
+ <bean name="MyName" class="com.acme.POJO">
+ <constructor .../>
+ <property .../>
+ <property .../>
+ <depends .../>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractBeanMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="constructor" type="constructorType" minOccurs="0"/>
+ <xsd:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="properties" collectionType="java.util.HashSet"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="create" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="start" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="stop" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="destroy" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="depends" type="dependsType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="depends" collectionType="java.util.HashSet"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="demand" type="demandType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="demands" collectionType="java.util.HashSet"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="supply" type="supplyType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="supplies" collectionType="java.util.HashSet"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="class" type="xsd:token" use="required">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="bean"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="mode" type="controllerModeType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="beanfactoryType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The beanfactory is a org.jboss.beans.metadata.plugins.factory.GenericBeanFactory deployment.
+ This gives you a factory such you can invoke createBean() multiple times with the guarantee
+ that the injected objects are "installed".
+
+ e.g.
+ <bean name="User" class="com.acme.User">
+ <property name="factory"><inject bean="Factory"/></property>
+ </bean>
+
+ <beanfactory name="Factory" class="com.acme.SomeBean">
+ <property name="someProperty"><inject bean="SomeOtherBean"/></property>
+ </beanFactory>
+
+ package com.acme.User;
+ public class User {
+ // factory has been configured at this point
+ public void setFactory(GenericBeanFactory factory) {
+ SomeBean bean1 = factory.createBean();
+ System.out.println(bean1.getSomeProperty()); // "SomeOtherBean"
+ SomeBean bean2 = factory.createBean();
+ System.out.println(bean2.getSomeProperty()); // "SomeOtherBean"
+ }
+ }
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="constructor" type="constructorType" minOccurs="0"/>
+ <xsd:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="class" type="xsd:token" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="constructorType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The constructor for this bean(factory) instance.
+
+ e.g. simple constructor - new POJO(new String("String value"));
+ <bean name="MyBean" class="com.acme.POJO">
+ <constructor>
+ <parameter>String value</parameter>
+ </constructor>
+ </bean>
+
+ e.g. static factory - com.acme.Factory.newInstance(new String("String value"));
+ <bean name="MyBean" class="com.acme.POJO">
+ <constructor factoryClass="com.acme.Factory" factoryMethod="newInstance">
+ <parameter>String value</parameter>
+ </constructor>
+ </bean>
+
+ e.g. instance factory - "SomeOtherBean".newInstance(new String("String value"));
+ <bean name="MyBean" class="com.acme.POJO">
+ <constructor factoryMethod="newInstance">
+ <factory bean="SomeOtherBean"/>
+ <parameter>String value</parameter>
+ </constructor>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractConstructorMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="factory" type="dependencyType" minOccurs="0"/>
+ <xsd:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="parameters" collectionType="java.util.ArrayList"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="factoryClass" type="classNameType" use="optional"/>
+ <xsd:attribute name="factoryMethod" type="xsd:token" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="lifecycleType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The lifecycle lets you override the method parameters passed to the
+ create, start, stop, destroy lifecycle callbacks.
+
+ e.g.
+ <bean>
+ <create method="initialize">
+ <parameter>String value</parameter>
+ </create>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractLifecycleMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="method" type="xsd:token" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="dependencyType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A dependency represents an injection into the bean.
+ They can be used anywhere a string value can appear.
+
+ e.g. Bean instance - "InjectedIntoMe".setSomeProperty("BeanInjected");
+ <bean name="InjectedIntoMe" ...>
+ <property name="someProperty"><inject bean="BeanInjected"/>
+ </bean>
+ <bean name="BeanInjected" .../>
+
+ e.g. Bean property - "InjectedIntoMe".setSomeProperty("BeanInjected".getOtherProperty());
+ <bean name="InjectedIntoMe" ...>
+ <property name="someProperty"><inject bean="BeanInjected" property="otherProperty"/>
+ </bean>
+ <bean name="BeanInjected" .../>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractDependencyValueMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:attribute name="bean" type="xsd:string" use="required">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="property" type="xsd:string" use="optional"/>
+ <xsd:attribute name="state" type="controllerStateType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="parameterType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A parameter is used to define the constructor, factory
+ and lifecycle method usage.
+
+ e.g. Using number of parameters when this is unique enough
+ <bean ...>
+ <constructor>
+ <parameter>1st Parameter</parameter>
+ <parameter>2nd Parameter</parameter>
+ </constructor>
+ </bean>
+
+ e.g. Explicitly stating the parameter type to resolve overloading
+ <bean ...>
+ <constructor>
+ <parameter>1st Parameter</parameter>
+ <parameter class="java.lang.String">2nd Parameter</parameter>
+ </constructor>
+ </bean>
+
+ e.g. To override the injected type use <value/>
+ <bean ...>
+ <constructor>
+ <parameter>1st Parameter</parameter>
+ <!-- Parameter is java.lang.Object, but we inject a String -->
+ <parameter class="java.lang.Object">
+ <value class="java.lang.String">2nd Parameter</value>
+ </parameter>
+ </constructor>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractParameterMetaData"/>
+ <jaxb:characters>
+ <jaxb:property name="value"/>
+ </jaxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="annotatedValueType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertyType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A property defines values passed to the setters.
+
+ e.g. Using the type from the setter argument
+ <bean ...>
+ <property name="someProperty">Some value</property>
+ </bean>
+
+ e.g. Overridding the injected type
+ <bean ...>
+ <property name="someProperty" class="java.lang.String">Some value</property>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractPropertyMetaData"/>
+ <jaxb:characters>
+ <jaxb:property name="value"/>
+ </jaxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="namedValueType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="annotationType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The annotation type represents an annotation on the particular join point.
+ TODO: This is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="attribute" type="annotationAttributeType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="annotationAttributeType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ An attribute attached to a particular annotation.
+ TODO: This is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="value" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:simpleType name="classNameType">
+ <xsd:annotation>
+ <xsd:documentation> The elements that use this type designate the name
+ of a Java class or interface. The name is in the form of a "binary
+ name", as defined in the JLS and as used in Class.forName().
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:group name="valueGroup">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The value group represents the comment elements of the other configurations
+ <parameter/>, <property/> or collection components
+ e.g.
+
+ <property name="someProperty">
+ <list><value class="java.lang.String">Hello</value></list>
+ </property>
+
+ e.g. This also defines the null value
+ <property name="someProperty"><null/></property>
+ as opposed to the empty string
+ <property name="someProperty"></property>
+ or the string "null"
+ <property name="someProperty">null</property>
+
+ TODO: "any" is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice>
+ <xsd:element name="value" type="plainValueType"/>
+ <xsd:element name="collection" type="collectionType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="list" type="listType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="set" type="setType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="array" type="arrayType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="map" type="mapType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="inject" type="dependencyType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="null">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="value"/>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractValueMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType/>
+ </xsd:element>
+ <xsd:any namespace="##other" processContents="strict">
+ <xsd:annotation>
+ <xsd:documentation>An extension value</xsd:documentation>
+ </xsd:annotation>
+ </xsd:any>
+ </xsd:choice>
+ </xsd:group>
+
+ <xsd:complexType name="plainValueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A simple value, used in collections and to specify a type for parameters.
+
+ e.g.
+ <parameter><value class="com.acme.MyClass">xxx</value></parameter>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.StringValueMetaData"/>
+ <jaxb:characters>
+ <jaxb:property name="value"/>
+ </jaxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:attribute name="class" type="classNameType" use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="type"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:complexType name="valueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A value that can take other values, i.e. properties and parameters.
+
+ e.g.
+ <parameter><value class="com.acme.MyClass">xxx</value></parameter>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="plainValueType">
+ <xsd:sequence>
+ <xsd:choice minOccurs="0">
+ <xsd:group ref="valueGroup"/>
+ </xsd:choice>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="annotatedValueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A value that can take annotations.
+ TODO: This is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="valueType">
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="namedValueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A value that has a name, currently only a property.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="annotatedValueType">
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="baseCollectionType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A collection defines a java.util.Collection object.
+ It has two class definitions:
+ class: The implementation class of the collection
+ elementClass: The default implementation class of the elements
+ The default "class" is a java.util.ArrayList unless the point of injection
+ defines a concrete type, e.g. in the signature of the setter
+
+ example:
+ <property name="whatever" class="java.util.ArrayList" elementClass="java.net.URL">
+ <value>http://localhost</value> <!-- Creates a URL -->
+ <value class="java.lang.String">http://localhost</value> <!-- Creates a String -->
+ </property>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:group ref="valueGroup"/>
+ </xsd:choice>
+ <xsd:attribute name="class" type="classNameType" use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="type"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="elementClass" type="classNameType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="collectionType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A collection, see baseCollectionType
+ the default collection is a java.util.ArrayList
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractCollectionMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="listType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A list, see baseCollectionType
+ the default list is a java.util.ArrayList
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractListMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="setType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A set, see baseCollectionType
+ the default set is a java.util.HashSet
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractSetMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="arrayType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ An array, see baseCollectionType
+ the default array is a java.lang.Object[]
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractArrayMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="mapType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A map defines a java.util.Map object.
+ It has three class definitions:
+ class: The implementation class of the class
+ keyClass: The default implementation class of the keys
+ valueClass: The default implementation class of the values
+ The default "class" is a java.util.HashMap unless the point of injection
+ defines a concrete type, e.g. in the signature of the setter
+
+ e.g.:
+ <property name="whatever" class="java.util.HashMap" keyClass="java.lang.String" valueClas="java.net.URL">
+ <!-- map.put(new String("default"), new URL("http://localhost"));
+ <entry><key>default</key><value>http://localhost</value>
+ <!-- map.put(new String("default"), new String("http://localhost"));
+ <entry><key>default</key><value class="java.lang.String">http://localhost</value>
+ </property>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractMapMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="entry" type="entryType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="class" type="classNameType" use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="type"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="keyClass" type="classNameType" use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="keyType"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="valueClass" type="classNameType" use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="valueType"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:complexType name="entryType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ An entry in map. These are made of key/value pairs
+
+ e.g.:
+ <entry><key>default</key><value>http://localhost</value>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="key" type="valueType" minOccurs="0"/>
+ <xsd:element name="value" type="valueType" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="dependsType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The depends element is used to define that one bean depends upon
+ another for the create/start/stop/destroy lifecycle
+
+ e.g.:
+ <bean name="IGoFirst" .../>
+ <bean name="IGoSecond" ...>
+ <depends>IGoFirst</depends>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractDependencyMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="demandType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The demand is used to specify a dependency on a supply
+ and when the demand is should be deplied
+
+ e.g.:
+ ISupply must be installed before IDemand is constructed
+
+ <bean name="IDemand" ... whenRequired="Instantiated">
+ <demand>theSupply</demand>
+ </bean>
+ <bean name="ISupply" ...>
+ <supply>theSupply</supply>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.pojoserver.metadata.AbstractDemandMetaData"/>
+ <jaxb:characters>
+ <jaxb:property name="demand"/>
+ </jaxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="whenRequired" type="controllerStateType" use="optional"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="supplyType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The supply is used to specify that the bean supplies a demanded dependency
+
+ e.g.:
+ <bean name="IDemand" ...>
+ <demand>theSupply</demand>
+ </bean>
+ <bean name="ISupply" ...>
+ <supply>theSupply</supply>
+ </bean>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:simpleType name="controllerStateType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The controller state is used to say when dependencies must be satisfied.
+ Valid values include:
+ Described
+ Instantiated
+ Configured
+ Create
+ Start
+ Installed
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jaxb:value name="org.jboss.test.xml.pojoserver.metadata.ControllerState"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="controllerModeType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The controller mode, used to control how automatic the bean progresses
+ through the controller lifecyle (the states).
+ Valid values include:
+ Automatic (default) - the controller takes the bean to "Installed"
+ Manual - the user must tell the controller the required state
+ On Demand - the controller takes the bean to "Installed" when another bean depends on it
+ Disabled - the controller or user cannot change the state
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!--
+ WARN:
+ Do not use this in the bean deployer, it won't work!
+ FIXME:
+ The correct way to do this is to have two separate
+ schemas (one for deployments the other for beans)
+ then use schema imports.
+ -->
+ <xsd:element name="bean" type="beanType"/>
+
+ <!--
+ WARN:
+ Do not use this in the bean deployer, it won't work!
+ FIXME:
+ The correct way to do this is to have two separate
+ schemas (one for deployments the other for beans)
+ then use schema imports.
+ -->
+ <xsd:element name="beanfactory" type="beanfactoryType"/>
+
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/any.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/any.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/any.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.org/test/xml/any any.xsd"
+ xmlns="http://www.jboss.org/test/xml/any">
+
+ <id>any test</id>
+ <any-content>
+ <collections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.org/test/xml/collections collections.xsd"
+ xmlns="http://www.jboss.org/test/xml/collections">
+
+ <stringArray>str1</stringArray>
+ <stringArray>str2</stringArray>
+ <stringArray>str3</stringArray>
+
+ <intCol>1</intCol>
+ <intCol>2</intCol>
+ <intCol>3</intCol>
+
+ <itemArray>
+ <item>item1</item>
+ <item>item2</item>
+ <item>item3</item>
+ </itemArray>
+
+ <itemCol>
+ <item>item4</item>
+ <item>item5</item>
+ <item>item6</item>
+ </itemCol>
+
+ <intArray>1</intArray>
+ <intArray>0</intArray>
+ <intArray>-1</intArray>
+ </collections>
+ </any-content>
+
+</container>
Added: jbossxb/trunk/src/test/resources/xml/any.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/any.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/any.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.jboss.org/test/xml/any"
+ xmlns="http://www.jboss.org/test/xml/any"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:complexType name="container">
+ <xsd:sequence>
+ <xsd:element name="id" type="xsd:string"/>
+ <xsd:element name="any-content" type="xsd:anyType"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="container" type="container"/>
+
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/aop/bean.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/aop/bean.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/aop/bean.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer">
+ <bean name="Aspectized" class="org.jboss.test.xml.aop.Aspectized"/>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/aop/test-aop.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/aop/test-aop.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/aop/test-aop.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop xmlns="urn:jboss:aop-deployer">
+
+ <interceptor name="SimpleInterceptor">
+ <class>
+ <beanfactory xmlns="urn:jboss:bean-deployer" class="org.jboss.test.xml.aop.SimpleInterceptor">
+ <constructor>
+ <parameter>Hello</parameter>
+ </constructor>
+ <property name="second">World</property>
+ </beanfactory>
+ </class>
+ </interceptor>
+
+ <bind pointcut="execution(* org.jboss.test.xml.aop.Aspectized->*(..))">
+ <interceptor-ref name="SimpleInterceptor"/>
+ </bind>
+
+</aop>
Added: jbossxb/trunk/src/test/resources/xml/bean-deployer_1_0.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/bean-deployer_1_0.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/bean-deployer_1_0.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,688 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A prototype xsd schema for the pojoserver xml deployer
+$Id: bean-deployer_1_0.xsd 39207 2005-12-21 22:49:56Z adrian $
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:bean-deployer"
+ xmlns="urn:jboss:bean-deployer"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The xml deployer schema. The deployment document instance
+ root element should reference the schema in the root
+ deployment element using something like:
+
+ <deployment
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ ...
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <xsd:element name="deployment" type="deploymentType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The root of the xml deployer instance document
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+
+ <xsd:complexType name="deploymentType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The deployment contains a number of beans and bean factories.
+
+ e.g.
+ <deployment ...>
+ <bean .../>
+ <bean .../>
+ <beanfactory .../>
+ </deployment>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="bean" type="beanType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="beanfactory" type="beanfactoryType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:choice>
+ </xsd:complexType>
+
+ <xsd:complexType name="beanType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The bean is an instance of a pojo.
+
+ e.g.
+ <bean name="MyName" class="com.acme.POJO">
+ <constructor .../>
+ <property .../>
+ <property .../>
+ <depends .../>
+ </bean>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="constructor" type="constructorType" minOccurs="0"/>
+ <xsd:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="create" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="start" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="stop" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="destroy" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="depends" type="dependsType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="demand" type="demandType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="supply" type="supplyType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="class" type="xsd:token" use="required"/>
+ <xsd:attribute name="mode" type="controllerModeType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="beanfactoryType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The beanfactory is a org.jboss.beans.metadata.plugins.factory.GenericBeanFactory deployment.
+ This gives you a factory such you can invoke createBean() multiple times with the guarantee
+ that the injected objects are "installed".
+
+ e.g.
+ <bean name="User" class="com.acme.User">
+ <property name="factory"><inject bean="Factory"/></property>
+ </bean>
+
+ <beanfactory name="Factory" class="com.acme.SomeBean">
+ <property name="someProperty"><inject bean="SomeOtherBean"/></property>
+ </beanFactory>
+
+ package com.acme.User;
+ public class User {
+ // factory has been configured at this point
+ public void setFactory(GenericBeanFactory factory) {
+ SomeBean bean1 = factory.createBean();
+ System.out.println(bean1.getSomeProperty()); // "SomeOtherBean"
+ SomeBean bean2 = factory.createBean();
+ System.out.println(bean2.getSomeProperty()); // "SomeOtherBean"
+ }
+ }
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="constructor" type="constructorType" minOccurs="0"/>
+ <xsd:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="class" type="xsd:token" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="constructorType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The constructor for this bean(factory) instance.
+
+ e.g. simple constructor - new POJO(new String("String value"));
+ <bean name="MyBean" class="com.acme.POJO">
+ <constructor>
+ <parameter>String value</parameter>
+ </constructor>
+ </bean>
+
+ e.g. static factory - com.acme.Factory.newInstance(new String("String value"));
+ <bean name="MyBean" class="com.acme.POJO">
+ <constructor factoryClass="com.acme.Factory" factoryMethod="newInstance">
+ <parameter>String value</parameter>
+ </constructor>
+ </bean>
+
+ e.g. instance factory - "SomeOtherBean".newInstance(new String("String value"));
+ <bean name="MyBean" class="com.acme.POJO">
+ <constructor factoryMethod="newInstance">
+ <factory bean="SomeOtherBean"/>
+ <parameter>String value</parameter>
+ </constructor>
+ </bean>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="factory" type="dependencyType" minOccurs="0"/>
+ <xsd:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="factoryClass" type="classNameType" use="optional"/>
+ <xsd:attribute name="factoryMethod" type="xsd:token" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="lifecycleType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The lifecycle lets you override the method parameters passed to the
+ create, start, stop, destroy lifecycle callbacks.
+
+ e.g.
+ <bean>
+ <create method="initialize">
+ <parameter>String value</parameter>
+ </create>
+ </bean>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="method" type="xsd:token" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="dependencyType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A dependency represents an injection into the bean.
+ They can be used anywhere a string value can appear.
+
+ e.g. Bean instance - "InjectedIntoMe".setSomeProperty("BeanInjected");
+ <bean name="InjectedIntoMe" ...>
+ <property name="someProperty"><inject bean="BeanInjected"/>
+ </bean>
+ <bean name="BeanInjected" .../>
+
+ e.g. Bean property - "InjectedIntoMe".setSomeProperty("BeanInjected".getOtherProperty());
+ <bean name="InjectedIntoMe" ...>
+ <property name="someProperty"><inject bean="BeanInjected" property="otherProperty"/>
+ </bean>
+ <bean name="BeanInjected" .../>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="bean" type="xsd:string" use="required"/>
+ <xsd:attribute name="property" type="xsd:string" use="optional"/>
+ <xsd:attribute name="state" type="controllerStateType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="parameterType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A parameter is used to define the constructor, factory
+ and lifecycle method usage.
+
+ e.g. Using number of parameters when this is unique enough
+ <bean ...>
+ <constructor>
+ <parameter>1st Parameter</parameter>
+ <parameter>2nd Parameter</parameter>
+ </constructor>
+ </bean>
+
+ e.g. Explicitly stating the parameter type to resolve overloading
+ <bean ...>
+ <constructor>
+ <parameter>1st Parameter</parameter>
+ <parameter class="java.lang.String">2nd Parameter</parameter>
+ </constructor>
+ </bean>
+
+ e.g. To override the injected type use <value/>
+ <bean ...>
+ <constructor>
+ <parameter>1st Parameter</parameter>
+ <!-- Parameter is java.lang.Object, but we inject a String -->
+ <parameter class="java.lang.Object">
+ <value class="java.lang.String">2nd Parameter</value>
+ </parameter>
+ </constructor>
+ </bean>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="annotatedValueType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertyType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A property defines values passed to the setters.
+
+ e.g. Using the type from the setter argument
+ <bean ...>
+ <property name="someProperty">Some value</property>
+ </bean>
+
+ e.g. Overridding the injected type
+ <bean ...>
+ <property name="someProperty" class="java.lang.String">Some value</property>
+ </bean>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="namedValueType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="annotationType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The annotation type represents an annotation on the particular join point.
+ TODO: This is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="attribute" type="annotationAttributeType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="annotationAttributeType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ An attribute attached to a particular annotation.
+ TODO: This is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="value" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:simpleType name="classNameType">
+ <xsd:annotation>
+ <xsd:documentation> The elements that use this type designate the name
+ of a Java class or interface. The name is in the form of a "binary
+ name", as defined in the JLS and as used in Class.forName().
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:group name="valueGroup">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The value group represents the comment elements of the other configurations
+ <parameter/>, <property/> or collection components
+ e.g.
+
+ <property name="someProperty">
+ <list><value class="java.lang.String">Hello</value></list>
+ </property>
+
+ e.g. This also defines the null value
+ <property name="someProperty"><null/></property>
+ as opposed to the empty string
+ <property name="someProperty"></property>
+ or the string "null"
+ <property name="someProperty">null</property>
+
+ TODO: "any" is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice>
+ <xsd:element name="value" type="plainValueType"/>
+ <xsd:element name="collection" type="collectionType"/>
+ <xsd:element name="list" type="listType"/>
+ <xsd:element name="set" type="setType"/>
+ <xsd:element name="array" type="arrayType"/>
+ <xsd:element name="map" type="mapType"/>
+ <xsd:element name="inject" type="dependencyType"/>
+ <xsd:element name="null">
+ <xsd:complexType/>
+ </xsd:element>
+ <xsd:any namespace="##other" processContents="strict">
+ <xsd:annotation>
+ <xsd:documentation>An extension value</xsd:documentation>
+ </xsd:annotation>
+ </xsd:any>
+ </xsd:choice>
+ </xsd:group>
+
+ <xsd:complexType name="plainValueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A simple value, used in collections and to specify a type for parameters.
+
+ e.g.
+ <parameter><value class="com.acme.MyClass">xxx</value></parameter>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="class" type="classNameType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="valueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A value that can take other values, i.e. properties and parameters.
+
+ e.g.
+ <parameter><value class="com.acme.MyClass">xxx</value></parameter>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="plainValueType">
+ <xsd:sequence>
+ <xsd:choice minOccurs="0">
+ <xsd:group ref="valueGroup"/>
+ </xsd:choice>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="annotatedValueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A value that can take annotations.
+ TODO: This is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="valueType">
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="namedValueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A value that has a name, currently only a property.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="annotatedValueType">
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="baseCollectionType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A collection defines a java.util.Collection object.
+ It has two class definitions:
+ class: The implementation class of the collection
+ elementClass: The default implementation class of the elements
+ The default "class" is a java.util.ArrayList unless the point of injection
+ defines a concrete type, e.g. in the signature of the setter
+
+ example:
+ <property name="whatever" class="java.util.ArrayList" elementClass="java.net.URL">
+ <value>http://localhost</value> <!-- Creates a URL -->
+ <value class="java.lang.String">http://localhost</value> <!-- Creates a String -->
+ </property>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:group ref="valueGroup"/>
+ </xsd:choice>
+ <xsd:attribute name="class" type="classNameType" use="optional"/>
+ <xsd:attribute name="elementClass" type="classNameType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="collectionType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A collection, see baseCollectionType
+ the default collection is a java.util.ArrayList
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="listType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A list, see baseCollectionType
+ the default list is a java.util.ArrayList
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="setType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A set, see baseCollectionType
+ the default set is a java.util.HashSet
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="arrayType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ An array, see baseCollectionType
+ the default array is a java.lang.Object[]
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="mapType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A map defines a java.util.Map object.
+ It has three class definitions:
+ class: The implementation class of the class
+ keyClass: The default implementation class of the keys
+ valueClass: The default implementation class of the values
+ The default "class" is a java.util.HashMap unless the point of injection
+ defines a concrete type, e.g. in the signature of the setter
+
+ e.g.:
+ <property name="whatever" class="java.util.HashMap" keyClass="java.lang.String" valueClas="java.net.URL">
+ <!-- map.put(new String("default"), new URL("http://localhost"));
+ <entry><key>default</key><value>http://localhost</value>
+ <!-- map.put(new String("default"), new String("http://localhost"));
+ <entry><key>default</key><value class="java.lang.String">http://localhost</value>
+ </property>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="entry" type="entryType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="class" type="classNameType" use="optional"/>
+ <xsd:attribute name="keyClass" type="classNameType" use="optional"/>
+ <xsd:attribute name="valueClass" type="classNameType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="entryType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ An entry in map. These are made of key/value pairs
+
+ e.g.:
+ <entry><key>default</key><value>http://localhost</value>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="key" type="valueType" minOccurs="0"/>
+ <xsd:element name="value" type="valueType" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="dependsType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The depends element is used to define that one bean depends upon
+ another for the create/start/stop/destroy lifecycle
+
+ e.g.:
+ <bean name="IGoFirst" .../>
+ <bean name="IGoSecond" ...>
+ <depends>IGoFirst</depends>
+ </bean>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="demandType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The demand is used to specify a dependency on a supply
+ and when the demand is should be deplied
+
+ e.g.:
+ ISupply must be installed before IDemand is constructed
+
+ <bean name="IDemand" ... whenRequired="Instantiated">
+ <demand>theSupply</demand>
+ </bean>
+ <bean name="ISupply" ...>
+ <supply>theSupply</supply>
+ </bean>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="whenRequired" type="controllerStateType" use="optional"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="supplyType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The supply is used to specify that the bean supplies a demanded dependency
+
+ e.g.:
+ <bean name="IDemand" ...>
+ <demand>theSupply</demand>
+ </bean>
+ <bean name="ISupply" ...>
+ <supply>theSupply</supply>
+ </bean>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:simpleType name="controllerStateType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The controller state is used to say when dependencies must be satisfied.
+ Valid values include:
+ Described
+ Instantiated
+ Configured
+ Create
+ Start
+ Installed
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="controllerModeType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The controller mode, used to control how automatic the bean progresses
+ through the controller lifecyle (the states).
+ Valid values include:
+ Automatic (default) - the controller takes the bean to "Installed"
+ Manual - the user must tell the controller the required state
+ On Demand - the controller takes the bean to "Installed" when another bean depends on it
+ Disabled - the controller or user cannot change the state
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!--
+ WARN:
+ Do not use this in the bean deployer, it won't work!
+ FIXME:
+ The correct way to do this is to have two separate
+ schemas (one for deployments the other for beans)
+ then use schema imports.
+ -->
+ <xsd:element name="bean" type="beanType"/>
+
+ <!--
+ WARN:
+ Do not use this in the bean deployer, it won't work!
+ FIXME:
+ The correct way to do this is to have two separate
+ schemas (one for deployments the other for beans)
+ then use schema imports.
+ -->
+ <xsd:element name="beanfactory" type="beanfactoryType"/>
+
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/book/annotated_books.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/book/annotated_books.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/book/annotated_books.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsd:schema
+ targetNamespace="http://example.org/ns/books/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:bk="http://example.org/ns/books/"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
+
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:schemaBindings>
+ <jaxb:package name="org.jboss.test.xml.book"/>
+ </jaxb:schemaBindings>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:element name="book">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="title" type="xsd:string"/>
+ <xsd:element name="author" type="xsd:string"/>
+ <xsd:element name="character" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property name="characters" collectionType="java.util.ArrayList"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:class implClass="org.jboss.test.xml.book.BookCharacter"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="friend-of" type="xsd:string" minOccurs="0" maxOccurs="1"/>
+
+ <xsd:element name="since" type="xsd:date">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jaxb:property>
+ <jaxb:baseType>
+ <jaxb:javaType
+ name="java.lang.String"
+ parseMethod="org.jboss.test.xml.book.DateDatatypeConverter.unmarshal"
+ printMethod="org.jboss.test.xml.book.DateDatatypeConverter.marshal"/>
+ </jaxb:baseType>
+ </jaxb:property>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+
+ <xsd:element name="qualification" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="isbn" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/book/book-dtd.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/book/book-dtd.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/book/book-dtd.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//DTD Books//EN" "resources/xml/book/books.dtd">
+
+<book isbn="0836217462">
+ <title>Being a Dog Is a Full-Time Job</title>
+ <author>Charles M. Schulz</author>
+ <character>
+ <name>Snoopy</name>
+ <friend-of>Peppermint Patty</friend-of>
+ <since>1950-10-04</since>
+ <qualification>extroverted beagle</qualification>
+ </character>
+ <character>
+ <name>Peppermint Patty</name>
+ <since>1966-08-22</since>
+ <qualification>bold, brash and tomboyish</qualification>
+ </character>
+</book>
Added: jbossxb/trunk/src/test/resources/xml/book/book-xs.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/book/book-xs.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/book/book-xs.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<book
+ isbn="0836217462"
+ xmlns="http://example.org/ns/books/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://example.org/ns/books/ resources/xml/book/books.xsd">
+
+ <title>Being a Dog Is a Full-Time Job</title>
+ <author>Charles M. Schulz</author>
+ <character>
+ <name>Snoopy</name>
+ <friend-of>Peppermint Patty</friend-of>
+ <since>1950-10-04</since>
+ <qualification>extroverted beagle</qualification>
+ </character>
+ <character>
+ <name>Peppermint Patty</name>
+ <since>1966-08-22</since>
+ <qualification>bold, brash and tomboyish</qualification>
+ </character>
+</book>
Added: jbossxb/trunk/src/test/resources/xml/book/books.dtd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/book/books.dtd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/book/books.dtd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,15 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!ELEMENT book (title, author, character*)>
+<!ATTLIST book isbn CDATA #REQUIRED>
+
+<!ELEMENT title (#PCDATA)>
+
+<!ELEMENT author (#PCDATA)>
+
+<!ELEMENT character (name, friend-of?, since?, qualification?)>
+
+<!ELEMENT name (#PCDATA)>
+<!ELEMENT friend-of (#PCDATA)>
+<!ELEMENT since (#PCDATA)>
+<!ELEMENT qualification (#PCDATA)>
Added: jbossxb/trunk/src/test/resources/xml/book/books.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/book/books.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/book/books.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsd:schema
+ targetNamespace="http://example.org/ns/books/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:bk="http://example.org/ns/books/"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+ <xsd:element name="book">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="title" type="xsd:string"/>
+ <xsd:element name="author" type="xsd:string"/>
+ <xsd:element name="character" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="friend-of" type="xsd:string" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="since" type="xsd:date"/>
+ <xsd:element name="qualification" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="isbn" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/choice.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/choice.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/choice.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsd:schema
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.jboss.org/test/xml/choice/"
+ elementFormDefault="qualified">
+
+<!--
+WARN: this schema is broken. If validator is used it will complain, e.g. like this
+'During validation against this schema, ambiguity would be created for those two particles.'
+Used for choice groups marshalling tests.
+-->
+
+ <xsd:element name="root">
+ <xsd:complexType>
+ <xsd:sequence>
+
+ <xsd:element name="choice1" maxOccurs="3">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="a" type="xsd:string"/>
+ <xsd:element name="b" type="xsd:string"/>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="choice2" maxOccurs="2">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:sequence>
+ <xsd:element name="a" type="xsd:string"/>
+ <xsd:element name="b" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:sequence>
+ <xsd:element name="a" type="xsd:string"/>
+ <xsd:element name="c" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/collections.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/collections.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/collections.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<collections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.org/test/xml/collections collections.xsd"
+ xmlns="http://www.jboss.org/test/xml/collections">
+
+ <stringArray>str1</stringArray>
+ <stringArray>str2</stringArray>
+ <stringArray>str3</stringArray>
+
+ <intCol>1</intCol>
+ <intCol>2</intCol>
+ <intCol>3</intCol>
+
+ <itemArray>
+ <item>item1</item>
+ <item>item2</item>
+ <item>item3</item>
+ </itemArray>
+
+ <itemCol>
+ <item>item4</item>
+ <item>item5</item>
+ <item>item6</item>
+ </itemCol>
+
+ <intArray>1</intArray>
+ <intArray>0</intArray>
+ <intArray>-1</intArray>
+</collections>
Added: jbossxb/trunk/src/test/resources/xml/collections.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/collections.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/collections.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.jboss.org/test/xml/collections"
+ xmlns="http://www.jboss.org/test/xml/collections"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:complexType name="collections">
+ <xsd:sequence>
+ <xsd:element name="stringArray" type="xsd:string" maxOccurs="unbounded"/>
+ <xsd:element name="intCol" type="xsd:int" maxOccurs="unbounded"/>
+ <xsd:element name="itemArray" type="arrayItem"/>
+ <xsd:element name="itemCol" type="arrayItem"/>
+ <xsd:element name="intArray" type="xsd:int" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="arrayItem">
+ <xsd:sequence>
+ <xsd:element name="item" type="xsd:string" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/immutable.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/immutable.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/immutable.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsd:schema
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.jboss.org/test/xml/immutable/"
+ elementFormDefault="qualified">
+
+ <xsd:element name="parent">
+ <xsd:complexType>
+ <xsd:sequence>
+
+ <xsd:element name="child1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="child2" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="other-children" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="child3" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="immutable-choice" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="choice1" type="xsd:string"/>
+ <xsd:element name="child1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/jbxb/characters/schema1.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/jbxb/characters/schema1.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/jbxb/characters/schema1.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ targetNamespace="urn:jboss:jbxb-characters-schema1"
+ elementFormDefault="qualified"
+ >
+ <xs:element name="binding">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.characters.Binding"/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:choice minOccurs="1" maxOccurs="1">
+ <xs:element name="value">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:property name="text"/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="type" type="xs:string" use="optional" default="java.lang.String"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="value2">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.characters.Binding$Value2"/>
+ <jbxb:characters>
+ <jbxb:property name="text"/>
+ </jbxb:characters>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:simpleContent>
+ <xs:extension base="xs:string"/>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="value3">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.characters.Binding$Value3"/>
+ <jbxb:characters>
+ <jbxb:value unmarshalMethod="org.jboss.test.xml.jbxb.characters.Binding$Value3.unmarshalChars"/>
+ <jbxb:property name="chars"/>
+ </jbxb:characters>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="attr" type="xs:string" use="optional"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="value4">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.characters.Binding$Value4"/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:simpleContent>
+ <xs:extension base="xs:string"/>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ <xs:any namespace="##other">
+ <xs:annotation>
+ <xs:documentation>An extension point for arbitrary xml value fragments</xs:documentation>
+ </xs:annotation>
+ </xs:any>
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/jbxb/characters/testSchema1.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/jbxb/characters/testSchema1.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/jbxb/characters/testSchema1.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<binding xmlns="urn:jboss:jbxb-characters-schema1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:jbxb-characters-schema1 schema1.xsd"
+ name="root">
+ <value>value1</value>
+</binding>
Added: jbossxb/trunk/src/test/resources/xml/jbxb/defaults/schema1.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/jbxb/defaults/schema1.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/jbxb/defaults/schema1.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ targetNamespace="urn:jboss:jbxb-defaults-schema1"
+ elementFormDefault="qualified"
+ >
+ <xs:element name="jbean">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.defaults.JBean"/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attribute name="attr1" type="xs:string" default="DefaultValue" />
+ <xs:attribute name="attr2" type="xs:int" default="12345" />
+ <xs:attribute name="attr3" type="xs:boolean" default="true" />
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/jbxb/defaults/schema2.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/jbxb/defaults/schema2.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/jbxb/defaults/schema2.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ targetNamespace="urn:jboss:jbxb-defaults-schema2"
+ elementFormDefault="qualified"
+ >
+ <xs:element name="jbean">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.defaults.JBean"/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="attr1" type="xs:string" default="DefaultValue" />
+ <xs:attribute name="attr2" type="xs:int" default="12345" />
+ <xs:attribute name="attr3" type="xs:boolean" default="true" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/jbxb/defaults/testSchema1.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/jbxb/defaults/testSchema1.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/jbxb/defaults/testSchema1.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbean xmlns="urn:jboss:jbxb-defaults-schema1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:jbxb-defaults-schema1 schema1.xsd"
+ attr2="123"
+/>
Added: jbossxb/trunk/src/test/resources/xml/jbxb/defaults/testSchema2.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/jbxb/defaults/testSchema2.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/jbxb/defaults/testSchema2.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbean xmlns="urn:jboss:jbxb-defaults-schema2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:jbxb-defaults-schema2 schema2.xsd"
+ attr2="123"
+/>
Added: jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/schema1.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/schema1.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/schema1.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ targetNamespace="urn:jboss:jbxb-minOccurs-schema1"
+ xmlns:x="urn:jboss:jbxb-minOccurs-schema1"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ >
+ <xs:element name="jbean">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.defaults.JBean"/>
+ </xs:appinfo>
+ </xs:annotation>
+
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" ref="x:element1" />
+ <xs:element minOccurs="0" ref="x:element2" />
+ </xs:sequence>
+ <xs:attribute name="attr1" type="xs:string" default="DefaultValue" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="element1" type="xs:string">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.defaults.JBean"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:element name="element2" type="xs:string">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.defaults.JBean"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/schema1v2.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/schema1v2.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/schema1v2.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ targetNamespace="urn:jboss:jbxb-minOccurs-schema1"
+ xmlns:x="urn:jboss:jbxb-minOccurs-schema1"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ >
+ <xs:element name="jbean">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.defaults.JBean"/>
+ </xs:appinfo>
+ </xs:annotation>
+
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="element1" type="x:elementType1" minOccurs="0">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.defaults.JBean"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="element2" type="x:elementType1" minOccurs="0">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.jbxb.defaults.JBean"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="attr1" type="xs:string" default="DefaultValue" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="elementType1">
+ <xs:attribute name="attr1" type="xs:string" default="AnotherDefaultValue" />
+ <xs:attribute name="attr2" type="xs:int" default="1234" />
+ </xs:complexType>
+
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/testSchema1.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/testSchema1.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/jbxb/minOccurs/testSchema1.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbean xmlns="urn:jboss:jbxb-minOccurs-schema1"
+ attr1="123">
+ <element2 />
+</jbean>
Added: jbossxb/trunk/src/test/resources/xml/jbxb-bean-deployer_1_0.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/jbxb-bean-deployer_1_0.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/jbxb-bean-deployer_1_0.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,929 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A prototype xsd schema for the pojoserver xml deployer
+$Id: jbxb-bean-deployer_1_0.xsd 39207 2005-12-21 22:49:56Z adrian $
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:bean-deployer"
+ xmlns="urn:jboss:bean-deployer"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0"
+>
+
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The xml deployer schema. The deployment document instance
+ root element should reference the schema in the root
+ deployment element using something like:
+
+ <deployment
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ ...
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:schemaBindings>
+ <jbxb:package name="org.jboss.test.xml.pojoserver.metadata"/>
+ <jbxb:ignoreUnresolvedFieldOrClass>false</jbxb:ignoreUnresolvedFieldOrClass>
+ </jbxb:schemaBindings>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:element name="deployment" type="deploymentType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The root of the xml deployer instance document
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+
+ <xsd:complexType name="deploymentType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The deployment contains a number of beans and bean factories.
+
+ e.g.
+ <deployment ...>
+ <bean .../>
+ <bean .../>
+ <beanfactory .../>
+ </deployment>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.deployment.AbstractKernelDeployment"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="bean" type="beanType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="beans" collectionType="java.util.ArrayList"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="beanfactory" type="beanfactoryType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="beans" collectionType="java.util.ArrayList"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+
+ <xsd:complexType name="beanType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The bean is an instance of a pojo.
+
+ e.g.
+ <bean name="MyName" class="com.acme.POJO">
+ <constructor .../>
+ <property .../>
+ <property .../>
+ <depends .../>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractBeanMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="constructor" type="constructorType" minOccurs="0"/>
+ <xsd:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="properties" collectionType="java.util.HashSet"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="create" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="start" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="stop" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="destroy" type="lifecycleType" minOccurs="0"/>
+ <xsd:element name="depends" type="dependsType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="depends" collectionType="java.util.HashSet"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="demand" type="demandType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="demands" collectionType="java.util.HashSet"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="supply" type="supplyType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="supplies" collectionType="java.util.HashSet"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="class" type="xsd:token" use="required">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="bean"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="mode" type="controllerModeType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="beanfactoryType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The beanfactory is a org.jboss.beans.metadata.plugins.factory.GenericBeanFactory deployment.
+ This gives you a factory such you can invoke createBean() multiple times with the guarantee
+ that the injected objects are "installed".
+
+ e.g.
+ <bean name="User" class="com.acme.User">
+ <property name="factory"><inject bean="Factory"/></property>
+ </bean>
+
+ <beanfactory name="Factory" class="com.acme.SomeBean">
+ <property name="someProperty"><inject bean="SomeOtherBean"/></property>
+ </beanFactory>
+
+ package com.acme.User;
+ public class User {
+ // factory has been configured at this point
+ public void setFactory(GenericBeanFactory factory) {
+ SomeBean bean1 = factory.createBean();
+ System.out.println(bean1.getSomeProperty()); // "SomeOtherBean"
+ SomeBean bean2 = factory.createBean();
+ System.out.println(bean2.getSomeProperty()); // "SomeOtherBean"
+ }
+ }
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="constructor" type="constructorType" minOccurs="0"/>
+ <xsd:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="class" type="xsd:token" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="constructorType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The constructor for this bean(factory) instance.
+
+ e.g. simple constructor - new POJO(new String("String value"));
+ <bean name="MyBean" class="com.acme.POJO">
+ <constructor>
+ <parameter>String value</parameter>
+ </constructor>
+ </bean>
+
+ e.g. static factory - com.acme.Factory.newInstance(new String("String value"));
+ <bean name="MyBean" class="com.acme.POJO">
+ <constructor factoryClass="com.acme.Factory" factoryMethod="newInstance">
+ <parameter>String value</parameter>
+ </constructor>
+ </bean>
+
+ e.g. instance factory - "SomeOtherBean".newInstance(new String("String value"));
+ <bean name="MyBean" class="com.acme.POJO">
+ <constructor factoryMethod="newInstance">
+ <factory bean="SomeOtherBean"/>
+ <parameter>String value</parameter>
+ </constructor>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractConstructorMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="factory" type="dependencyType" minOccurs="0"/>
+ <xsd:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="parameters" collectionType="java.util.ArrayList"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="factoryClass" type="classNameType" use="optional"/>
+ <xsd:attribute name="factoryMethod" type="xsd:token" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="lifecycleType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The lifecycle lets you override the method parameters passed to the
+ create, start, stop, destroy lifecycle callbacks.
+
+ e.g.
+ <bean>
+ <create method="initialize">
+ <parameter>String value</parameter>
+ </create>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractLifecycleMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="method" type="xsd:token" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="dependencyType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A dependency represents an injection into the bean.
+ They can be used anywhere a string value can appear.
+
+ e.g. Bean instance - "InjectedIntoMe".setSomeProperty("BeanInjected");
+ <bean name="InjectedIntoMe" ...>
+ <property name="someProperty"><inject bean="BeanInjected"/>
+ </bean>
+ <bean name="BeanInjected" .../>
+
+ e.g. Bean property - "InjectedIntoMe".setSomeProperty("BeanInjected".getOtherProperty());
+ <bean name="InjectedIntoMe" ...>
+ <property name="someProperty"><inject bean="BeanInjected" property="otherProperty"/>
+ </bean>
+ <bean name="BeanInjected" .../>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractDependencyValueMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:attribute name="bean" type="xsd:string" use="required">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="property" type="xsd:string" use="optional"/>
+ <xsd:attribute name="state" type="controllerStateType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="annotationType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The annotation type represents an annotation on the particular join point.
+ TODO: This is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="attribute" type="annotationAttributeType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="annotationAttributeType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ An attribute attached to a particular annotation.
+ TODO: This is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="value" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:simpleType name="classNameType">
+ <xsd:annotation>
+ <xsd:documentation> The elements that use this type designate the name
+ of a Java class or interface. The name is in the form of a "binary
+ name", as defined in the JLS and as used in Class.forName().
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:group name="valueGroup">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The value group represents the comment elements of the other configurations
+ <parameter/>, <property/> or collection components
+ e.g.
+
+ <property name="someProperty">
+ <list><value class="java.lang.String">Hello</value></list>
+ </property>
+
+ e.g. This also defines the null value
+ <property name="someProperty"><null/></property>
+ as opposed to the empty string
+ <property name="someProperty"></property>
+ or the string "null"
+ <property name="someProperty">null</property>
+
+ TODO: "any" is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice>
+ <xsd:element name="value" type="plainValueType"/>
+ <xsd:element name="collection" type="collectionType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="list" type="listType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="set" type="setType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="array" type="arrayType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="map" type="mapType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="inject" type="dependencyType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="value"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="null">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="value"/>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractValueMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType/>
+ </xsd:element>
+ <xsd:any namespace="##other" processContents="strict">
+ <xsd:annotation>
+ <xsd:documentation>An extension value</xsd:documentation>
+ </xsd:annotation>
+ </xsd:any>
+ </xsd:choice>
+ </xsd:group>
+
+ <xsd:complexType name="plainValueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A simple value, used in collections and to specify a type for parameters.
+
+ e.g.
+ <parameter><value class="com.acme.MyClass">xxx</value></parameter>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.StringValueMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:attribute name="class" type="classNameType" use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="type"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:complexType name="valueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A value that can take other values, i.e. properties and parameters.
+
+ e.g.
+ <parameter><value class="com.acme.MyClass">xxx</value></parameter>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractValueMetaData"/>
+ <jbxb:characters>
+ <jbxb:property name="value"/>
+ <jbxb:value unmarshalMethod="org.jboss.test.xml.pojoserver.metadata.DataTypeConverter.unmarshalStringValue"/>
+ </jbxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="plainValueType">
+ <xsd:sequence>
+ <xsd:choice minOccurs="0">
+ <xsd:group ref="valueGroup"/>
+ </xsd:choice>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="annotatedValueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A value that can take annotations.
+ TODO: This is currently unimplemented.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="valueType">
+ <xsd:sequence>
+ <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="parameterType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A parameter is used to define the constructor, factory
+ and lifecycle method usage.
+
+ e.g. Using number of parameters when this is unique enough
+ <bean ...>
+ <constructor>
+ <parameter>1st Parameter</parameter>
+ <parameter>2nd Parameter</parameter>
+ </constructor>
+ </bean>
+
+ e.g. Explicitly stating the parameter type to resolve overloading
+ <bean ...>
+ <constructor>
+ <parameter>1st Parameter</parameter>
+ <parameter class="java.lang.String">2nd Parameter</parameter>
+ </constructor>
+ </bean>
+
+ e.g. To override the injected type use <value/>
+ <bean ...>
+ <constructor>
+ <parameter>1st Parameter</parameter>
+ <!-- Parameter is java.lang.Object, but we inject a String -->
+ <parameter class="java.lang.Object">
+ <value class="java.lang.String">2nd Parameter</value>
+ </parameter>
+ </constructor>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractParameterMetaData"/>
+ <jbxb:characters>
+ <jbxb:property name="value"/>
+ <jbxb:value unmarshalMethod="org.jboss.test.xml.pojoserver.metadata.DataTypeConverter.unmarshalStringValue"/>
+ </jbxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="annotatedValueType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="namedValueType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A value that has a name, currently only a property.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="annotatedValueType">
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="propertyType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A property defines values passed to the setters.
+
+ e.g. Using the type from the setter argument
+ <bean ...>
+ <property name="someProperty">Some value</property>
+ </bean>
+
+ e.g. Overridding the injected type
+ <bean ...>
+ <property name="someProperty" class="java.lang.String">Some value</property>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractPropertyMetaData"/>
+ <jbxb:characters>
+ <jbxb:property name="value"/>
+ <jbxb:value unmarshalMethod="org.jboss.test.xml.pojoserver.metadata.DataTypeConverter.unmarshalStringValue"/>
+ </jbxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="namedValueType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="baseCollectionType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A collection defines a java.util.Collection object.
+ It has two class definitions:
+ class: The implementation class of the collection
+ elementClass: The default implementation class of the elements
+ The default "class" is a java.util.ArrayList unless the point of injection
+ defines a concrete type, e.g. in the signature of the setter
+
+ example:
+ <property name="whatever" class="java.util.ArrayList" elementClass="java.net.URL">
+ <value>http://localhost</value> <!-- Creates a URL -->
+ <value class="java.lang.String">http://localhost</value> <!-- Creates a String -->
+ </property>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:group ref="valueGroup"/>
+ </xsd:choice>
+ <xsd:attribute name="class" type="classNameType" use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="type"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="elementClass" type="classNameType" use="optional"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="collectionType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A collection, see baseCollectionType
+ the default collection is a java.util.ArrayList
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractCollectionMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="listType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A list, see baseCollectionType
+ the default list is a java.util.ArrayList
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractListMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="setType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A set, see baseCollectionType
+ the default set is a java.util.HashSet
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractSetMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="arrayType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ An array, see baseCollectionType
+ the default array is a java.lang.Object[]
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractArrayMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="mapType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A map defines a java.util.Map object.
+ It has three class definitions:
+ class: The implementation class of the class
+ keyClass: The default implementation class of the keys
+ valueClass: The default implementation class of the values
+ The default "class" is a java.util.HashMap unless the point of injection
+ defines a concrete type, e.g. in the signature of the setter
+
+ e.g.:
+ <property name="whatever" class="java.util.HashMap" keyClass="java.lang.String" valueClas="java.net.URL">
+ <!-- map.put(new String("default"), new URL("http://localhost"));
+ <entry><key>default</key><value>http://localhost</value>
+ <!-- map.put(new String("default"), new String("http://localhost"));
+ <entry><key>default</key><value class="java.lang.String">http://localhost</value>
+ </property>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractMapMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="entry" type="entryType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="class" type="classNameType" use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="type"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="keyClass" type="classNameType" use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="keyType"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="valueClass" type="classNameType" use="optional">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="valueType"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:complexType name="entryType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ An entry in map. These are made of key/value pairs
+
+ e.g.:
+ <entry><key>default</key><value>http://localhost</value>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:mapEntry impl="org.jboss.test.xml.pojoserver.metadata.AbstractMapMetaDataEntry" getKeyMethod="getKey" setKeyMethod="setKey" getValueMethod="getValue" setValueMethod="setValue"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="key" type="valueType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryKey/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="value" type="valueType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryValue/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="dependsType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The depends element is used to define that one bean depends upon
+ another for the create/start/stop/destroy lifecycle
+
+ e.g.:
+ <bean name="IGoFirst" .../>
+ <bean name="IGoSecond" ...>
+ <depends>IGoFirst</depends>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractDependencyMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="demandType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The demand is used to specify a dependency on a supply
+ and when the demand is should be deplied
+
+ e.g.:
+ ISupply must be installed before IDemand is constructed
+
+ <bean name="IDemand" ... whenRequired="Instantiated">
+ <demand>theSupply</demand>
+ </bean>
+ <bean name="ISupply" ...>
+ <supply>theSupply</supply>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractDemandMetaData"/>
+ <jbxb:characters>
+ <jbxb:property name="demand"/>
+ </jbxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="whenRequired" type="controllerStateType" use="optional"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="supplyType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The supply is used to specify that the bean supplies a demanded dependency
+
+ e.g.:
+ <bean name="IDemand" ...>
+ <demand>theSupply</demand>
+ </bean>
+ <bean name="ISupply" ...>
+ <supply>theSupply</supply>
+ </bean>
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractSupplyMetaData"/>
+ <jbxb:characters>
+ <jbxb:property name="supply"/>
+ </jbxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:simpleType name="controllerStateType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The controller state is used to say when dependencies must be satisfied.
+ Valid values include:
+ Described
+ Instantiated
+ Configured
+ Create
+ Start
+ Installed
+ ]]>
+ </xsd:documentation>
+
+ <xsd:appinfo>
+ <jbxb:value name="org.jboss.test.xml.pojoserver.metadata.ControllerState"
+ unmarshalMethod="org.jboss.test.xml.pojoserver.metadata.ControllerStateDataTypeConverter.unmarshalStringValue"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="controllerModeType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ The controller mode, used to control how automatic the bean progresses
+ through the controller lifecyle (the states).
+ Valid values include:
+ Automatic (default) - the controller takes the bean to "Installed"
+ Manual - the user must tell the controller the required state
+ On Demand - the controller takes the bean to "Installed" when another bean depends on it
+ Disabled - the controller or user cannot change the state
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:whiteSpace value="collapse"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!--
+ WARN:
+ Do not use this in the bean deployer, it won't work!
+ FIXME:
+ The correct way to do this is to have two separate
+ schemas (one for deployments the other for beans)
+ then use schema imports.
+ -->
+ <xsd:element name="bean" type="beanType"/>
+
+ <!--
+ WARN:
+ Do not use this in the bean deployer, it won't work!
+ FIXME:
+ The correct way to do this is to have two separate
+ schemas (one for deployments the other for beans)
+ then use schema imports.
+ -->
+ <xsd:element name="beanfactory" type="beanfactoryType"/>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/loginconfig/config.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/loginconfig/config.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/loginconfig/config.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: config.xml 34316 2005-07-31 23:13:44Z starksm $ -->
+
+<jaas:policy
+ xsi:schemaLocation="urn:jboss:security-config security-config_4_1.xsd"
+ xmlns:jaas="urn:jboss:security-config"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+ <jaas:application-policy name="conf1">
+ <jaas:authentication>
+ <jaas:login-module code="org.jboss.security.auth.spi.XMLLoginModule"
+ flag="required">
+ <jaas:module-option name="userInfo">
+ <ur:users
+ xsi:schemaLocation="urn:jboss:user-roles user-roles_1_0.xsd"
+ xmlns:ur="urn:jboss:user-roles">
+ <ur:user name="jduke" password="theduke">
+ <ur:role name="Role1"/>
+ <ur:role name="Role2"/>
+ <ur:role name="Echo"/>
+ <ur:role name="callerJduke" group="CallerPrincipal"/>
+ </ur:user>
+ <ur:user name="scott" password="echoman">
+ <ur:role name="Echo"/>
+ <ur:role name="ProjectUser"/>
+ <ur:role name="callerScott" group="CallerPrincipal"/>
+ </ur:user>
+ <ur:user name="stark" password="javaman">
+ <ur:role name="Java"/>
+ <ur:role name="Coder"/>
+ <ur:role name="callerStark" group="CallerPrincipal"/>
+ </ur:user>
+ <ur:user name="jdukeman" password="anotherduke">
+ <ur:role name="Role2"/>
+ <ur:role name="Role3"/>
+ <ur:role name="callerJdukeman" group="CallerPrincipal"/>
+ </ur:user>
+ <ur:user name="invoker" password="invoker">
+ <ur:role name="HttpInvoker"/>
+ </ur:user>
+ <ur:user name="admin" password="admin">
+ <ur:role name="JBossAdmin"/>
+ </ur:user>
+ </ur:users>
+ </jaas:module-option>
+ <jaas:module-option name="unauthenticatedIdentity">guest</jaas:module-option>
+ </jaas:login-module>
+ </jaas:authentication>
+ </jaas:application-policy>
+</jaas:policy>
Added: jbossxb/trunk/src/test/resources/xml/loginconfig/jaspi-config.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/loginconfig/jaspi-config.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/loginconfig/jaspi-config.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: jaspi-config.xml 39298 2005-12-27 21:55:57Z asaldhana $ -->
+
+<jbsx:policy
+ xsi:schemaLocation="urn:jboss:security-config security-config_5_0.xsd"
+ xmlns:jbsx="urn:jboss:security-config"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+ <jbsx:application-policy name="conf1">
+ <jbsx:authentication>
+ <jbsx:login-module code="org.jboss.security.auth.spi.XMLLoginModule"
+ flag="required">
+ <jbsx:module-option name="userInfo">
+ <ur:users
+ xsi:schemaLocation="urn:jboss:user-roles user-roles_1_0.xsd"
+ xmlns:ur="urn:jboss:user-roles">
+ <ur:user name="jduke" password="theduke">
+ <ur:role name="Role1"/>
+ <ur:role name="Role2"/>
+ <ur:role name="Echo"/>
+ <ur:role name="callerJduke" group="CallerPrincipal"/>
+ </ur:user>
+ <ur:user name="scott" password="echoman">
+ <ur:role name="Echo"/>
+ <ur:role name="ProjectUser"/>
+ <ur:role name="callerScott" group="CallerPrincipal"/>
+ </ur:user>
+ <ur:user name="stark" password="javaman">
+ <ur:role name="Java"/>
+ <ur:role name="Coder"/>
+ <ur:role name="callerStark" group="CallerPrincipal"/>
+ </ur:user>
+ <ur:user name="jdukeman" password="anotherduke">
+ <ur:role name="Role2"/>
+ <ur:role name="Role3"/>
+ <ur:role name="callerJdukeman" group="CallerPrincipal"/>
+ </ur:user>
+ <ur:user name="invoker" password="invoker">
+ <ur:role name="HttpInvoker"/>
+ </ur:user>
+ <ur:user name="admin" password="admin">
+ <ur:role name="JBossAdmin"/>
+ </ur:user>
+ </ur:users>
+ </jbsx:module-option>
+ <jbsx:module-option name="unauthenticatedIdentity">guest</jbsx:module-option>
+ </jbsx:login-module>
+ </jbsx:authentication>
+ </jbsx:application-policy>
+
+ <jbsx:application-policy name="conf-jaspi">
+ <jbsx:authentication-jaspi>
+ <jbsx:login-module-stack name="lm-stack">
+ <jbsx:login-module
+ code="org.jboss.security.auth.spi.UsersRolesLoginModule"
+ flag="required">
+ <jbsx:module-option name="usersProperties">props/jbossws-users.properties</jbsx:module-option>
+ <jbsx:module-option name="rolesProperties">props/jbossws-roles.properties</jbsx:module-option>
+ <jbsx:module-option name="unauthenticatedIdentity">anonymous</jbsx:module-option>
+ </jbsx:login-module>
+ </jbsx:login-module-stack>
+ <jbsx:auth-module code="auth.module1.class.name">
+ <jbsx:module-option name="usersProperties">props/jbossws-users.properties</jbsx:module-option>
+ <jbsx:module-option name="rolesProperties">props/jbossws-roles.properties</jbsx:module-option>
+ <jbsx:module-option name="unauthenticatedIdentity">anonymous</jbsx:module-option>
+ </jbsx:auth-module>
+
+ <jbsx:auth-module code="auth.module2.class.name" login-module-stack-ref="lm-stack"/>
+ </jbsx:authentication-jaspi>
+ </jbsx:application-policy>
+</jbsx:policy>
Added: jbossxb/trunk/src/test/resources/xml/loginconfig/security-config_4_1.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/loginconfig/security-config_4_1.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/loginconfig/security-config_4_1.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: security-config_4_1.xsd 45786 2006-06-23 19:01:35Z asaldhana $ -->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ xmlns:jaas="urn:jboss:security-config"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ targetNamespace="urn:jboss:security-config">
+
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:schemaBindings>
+ <jbxb:package name="org.jboss.security.config"/>
+ </jbxb:schemaBindings>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:element name="policy">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.security.config.PolicyConfig"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" ref="jaas:application-policy"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="application-policy">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.security.config.ApplicationPolicyContainer"/>
+ <jbxb:addMethod name="add" valueType="org.jboss.security.config.ApplicationPolicy"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:sequence>
+ <xsd:element ref="jaas:authentication"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="authentication">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:skip/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="jaas:login-module"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="login-module">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.security.auth.login.AppConfigurationEntryHolder"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" ref="jaas:module-option"/>
+ </xsd:sequence>
+ <xsd:attribute name="code" use="required" type="xsd:string"/>
+ <xsd:attribute name="flag" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="required" />
+ <xsd:enumeration value="requisite" />
+ <xsd:enumeration value="sufficient" />
+ <xsd:enumeration value="optional" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="module-option">
+ <xsd:complexType mixed="true">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <!-- ModuleOption declares a constructor that takes name as a parameter
+ while the value should be set with the setter.
+ This use-case is not supported out-of-the-box. So, we use this container. -->
+ <jbxb:class impl="org.jboss.security.auth.login.ModuleOptionContainer"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" namespace="##other" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/loginconfig/security-config_5_0.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/loginconfig/security-config_5_0.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/loginconfig/security-config_5_0.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: security-config_5_0.xsd 45787 2006-06-23 19:02:45Z asaldhana $ -->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ xmlns:jbsx="urn:jboss:security-config"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ targetNamespace="urn:jboss:security-config">
+
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:schemaBindings>
+ <jbxb:package name="org.jboss.security.config"/>
+ <jbxb:ignoreUnresolvedFieldOrClass>
+ false</jbxb:ignoreUnresolvedFieldOrClass>
+ </jbxb:schemaBindings>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:element name="policy">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
+ impl="org.jboss.security.config.PolicyConfig"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" ref="jbsx:application-policy"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="application-policy">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.security.config.ApplicationPolicyContainer"/>
+ <jbxb:addMethod name="add" valueType="org.jboss.security.config.ApplicationPolicy"/>
+ </xsd:appinfo>
+
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:choice>
+ <xsd:element ref="jbsx:authentication"/>
+ <xsd:element ref="jbsx:authentication-jaspi"/>
+ </xsd:choice>
+ <xsd:element minOccurs="0" maxOccurs="1"
+ ref="jbsx:authorization"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="authentication">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:skip/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="jbsx:login-module"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="login-module">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
+ impl="org.jboss.security.auth.login.AppConfigurationEntryHolder"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="unbounded"
+ ref="jbsx:module-option"/>
+ </xsd:sequence>
+ <xsd:attribute name="code" use="required" type="xsd:string"/>
+ <xsd:attribute name="flag" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="required"/>
+ <xsd:enumeration value="requisite"/>
+ <xsd:enumeration value="sufficient"/>
+ <xsd:enumeration value="optional"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="module-option">
+ <xsd:complexType mixed="true">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <!-- ModuleOption declares a constructor that takes name as a parameter
+ while the value should be set with the setter.
+
+ This use-case is not supported out-of-the-box. So, we use this container. -->
+ <jbxb:class
+ impl="org.jboss.security.auth.login.ModuleOptionContainer"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" namespace="##other"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="authentication-jaspi">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:skip/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element maxOccurs="unbounded" ref="jbsx:login-module-stack"/>
+ <xsd:element maxOccurs="unbounded" ref="jbsx:auth-module"/>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="login-module-stack">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
+ impl="org.jboss.security.auth.login.LoginModuleStackContainer"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element minOccurs="1" maxOccurs="unbounded"
+ ref="jbsx:login-module"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="auth-module">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
+ impl="org.jboss.security.auth.container.config.AuthModuleEntryHolder"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="unbounded"
+ ref="jbsx:module-option"/>
+ </xsd:sequence>
+ <xsd:attribute name="code" use="required" type="xsd:string"/>
+ <xsd:attribute name="login-module-stack-ref" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="authorization">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:skip/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="jbsx:policy-module"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="policy-module">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class
+ impl="org.jboss.security.authorization.config.AuthorizationConfigEntryHolder"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="unbounded"
+ ref="jbsx:module-option"/>
+ </xsd:sequence>
+ <xsd:attribute name="code" use="required" type="xsd:string"/>
+ <xsd:attribute name="flag" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="required"/>
+ <xsd:enumeration value="requisite"/>
+ <xsd:enumeration value="sufficient"/>
+ <xsd:enumeration value="optional"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/loginconfig/user-roles_1_0.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/loginconfig/user-roles_1_0.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/loginconfig/user-roles_1_0.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: user-roles_1_0.xsd 34316 2005-07-31 23:13:44Z starksm $ -->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ targetNamespace="urn:jboss:user-roles"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ xmlns:ur="urn:jboss:user-roles">
+
+ <xsd:element name="users">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.security.auth.spi.Users"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="1" maxOccurs="unbounded" ref="ur:user"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="user">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.security.auth.spi.Users$User"/>
+ <jbxb:addMethod name="addUser" valueType="child"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="unbounded" ref="ur:role"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:NCName"/>
+ <xsd:attribute name="password" use="required" type="xsd:NCName"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="role">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntry/>
+ <jbxb:putMethod name="addRole"
+ keyType="java.lang.String" valueType="java.lang.String" />
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:complexType>
+ <xsd:attribute name="group" use="optional" type="xsd:NCName" default="Roles">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryValue/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="name" use="required" type="xsd:NCName">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryKey/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/maps.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/maps.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/maps.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,20 @@
+<map
+ xmlns="http://www.jboss.org/test/xml/maps"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <entry1>
+ <key1>key1</key1>
+ <value1>value1</value1>
+ </entry1>
+ <entry2 key2="key2">
+ <value2>value2</value2>
+ </entry2>
+ <entry3 key3="key3" value3="value3"/>
+ <entry4 key4="key4">value4</entry4>
+
+ <key>key_1</key><value>value_1</value>
+ <key>key_2</key><value>value_2</value>
+
+ <submap key="submap">
+ <entry3 key3="submapKey" value3="submapValue"/>
+ </submap>
+</map>
Added: jbossxb/trunk/src/test/resources/xml/maps.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/maps.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/maps.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,233 @@
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.jboss.org/test/xml/maps"
+ xmlns="http://www.jboss.org/test/xml/maps"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:complexType name="mapType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ This type declares various elements that are bound to map entries.
+ This type itself is also bound to a map entry. The value of the map entry is bound to java.util.Map
+ (all the elements declared in this type are going to be bound to its entries)
+ and the key of the map entry is represented by the attribute "key" declared below.
+ ]]>
+ </xsd:documentation>
+ <xsd:appinfo>
+ <jbxb:mapEntry valueType="java.util.HashMap" nonNullValue="false"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="entry1" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ This element represents a map entry of the following style:
+ <entry>
+ <key>key_data</key>
+ <value>value_data</value>
+ </entry>
+ ]]>
+ </xsd:documentation>
+ <!-- specifying putMethod is optional if the parent is an instance of java.util.Map
+ <xsd:appinfo>
+ <jbxb:putMethod name="put" keyType="java.lang.Object" valueType="java.lang.Object"/>
+ </xsd:appinfo>
+ -->
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntry getKeyMethod="getKey" getValueMethod="getValue"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="key1" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryKey/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="value1" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryValue/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="entry2" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ This element represents a map entry of the following style:
+ <entry key="key_data">
+ <value>value_data</value>
+ </entry>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntry/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="value2" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryValue/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="key2" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryKey/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="entry3" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ This element represents a map entry of the following style:
+ <entry key="key_data" value="value_data"/>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntry/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:attribute name="key3" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryKey/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="value3" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryValue/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="entry4" minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ This element represents a map entry of the following style:
+ <entry key="key_data">value_data</entry>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntry/>
+ <jbxb:characters>
+ <jbxb:mapEntryValue/>
+ </jbxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="key4" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryKey/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ This is another kind of entry which is represented by a sequence of two elements.
+ ]]>
+ </xsd:documentation>
+ <xsd:appinfo>
+ <jbxb:mapEntry/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:element name="key" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryKey/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="value" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryValue/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+
+ <xsd:element name="submap" type="mapType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ This element also represents a map entry. But while previous entries contained text values,
+ this one has a value that is bound to java.util.Map as it is annotated in its complex type definition.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+
+ <xsd:attribute name="key" type="xsd:string">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[This attribute is bound to a map entry key.]]>
+ </xsd:documentation>
+ <xsd:appinfo>
+ <jbxb:mapEntryKey/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:element name="map" type="mapType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ Here, we declare an element of complex type map. Complex type map is bound to a map entry.
+ Elements inherit bindings from their types. So, this element inherits map entry binding metadata.
+ But that's not what we want for the root element in an XML content.
+ So, we override binding here using class annotation and bind this element to java.util.Map.
+ (See binding documentation: class and mapEntry are mutually exclusive)
+ ]]>
+ </xsd:documentation>
+ <xsd:appinfo>
+ <jbxb:class impl="java.util.HashMap"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/multispaced/jdbcpm.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/multispaced/jdbcpm.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/multispaced/jdbcpm.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jdbcpm="http://jboss.org/xmbean/persistence/jdbc"
+ targetNamespace="http://jboss.org/xmbean/persistence/jdbc"
+ elementFormDefault="qualified">
+
+ <xs:element name="persistence-manager">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="datasource" type="xs:string"/>
+ <xs:element name="table" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/multispaced/xmbean-localns.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/multispaced/xmbean-localns.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/multispaced/xmbean-localns.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,50 @@
+<xmbean:mbean
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation=
+ "http://jboss.org/xmbean resources/xml/multispaced/xmbean.xsd"
+ xmlns:xmbean="http://jboss.org/xmbean">
+
+ <xmbean:description>The JBoss XMBean version of the monitor server</xmbean:description>
+
+ <xmbean:class>monitor.MonitorPOJO</xmbean:class>
+ <xmbean:constructor>
+ <xmbean:description>The no-arg constructor</xmbean:description>
+ <xmbean:name>monitor.MonitorPOJO</xmbean:name>
+ </xmbean:constructor>
+
+ <xmbean:attribute
+ access="read-write"
+ getMethod="getInterval"
+ setMethod="setInterval">
+
+ <xmbean:description>
+ The interval in milliseconds between checks of VM memory and threads
+ </xmbean:description>
+
+ <xmbean:name>Interval</xmbean:name>
+ <xmbean:type>int</xmbean:type>
+ </xmbean:attribute>
+
+ <xmbean:operation>
+ <xmbean:description>Access the last HistoryLength monitor reports</xmbean:description>
+ <xmbean:name>history</xmbean:name>
+ <xmbean:return-type>java.lang.String</xmbean:return-type>
+ </xmbean:operation>
+
+ <xmbean:notification>
+ <xmbean:description>
+ A notification sent when the monitor interval expires
+ </xmbean:description>
+ <xmbean:name>javax.management.Notification</xmbean:name>
+ <xmbean:notification-type>monitor.IntervalElapsed</xmbean:notification-type>
+ </xmbean:notification>
+
+ <xmbean:persistence>
+ <jdbcpm:persistence-manager
+ xmlns:jdbcpm="http://jboss.org/xmbean/persistence/jdbc"
+ xsi:schemaLocation="http://jboss.org/xmbean/persistence/jdbc resources/xml/multispaced/jdbcpm.xsd">
+ <jdbcpm:datasource xmlns:xmbean="http://jboss.org/persistence/jdbc2">java:/DefaultDS</jdbcpm:datasource>
+ <jdbcpm:table>xmbeans</jdbcpm:table>
+ </jdbcpm:persistence-manager>
+ </xmbean:persistence>
+</xmbean:mbean>
Added: jbossxb/trunk/src/test/resources/xml/multispaced/xmbean.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/multispaced/xmbean.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/multispaced/xmbean.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,50 @@
+<xmbean:mbean
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation=
+ "http://jboss.org/xmbean resources/xml/multispaced/xmbean.xsd
+ http://jboss.org/xmbean/persistence/jdbc resources/xml/multispaced/jdbcpm.xsd"
+ xmlns:xmbean="http://jboss.org/xmbean"
+ xmlns:jdbcpm="http://jboss.org/xmbean/persistence/jdbc">
+
+ <xmbean:description>The JBoss XMBean version of the monitor server</xmbean:description>
+
+ <xmbean:class>monitor.MonitorPOJO</xmbean:class>
+ <xmbean:constructor>
+ <xmbean:description>The no-arg constructor</xmbean:description>
+ <xmbean:name>monitor.MonitorPOJO</xmbean:name>
+ </xmbean:constructor>
+
+ <xmbean:attribute
+ access="read-write"
+ getMethod="getInterval"
+ setMethod="setInterval">
+
+ <xmbean:description>
+ The interval in milliseconds between checks of VM memory and threads
+ </xmbean:description>
+
+ <xmbean:name>Interval</xmbean:name>
+ <xmbean:type>int</xmbean:type>
+ </xmbean:attribute>
+
+ <xmbean:operation>
+ <xmbean:description>Access the last HistoryLength monitor reports</xmbean:description>
+ <xmbean:name>history</xmbean:name>
+ <xmbean:return-type>java.lang.String</xmbean:return-type>
+ </xmbean:operation>
+
+ <xmbean:notification>
+ <xmbean:description>
+ A notification sent when the monitor interval expires
+ </xmbean:description>
+ <xmbean:name>javax.management.Notification</xmbean:name>
+ <xmbean:notification-type>monitor.IntervalElapsed</xmbean:notification-type>
+ </xmbean:notification>
+
+ <xmbean:persistence>
+ <jdbcpm:persistence-manager>
+ <jdbcpm:datasource xmlns:xmbean="http://jboss.org/persistence/jdbc2">java:/DefaultDS</jdbcpm:datasource>
+ <jdbcpm:table>xmbeans</jdbcpm:table>
+ </jdbcpm:persistence-manager>
+ </xmbean:persistence>
+</xmbean:mbean>
Added: jbossxb/trunk/src/test/resources/xml/multispaced/xmbean.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/multispaced/xmbean.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/multispaced/xmbean.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xmbean="http://jboss.org/xmbean"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ targetNamespace="http://jboss.org/xmbean"
+ elementFormDefault="qualified">
+
+ <xs:simpleType name="descriptionType">
+ <xs:restriction base="xs:string"/>
+ </xs:simpleType>
+
+ <xs:complexType name="constructorType">
+ <xs:sequence>
+ <xs:element name="description" type="xmbean:descriptionType"/>
+ <xs:element name="name" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="attributeType">
+ <xs:sequence>
+ <xs:element name="description" type="xmbean:descriptionType"/>
+ <xs:element name="name" type="xs:string"/>
+ <xs:element name="type" type="xs:string"/>
+ </xs:sequence>
+ <xs:attribute name="access" type="xs:string"/>
+ <xs:attribute name="getMethod" type="xs:string"/>
+ <xs:attribute name="setMethod" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:complexType name="operationType">
+ <xs:sequence>
+ <xs:element name="description" type="xmbean:descriptionType"/>
+ <xs:element name="name" type="xs:string"/>
+ <xs:element name="return-type" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="notificationType">
+ <xs:sequence>
+ <xs:element name="description" type="xmbean:descriptionType"/>
+ <xs:element name="name" type="xs:string"/>
+ <xs:element name="notification-type" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="xmbeanType">
+ <xs:sequence>
+ <xs:element name="description" type="xmbean:descriptionType"/>
+ <xs:element name="class" type="xs:string">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:property name="mbeanClass"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="constructor" type="xmbean:constructorType" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:property name="constructors"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="attribute" type="xmbean:attributeType" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:property name="attributes"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="operation" type="xmbean:operationType" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:property name="operations"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="notification" type="xmbean:notificationType" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:property name="notifications"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="persistence" type="xs:anyType">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:property name="persistenceManager"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="mbean" type="xmbean:xmbeanType"/>
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/naming/custom-object-binding.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/naming/custom-object-binding.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/naming/custom-object-binding.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema version="1.0" attributeFormDefault="unqualified"
+ elementFormDefault="qualified"
+ targetNamespace="urn:jboss:custom-object-binding"
+ xmlns:custom="urn:jboss:custom-object-binding"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ >
+ <xs:annotation>
+ <xs:documentation>A custom schema for specifying how a java.util.Properties
+ object is unmarshalled.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:element name="properties">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="java.util.Properties"/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="property" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:putMethod name="setProperty" keyType="java.lang.String" valueType="java.lang.String" />
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType id="propertyType">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:mapEntry/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="key" type="xs:string">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:mapEntryKey/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="value" type="xs:string">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:mapEntryValue/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/naming/jndi-binding-service_1_0.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/naming/jndi-binding-service_1_0.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/naming/jndi-binding-service_1_0.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema version="1.0beta" attributeFormDefault="unqualified"
+ elementFormDefault="qualified"
+ targetNamespace="urn:jboss:jndi-binding-service"
+ xmlns:jndi="urn:jboss:jndi-binding-service"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ >
+ <xs:annotation>
+ <xs:documentation>This schema defines the content model for the
+ JNDIBindingService BindingsConfig attribute content.<![CDATA[
+ <jndi:bindings xmlns:jndi="urn:jboss:jndi-binding-service"
+ version="1.0">
+ ...
+ </jndi:bindings>
+ ]]></xs:documentation>
+ <xs:appinfo>
+ <jbxb:schemaBindings>
+ <jbxb:ignoreUnresolvedFieldOrClass>false</jbxb:ignoreUnresolvedFieldOrClass>
+ <jbxb:replacePropertyRefs>true</jbxb:replacePropertyRefs>
+ </jbxb:schemaBindings>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:element name="bindings">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.naming.JNDIBindings"/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="binding" minOccurs="1"
+ maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:class impl="org.jboss.naming.JNDIBinding"/>
+ <jbxb:property name="Bindings" />
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:choice minOccurs="1" maxOccurs="1">
+ <xs:element name="value">
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:skip/>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:annotation>
+ <xs:appinfo>
+ <jbxb:characters>
+ <jbxb:property name="text"/>
+ </jbxb:characters>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="type" type="xs:string" use="optional">
+ </xs:attribute>
+ <xs:attribute name="editor" type="xs:string" use="optional">
+ </xs:attribute>
+ <xs:attribute name="trim" type="xs:boolean" default="true">
+ </xs:attribute>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ <xs:any namespace="##other">
+ <xs:annotation>
+ <xs:documentation>An extension point for arbitrary xml value fragments</xs:documentation>
+ <xs:appinfo>
+ <jbxb:property name="value"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:any>
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>The JNDI name of the binding</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/naming/testBindings.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/naming/testBindings.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/naming/testBindings.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jndi:bindings
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jndi="urn:jboss:jndi-binding-service"
+ xs:schemaLocation="urn:jboss:jndi-binding-service jndi-binding-service_1_0.xsd"
+ >
+ <jndi:binding name="ctx1/key1">
+ <jndi:value>value1</jndi:value>
+ </jndi:binding>
+ <jndi:binding name="ctx1/user.home">
+ <jndi:value>${user.home}</jndi:value>
+ </jndi:binding>
+ <jndi:binding name="ctx1/key2">
+ <jndi:value type="java.net.URL">http://www.jboss.org</jndi:value>
+ </jndi:binding>
+ <jndi:binding name="ctx2/key1">
+ <custom:properties xmlns:custom="urn:jboss:custom-object-binding"
+ xs:schemaLocation="urn:jboss:custom-object-binding custom-object-binding.xsd">
+ <custom:property>
+ <custom:key>key1</custom:key>
+ <custom:value>value1</custom:value>
+ </custom:property>
+ <custom:property>
+ <custom:key>key2</custom:key>
+ <custom:value>value2</custom:value>
+ </custom:property>
+ </custom:properties>
+ </jndi:binding>
+
+ <jndi:binding name="hosts/localhost">
+ <jndi:value editor="org.jboss.util.propertyeditor.InetAddressEditor">
+ 127.0.0.1
+ </jndi:value>
+ </jndi:binding>
+
+</jndi:bindings>
Added: jbossxb/trunk/src/test/resources/xml/newmetadata.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/newmetadata.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/newmetadata.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,44 @@
+<config>
+ <attribute>default value</attribute>
+ <attribute>
+ <value1>
+ <property>value1</property>
+ </value1>
+ </attribute>
+ <attribute>
+ <value2>value2</value2>
+ </attribute>
+
+ <beans>
+ <bean>
+ <name>A</name>
+ </bean>
+ <bean>
+ <name>B</name>
+ </bean>
+ </beans>
+
+ <list>
+ <value type="some.type">foo</value>
+ <depends value="SomeBean"/>
+ <list>
+ <value type="another.type">bar</value>
+ <depends value="AnotherBean"/>
+ </list>
+ </list>
+
+ <map>
+ <entry1>
+ <key1>key1</key1>
+ <value1>value1</value1>
+ </entry1>
+ <entry2 key2="key2">
+ <value2>value2</value2>
+ </entry2>
+ <entry3 key3="key3" value3="value3"/>
+ <entry4 key4="key4">value4</entry4>
+ <map key="submap">
+ <entry3 key3="submapKey3" value3="submapValue3"/>
+ </map>
+ </map>
+</config>
Added: jbossxb/trunk/src/test/resources/xml/person.dtd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/person.dtd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/person.dtd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,14 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!ELEMENT person (first-name, last-name, date-of-birth, phones, addresses)>
+
+<!ELEMENT first-name (#PCDATA)>
+<!ELEMENT last-name (#PCDATA)>
+<!ELEMENT date-of-birth (#PCDATA)>
+
+<!ELEMENT phones (phone*)>
+<!ELEMENT phone (#PCDATA)>
+
+<!ELEMENT addresses (address*)>
+<!ELEMENT address (street)>
+<!ELEMENT street (#PCDATA)>
Added: jbossxb/trunk/src/test/resources/xml/person.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/person.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/person.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE person PUBLIC "-//DTD Person//EN" "resources/xml/person.dtd">
+
+<person>
+ <first-name>Vasiliy</first-name>
+ <last-name>Poupkin</last-name>
+ <date-of-birth>1980-01-01</date-of-birth>
+ <phones>
+ <phone>01</phone>
+ <phone>02</phone>
+ </phones>
+ <addresses>
+ <address>
+ <street>prosp. Rad. Ukr. 11A, 70</street>
+ </address>
+ <address>
+ <street>Sky 7</street>
+ </address>
+ </addresses>
+</person>
Added: jbossxb/trunk/src/test/resources/xml/person.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/person.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/person.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsd:schema
+ targetNamespace="http://example.org/ns/person/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:p="http://example.org/ns/person/"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+ <xsd:element name="person">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="first-name" type="xsd:string"/>
+ <xsd:element name="last-name" type="xsd:string"/>
+ <xsd:element name="date-of-birth" type="xsd:string"/>
+ <xsd:element name="phones" minOccurs="0">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="phone" type="xsd:string" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="addresses" minOccurs="0">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="address" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="street" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/po.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/po.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/po.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<purchaseOrder orderDate="1999-10-20">
+ <shipTo country="US">
+ <name>Alice Smith</name>
+ <street>123 Maple Street</street>
+ <city>Mill Valley</city>
+ <state>CA</state>
+ <zip>90952</zip>
+ </shipTo>
+ <billTo country="US">
+ <name>Robert Smith</name>
+ <street>8 Oak Avenue</street>
+ <city>Old Town</city>
+ <state>PA</state>
+ <zip>95819</zip>
+ </billTo>
+ <comment>Hurry, my lawn is going wild!</comment>
+ <items>
+ <item partNum="872-AA">
+ <productName>Lawnmower</productName>
+ <quantity>1</quantity>
+ <USPrice>148.95</USPrice>
+ <comment>Confirm this is electric</comment>
+ </item>
+ <item partNum="926-AA">
+ <productName>Baby Monitor</productName>
+ <quantity>1</quantity>
+ <USPrice>39.98</USPrice>
+ <shipDate>1999-05-21</shipDate>
+ </item>
+ </items>
+</purchaseOrder>
Added: jbossxb/trunk/src/test/resources/xml/po.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/po.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/po.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,77 @@
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb">
+
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ Purchase order schema for Example.com.
+ Copyright 2000 Example.com. All rights reserved.
+ </xsd:documentation>
+ <xsd:appinfo>
+ <jbxb:schemaBindings>
+ <jbxb:package name="org.jboss.test.xml.po"/>
+ </jbxb:schemaBindings>
+ </xsd:appinfo>
+ </xsd:annotation>
+
+ <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
+
+ <xsd:element name="comment" type="xsd:string"/>
+
+ <xsd:complexType name="PurchaseOrderType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.po.PurchaseOrder"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="shipTo" type="USAddress"/>
+ <xsd:element name="billTo" type="USAddress"/>
+ <xsd:element ref="comment" minOccurs="0"/>
+ <xsd:element name="items" type="Items"/>
+ </xsd:sequence>
+ <xsd:attribute name="orderDate" type="xsd:date"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="USAddress">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="street" type="xsd:string"/>
+ <xsd:element name="city" type="xsd:string"/>
+ <xsd:element name="state" type="xsd:string"/>
+ <xsd:element name="zip" type="xsd:decimal"/>
+ </xsd:sequence>
+ <xsd:attribute name="country" type="xsd:NMTOKEN"
+ fixed="US"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="Items">
+ <xsd:sequence>
+ <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="productName" type="xsd:string"/>
+ <xsd:element name="quantity">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:positiveInteger">
+ <xsd:maxExclusive value="100"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:element>
+ <xsd:element name="USPrice" type="xsd:decimal"/>
+ <xsd:element ref="comment" minOccurs="0"/>
+ <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
+ </xsd:sequence>
+ <xsd:attribute name="partNum" type="SKU" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <!-- Stock Keeping Unit, a code for identifying products -->
+ <xsd:simpleType name="SKU">
+ <xsd:restriction base="xsd:string">
+ <xsd:pattern value="\d{3}-[A-Z]{2}"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/ejb-cache_1_0.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/ejb-cache_1_0.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/ejb-cache_1_0.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:ejb-cache"
+ xmlns="urn:jboss:ejb-cache"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xs:element name="container-cache-conf" type="CacheConfigType">
+ </xs:element>
+
+ <xs:complexType name="CacheConfigType">
+ <xs:sequence>
+ <xs:element name="cache-policy" type="xs:token"
+ minOccurs="0" maxOccurs="1"/>
+ <xs:element name="cache-policy-conf" type="PolicyConfType"
+ minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ <xs:attribute name="name" />
+ </xs:complexType>
+
+ <xs:complexType name="PolicyConfType">
+ <xs:sequence>
+ <xs:element name="min-capacity" type="xs:int" default="50" />
+ <xs:element name="max-capacity" type="xs:int" default="1000000" />
+ <xs:element name="remover-period" type="xs:int" default="1800" />
+ <xs:element name="max-bean-life" type="xs:long" default="1800" />
+ <xs:element name="overager-period" type="xs:int" default="300" />
+ <xs:element name="max-bean-age" type="xs:int" default="600" />
+ <xs:element name="resizer-period" type="xs:int" default="400" />
+ <xs:element name="max-cache-miss-period" type="xs:int" default="60" />
+ <xs:element name="min-cache-miss-period" type="xs:int" default="1" />
+ <xs:element name="cache-load-factor" type="xs:double" default="0.75" />
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/ejb-config_1_0.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/ejb-config_1_0.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/ejb-config_1_0.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:testejb-ns1"
+ xmlns="urn:jboss:testejb-ns1"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xs:element name="ejb-container" type="EjbContainerType">
+ </xs:element>
+
+ <xs:complexType name="EjbContainerType">
+ <xs:sequence>
+ <xs:element name="invoker-proxy-bindings" type="InvokerBindingsType"
+ minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="container-interceptors" type="InterceptorStackType"
+ minOccurs="0" maxOccurs="1"/>
+ <xs:element name="instance-cache" type="EjbCacheType"
+ minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ <xs:attribute name="name" />
+ </xs:complexType>
+
+ <xs:complexType name="InvokerBindingsType">
+ <xs:sequence>
+ <xs:element name="invoker-proxy-binding">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="invoker-mbean" type="xs:token" />
+ <xs:element name="proxy-factory" type="xs:token" />
+ <xs:element name="proxy-factory-config">
+ <xs:complexType>
+ <xs:choice>
+ <xs:element name="client-interceptors">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="home" type="InterceptorStackType"
+ minOccurs="0" maxOccurs="1" />
+ <xs:element name="bean" type="InterceptorStackType"
+ minOccurs="0" maxOccurs="1" />
+ <xs:element name="list-entity" type="InterceptorStackType"
+ minOccurs="0" maxOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:any namespace="##other" />
+ </xs:choice>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="name" use="required" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="InterceptorStackType">
+ <xs:sequence>
+ <xs:element name="interceptor" minOccurs="1" maxOccurs="unbounded">
+ <xs:complexType mixed="true">
+ <xs:choice minOccurs="0">
+ <xs:any />
+ </xs:choice>
+ <xs:attribute name="callByValue" type="xs:boolean" default="false" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:anyAttribute />
+ </xs:complexType>
+
+ <xs:complexType name="EjbCacheType">
+ <xs:choice>
+ <xs:any processContents="strict" />
+ </xs:choice>
+ <xs:attribute name="class" type="xs:token" use="required" />
+ </xs:complexType>
+
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/test1-ejb-deployment.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/test1-ejb-deployment.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/test1-ejb-deployment.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd
+ urn:jboss:testejb-ns1 ejb-config_1_0.xsd
+ urn:jboss:ejb-cache ejb-cache_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer"
+ xmlns:ejb="urn:jboss:testejb-ns1"
+ xmlns:cache="urn:jboss:ejb-cache"
+ >
+ <bean name="EJBContainerConfig" class="org.jboss.ejb.Container">
+ <property name="Config">
+ <ejb:ejb-container>
+ <ejb:invoker-proxy-bindings>
+ <ejb:invoker-proxy-binding name="stateless-rmi-invoker">
+ <ejb:invoker-mbean>jboss:service=invoker,type=jrmp</ejb:invoker-mbean>
+ <ejb:proxy-factory>org.jboss.proxy.ejb.ProxyFactory</ejb:proxy-factory>
+ <ejb:proxy-factory-config>
+ <ejb:client-interceptors>
+ <ejb:home>
+ <ejb:interceptor>org.jboss.proxy.ejb.HomeInterceptor</ejb:interceptor>
+ <ejb:interceptor>org.jboss.proxy.SecurityInterceptor</ejb:interceptor>
+ <ejb:interceptor>org.jboss.proxy.TransactionInterceptor</ejb:interceptor>
+ <ejb:interceptor callByValue="false">org.jboss.invocation.InvokerInterceptor</ejb:interceptor>
+ <ejb:interceptor callByValue="true">org.jboss.invocation.MarshallingInvokerInterceptor</ejb:interceptor>
+ </ejb:home>
+ <ejb:bean>
+ <ejb:interceptor>org.jboss.proxy.ejb.StatelessSessionInterceptor</ejb:interceptor>
+ <ejb:interceptor>org.jboss.proxy.SecurityInterceptor</ejb:interceptor>
+ <ejb:interceptor>org.jboss.proxy.TransactionInterceptor</ejb:interceptor>
+ <ejb:interceptor callByValue="false">org.jboss.invocation.InvokerInterceptor</ejb:interceptor>
+ <ejb:interceptor callByValue="true">org.jboss.invocation.MarshallingInvokerInterceptor</ejb:interceptor>
+ </ejb:bean>
+ </ejb:client-interceptors>
+ </ejb:proxy-factory-config>
+ </ejb:invoker-proxy-binding>
+ </ejb:invoker-proxy-bindings>
+
+ <ejb:instance-cache class="org.jboss.ejb.plugins.StatefulSessionInstanceCache">
+ <cache:container-cache-conf>
+ <cache:cache-policy>org.jboss.ejb.plugins.LRUStatefulContextCachePolicy</cache:cache-policy>
+ <cache:cache-policy-conf>
+ <cache:min-capacity>50</cache:min-capacity>
+ <cache:max-capacity>1000000</cache:max-capacity>
+ <cache:remover-period>1800</cache:remover-period>
+ <cache:max-bean-life>1800</cache:max-bean-life>
+ <cache:overager-period>300</cache:overager-period>
+ <cache:max-bean-age>600</cache:max-bean-age>
+ <cache:resizer-period>400</cache:resizer-period>
+ <cache:max-cache-miss-period>60</cache:max-cache-miss-period>
+ <cache:min-cache-miss-period>1</cache:min-cache-miss-period>
+ <cache:cache-load-factor>0.75</cache:cache-load-factor>
+ </cache:cache-policy-conf>
+ </cache:container-cache-conf>
+ </ejb:instance-cache>
+ </ejb:ejb-container>
+ </property>
+ </bean>
+</deployment>
\ No newline at end of file
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testAnnotations.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testAnnotations.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testAnnotations.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <annotation name="beanLevelAnnotation">
+ <attribute name="beanLevelAttribute" value="value1"/>
+ </annotation>
+ <property name="other">
+ <annotation name="propertyLevelAnnotation">
+ <attribute name="propertyLevelAttribute" value="value2"/>
+ </annotation>
+ <dependency value="SimpleBean2"/>
+ </property>
+ </bean>
+ <bean name="SimpleBean2"
+ class="org.jboss.test.kernel.xml.support.SimpleBeanImpl">
+ <constructor>
+ <annotation name="constructorLevelAnnotation">
+ <attribute name="constructorLevelAttribute" value="value3"/>
+ </annotation>
+ <parameter class="java.lang.String">Bean2</parameter>
+ </constructor>
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testAttributeDependency.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testAttributeDependency.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testAttributeDependency.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1"
+ class="org.jboss.test.kernel.xml.support.SimpleBeanImpl">
+ <property name="other">
+ <inject bean="SimpleBean2"/>
+ </property>
+ </bean>
+ <bean name="SimpleBean2"
+ class="org.jboss.test.kernel.xml.support.SimpleBeanImpl">
+ <constructor>
+ <parameter class="java.lang.String">Bean2</parameter>
+ </constructor>
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testAttributeDependencyDependentState.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testAttributeDependencyDependentState.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testAttributeDependencyDependentState.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <property name="other">
+ <inject bean="SimpleBean2"/>
+ </property>
+ </bean>
+ <bean name="SimpleBean2"
+ class="org.jboss.test.kernel.xml.support.SimpleBeanImpl">
+ <constructor>
+ <parameter class="java.lang.String">Bean2</parameter>
+ </constructor>
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testConfigure.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testConfigure.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testConfigure.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <property name="aString">StringValue</property>
+ <property name="aByte">12</property>
+ <property name="aBoolean">true</property>
+ <property name="aShort">123</property>
+ <property name="anInt">1234</property>
+ <property name="aLong">12345</property>
+ <property name="aFloat">3.14</property>
+ <property name="aDouble">3.14e12</property>
+ <property name="aDate">12/12/12</property>
+ <property name="aBigDecimal">12e4</property>
+ <property name="aBigInteger">123456</property>
+ <property name="abyte">12</property>
+ <property name="aboolean">true</property>
+ <property name="ashort">123</property>
+ <property name="anint">1234</property>
+ <property name="along">12345</property>
+ <property name="afloat">3.14</property>
+ <property name="adouble">3.14e12</property>
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testConfigureNested.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testConfigureNested.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testConfigureNested.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1" class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <property name="aString">StringValue</property>
+ <property name="aByte">12</property>
+ <property name="aBoolean">true</property>
+ <property name="aShort">123</property>
+ <property name="anInt">1234</property>
+ <property name="aLong">12345</property>
+ <property name="aFloat">3.14</property>
+ <property name="aDouble">3.14e12</property>
+ <property name="aDate">12/12/12</property>
+ <property name="aBigDecimal">12e4</property>
+ <property name="aBigInteger">123456</property>
+ <property name="abyte">12</property>
+ <property name="aboolean">true</property>
+ <property name="ashort">123</property>
+ <property name="anint">1234</property>
+ <property name="along">12345</property>
+ <property name="afloat">3.14</property>
+ <property name="adouble">3.14e12</property>
+ <property name="other">
+ <!-- TODO bean name="NestedSimpleBean1"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <property name="aString">StringValue</property>
+ <property name="aByte">12</property>
+ <property name="aBoolean">true</property>
+ <property name="aShort">123</property>
+ <property name="anInt">1234</property>
+ <property name="aLong">12345</property>
+ <property name="aFloat">3.14</property>
+ <property name="aDouble">3.14e12</property>
+ <property name="aDate">12/12/12</property>
+ <property name="aBigDecimal">12e4</property>
+ <property name="aBigInteger">123456</property>
+ <property name="abyte">12</property>
+ <property name="aboolean">true</property>
+ <property name="ashort">123</property>
+ <property name="anint">1234</property>
+ <property name="along">12345</property>
+ <property name="afloat">3.14</property>
+ <property name="adouble">3.14e12</property>
+ <property name="other"><null/></property>
+ </bean -->
+ </property>
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testConstructorDependency.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testConstructorDependency.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testConstructorDependency.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <constructor>
+ <parameter class="org.jboss.test.kernel.xml.support.SimpleBean">
+ <inject bean="SimpleBean2"/>
+ </parameter>
+ </constructor>
+ </bean>
+ <bean name="SimpleBean2"
+ class="org.jboss.test.kernel.xml.support.SimpleBeanImpl">
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testDemandSupply.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testDemandSupply.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testDemandSupply.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <demand>SimpleBean2</demand>
+ <demand>XYZZY</demand>
+ </bean>
+ <bean name="SimpleBean2"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl"/>
+ <bean name="SimpleBean3"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <supply>XYZZY</supply>
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testDemandSupplyWhenRequired.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testDemandSupplyWhenRequired.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testDemandSupplyWhenRequired.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <demand whenRequired="Lifecycle">SimpleBean2</demand>
+ </bean>
+ <bean name="SimpleBean2"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <constructor>
+ <parameter class="java.lang.String">whenRequired</parameter>
+ </constructor>
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testFactoryDependency.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testFactoryDependency.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testFactoryDependency.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <constructor factoryMethod="createSimpleBean">
+ <factory bean="SimpleBeanFactory"/>
+ <parameter class="org.jboss.test.xml.pojoserver.SimpleBean">
+ <inject bean="SimpleBean2"/>
+ </parameter>
+ </constructor>
+ </bean>
+ <bean name="SimpleBean2"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ </bean>
+ <bean name="SimpleBeanFactory"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanFactory">
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testGenericBeanFactory.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testGenericBeanFactory.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testGenericBeanFactory.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <beanfactory name="GenericBeanFactory" class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <constructor>
+ <parameter class="java.lang.String">Bean1</parameter>
+ </constructor>
+ <property name="other">
+ <inject bean="SimpleBean2"/>
+ </property>
+ </beanfactory>
+ <bean name="SimpleBean2"
+ class="org.jboss.test.kernel.xml.support.SimpleBeanImpl">
+ <constructor>
+ <parameter class="java.lang.String">Bean2</parameter>
+ </constructor>
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testSimpleCollection.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testSimpleCollection.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testSimpleCollection.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <property name="aList">
+ <list class="java.util.LinkedList">
+ <value>value0</value>
+ <value>value1</value>
+ </list>
+ </property>
+ <property name="aSet">
+ <set class="java.util.HashSet">
+ <value>value0</value>
+ <value>value1</value>
+ </set>
+ </property>
+ <property name="aMap">
+ <map class="testMapClass" keyClass="testKeyClass" valueClass="testValueClass">
+ <entry>
+ <key>other</key>
+ <value><inject bean="SimpleBean2"/></value>
+ </entry>
+ <entry>
+ <key>nullKey</key>
+ <value><null/></value>
+ </entry>
+ </map>
+ </property>
+ <property name="props">
+ <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>prop0</key>
+ <value>value0</value>
+ </entry>
+ <entry>
+ <key>prop1</key>
+ <value>value1</value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/pojoserver/testStaticFactoryDependency.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/pojoserver/testStaticFactoryDependency.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/pojoserver/testStaticFactoryDependency.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="SimpleBean1"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl">
+ <constructor
+ factoryClass="org.jboss.test.kernel.xml.support.SimpleBeanFactory"
+ factoryMethod="staticCreateSimpleBean">
+ <parameter class="org.jboss.test.kernel.xml.support.SimpleBean">
+ <inject bean="SimpleBean2"/>
+ </parameter>
+ </constructor>
+ </bean>
+ <bean name="SimpleBean2"
+ class="org.jboss.test.xml.pojoserver.SimpleBeanImpl"
+ />
+</deployment>
Added: jbossxb/trunk/src/test/resources/xml/sandbox.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/sandbox.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/sandbox.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,32 @@
+<sb:root
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.org/test/xml/sandbox sandbox.xsd"
+ xmlns:sb="http://www.jboss.org/test/xml/sandbox">
+
+ <sb:choiceCollection1>
+ <sb:a>choice1_a</sb:a>
+ </sb:choiceCollection1>
+ <sb:choiceCollection1>
+ <sb:b>choice1_b</sb:b>
+ </sb:choiceCollection1>
+
+ <sb:choice2>
+ <sb:c>choice2_c</sb:c>
+ <sb:d>choice2_d</sb:d>
+ </sb:choice2>
+ <sb:choice2>
+ <sb:e>choice2_e</sb:e>
+ <sb:d>choice2_d</sb:d>
+ </sb:choice2>
+
+ <sb:choice3>
+ <sb:listOfIntegers>1</sb:listOfIntegers>
+ <sb:listOfIntegers>2</sb:listOfIntegers>
+ <sb:listOfIntegers>3</sb:listOfIntegers>
+ </sb:choice3>
+ <sb:choice3>
+ <sb:listOfStrings>1</sb:listOfStrings>
+ <sb:listOfStrings>2</sb:listOfStrings>
+ <sb:listOfStrings>3</sb:listOfStrings>
+ </sb:choice3>
+</sb:root>
Added: jbossxb/trunk/src/test/resources/xml/sandbox.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/sandbox.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/sandbox.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<xsd:schema
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:sb="http://www.jboss.org/test/xml/sandbox"
+ targetNamespace="http://www.jboss.org/test/xml/sandbox"
+ elementFormDefault="qualified">
+
+ <xsd:element name="root">
+ <xsd:complexType>
+ <xsd:sequence>
+
+ <xsd:element name="choiceCollection1" type="sb:choice1" maxOccurs="3"/>
+
+ <xsd:element name="choice2" maxOccurs="2">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:sequence>
+ <xsd:element name="c" type="xsd:string"/>
+ <xsd:element name="d" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:sequence>
+ <xsd:element name="e" type="xsd:string"/>
+ <xsd:element name="d" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="choice3" maxOccurs="2">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="listOfIntegers" type="xsd:int" maxOccurs="unbounded"/>
+ <xsd:element name="listOfStrings" type="xsd:string" maxOccurs="unbounded"/>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="choice1">
+ <xsd:choice>
+ <xsd:element name="a" type="xsd:string"/>
+ <xsd:element name="b" type="xsd:string"/>
+ </xsd:choice>
+ </xsd:complexType>
+
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/soapenc/soapenc.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/soapenc/soapenc.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/soapenc/soapenc.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,92 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://schemas.xmlsoap.org/soap/encoding/"
+ targetNamespace="http://schemas.xmlsoap.org/soap/encoding/">
+
+ <xs:attributeGroup name="commonAttributes" >
+ <xs:annotation>
+ <xs:documentation>
+ Attributes common to all elements that function as accessors or
+ represent independent (multi-ref) values. The href attribute is
+ intended to be used in a manner like CONREF. That is, the element
+ content should be empty iff the href attribute appears
+ </xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="id" type="xs:ID" />
+ <xs:attribute name="href" type="xs:anyURI" />
+ <xs:anyAttribute namespace="##other" processContents="lax" />
+ </xs:attributeGroup>
+
+ <xs:complexType name="string" >
+ <xs:simpleContent>
+ <xs:extension base="xs:string" >
+ <xs:attributeGroup ref="tns:commonAttributes" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="boolean" >
+ <xs:simpleContent>
+ <xs:extension base="xs:boolean" >
+ <xs:attributeGroup ref="tns:commonAttributes" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="float" >
+ <xs:simpleContent>
+ <xs:extension base="xs:float" >
+ <xs:attributeGroup ref="tns:commonAttributes" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="double" >
+ <xs:simpleContent>
+ <xs:extension base="xs:double" >
+ <xs:attributeGroup ref="tns:commonAttributes" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="decimal" >
+ <xs:simpleContent>
+ <xs:extension base="xs:decimal" >
+ <xs:attributeGroup ref="tns:commonAttributes" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="int" >
+ <xs:simpleContent>
+ <xs:extension base="xs:int" >
+ <xs:attributeGroup ref="tns:commonAttributes" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="short" >
+ <xs:simpleContent>
+ <xs:extension base="xs:short" >
+ <xs:attributeGroup ref="tns:commonAttributes" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="byte" >
+ <xs:simpleContent>
+ <xs:extension base="xs:byte" >
+ <xs:attributeGroup ref="tns:commonAttributes" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="base64Binary" >
+ <xs:simpleContent>
+ <xs:extension base="xs:base64Binary" >
+ <xs:attributeGroup ref="tns:commonAttributes" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="hexBinary" >
+ <xs:simpleContent>
+ <xs:extension base="xs:hexBinary" >
+ <xs:attributeGroup ref="tns:commonAttributes" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:simpleType name="base64" >
+ <xs:restriction base="xs:base64Binary" />
+ </xs:simpleType>
+</xs:schema>
Added: jbossxb/trunk/src/test/resources/xml/soapenc/test.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/soapenc/test.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/soapenc/test.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,42 @@
+<xsd:schema xmlns='http://ParameterModeTest.org/xsd'
+ xmlns:xsd='http://www.w3.org/2001/XMLSchema'
+ xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ targetNamespace='http://ParameterModeTest.org/xsd'>
+
+ <xsd:import namespace='http://schemas.xmlsoap.org/soap/encoding/'/>
+
+ <xsd:complexType name='AllStruct'>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl='org.jboss.test.xml.SoapEncUnitTestCase$AllStruct'/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:all>
+ <xsd:element name='varString' type='xsd:string'/>
+ <xsd:element name='varInteger' type='xsd:integer'/>
+ <xsd:element name='varInt' type='xsd:int'/>
+ <xsd:element name='varLong' type='xsd:long'/>
+ <xsd:element name='varShort' type='xsd:short'/>
+ <xsd:element name='varDecimal' type='xsd:decimal'/>
+ <xsd:element name='varFloat' type='xsd:float'/>
+ <xsd:element name='varDouble' type='xsd:double'/>
+ <xsd:element name='varBoolean' type='xsd:boolean'/>
+ <xsd:element name='varByte' type='xsd:byte'/>
+ <xsd:element name='varQName' type='xsd:QName'/>
+ <xsd:element name='varDateTime' type='xsd:dateTime'/>
+ <xsd:element name='varSoapString' type='soapenc:string'/>
+ <xsd:element name='varSoapBoolean' type='soapenc:boolean'/>
+ <xsd:element name='varSoapFloat' type='soapenc:float'/>
+ <xsd:element name='varSoapDouble' type='soapenc:double'/>
+ <xsd:element name='varSoapDecimal' type='soapenc:decimal'/>
+ <xsd:element name='varSoapInt' type='soapenc:int'/>
+ <xsd:element name='varSoapShort' type='soapenc:short'/>
+ <xsd:element name='varSoapByte' type='soapenc:byte'/>
+ <xsd:element name='varBase64Binary' type='xsd:base64Binary'/>
+ <xsd:element name='varHexBinary' type='xsd:hexBinary'/>
+ <xsd:element name='varSoapBase64' type='soapenc:base64'/>
+ </xsd:all>
+ </xsd:complexType>
+ <xsd:element name='allStruct' type='AllStruct'/>
+</xsd:schema>
Added: jbossxb/trunk/src/test/resources/xml/valuebinding.xml
===================================================================
--- jbossxb/trunk/src/test/resources/xml/valuebinding.xml 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/valuebinding.xml 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,25 @@
+<config>
+ <attribute>default value</attribute>
+ <attribute>
+ <value1>
+ <property>value1</property>
+ </value1>
+ </attribute>
+ <attribute>
+ <value2>value2</value2>
+ </attribute>
+
+ <beans>
+ <bean>
+ <name>A</name>
+ </bean>
+ <bean>
+ <name>B</name>
+ </bean>
+ </beans>
+
+ <list>
+ <value type="some.type">foo</value>
+ <depends value="SomeBean"/>
+ </list>
+</config>
Added: jbossxb/trunk/src/test/resources/xml/xerces-bug.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/xml/xerces-bug.xsd 2006-10-10 19:37:49 UTC (rev 2123)
+++ jbossxb/trunk/src/test/resources/xml/xerces-bug.xsd 2006-10-12 12:03:53 UTC (rev 2124)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:xerces:bug"
+ xmlns="urn:xerces:bug"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0"
+>
+
+ <xsd:complexType name="derivedType3" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ derivedType3
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="derivedType2"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="baseType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ baseType
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:complexType>
+
+ <xsd:complexType name="derivedType" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ derivedType
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="baseType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="derivedType2" mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ derivedType2
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="derivedType"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+</xsd:schema>
More information about the jboss-svn-commits
mailing list