Index: src/test/java/org/castor/xml/schema/ComplexTypeTest.java =================================================================== --- src/test/java/org/castor/xml/schema/ComplexTypeTest.java (Revision 0) +++ src/test/java/org/castor/xml/schema/ComplexTypeTest.java (Revision 0) @@ -0,0 +1,63 @@ +/* + * Copyright 2008 Le Duc Bao + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.castor.xml.schema; + +import org.castor.xml.schema.framework.AbstractSchemaTest; +import org.exolab.castor.xml.schema.ComplexType; +import org.exolab.castor.xml.schema.ElementDecl; +import org.exolab.castor.xml.schema.Group; + +/** + * Complex type tests + * + * @author Le Duc Bao + */ +public class ComplexTypeTest extends AbstractSchemaTest { + + /** + * @param testcase + */ + public ComplexTypeTest(String testcase) { + super(testcase); + } + + /** + * Create simple type + */ + public void testSingleAttribute() { + + try { + // create targeted schema + _schema.addNamespace("pre", "my.namespace.org"); + ComplexType cType = _schema.createComplexType("myType"); + _schema.addComplexType(cType); + + Group group = new Group(); + cType.addGroup(group); + + ElementDecl e = new ElementDecl(_schema); + e.setName("myAttr"); + group.addElementDecl(e); + + // compare + int result = doTest("complextype_singleattribute.xsd"); + assertEquals("single attribute test failed", NO_DIFFERENCE, result); + } catch (Exception e) { + fail("testSingleNamespace: " + e.getMessage()); + } + } + +} Index: src/test/java/org/castor/xml/schema/NamespaceTest.java =================================================================== --- src/test/java/org/castor/xml/schema/NamespaceTest.java (Revision 0) +++ src/test/java/org/castor/xml/schema/NamespaceTest.java (Revision 0) @@ -0,0 +1,45 @@ +/* + * Copyright 2008 Le Duc Bao + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.castor.xml.schema; + +import org.castor.xml.schema.framework.AbstractSchemaTest; + +/** + * Namespace tests. + * + * @author Le Duc Bao + */ +public final class NamespaceTest extends AbstractSchemaTest { + public NamespaceTest(final String testcase) { + super(testcase); + } + + /** + * Create a schema with single namespace + */ + public void testSingleNamespace() { + + try { + // create targeted schema + _schema.addNamespace("myprefix", "my.namespace.org"); + + int result = doTest("namespace_1.xsd"); + assertEquals("single namespace add failed", NO_DIFFERENCE, result); + } catch (Exception e) { + fail("testSingleNamespace: " + e.getMessage()); + } + } +} Index: src/test/java/org/castor/xml/schema/framework/AbstractSchemaTest.java =================================================================== --- src/test/java/org/castor/xml/schema/framework/AbstractSchemaTest.java (Revision 0) +++ src/test/java/org/castor/xml/schema/framework/AbstractSchemaTest.java (Revision 0) @@ -0,0 +1,116 @@ +/* + * Copyright 2008 Le Duc Bao + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.castor.xml.schema.framework; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.Writer; +import java.net.URL; + +import org.castor.xmlctf.xmldiff.XMLDiff; +import org.exolab.castor.xml.schema.Schema; +import org.exolab.castor.xml.schema.writer.SchemaWriter; + +import junit.framework.TestCase; + +/** + * This class aims to set up a test environment and to provide a skeleton for + * testing Schema API. A typical scenarios test is + *