[jboss-cvs] JBossAS SVN: r57583 - in trunk/testsuite/src: main/org/jboss/test/xml resources/org/jboss/test/xml resources/xml
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 12 08:54:09 EDT 2006
Author: alex.loubyansky at jboss.com
Date: 2006-10-12 08:53:48 -0400 (Thu, 12 Oct 2006)
New Revision: 57583
Removed:
trunk/testsuite/src/main/org/jboss/test/xml/AnnotatedPojoServerUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/AnnotationsUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/AnyUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/ArrayWrapperUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/AttributesUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/BasicArraysUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/BooleanPatternUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/CollectionsUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/Dom2SaxUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/EnumUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/ExceptionUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/IntrospectionUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/JbxbCharactersUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/JbxbPojoServerUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/MappingTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/MapsUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/MinOccurs0UnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/MiscUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/ModelGroupBindingUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/MultispacedUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/NamespaceRegistryUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/PoUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/PojoServerTestBase.java
trunk/testsuite/src/main/org/jboss/test/xml/PojoServerUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/QNameAttributesUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/RepeatableTermsUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/SchemaBindingInitializerUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/SchemaImportUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/SchemaIncludeUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/SchemalessTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/SimpleTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/SimpleTypeBindingUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/SoapEncUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/SundayUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/ValueListUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/WildcardUnresolvedElementsUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/WildcardWrapperUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/XMLNameToJavaIdentifierUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/XOPUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/XercesBugTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/XsiTypeUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/xml/any/
trunk/testsuite/src/main/org/jboss/test/xml/book/
trunk/testsuite/src/main/org/jboss/test/xml/choice/
trunk/testsuite/src/main/org/jboss/test/xml/collections/
trunk/testsuite/src/main/org/jboss/test/xml/config/
trunk/testsuite/src/main/org/jboss/test/xml/immutable/
trunk/testsuite/src/main/org/jboss/test/xml/jbxb/
trunk/testsuite/src/main/org/jboss/test/xml/multispaced/
trunk/testsuite/src/main/org/jboss/test/xml/person/
trunk/testsuite/src/main/org/jboss/test/xml/po/
trunk/testsuite/src/main/org/jboss/test/xml/pojoserver/
trunk/testsuite/src/main/org/jboss/test/xml/sandbox/
trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal1.xml
trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal1.xsd
trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal2.xml
trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal2.xsd
trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xml
trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xsd
trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxNotSimple.xml
trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxSimple.xml
trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipNotSimple.xml
trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipSimple.xml
trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictNotSimple.xml
trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictSimple.xml
trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xml
trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xsd
trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCase.xsd
trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseSimple.xml
trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseWildcard.xml
trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCase.xml
trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCase.xsd
trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseImageWithContentType.xml
trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseJpeg.xml
trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseOptimized.xml
trunk/testsuite/src/resources/org/jboss/test/xml/xmlmime.xsd
trunk/testsuite/src/resources/xml/SchemaIncludeUnitTestCase.xsd
trunk/testsuite/src/resources/xml/SchemaIncludeUnitTestCaseIncluded.xsd
trunk/testsuite/src/resources/xml/annotated-bean-deployer_1_0.xsd
trunk/testsuite/src/resources/xml/any.xml
trunk/testsuite/src/resources/xml/any.xsd
trunk/testsuite/src/resources/xml/aop/
trunk/testsuite/src/resources/xml/bean-deployer_1_0.xsd
trunk/testsuite/src/resources/xml/book/
trunk/testsuite/src/resources/xml/choice.xsd
trunk/testsuite/src/resources/xml/collections.xml
trunk/testsuite/src/resources/xml/collections.xsd
trunk/testsuite/src/resources/xml/immutable.xsd
trunk/testsuite/src/resources/xml/jbxb-bean-deployer_1_0.xsd
trunk/testsuite/src/resources/xml/jbxb/
trunk/testsuite/src/resources/xml/maps.xml
trunk/testsuite/src/resources/xml/maps.xsd
trunk/testsuite/src/resources/xml/multispaced/
trunk/testsuite/src/resources/xml/newmetadata.xml
trunk/testsuite/src/resources/xml/person.dtd
trunk/testsuite/src/resources/xml/person.xml
trunk/testsuite/src/resources/xml/person.xsd
trunk/testsuite/src/resources/xml/po.xml
trunk/testsuite/src/resources/xml/po.xsd
trunk/testsuite/src/resources/xml/pojoserver/
trunk/testsuite/src/resources/xml/sandbox.xml
trunk/testsuite/src/resources/xml/sandbox.xsd
trunk/testsuite/src/resources/xml/soapenc/
trunk/testsuite/src/resources/xml/valuebinding.xml
trunk/testsuite/src/resources/xml/xerces-bug.xsd
Log:
moved XB functional tests to the XB project
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/AnnotatedPojoServerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/AnnotatedPojoServerUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/AnnotatedPojoServerUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,299 +0,0 @@
-/*
- * 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$</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";
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/AnnotationsUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/AnnotationsUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/AnnotationsUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,72 +0,0 @@
-/*
- * 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$</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();
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/AnyUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/AnyUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/AnyUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,120 +0,0 @@
-/*
- * 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$</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();
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/ArrayWrapperUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/ArrayWrapperUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/ArrayWrapperUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,342 +0,0 @@
-/*
- * 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$</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 final 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");
- }
-
- 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);
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/AttributesUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/AttributesUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/AttributesUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,261 +0,0 @@
-/*
- * 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$</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 final SchemaBinding SCHEMA = XsdBinder.bind(new StringReader(XSD), null, SCHEMA_RESOLVER);
-
- 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'/>";
-
- static
- {
- SCHEMA.setIgnoreUnresolvedFieldOrClass(false);
- }
-
- public AttributesUnitTestCase(String name)
- {
- super(name);
- }
-
- 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;
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/BasicArraysUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/BasicArraysUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/BasicArraysUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,558 +0,0 @@
-/*
- * 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$</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;
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/BooleanPatternUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/BooleanPatternUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/BooleanPatternUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,165 +0,0 @@
-/*
- * 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$</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 final SchemaBinding SCHEMA = XsdBinder.bind(new StringReader(XSD), null);
- static
- {
- SCHEMA.setIgnoreUnresolvedFieldOrClass(false);
- }
-
- 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);
- }
-
- 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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/CollectionsUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/CollectionsUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/CollectionsUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,437 +0,0 @@
-/*
- * 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$</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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/Dom2SaxUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/Dom2SaxUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/Dom2SaxUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,90 +0,0 @@
-/*
- * 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$</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();
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/EnumUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/EnumUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/EnumUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,395 +0,0 @@
-/*
- * 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$</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;
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/ExceptionUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/ExceptionUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/ExceptionUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,156 +0,0 @@
-/*
- * 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$</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 final SchemaBinding SCHEMA = XsdBinder.bind(new StringReader(XSD), null);
-
- 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());
- }
-
- 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());
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/IntrospectionUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/IntrospectionUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/IntrospectionUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,161 +0,0 @@
-/*
- * 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$</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.");
- }
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/JbxbCharactersUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/JbxbCharactersUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/JbxbCharactersUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,181 +0,0 @@
-/*
- * 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$
- */
-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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/JbxbPojoServerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/JbxbPojoServerUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/JbxbPojoServerUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,70 +0,0 @@
-/*
- * 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$</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";
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/MappingTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/MappingTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/MappingTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,276 +0,0 @@
-/*
- * 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.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.FileReader;
-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$</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();
-
- 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
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/MapsUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/MapsUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/MapsUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,390 +0,0 @@
-/*
- * 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$</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();
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/MinOccurs0UnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/MinOccurs0UnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/MinOccurs0UnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,206 +0,0 @@
-/*
- * 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$</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 final SchemaBinding SCHEMA = XsdBinder.bind(new StringReader(XSD), null);
- static
- {
- SCHEMA.setIgnoreUnresolvedFieldOrClass(false);
- }
-
- 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);
- }
-
- 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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/MiscUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/MiscUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/MiscUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,396 +0,0 @@
-/*
- * 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$</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());
- }
-
- /**
- * This one fails perhaps because of the switch to sax parser from the xni one
- */
- public void testSandboxXml() throws Exception
- {
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- Root unmarshalled = (Root)unmarshaller.unmarshal(getXmlUrl("xml/sandbox.xml"),
- new MappingObjectModelFactory(),
- null
- );
- assertUnmarshalled(unmarshalled);
- }
-
- // 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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/ModelGroupBindingUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/ModelGroupBindingUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/ModelGroupBindingUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,389 +0,0 @@
-/*
- * 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$</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 final SchemaBinding SCHEMA = XsdBinder.bind(new StringReader(XSD), null);
-
- static
- {
- SCHEMA.setIgnoreUnresolvedFieldOrClass(false);
- }
-
- 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);
- }
-
- 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;
- }
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/MultispacedUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/MultispacedUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/MultispacedUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,267 +0,0 @@
-/*
- * 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$</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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/NamespaceRegistryUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/NamespaceRegistryUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/NamespaceRegistryUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,97 +0,0 @@
-/*
- * 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$</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]));
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/PoUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/PoUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/PoUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,67 +0,0 @@
-/*
- * 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$</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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/PojoServerTestBase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/PojoServerTestBase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/PojoServerTestBase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,1002 +0,0 @@
-/*
- * 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$</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);
- }
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/PojoServerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/PojoServerUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/PojoServerUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,1065 +0,0 @@
-/*
- * 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$</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);
- }
- });
-
-/* TODO uncomment when the latest snapshot of XB with the
- * global model group support is available in the thirdparty
- * (depends on the MC snapshot to be able to boot the AS)
- 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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/QNameAttributesUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/QNameAttributesUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/QNameAttributesUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,190 +0,0 @@
-/*
- * 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$</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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/RepeatableTermsUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/RepeatableTermsUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/RepeatableTermsUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,240 +0,0 @@
-/*
- * 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.Arrays;
-import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-
-/**
- * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
- * @version <tt>$Revision: $</tt>
- */
-public class RepeatableTermsUnitTestCase
- extends AbstractJBossXBTest
-{
- public RepeatableTermsUnitTestCase(String name)
- {
- super(name);
- }
-
- protected void configureLogging()
- {
- //enableTrace("org.jboss.xb.binding.sunday");
- //enableTrace("org.jboss.xb.binding.sunday.unmarshalling.SequenceBinding");
- //enableTrace("org.jboss.xb.binding.sunday.unmarshalling.ChoiceBinding");
- }
-
- public void testUnmarshal1() throws Exception
- {
- Object o = unmarshal();
-
- assertNotNull(o);
- assertTrue(o instanceof Top);
- Top top = (Top)o;
-
- assertNotNull(top.item);
- assertEquals(3, top.item.length);
- assertEquals(new String[]{"item1", "item2", "item3"}, top.item);
-
- assertNotNull(top.sequence);
- //assertEquals(5, top.sequence.length);
- assertEquals(
- new Sequence[]
- {
- new Sequence("sequenceChoice1_1", null),
- new Sequence(null, "sequenceChoice2_1"),
- new Sequence("sequenceChoice1_2", null),
- new Sequence("sequenceChoice1_3", null),
- new Sequence(null, "sequenceChoice2_2")
- },
- top.sequence
- );
-
- assertNotNull(top.choice);
- assertEquals(3, top.choice.length);
- assertEquals(
- new Choice[]
- {
- new Choice(new String[]{"choiceChoice1_1", "choiceChoice1_2"}, null),
- new Choice(null, new String[]{"choiceChoice2_1", "choiceChoice2_2"}),
- new Choice(new String[]{"choiceChoice1_3", "choiceChoice1_4"}, null),
- },
- top.choice
- );
- }
-
- public void testUnmarshal2() throws Exception
- {
- Object o = unmarshal();
- assertNotNull(o);
- assertTrue(o instanceof Top);
- Top top = (Top)o;
-
- assertNull(top.item);
- assertNull(top.choice);
- assertNull(top.sequence);
-
- assertEquals("item1", top.item1);
- assertEquals("item2", top.item2);
- }
-
- private Object unmarshal() throws Exception
- {
- String testXsd = findXML(rootName + "_" + getName() + ".xsd");
- SchemaBinding schema = XsdBinder.bind(testXsd, (SchemaBindingResolver)null);
- schema.setIgnoreUnresolvedFieldOrClass(false);
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- return unmarshaller.unmarshal(findXML(rootName + "_" + getName() + ".xml"), schema);
- }
-
- // Inner
-
- public static final class Top
- {
- public String[] item;
- public Sequence[] sequence;
- public Choice[] choice;
-
- public String item1;
- public String item2;
-
- public String toString()
- {
- return "[top item=" + (item == null ? null : Arrays.asList(item)) +
- " sequence=" + (sequence == null ? null : Arrays.asList(sequence)) +
- " choice=" + (choice == null ? null : Arrays.asList(choice)) +
- " item1=" + item1 + " item2=" + item2 + "]";
- }
- }
-
- public static final class Sequence
- {
- public String sequenceChoice1;
- public String sequenceChoice2;
-
- public Sequence()
- {
- }
-
- public Sequence(String sequenceChoice1, String sequenceChoice2)
- {
- this.sequenceChoice1 = sequenceChoice1;
- this.sequenceChoice2 = sequenceChoice2;
- }
-
- public String toString()
- {
- return "[" + sequenceChoice1 + " " + sequenceChoice2 + "]";
- }
-
- public boolean equals(Object o)
- {
- if(this == o)
- {
- return true;
- }
- if(!(o instanceof Sequence))
- {
- return false;
- }
-
- final Sequence sequence = (Sequence)o;
-
- if(sequenceChoice1 != null ? !sequenceChoice1.equals(sequence.sequenceChoice1) : sequence.sequenceChoice1 != null)
- {
- return false;
- }
- if(sequenceChoice2 != null ? !sequenceChoice2.equals(sequence.sequenceChoice2) : sequence.sequenceChoice2 != null)
- {
- return false;
- }
-
- return true;
- }
-
- public int hashCode()
- {
- int result;
- result = (sequenceChoice1 != null ? sequenceChoice1.hashCode() : 0);
- result = 29 * result + (sequenceChoice2 != null ? sequenceChoice2.hashCode() : 0);
- return result;
- }
- }
-
- public static final class Choice
- {
- public String[] choiceChoice1;
- public String[] choiceChoice2;
-
- public Choice()
- {
- }
-
- public Choice(String[] choiceChoice1, String[] choiceChoice2)
- {
- this.choiceChoice1 = choiceChoice1;
- this.choiceChoice2 = choiceChoice2;
- }
-
- public String toString()
- {
- return "[" +
- (choiceChoice1 == null ? null : Arrays.asList(choiceChoice1)) +
- " " + (choiceChoice2 == null ? null : Arrays.asList(choiceChoice2)) + "]";
- }
-
- public boolean equals(Object o)
- {
- if(this == o)
- {
- return true;
- }
- if(!(o instanceof Choice))
- {
- return false;
- }
-
- final Choice choice = (Choice)o;
-
- if(!Arrays.equals(choiceChoice1, choice.choiceChoice1))
- {
- return false;
- }
- if(!Arrays.equals(choiceChoice2, choice.choiceChoice2))
- {
- return false;
- }
-
- return true;
- }
-
- public int hashCode()
- {
- return 0;
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/SchemaBindingInitializerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/SchemaBindingInitializerUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/SchemaBindingInitializerUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,140 +0,0 @@
-/*
-* 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$
- */
-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);
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/SchemaImportUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/SchemaImportUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/SchemaImportUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,187 +0,0 @@
-/*
- * 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$</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");
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/SchemaIncludeUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/SchemaIncludeUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/SchemaIncludeUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,59 +0,0 @@
-/*
-* 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$
- */
-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);
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/SchemalessTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/SchemalessTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/SchemalessTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,72 +0,0 @@
-/*
- * 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$</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);
- }
-
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/SimpleTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/SimpleTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/SimpleTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,324 +0,0 @@
-/*
- * 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.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.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 junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
- * @version <tt>$Revision$</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 = UnmarshallerFactory.newInstance().newUnmarshaller();
-
- // 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 reader = UnmarshallerFactory.newInstance().newUnmarshaller();
-
- StringReader strReader = new StringReader(content);
- reader.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 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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/SimpleTypeBindingUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/SimpleTypeBindingUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/SimpleTypeBindingUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,491 +0,0 @@
-/*
- * 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$</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);
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/SoapEncUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/SoapEncUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/SoapEncUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,729 +0,0 @@
-/*
- * 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$</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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/SundayUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/SundayUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/SundayUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,613 +0,0 @@
-/*
- * 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$</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();
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/ValueListUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/ValueListUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/ValueListUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,168 +0,0 @@
-/*
- * 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.Map;
-import java.util.Iterator;
-import javax.xml.namespace.QName;
-import org.jboss.xb.binding.group.ValueListInitializer;
-import org.jboss.xb.binding.group.ValueList;
-import org.jboss.xb.binding.group.ValueListHandler;
-
-/**
- * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
- * @version <tt>$Revision$</tt>
- */
-public class ValueListUnitTestCase
- extends AbstractJBossXBTest
-{
- public ValueListUnitTestCase(String name)
- {
- super(name);
- }
-
- public void testNone()
- {
- fail("todo: needs update");
- }
-
-/*
- public void testNonReqAttrAndElemWithEqualQName() throws Exception
- {
- ValueListInitializer init = new ValueListInitializer();
- ValueList valueList = init.newValueList(ValueListHandler.IMMUTABLE, String.class);
-
- QName nonReqAttrQName = new QName("nonReqQName");
- QName nonReqElemQName = new QName("nonReqQName");
-
- init.addElementValue(nonReqElemQName, null, valueList, "nonReqElemQName");
- init.addAttributeValue(nonReqAttrQName, null, valueList, "nonReqAttrQName");
-
- // this is a very well known issue...
- assertEquals("nonReqAttrQName", init.getAttributeValue(nonReqAttrQName, valueList));
- assertEquals("This is a known issue", "nonReqElemQName", init.getElementValue(nonReqElemQName, valueList));
- }
-
- public void testNonRequired() throws Exception
- {
- ValueListInitializer init = new ValueListInitializer();
- ValueList valueList = init.newValueList(ValueListHandler.IMMUTABLE, String.class);
- assertTrue(init.isInitialized(valueList));
-
- QName nonReqAttrQName = new QName("nonReqAttrQName");
- QName nonReqElemQName = new QName("nonReqElemQName");
-
- init.addElementValue(nonReqElemQName, null, valueList, nonReqElemQName.getLocalPart());
- assertTrue(init.isInitialized(valueList));
- init.addAttributeValue(nonReqAttrQName, null, valueList, nonReqAttrQName.getLocalPart());
- assertTrue(init.isInitialized(valueList));
-
- Map nonReqValues = valueList.getNonRequiredValues();
- assertNotNull(nonReqValues);
- assertEquals(2, nonReqValues.size());
- assertEquals(nonReqAttrQName.getLocalPart(), nonReqValues.get(nonReqAttrQName));
- assertEquals(nonReqElemQName.getLocalPart(), nonReqValues.get(nonReqElemQName));
-
- Iterator iter = nonReqValues.entrySet().iterator();
- Map.Entry entry = (Map.Entry)iter.next();
- assertEquals(nonReqElemQName, entry.getKey());
- entry = (Map.Entry)iter.next();
- assertEquals(nonReqAttrQName, entry.getKey());
-
- assertEquals(nonReqAttrQName.getLocalPart(), init.getAttributeValue(nonReqAttrQName, valueList));
- assertEquals(nonReqElemQName.getLocalPart(), init.getElementValue(nonReqElemQName, valueList));
- }
-
- public void testRequired() throws Exception
- {
- QName attrAQName = new QName("attrA");
- QName attrBQName = new QName("attrB");
- QName attrCQName = new QName("attrC");
- QName elemAQName = new QName("nsa", "elemA");
- QName elemBQName = new QName("nsa", "elemB");
- QName elemCQName = new QName("nsc", "elemC");
-
- QName nonReqAttrQName = new QName("nonReqAttrQName");
- QName nonReqElemQName = new QName("nonReqElemQName");
-
- ValueListInitializer init = new ValueListInitializer();
-
- init.addRequiredAttribute(attrAQName, null);
- init.addRequiredAttribute(attrBQName, null);
- init.addRequiredAttribute(attrCQName, null);
- init.addRequiredElement(elemAQName, null);
- init.addRequiredElement(elemBQName, null);
- init.addRequiredElement(elemCQName, null);
-
- ValueList valueList = init.newValueList(ValueListHandler.IMMUTABLE, String.class);
- assertFalse(init.isInitialized(valueList));
-
- init.addAttributeValue(nonReqAttrQName, null, valueList, nonReqAttrQName.getLocalPart());
- init.addElementValue(nonReqElemQName, null, valueList, nonReqElemQName.getLocalPart());
-
- init.addAttributeValue(attrBQName, null, valueList, attrBQName.getLocalPart());
- assertFalse(init.isInitialized(valueList));
- init.addElementValue(elemCQName, null, valueList, elemCQName.getLocalPart());
- assertFalse(init.isInitialized(valueList));
- init.addAttributeValue(attrCQName, null, valueList, attrCQName.getLocalPart());
- assertFalse(init.isInitialized(valueList));
- init.addAttributeValue(attrAQName, null, valueList, attrAQName.getLocalPart());
- assertFalse(init.isInitialized(valueList));
- init.addElementValue(elemAQName, null, valueList, elemAQName.getLocalPart());
- assertFalse(init.isInitialized(valueList));
- init.addElementValue(elemBQName, null, valueList, elemBQName.getLocalPart());
- assertTrue(init.isInitialized(valueList));
-
- List values = valueList.getRequiredValues();
- assertNotNull(values);
- assertEquals(6, values.size());
- assertEquals(attrAQName.getLocalPart(), values.get(0));
- assertEquals(attrBQName.getLocalPart(), values.get(1));
- assertEquals(attrCQName.getLocalPart(), values.get(2));
- assertEquals(elemAQName.getLocalPart(), values.get(3));
- assertEquals(elemBQName.getLocalPart(), values.get(4));
- assertEquals(elemCQName.getLocalPart(), values.get(5));
-
- Map nonReqValues = valueList.getNonRequiredValues();
- assertNotNull(nonReqValues);
- assertEquals(2, nonReqValues.size());
- assertEquals(nonReqAttrQName.getLocalPart(), nonReqValues.get(nonReqAttrQName));
- assertEquals(nonReqElemQName.getLocalPart(), nonReqValues.get(nonReqElemQName));
-
- Iterator iter = nonReqValues.entrySet().iterator();
- Map.Entry entry = (Map.Entry)iter.next();
- assertEquals(nonReqAttrQName, entry.getKey());
- entry = (Map.Entry)iter.next();
- assertEquals(nonReqElemQName, entry.getKey());
-
- assertEquals(attrAQName.getLocalPart(), init.getAttributeValue(attrAQName, valueList));
- assertEquals(attrBQName.getLocalPart(), init.getAttributeValue(attrBQName, valueList));
- assertEquals(attrCQName.getLocalPart(), init.getAttributeValue(attrCQName, valueList));
- assertEquals(nonReqAttrQName.getLocalPart(), init.getAttributeValue(nonReqAttrQName, valueList));
- assertEquals(elemAQName.getLocalPart(), init.getElementValue(elemAQName, valueList));
- assertEquals(elemBQName.getLocalPart(), init.getElementValue(elemBQName, valueList));
- assertEquals(elemCQName.getLocalPart(), init.getElementValue(elemCQName, valueList));
- assertEquals(nonReqElemQName.getLocalPart(), init.getElementValue(nonReqElemQName, valueList));
- }
-*/
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/WildcardUnresolvedElementsUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/WildcardUnresolvedElementsUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/WildcardUnresolvedElementsUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,1015 +0,0 @@
-/*
- * 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 javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXResult;
-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.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.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.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-
-/**
- * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
- * @version <tt>$Revision$</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();
-
- DOMSource domSource = new DOMSource(e);
- SAXResult streamResult = new SAXResult(ch);
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer serializer = null;
- try
- {
- serializer = tf.newTransformer();
- }
- catch(TransformerConfigurationException e1)
- {
- throw new JBossXBRuntimeException("Failed to create transformer", e1);
- }
-
- try
- {
- serializer.transform(domSource, streamResult);
- }
- catch(TransformerException e1)
- {
- throw new JBossXBRuntimeException("Failed to marshal with transform", e1);
- }
- }
- }
- );
- }
-
- 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);
- 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;
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/WildcardWrapperUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/WildcardWrapperUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/WildcardWrapperUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,100 +0,0 @@
-/*
-* 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$
- */
-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);
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/XMLNameToJavaIdentifierUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/XMLNameToJavaIdentifierUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/XMLNameToJavaIdentifierUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,160 +0,0 @@
-/*
- * 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$</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]));
- }
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/XOPUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/XOPUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/XOPUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,547 +0,0 @@
-/*
- * 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.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.marshalling.MarshallerImpl;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
-import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
-import org.jboss.xb.binding.sunday.xop.XOPMarshaller;
-import org.jboss.xb.binding.sunday.xop.XOPObject;
-import org.jboss.xb.binding.sunday.xop.XOPUnmarshaller;
-import org.jboss.xb.binding.sunday.xop.SimpleDataSource;
-import org.xml.sax.SAXException;
-
-import javax.xml.transform.Source;
-import javax.activation.DataSource;
-import java.awt.*;
-import java.awt.image.ImageObserver;
-import java.awt.image.ImageProducer;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Arrays;
-
-
-/**
- * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
- * @version <tt>$Revision$</tt>
- */
-public class XOPUnitTestCase
- extends AbstractJBossXBTest
-{
- public XOPUnitTestCase(String name)
- {
- super(name);
- }
-
- private static final XOPMarshaller XOP_ENABLED_MARSH = new XOPMarshaller()
- {
- public boolean isXOPPackage()
- {
- return true;
- }
-
- public String addMtomAttachment(byte[] data, String elementNamespace, String elementName)
- {
- return "cid:" + elementName;
- }
-
- public String addMtomAttachment(XOPObject dataHandler, String elementNamespace, String elementName)
- {
- return "cid:" + elementName;
- }
- };
-
- private static final XOPMarshaller XOP_DISABLED_MARSH = new XOPMarshaller()
- {
- public boolean isXOPPackage()
- {
- return false;
- }
-
- public String addMtomAttachment(byte[] data, String elementNamespace, String elementName)
- {
- return "cid:" + elementName;
- }
-
- public String addMtomAttachment(XOPObject dataHandler, String elementNamespace, String elementName)
- {
- return "cid:" + elementName;
- }
- };
-
- private static final Image AWT_IMAGE = new Image()
- {
- private final int width = 5;
- private final int height = 7;
-
- public int getWidth(ImageObserver observer)
- {
- return width;
- }
-
- public int getHeight(ImageObserver observer)
- {
- return height;
- }
-
- public ImageProducer getSource()
- {
- throw new UnsupportedOperationException("getSource is not implemented.");
- }
-
- public Graphics getGraphics()
- {
- throw new UnsupportedOperationException("getGraphics is not implemented.");
- }
-
- public Object getProperty(String name, ImageObserver observer)
- {
- throw new UnsupportedOperationException("getProperty is not implemented.");
- }
-
- public void flush()
- {
- throw new UnsupportedOperationException("flush is not implemented.");
- }
- };
-
- private static final Source SOURCE = new Source()
- {
- private String systemId = "http://www.jboss.org/test/xml/xop";
-
- public void setSystemId(String systemId)
- {
- this.systemId = systemId;
- }
-
- public String getSystemId()
- {
- return systemId;
- }
- };
-
- private static final XOPUnmarshaller XOP_ENABLED_UNMARSH = new XOPUnmarshaller()
- {
- public boolean isXOPPackage()
- {
- return true;
- }
-
- public XOPObject getAttachmentAsDataHandler(String cid)
- {
- XOPObject xopObject;
-
- if(cid.endsWith("awtImage"))
- {
- xopObject = new XOPObject(AWT_IMAGE);
- xopObject.setContentType("image/jpeg");
- }
- else if(cid.endsWith("source"))
- {
- xopObject = new XOPObject(SOURCE);
- xopObject.setContentType("application/xml");
- }
- else if(cid.endsWith("string"))
- {
- xopObject = new XOPObject("string");
- xopObject.setContentType("text/xml");
- }
- else if(cid.endsWith("octets"))
- {
- xopObject = new XOPObject("octets".getBytes());
- xopObject.setContentType("application/octet-stream");
- }
- else
- {
- try
- {
- DataSource ds = new SimpleDataSource(cid.substring(4).getBytes(), "application/octet-stream");
- xopObject = new XOPObject(ds.getInputStream());
- xopObject.setContentType("application/octet-stream");
- }
- catch (IOException e)
- {
- throw new IllegalStateException(e.getMessage());
-
- }
- }
-
- return xopObject;
- }
-
- public byte[] getAttachmentAsByteArray(String cid)
- {
- return cid.substring(4).getBytes();
- }
- };
-
- private static final XOPUnmarshaller XOP_DISABLED_UNMARSH = new XOPUnmarshaller()
- {
- public boolean isXOPPackage()
- {
- return false;
- }
-
- public XOPObject getAttachmentAsDataHandler(String cid)
- {
- throw new UnsupportedOperationException("getAttachmentAsDataHandler is not implemented.");
- }
-
- public byte[] getAttachmentAsByteArray(String cid)
- {
- throw new UnsupportedOperationException("getAttachmentAsByteArray is not implemented.");
- }
- };
-
- private static SchemaBinding SCHEMA;
- private static String NON_OPT_XML;
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- if(SCHEMA == null)
- {
- String testXsd = findXML(rootName + ".xsd");
-
- DefaultSchemaResolver resolver = new DefaultSchemaResolver();
- String xmimeXsd = getSchemaLocation(getClass(), "xmlmime.xsd");
- resolver.addSchemaLocation("http://www.w3.org/2005/05/xmlmime", xmimeXsd);
-
- SCHEMA = XsdBinder.bind(testXsd, resolver);
- SCHEMA.setIgnoreUnresolvedFieldOrClass(false);
- }
-
- if(NON_OPT_XML == null)
- {
- NON_OPT_XML = readXml(rootName + ".xml");
- }
- }
-
- public void testUnmarshalNonOptimized() throws Exception
- {
- SCHEMA.setXopUnmarshaller(XOP_DISABLED_UNMARSH);
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- Object o = unmarshaller.unmarshal(new StringReader(NON_OPT_XML), SCHEMA);
-
- assertNotNull(o);
- assertTrue(o instanceof E);
-
- E e = (E)o;
- assertNotNull(e.image);
- assertEquals("image", new String(e.image));
- assertNotNull(e.sig);
- assertEquals("sig", new String(e.sig));
- }
-
- public void testMarshalWithDisabledXop() throws Exception
- {
- assertXmlEqual(NON_OPT_XML, marshal(XOP_DISABLED_MARSH));
- }
-
- public void testUnmarshalOptimized() throws Exception
- {
- SCHEMA.setXopUnmarshaller(XOP_ENABLED_UNMARSH);
-
- String xml = readXml(rootName + "Optimized.xml");
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- Object o = unmarshaller.unmarshal(new StringReader(xml), SCHEMA);
-
- assertNotNull(o);
- assertTrue(o instanceof E);
-
- E e = (E)o;
- assertNotNull(e.image);
- assertEquals("image", new String(e.image));
- assertNotNull(e.sig);
- assertEquals("sig", new String(e.sig));
-
- }
-
- public void testMarshalWithEnabledXop() throws Exception
- {
- String xml = readXml(rootName + "Optimized.xml");
- assertXmlEqual(xml, marshal(XOP_ENABLED_MARSH));
- }
-
- public void testUnmarshalImageWithOptimized() throws Exception
- {
- SCHEMA.setXopUnmarshaller(XOP_ENABLED_UNMARSH);
-
- String xml = readXml(rootName + "ImageWithContentType.xml");
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- Object o = unmarshaller.unmarshal(new StringReader(xml), SCHEMA);
-
- assertNotNull(o);
- assertTrue(o instanceof E);
-
- E e = (E)o;
- assertNotNull(e.imageWithContentType);
- assertEquals("imageWithContentType", new String(e.imageWithContentType));
-
- }
-
- public void testMarshalImageWithContentType() throws Exception
- {
- String xml = readXml(rootName + "ImageWithContentType.xml");
- E e = new E();
- e.imageWithContentType = "imageWithContentType".getBytes();
- String marshalled = marshal(XOP_ENABLED_MARSH, e);
- assertXmlEqual(xml, marshalled);
-
- }
-
- public void testUnmarshalJpegOptimized() throws Exception
- {
- SCHEMA.setXopUnmarshaller(XOP_ENABLED_UNMARSH);
-
- String xml = readXml(rootName + "Jpeg.xml");
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- Object o = unmarshaller.unmarshal(new StringReader(xml), SCHEMA);
-
- assertNotNull(o);
- assertTrue(o instanceof E);
-
- E e = (E)o;
- assertNotNull(e.jpeg);
- assertEquals("jpeg", new String(e.jpeg));
- }
-
- public void testMarshalJpeg() throws Exception
- {
- String xml = readXml(rootName + "Jpeg.xml");
- E e = new E();
- e.jpeg = "jpeg".getBytes();
- String marshalled = marshal(XOP_ENABLED_MARSH, e);
- assertXmlEqual(xml, marshalled);
- }
-
- public void testMarshalAWTImage() throws Exception
- {
- E e = new E();
- e.awtImage = AWT_IMAGE;
- String marshalled = marshal(XOP_ENABLED_MARSH, e);
- assertXmlEqual(getOptimizedXml("awtImage"), marshalled);
- }
-
- public void testUnmarshalAwtImage() throws Exception
- {
- SCHEMA.setXopUnmarshaller(XOP_ENABLED_UNMARSH);
-
- String xml = getOptimizedXml("awtImage");
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- Object o = unmarshaller.unmarshal(new StringReader(xml), SCHEMA);
-
- assertNotNull(o);
- assertTrue(o instanceof E);
-
- E e = (E)o;
- assertNotNull(e.awtImage);
- assertEquals(5, e.awtImage.getWidth(null));
- assertEquals(7, e.awtImage.getHeight(null));
- }
-
- public void testMarshalSource() throws Exception
- {
- E e = new E();
- e.source = SOURCE;
- String marshalled = marshal(XOP_ENABLED_MARSH, e);
- assertXmlEqual(getOptimizedXml("source"), marshalled);
- }
-
- public void testUnmarshalSource() throws Exception
- {
- SCHEMA.setXopUnmarshaller(XOP_ENABLED_UNMARSH);
-
- String xml = getOptimizedXml("source");
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- Object o = unmarshaller.unmarshal(new StringReader(xml), SCHEMA);
-
- assertNotNull(o);
- assertTrue(o instanceof E);
-
- E e = (E)o;
- assertNotNull(e.source);
- assertEquals("http://www.jboss.org/test/xml/xop", e.source.getSystemId());
- }
-
- public void testMarshalString() throws Exception
- {
- E e = new E();
- e.string = "string";
- String marshalled = marshal(XOP_ENABLED_MARSH, e);
- assertXmlEqual(getOptimizedXml("string"), marshalled);
- }
-
- /**
- * Test a simple xsd:base64Binary declaration
- */
- public void testMarshalOctets() throws Exception
- {
- E e = new E();
- e.octets = "octets".getBytes();
- String marshalled = marshal(XOP_ENABLED_MARSH, e);
- assertXmlEqual(getOptimizedXml("octets"), marshalled);
- }
-
- /**
- * Test unmarshalling of a simple xsd:base64Binary declaration
- */
- public void testUnmarshalOctets() throws Exception
- {
- SCHEMA.setXopUnmarshaller(XOP_ENABLED_UNMARSH);
-
- String xml = getOptimizedXml("octets");
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- Object o = unmarshaller.unmarshal(new StringReader(xml), SCHEMA);
-
- assertNotNull(o);
- assertTrue(o instanceof E);
-
- E e = (E)o;
- assertNotNull(e.octets);
- assertEquals("octets", new String(e.octets));
- }
-
- public void testUnmarshalString() throws Exception
- {
- SCHEMA.setXopUnmarshaller(XOP_ENABLED_UNMARSH);
-
- String xml = getOptimizedXml("string");
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- Object o = unmarshaller.unmarshal(new StringReader(xml), SCHEMA);
-
- assertNotNull(o);
- assertTrue(o instanceof E);
-
- E e = (E)o;
- assertNotNull(e.string);
- assertEquals("string", e.string);
- }
-
- public void testTopLevelUnmarshalling() throws Exception
- {
- String xsd =
- "<schema" +
- " xmlns='http://www.w3.org/2001/XMLSchema'" +
- " xmlns:xmime='http://www.w3.org/2005/05/xmlmime'" +
- " targetNamespace='http://www.jboss.org/xml/test/xop'>" +
- " <import namespace='http://www.w3.org/2005/05/xmlmime' schemaLocation='xmlmime.xsd'/>" +
- " <element name='applxml' xmime:expectedContentTypes='application/xml' type='xmime:base64Binary'/>" +
- "</schema>";
-
- DefaultSchemaResolver resolver = new DefaultSchemaResolver();
- String xmimeXsd = getSchemaLocation(getClass(), "xmlmime.xsd");
- resolver.addSchemaLocation("http://www.w3.org/2005/05/xmlmime", xmimeXsd);
-
- SchemaBinding schema = XsdBinder.bind(new StringReader(xsd), null, resolver);
- schema.setIgnoreUnresolvedFieldOrClass(false);
- schema.setXopUnmarshaller(XOP_ENABLED_UNMARSH);
-
- String xml =
- "<applxml xmlns='http://www.jboss.org/xml/test/xop'>" +
- " <xop:Include href='cid:applxml' xmlns:xop='http://www.w3.org/2004/08/xop/include'/>" +
- "</applxml>";
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- Object o = unmarshaller.unmarshal(new StringReader(xml), schema);
- assertNotNull(o);
- assertTrue(o instanceof byte[]);
- assertTrue(Arrays.equals("applxml".getBytes(), (byte[])o));
- }
-
- // Private
-
- private String readXml(String name)
- throws IOException
- {
- String testXml = getResource(name).getFile();
- FileInputStream fis = new FileInputStream(testXml);
- byte[] bytes = new byte[fis.available()];
- fis.read(bytes);
- fis.close();
- return new String(bytes);
- }
-
- private static String marshal(XOPMarshaller xopMarshaller)
- throws IOException, SAXException
- {
- E e = new E();
- e.image = "image".getBytes();
- e.sig = "sig".getBytes();
- return marshal(xopMarshaller, e);
- }
-
- private static String marshal(XOPMarshaller xopMarshaller, E e)
- throws IOException, SAXException
- {
- SCHEMA.setXopMarshaller(xopMarshaller);
- StringWriter writer = new StringWriter();
- MarshallerImpl marshaller = new MarshallerImpl();
- marshaller.marshal(SCHEMA, null, e, writer);
- return writer.getBuffer().toString();
- }
-
- private static String getOptimizedXml(String elementName)
- {
- return
- "<e xmlns='http://www.jboss.org/xml/test/xop'>" +
- " <" +
- elementName +
- ">" +
- " <xop:Include xmlns:xop='http://www.w3.org/2004/08/xop/include' href='cid:" +
- elementName +
- "'/>" +
- " </" +
- elementName +
- ">" +
- "</e>";
- }
-
- // Inner
-
- public static class E
- {
- public byte[] image;
- public byte[] sig;
- public byte[] imageWithContentType;
- public byte[] jpeg;
-
- public Image awtImage;
- public Source source;
- public String string;
- public byte[] octets;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/XercesBugTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/XercesBugTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/XercesBugTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,174 +0,0 @@
-/*
- * 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$</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;
- }
-}
Deleted: trunk/testsuite/src/main/org/jboss/test/xml/XsiTypeUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/XsiTypeUnitTestCase.java 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/main/org/jboss/test/xml/XsiTypeUnitTestCase.java 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,416 +0,0 @@
-/*
- * 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$</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 final SchemaBinding SCHEMA = XsdBinder.bind(new StringReader(PO_XSD), null, SCHEMA_RESOLVER);
-
- public XsiTypeUnitTestCase(String name)
- {
- super(name);
- }
-
- protected void configureLogging()
- {
- }
-
- 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;
- }
- }
-}
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal1.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal1.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal1.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<top xmlns='http://www.jboss.org/test/xml/repeatableterms'>
- <item>item1</item>
- <item>item2</item>
- <item>item3</item>
-
- <sequenceChoice1>sequenceChoice1_1</sequenceChoice1>
- <sequenceChoice2>sequenceChoice2_1</sequenceChoice2>
- <sequenceChoice1>sequenceChoice1_2</sequenceChoice1>
- <sequenceChoice1>sequenceChoice1_3</sequenceChoice1>
- <sequenceChoice2>sequenceChoice2_2</sequenceChoice2>
-
- <choiceChoice1>choiceChoice1_1</choiceChoice1>
- <choiceChoice1>choiceChoice1_2</choiceChoice1>
-
- <choiceChoice2>choiceChoice2_1</choiceChoice2>
- <choiceChoice2>choiceChoice2_2</choiceChoice2>
-
- <choiceChoice1>choiceChoice1_3</choiceChoice1>
- <choiceChoice1>choiceChoice1_4</choiceChoice1>
-</top>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal1.xsd
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal1.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal1.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://www.jboss.org/test/xml/repeatableterms"
- xmlns="http://www.jboss.org/test/xml/repeatableterms"
- xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="1.0">
-
- <xsd:element name="top">
- <xsd:annotation>
- <xsd:appinfo>
- <jbxb:class impl="org.jboss.test.xml.RepeatableTermsUnitTestCase$Top"/>
- </xsd:appinfo>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="item" type="xsd:string" maxOccurs="unbounded"/>
- <xsd:sequence maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:appinfo>
- <jbxb:class impl="org.jboss.test.xml.RepeatableTermsUnitTestCase$Sequence"/>
- <jbxb:property name="sequence"/>
- </xsd:appinfo>
- </xsd:annotation>
- <xsd:choice>
- <xsd:element name="sequenceChoice1" type="xsd:string"/>
- <xsd:element name="sequenceChoice2" type="xsd:string"/>
- </xsd:choice>
- </xsd:sequence>
- <xsd:choice maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:appinfo>
- <jbxb:class impl="org.jboss.test.xml.RepeatableTermsUnitTestCase$Choice"/>
- <jbxb:property name="choice"/>
- </xsd:appinfo>
- </xsd:annotation>
- <xsd:element name="choiceChoice1" type="xsd:string" maxOccurs="unbounded"/>
- <xsd:element name="choiceChoice2" type="xsd:string" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-</xsd:schema>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal2.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal2.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal2.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<top xmlns='http://www.jboss.org/test/xml/repeatableterms'>
- <item1>item1</item1>
- <item2>item2</item2>
-</top>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal2.xsd
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal2.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testUnmarshal2.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://www.jboss.org/test/xml/repeatableterms"
- xmlns="http://www.jboss.org/test/xml/repeatableterms"
- xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="1.0">
-
- <xsd:element name="top">
- <xsd:annotation>
- <xsd:appinfo>
- <jbxb:class impl="org.jboss.test.xml.RepeatableTermsUnitTestCase$Top"/>
- </xsd:appinfo>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence maxOccurs="unbounded">
- <xsd:sequence maxOccurs="unbounded">
- <xsd:choice maxOccurs="unbounded">
- <xsd:sequence maxOccurs="unbounded">
- <xsd:element name="item1" type="xsd:string"/>
- </xsd:sequence>
- <xsd:sequence maxOccurs="unbounded">
- <xsd:sequence maxOccurs="unbounded">
- <xsd:element name="item2" type="xsd:string"/>
- </xsd:sequence>
- </xsd:sequence>
- </xsd:choice>
- </xsd:sequence>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-</xsd:schema>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<containerStrict
-xmlns="dummy://www.jboss.org/container"
-/>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xsd
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainer.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,34 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxNotSimple.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxNotSimple.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxNotSimple.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,9 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxSimple.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxSimple.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerLaxSimple.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,9 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipNotSimple.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipNotSimple.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipNotSimple.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,9 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipSimple.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipSimple.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerSkipSimple.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,9 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictNotSimple.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictNotSimple.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictNotSimple.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,9 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictSimple.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictSimple.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseContainerStrictSimple.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,9 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<test
-xmlns="dummy://www.jboss.org/simple"
->SimpleTest</test>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xsd
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/SchemaBindingInitializerUnitTestCaseSimple.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,12 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCase.xsd
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCase.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCase.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,29 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseSimple.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseSimple.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseSimple.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<property xmlns="dummy://www.jboss.org/property">
- <value>testSimple</value>
-</property>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseWildcard.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseWildcard.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/WildcardWrapperUnitTestCaseWildcard.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,5 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCase.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCase.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCase.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,6 +0,0 @@
-<e xmlns="http://www.jboss.org/xml/test/xop"
- xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
- xsi:schemaLocation='http://www.jboss.org/xml/test/xop XOPUnitTestCase.xsd'>
- <image>aW1hZ2U=</image>
- <sig>c2ln</sig>
-</e>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCase.xsd
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCase.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCase.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://www.jboss.org/xml/test/xop"
- xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
- targetNamespace="http://www.jboss.org/xml/test/xop"
- xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
- elementFormDefault="qualified">
-
- <xs:import namespace="http://www.w3.org/2005/05/xmlmime" schemaLocation="xmlmime.xsd"/>
-
- <xs:element name="e">
- <xs:annotation>
- <xs:appinfo>
- <jbxb:class impl="org.jboss.test.xml.XOPUnitTestCase$E"/>
- </xs:appinfo>
- </xs:annotation>
- <xs:complexType>
- <xs:sequence>
- <xs:element name="image" type="xmime:base64Binary" minOccurs="0"/>
- <xs:element name="sig" type="tns:MyBinaryType" minOccurs="0"/>
- <xs:element name="imageWithContentType" type="tns:PictureType" minOccurs="0"/>
- <xs:element name="jpeg" type="tns:JPEGPictureType" minOccurs="0"/>
-
- <xs:element name="awtImage" type="xmime:base64Binary" minOccurs="0"/>
- <xs:element name="source" type="xmime:base64Binary" minOccurs="0"/>
- <xs:element name="string" type="xmime:base64Binary" minOccurs="0"/>
-
- <xs:element name="octets" type="xs:base64Binary" minOccurs="0"/>
-
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <!-- This element has binary content and requires the xmime:contentType
- attribute that indicates the content-type of the binary element -->
- <xs:complexType name="MyBinaryType">
- <xs:simpleContent>
- <xs:extension base="xs:base64Binary" >
- <xs:attribute ref="xmime:contentType" use="required"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-
- <xs:complexType name="PictureType">
- <xs:simpleContent>
- <xs:restriction base="xmime:base64Binary" >
- <xs:attribute ref="xmime:contentType" use="required" />
- </xs:restriction>
- </xs:simpleContent>
- </xs:complexType>
-
- <xs:simpleType name="JPEGPictureType" xmime:expectedContentTypes="image/jpeg">
- <xs:restriction base="xs:base64Binary"/>
- </xs:simpleType>
-
-</xs:schema>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseImageWithContentType.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseImageWithContentType.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseImageWithContentType.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ns_e:e xmlns:ns_e='http://www.jboss.org/xml/test/xop'>
- <ns_e:imageWithContentType>
- <xop:Include href='cid:imageWithContentType' xmlns:xop='http://www.w3.org/2004/08/xop/include'></xop:Include>
- </ns_e:imageWithContentType>
-</ns_e:e>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseJpeg.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseJpeg.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseJpeg.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<e xmlns="http://www.jboss.org/xml/test/xop">
- <jpeg>
- <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:jpeg"/>
- </jpeg>
-</e>
\ No newline at end of file
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseOptimized.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseOptimized.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/XOPUnitTestCaseOptimized.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<e xmlns="http://www.jboss.org/xml/test/xop"
- xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
- xsi:schemaLocation='http://www.jboss.org/xml/test/xop XOPUnitTestCase.xsd'>
- <image>
- <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:image"/>
- </image>
- <sig>
- <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:sig"/>
- </sig>
-</e>
Deleted: trunk/testsuite/src/resources/org/jboss/test/xml/xmlmime.xsd
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/xmlmime.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/xmlmime.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,49 +0,0 @@
-<!--
-
- W3C XML Schema defined in the Describing Media Content of Binary Data in XML
- specification
- http://www.w3.org/TR/xml-media-types
-
- Copyright c 2005 World Wide Web Consortium,
-
- (Massachusetts Institute of Technology, European Research Consortium for
- Informatics and Mathematics, Keio University). All Rights Reserved. This
- work is distributed under the W3CR Software License [1] 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.
-
- [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
-
- $Id$
--->
-<xs:schema
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
- targetNamespace="http://www.w3.org/2005/05/xmlmime">
-
- <xs:attribute name="contentType">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="3"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
-
- <xs:attribute name="expectedContentTypes" type="xs:string"/>
-
- <xs:complexType name="base64Binary">
- <xs:simpleContent>
- <xs:extension base="xs:base64Binary">
- <xs:attribute ref="xmime:contentType"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-
- <xs:complexType name="hexBinary">
- <xs:simpleContent>
- <xs:extension base="xs:hexBinary">
- <xs:attribute ref="xmime:contentType"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-</xs:schema>
Deleted: trunk/testsuite/src/resources/xml/SchemaIncludeUnitTestCase.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/SchemaIncludeUnitTestCase.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/SchemaIncludeUnitTestCase.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- A prototype xsd schema for the pojoserver xml deployer
-$Id$
- -->
-<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>
Deleted: trunk/testsuite/src/resources/xml/SchemaIncludeUnitTestCaseIncluded.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/SchemaIncludeUnitTestCaseIncluded.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/SchemaIncludeUnitTestCaseIncluded.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- A prototype xsd schema for the pojoserver xml deployer
-$Id$
- -->
-<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>
Deleted: trunk/testsuite/src/resources/xml/annotated-bean-deployer_1_0.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/annotated-bean-deployer_1_0.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/annotated-bean-deployer_1_0.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,898 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- A prototype xsd schema for the pojoserver xml deployer
-$Id$
- -->
-<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>
Deleted: trunk/testsuite/src/resources/xml/any.xml
===================================================================
--- trunk/testsuite/src/resources/xml/any.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/any.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,39 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/xml/any.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/any.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/any.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,19 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/xml/bean-deployer_1_0.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/bean-deployer_1_0.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/bean-deployer_1_0.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,688 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- A prototype xsd schema for the pojoserver xml deployer
-$Id$
- -->
-<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>
Deleted: trunk/testsuite/src/resources/xml/choice.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/choice.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/choice.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,44 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/xml/collections.xml
===================================================================
--- trunk/testsuite/src/resources/xml/collections.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/collections.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,30 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/xml/collections.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/collections.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/collections.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,25 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/xml/immutable.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/immutable.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/immutable.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,60 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/xml/jbxb-bean-deployer_1_0.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/jbxb-bean-deployer_1_0.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/jbxb-bean-deployer_1_0.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,929 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- A prototype xsd schema for the pojoserver xml deployer
-$Id$
- -->
-<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>
Deleted: trunk/testsuite/src/resources/xml/maps.xml
===================================================================
--- trunk/testsuite/src/resources/xml/maps.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/maps.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,20 +0,0 @@
-<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>
Deleted: trunk/testsuite/src/resources/xml/maps.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/maps.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/maps.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,233 +0,0 @@
-<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>
Deleted: trunk/testsuite/src/resources/xml/newmetadata.xml
===================================================================
--- trunk/testsuite/src/resources/xml/newmetadata.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/newmetadata.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,44 +0,0 @@
-<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>
Deleted: trunk/testsuite/src/resources/xml/person.dtd
===================================================================
--- trunk/testsuite/src/resources/xml/person.dtd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/person.dtd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,14 +0,0 @@
-<?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)>
Deleted: trunk/testsuite/src/resources/xml/person.xml
===================================================================
--- trunk/testsuite/src/resources/xml/person.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/person.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,20 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/xml/person.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/person.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/person.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,38 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/xml/po.xml
===================================================================
--- trunk/testsuite/src/resources/xml/po.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/po.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,32 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/xml/po.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/po.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/po.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,77 +0,0 @@
-<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>
Deleted: trunk/testsuite/src/resources/xml/sandbox.xml
===================================================================
--- trunk/testsuite/src/resources/xml/sandbox.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/sandbox.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,32 +0,0 @@
-<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>
Deleted: trunk/testsuite/src/resources/xml/sandbox.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/sandbox.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/sandbox.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,50 +0,0 @@
-<?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>
Deleted: trunk/testsuite/src/resources/xml/valuebinding.xml
===================================================================
--- trunk/testsuite/src/resources/xml/valuebinding.xml 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/valuebinding.xml 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,25 +0,0 @@
-<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>
Deleted: trunk/testsuite/src/resources/xml/xerces-bug.xsd
===================================================================
--- trunk/testsuite/src/resources/xml/xerces-bug.xsd 2006-10-12 12:25:44 UTC (rev 57582)
+++ trunk/testsuite/src/resources/xml/xerces-bug.xsd 2006-10-12 12:53:48 UTC (rev 57583)
@@ -1,60 +0,0 @@
-<?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-cvs-commits
mailing list