You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by bi...@apache.org on 2008/12/17 03:39:54 UTC
svn commit: r727246 [8/8] - in /webservices/commons/trunk/modules/XmlSchema:
./ etc/ etc/eclipse/ src/main/java/org/apache/ws/commons/schema/
src/main/java/org/apache/ws/commons/schema/constants/
src/main/java/org/apache/ws/commons/schema/extensions/ s...
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentExtensionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentExtensionTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentExtensionTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentExtensionTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,33 +19,25 @@
package tests;
-import junit.framework.TestCase;
-import org.apache.ws.commons.schema.*;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.stream.StreamSource;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
-/*
- * Copyright 2004,2007 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * 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.
- *
- */
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContent;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension;
+
public class SimpleContentExtensionTest extends TestCase {
/**
@@ -64,12 +56,12 @@
* </extension> </simpleContent> </complexType> </element> </schema>
*/
- QName ELEMENT_QNAME = new QName("http://soapinterop.org/types", "height");
+ QName elementQName = new QName("http://soapinterop.org/types", "height");
InputStream is = new FileInputStream(Resources.asURI("simplecontentextension.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema schema = schemaCol.read(new StreamSource(is), null);
- XmlSchemaElement elem = schema.getElementByName(ELEMENT_QNAME);
+ XmlSchemaElement elem = schema.getElementByName(elementQName);
assertNotNull(elem);
assertEquals("height", elem.getName());
assertEquals(new QName("http://soapinterop.org/types", "height"), elem.getQName());
@@ -86,27 +78,28 @@
XmlSchemaObjectCollection xsoc = xssce.getAttributes();
assertEquals(3, xsoc.getCount());
- Set s = new HashSet();
+ Set<String> s = new HashSet<String>();
s.add("units");
s.add("id");
s.add("desc");
for (int i = 0; i < xsoc.getCount(); i++) {
XmlSchemaAttribute xsa = (XmlSchemaAttribute)xsoc.getItem(i);
String name = xsa.getName();
- if (name.equals("units")) {
+ if ("units".equals(name)) {
assertEquals(new QName("http://soapinterop.org/types", "units"), xsa.getQName());
- assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"), xsa.getSchemaTypeName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"),
+ xsa.getSchemaTypeName());
assertNull(xsa.getDefaultValue());
assertEquals("required", xsa.getUse().getValue());
assertNull(xsa.getFixedValue());
- } else if (name.equals("id")) {
+ } else if ("id".equals(name)) {
assertEquals(new QName("http://soapinterop.org/types", "id"), xsa.getQName());
assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"), xsa
.getSchemaTypeName());
assertEquals("001", xsa.getDefaultValue());
assertEquals("required", xsa.getUse().getValue());
assertNull(xsa.getFixedValue());
- } else if (name.equals("desc")) {
+ } else if ("desc".equals(name)) {
assertEquals(new QName("http://soapinterop.org/types", "desc"), xsa.getQName());
assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "decimal"), xsa
.getSchemaTypeName());
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,16 +19,25 @@
package tests;
-import junit.framework.TestCase;
-import org.apache.ws.commons.schema.*;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.stream.StreamSource;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContent;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction;
+
/*
* Copyright 2004,2007 The Apache Software Foundation.
* Copyright 2006 International Business Machines Corp.
@@ -66,12 +75,12 @@
* default="001"/> </restriction> </simpleContent> </complexType> </schema>
*/
- QName TYPE_QNAME = new QName("http://soapinterop.org/types", "dietdrinksize");
+ QName typeQName = new QName("http://soapinterop.org/types", "dietdrinksize");
InputStream is = new FileInputStream(Resources.asURI("screstriction.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema schema = schemaCol.read(new StreamSource(is), null);
- XmlSchemaComplexType xsct = (XmlSchemaComplexType)schema.getTypeByName(TYPE_QNAME);
+ XmlSchemaComplexType xsct = (XmlSchemaComplexType)schema.getTypeByName(typeQName);
assertNotNull(xsct);
XmlSchemaSimpleContent xssc = (XmlSchemaSimpleContent)xsct.getContentModel();
@@ -84,19 +93,20 @@
assertNotNull(xsoc);
assertEquals(2, xsoc.getCount());
- Set s = new HashSet();
+ Set<String> s = new HashSet<String>();
s.add("units");
s.add("id");
for (int i = 0; i < xsoc.getCount(); i++) {
XmlSchemaAttribute xsa = (XmlSchemaAttribute)xsoc.getItem(i);
String name = xsa.getName();
- if (name.equals("units")) {
+ if ("units".equals(name)) {
assertEquals(new QName("http://soapinterop.org/types", "units"), xsa.getQName());
- assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"), xsa.getSchemaTypeName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"),
+ xsa.getSchemaTypeName());
assertNull(xsa.getDefaultValue());
assertEquals("required", xsa.getUse().getValue());
assertNull(xsa.getFixedValue());
- } else if (name.equals("id")) {
+ } else if ("id".equals(name)) {
assertEquals(new QName("http://soapinterop.org/types", "id"), xsa.getQName());
assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"), xsa
.getSchemaTypeName());
@@ -120,7 +130,7 @@
for (int i = 0; i < xsoc2.getCount(); i++) {
XmlSchemaEnumerationFacet xsef = (XmlSchemaEnumerationFacet)xsoc2.getItem(i);
String value = (String)xsef.getValue();
- if (!(value.equals("small") || value.equals("medium"))) {
+ if (!("small".equals(value) || "medium".equals(value))) {
fail("Unexpected enumeration value of \"" + value + "\" found.");
}
assertTrue(s.remove(value));
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestElementForm.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestElementForm.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestElementForm.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestElementForm.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,20 +18,26 @@
*/
package tests;
-import junit.framework.TestCase;
-import org.apache.ws.commons.schema.*;
+import java.io.FileInputStream;
+import java.io.InputStream;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
-import java.io.FileInputStream;
-import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
/**
* TestElementForm
*/
public class TestElementForm extends TestCase {
- String NS = "http://unqualified-elements.example.com";
- QName UNQUAL = new QName(NS, "unQualifiedLocals");
+ static final String NS = "http://unqualified-elements.example.com";
+ static final QName UNQUAL = new QName(NS, "unQualifiedLocals");
private XmlSchemaCollection schema;
protected void setUp() throws Exception {
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestForwardRefs.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestForwardRefs.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestForwardRefs.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestForwardRefs.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,25 +19,31 @@
package tests;
-import junit.framework.TestCase;
-import org.apache.ws.commons.schema.*;
+import java.io.FileInputStream;
+import java.io.InputStream;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
-import java.io.FileInputStream;
-import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
/**
*/
public class TestForwardRefs extends TestCase {
public void testForwardRefs() throws Exception {
- QName ELEMENT_QNAME = new QName("http://soapinterop.org/types", "attrTest");
+ QName elementQName = new QName("http://soapinterop.org/types", "attrTest");
InputStream is = new FileInputStream(Resources.asURI("forwardRef.xsd"));
XmlSchemaCollection schema = new XmlSchemaCollection();
schema.read(new StreamSource(is), null);
- XmlSchemaElement elem = schema.getElementByQName(ELEMENT_QNAME);
+ XmlSchemaElement elem = schema.getElementByQName(elementQName);
assertNotNull(elem);
XmlSchemaType type = elem.getSchemaType();
assertNotNull(type);
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestLocalUnnamedSimpleType.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestLocalUnnamedSimpleType.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestLocalUnnamedSimpleType.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestLocalUnnamedSimpleType.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,11 +19,13 @@
package tests;
-import junit.framework.TestCase;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
+import java.io.ByteArrayInputStream;
import javax.xml.transform.stream.StreamSource;
-import java.io.ByteArrayInputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchemaCollection;
/**
* TestElementForm
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestSimpleRestriction.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestSimpleRestriction.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestSimpleRestriction.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestSimpleRestriction.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,31 +18,33 @@
*/
package tests;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
import junit.framework.TestCase;
+
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaSimpleType;
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
import org.apache.ws.commons.schema.XmlSchemaType;
-import javax.xml.namespace.QName;
-import javax.xml.transform.stream.StreamSource;
-import java.io.FileInputStream;
-import java.io.InputStream;
-
public class TestSimpleRestriction extends TestCase {
public void testSimpleRestriction() throws Exception {
- QName TYPE_QNAME = new QName("http://soapinterop.org/types", "layoutComponentType");
- QName ELEMENT_QNAME = new QName("http://soapinterop.org/types", "foo");
+ QName typeQName = new QName("http://soapinterop.org/types", "layoutComponentType");
+ QName elementQName = new QName("http://soapinterop.org/types", "foo");
InputStream is = new FileInputStream(Resources.asURI("SimpleContentRestriction.xsd"));
XmlSchemaCollection schema = new XmlSchemaCollection();
schema.read(new StreamSource(is), null);
- XmlSchemaType simpleType = schema.getTypeByQName(TYPE_QNAME);
+ XmlSchemaType simpleType = schema.getTypeByQName(typeQName);
assertNotNull(simpleType);
- XmlSchemaElement elem = schema.getElementByQName(ELEMENT_QNAME);
+ XmlSchemaElement elem = schema.getElementByQName(elementQName);
assertNotNull(elem);
XmlSchemaType type = elem.getSchemaType();
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestUnqualifiedSchema.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestUnqualifiedSchema.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestUnqualifiedSchema.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestUnqualifiedSchema.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,13 +19,22 @@
package tests;
-import junit.framework.TestCase;
-import org.apache.ws.commons.schema.*;
-import org.w3c.dom.Document;
+import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
-import java.util.Iterator;
+
+import org.w3c.dom.Document;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
public class TestUnqualifiedSchema extends TestCase {
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasRefTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasRefTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasRefTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasRefTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,16 +19,18 @@
package tests;
-import junit.framework.TestCase;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.XmlSchemaElement;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
public class TwoSchemasRefTest extends TestCase {
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,15 +19,17 @@
package tests;
-import junit.framework.TestCase;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchemaCollection;
public class TwoSchemasTest extends TestCase {
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/UnionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/UnionTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/UnionTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/UnionTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,33 +19,22 @@
package tests;
-import junit.framework.TestCase;
-import org.apache.ws.commons.schema.*;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.stream.StreamSource;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
-/*
- * Copyright 2004,2007 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * 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.
- *
- */
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeUnion;
+
+
public class UnionTest extends TestCase {
/**
@@ -62,12 +51,12 @@
* </schema>
*/
- QName ELEMENT_QNAME = new QName("http://soapinterop.org/types", "unionTest");
+ QName elementQName = new QName("http://soapinterop.org/types", "unionTest");
InputStream is = new FileInputStream(Resources.asURI("union.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
schemaCol.read(new StreamSource(is), null);
- XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+ XmlSchemaElement elem = schemaCol.getElementByQName(elementQName);
assertNotNull(elem);
assertEquals("unionTest", elem.getName());
assertEquals(new QName("http://soapinterop.org/types", "unionTest"), elem.getQName());
@@ -79,7 +68,7 @@
assertNotNull(xsstu);
QName[] qname = xsstu.getMemberTypesQNames();
- Set s = new HashSet();
+ Set<QName> s = new HashSet<QName>();
s.add(new QName("http://www.w3.org/2001/XMLSchema", "float"));
s.add(new QName("http://www.w3.org/2001/XMLSchema", "decimal"));
for (QName element : qname) {
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCOMMONS377Test.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCOMMONS377Test.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCOMMONS377Test.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCOMMONS377Test.java Tue Dec 16 18:39:50 2008
@@ -1,20 +1,34 @@
-/*
- * Created on 31.08.2008
- * (C) Copyright 2003-2008 Alexander Veit
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 tests;
import javax.xml.parsers.DocumentBuilderFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
import junit.framework.TestCase;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.constants.Constants;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
/**
* @author alex $Revision$
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,12 +18,13 @@
*/
package tests.customext.attrib;
-import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.extensions.ExtensionDeserializer;
+import javax.xml.namespace.QName;
+
import org.w3c.dom.Attr;
import org.w3c.dom.Node;
-import javax.xml.namespace.QName;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.extensions.ExtensionDeserializer;
/**
* Custom attribute deserializer for our test custom attribute
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,13 +18,14 @@
*/
package tests.customext.attrib;
-import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.extensions.ExtensionSerializer;
+import java.util.Map;
+
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import java.util.Map;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.extensions.ExtensionSerializer;
/**
* serializer for the custom attribute
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,56 +18,62 @@
*/
package tests.customext.attrib;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+
import junit.framework.TestCase;
+
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.constants.Constants;
-import org.w3c.dom.Document;
-import tests.Resources;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.util.Iterator;
-import java.util.Map;
+import tests.Resources;
/**
* Deserialize the custom extension types
*/
-public class CustomExtDeserializerTest extends TestCase {
+public class CustomExtDeserializerTest
+ extends TestCase {
public void testDeserialization() throws Exception {
// set the system property for the custom extension registry
System.setProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY, CustomExtensionRegistry.class
.getName());
- // create a DOM document
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- documentBuilderFactory.setNamespaceAware(true);
- Document doc = documentBuilderFactory.newDocumentBuilder()
- .parse(Resources.asURI("/external/externalAnnotations.xsd"));
-
- XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(doc, null);
- assertNotNull(schema);
-
- // get the elements and check whether their annotations are properly
- // populated
- Iterator values = schema.getElements().getValues();
- while (values.hasNext()) {
- XmlSchemaElement elt = (XmlSchemaElement)values.next();
- assertNotNull(elt);
- Map metaInfoMap = elt.getMetaInfoMap();
- assertNotNull(metaInfoMap);
-
- CustomAttribute customAttrib = (CustomAttribute)metaInfoMap
- .get(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME);
- assertNotNull(customAttrib);
+ try {
+ // create a DOM document
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ Document doc = documentBuilderFactory.newDocumentBuilder()
+ .parse(Resources.asURI("/external/externalAnnotations.xsd"));
+
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(doc, null);
+ assertNotNull(schema);
+
+ // get the elements and check whether their annotations are properly
+ // populated
+ Iterator values = schema.getElements().getValues();
+ while (values.hasNext()) {
+ XmlSchemaElement elt = (XmlSchemaElement)values.next();
+ assertNotNull(elt);
+ Map metaInfoMap = elt.getMetaInfoMap();
+ assertNotNull(metaInfoMap);
+
+ CustomAttribute customAttrib = (CustomAttribute)metaInfoMap
+ .get(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME);
+ assertNotNull(customAttrib);
+
+ }
+ } finally {
+ // remove our system property
+ System.getProperties().remove(Constants.SystemConstants.EXTENSION_REGISTRY_KEY);
}
-
- // remove our system property
- System.getProperties().remove(Constants.SystemConstants.EXTENSION_REGISTRY_KEY);
- ;
-
}
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,19 +18,23 @@
*/
package tests.customext.attrib;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+
import junit.framework.TestCase;
+
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.constants.Constants;
-import org.w3c.dom.Document;
-import tests.Resources;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
-import java.util.Map;
+import tests.Resources;
/**
* Test class to do a full parsing run with the extensions
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,12 +18,13 @@
*/
package tests.customext.elt;
-import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.extensions.ExtensionDeserializer;
+import javax.xml.namespace.QName;
+
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import javax.xml.namespace.QName;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.extensions.ExtensionDeserializer;
/**
* Custom element deserializer
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,12 +18,13 @@
*/
package tests.customext.elt;
-import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.extensions.ExtensionSerializer;
+import java.util.Map;
+
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import java.util.Map;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.extensions.ExtensionSerializer;
/**
* Custom element serializer
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementDeserializerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementDeserializerTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementDeserializerTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementDeserializerTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,17 +18,21 @@
*/
package tests.customext.elt;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+
import junit.framework.TestCase;
+
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.constants.Constants;
-import org.w3c.dom.Document;
-import tests.Resources;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.util.Iterator;
-import java.util.Map;
+import tests.Resources;
/**
* Test class to run through the full cycle of build-check
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementSerializerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementSerializerTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementSerializerTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementSerializerTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,19 +18,23 @@
*/
package tests.customext.elt;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+
import junit.framework.TestCase;
+
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.constants.Constants;
-import org.w3c.dom.Document;
-import tests.Resources;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
-import java.util.Map;
+import tests.Resources;
/**
* Test class to run through the full cycle of build-serialize-build-check
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtensionRegistry.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtensionRegistry.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtensionRegistry.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtensionRegistry.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ext/PlainExtensionDeserializerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ext/PlainExtensionDeserializerTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ext/PlainExtensionDeserializerTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ext/PlainExtensionDeserializerTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,21 +18,23 @@
*/
package tests.ext;
-import junit.framework.TestCase;
-
-import java.util.Map;
import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+
+import junit.framework.TestCase;
-import tests.Resources;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.w3c.dom.Document;
-import javax.xml.parsers.DocumentBuilderFactory;
+import tests.Resources;
/**
- * Test the custom extension dserialization without any specialized hooks
+ * Test the custom extension deserialization without any specialized hooks
*/
public class PlainExtensionDeserializerTest extends TestCase {
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ext/PlainExtensionSerializerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ext/PlainExtensionSerializerTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ext/PlainExtensionSerializerTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ext/PlainExtensionSerializerTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -22,11 +22,12 @@
import javax.xml.parsers.DocumentBuilderFactory;
+import org.w3c.dom.Document;
+
import junit.framework.TestCase;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.w3c.dom.Document;
import tests.Resources;
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/SchemaTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/SchemaTest.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/SchemaTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/SchemaTest.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -27,19 +27,14 @@
*/
public class SchemaTest {
- private final static String SCHEMA_DOCUMENT = "schemaDocument";
-
- private final static String EXPECTED = "expected";
-
- private final static String CURRENT = "current";
-
- String schemaDocumentLink = null;
-
- private String expectedValidity = null;
-
- String currentStatus = null;
-
- String currentDate = null;
+ private static final String SCHEMA_DOCUMENT = "schemaDocument";
+ private static final String EXPECTED = "expected";
+ private static final String CURRENT = "current";
+
+ String schemaDocumentLink;
+ private String expectedValidity;
+ private String currentStatus;
+ private String currentDate;
public SchemaTest(Element n) throws Exception {
NodeList nl = n.getChildNodes();
@@ -55,7 +50,7 @@
// Workaround for mistake in the NISTXMLSchema1-0-20020116.testSet file
// See http://lists.w3.org/Archives/Public/www-xml-schema-comments/2006JulSep/0000.html
- if (schemaDocumentLink.equals("./NISTTestsAll/NISTSchema-anyURI-maxLength-1.xsd")) {
+ if ("./NISTTestsAll/NISTSchema-anyURI-maxLength-1.xsd".equals(schemaDocumentLink)) {
schemaDocumentLink = "./nisttest/NISTTestsAll/NISTSchema-anyURI-maxLength-1.xsd";
}
}
@@ -72,7 +67,7 @@
}
public boolean isValid() {
- return expectedValidity.equals("valid");
+ return "valid".equals(expectedValidity);
}
public String toString() {
@@ -87,4 +82,12 @@
return sb.toString();
}
+
+ public void setCurrentStatus(String currentStatus) {
+ this.currentStatus = currentStatus;
+ }
+
+ public String getCurrentStatus() {
+ return currentStatus;
+ }
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestRoundTripXSD.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestRoundTripXSD.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestRoundTripXSD.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestRoundTripXSD.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,14 +18,25 @@
*/
package tests.w3c;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ListIterator;
+
+import org.w3c.dom.Element;
+
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.custommonkey.xmlunit.*;
-import org.w3c.dom.Element;
-import java.io.*;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ListIterator;
+import org.custommonkey.xmlunit.DetailedDiff;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.Difference;
+import org.custommonkey.xmlunit.DifferenceConstants;
+import org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener;
+import org.custommonkey.xmlunit.XMLTestCase;
/**
* Class to test a single schema by roundtripping it using XMLUnit cmd line parms: arg0 - valid|invalid arg1 -
@@ -33,19 +44,47 @@
*/
public class TestRoundTripXSD extends XMLTestCase {
- private static boolean debug;
+ static class SchemaAttrDiff extends IgnoreTextAndAttributeValuesDifferenceListener {
- static {
- String debugString = System.getProperty("debug");
- debug = debugString == null ? false : debugString.equals("true");
+ public int differenceFound(Difference difference) {
+
+ if (difference.getId() == DifferenceConstants.ELEMENT_NUM_ATTRIBUTES.getId()) {
+ // control and test have to be elements
+ // check if they are schema elements .. they only
+ // seem to have the added attributeFormDefault and
+ // elementFormDefault attributes
+ // so shldnt have more than 2 attributes difference
+ Element actualEl = (Element)difference.getControlNodeDetail().getNode();
+
+ if (actualEl.getLocalName().equals("schema")) {
+
+ int expectedAttrs = Integer.parseInt(difference.getControlNodeDetail().getValue());
+ int actualAttrs = Integer.parseInt(difference.getTestNodeDetail().getValue());
+ if (Math.abs(actualAttrs - expectedAttrs) <= 2) {
+ return RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR;
+ }
+ }
+ } else if (difference.getId() == DifferenceConstants.ATTR_NAME_NOT_FOUND_ID) {
+ // sometimes the serializer throws in a few extra attributes...
+ Element actualEl = (Element)difference.getControlNodeDetail().getNode();
+
+ if (actualEl.getLocalName().equals("schema")) {
+ return RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR;
+ }
+ }
+
+ return super.differenceFound(difference);
+ }
}
- private File fileToTest = null;
+ private static boolean debug;
- private boolean valid = false;
+ private File fileToTest;
+ private boolean valid;
- public final static void main(String[] args) {
- junit.textui.TestRunner.run(new TestRoundTripXSD(new File(args[1]), args[0].equals("valid")));
+ static {
+ String debugString = System.getProperty("debug");
+ debug = debugString == null ? false : "true".equals(debugString);
}
public TestRoundTripXSD() {
@@ -61,23 +100,20 @@
this.valid = valid;
}
+ public static final void main(String[] args) {
+ junit.textui.TestRunner.run(new TestRoundTripXSD(new File(args[1]), args[0].equals("valid")));
+ }
+
private static String basename(File f) {
String path = f.getPath();
int i = path.lastIndexOf(System.getProperty("file.separator"));
- String retval = path.substring(i + 1);
- return retval;
+ return path.substring(i + 1);
}
- protected void runTest() throws Throwable {
- try {
- testRoundTrip();
- } catch (InvocationTargetException e) {
- e.fillInStackTrace();
- throw e.getTargetException();
- } catch (IllegalAccessException e) {
- e.fillInStackTrace();
- throw e;
- }
+ public XmlSchema loadSchema(File f) throws Exception {
+ XmlSchemaCollection col = new XmlSchemaCollection();
+ col.setBaseUri(f.getPath());
+ return col.read(new FileReader(f), null);
}
public void testRoundTrip() throws Exception {
@@ -119,43 +155,15 @@
}
- public XmlSchema loadSchema(File f) throws Exception {
- XmlSchemaCollection col = new XmlSchemaCollection();
- col.setBaseUri(f.getPath());
- XmlSchema xmlSchema = col.read(new FileReader(f), null);
- return xmlSchema;
- }
-
- static class SchemaAttrDiff extends IgnoreTextAndAttributeValuesDifferenceListener {
-
- public int differenceFound(Difference difference) {
-
- if (difference.getId() == DifferenceConstants.ELEMENT_NUM_ATTRIBUTES.getId()) {
- // control and test have to be elements
- // check if they are schema elements .. they only
- // seem to have the added attributeFormDefault and
- // elementFormDefault attributes
- // so shldnt have more than 2 attributes difference
- Element actualEl = (Element)difference.getControlNodeDetail().getNode();
-
- if (actualEl.getLocalName().equals("schema")) {
-
- int expectedAttrs = Integer.parseInt(difference.getControlNodeDetail().getValue());
- int actualAttrs = Integer.parseInt(difference.getTestNodeDetail().getValue());
- if (Math.abs(actualAttrs - expectedAttrs) <= 2) {
- return RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR;
- }
- }
- } else if (difference.getId() == DifferenceConstants.ATTR_NAME_NOT_FOUND_ID) {
- // sometimes the serializer throws in a few extra attributes...
- Element actualEl = (Element)difference.getControlNodeDetail().getNode();
-
- if (actualEl.getLocalName().equals("schema")) {
- return RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR;
- }
- }
-
- return super.differenceFound(difference);
+ protected void runTest() throws Throwable {
+ try {
+ testRoundTrip();
+ } catch (InvocationTargetException e) {
+ e.fillInStackTrace();
+ throw e.getTargetException();
+ } catch (IllegalAccessException e) {
+ e.fillInStackTrace();
+ throw e;
}
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestW3CSchemaBucket.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestW3CSchemaBucket.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestW3CSchemaBucket.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestW3CSchemaBucket.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,14 +18,14 @@
*/
package tests.w3c;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
/**
* Class to represent a bucket of tests described by a set of .testSet files. All of the tests described in
* all of the .testSet files present in the top level of the directory supplied will be round-trip tested.
@@ -35,7 +35,7 @@
*/
public class TestW3CSchemaBucket extends TestSuite {
- private static List allTestSetFiles;
+ private static List<File> allTestSetFiles;
// If tests run from cmd line without any args, run the full suite
private static String testSetsLocation = "./target/xmlschema2002-01-16";
@@ -56,24 +56,24 @@
testSetsLocation = System.getProperty("W3CTestLocation", testSetsLocation);
TestSuite suite = new TestSuite("Test for tests");
allTestSetFiles = getTestSetFiles(testSetsLocation);
- ListIterator li = allTestSetFiles.listIterator();
+ ListIterator<File> li = allTestSetFiles.listIterator();
while (li.hasNext()) {
Object o = li.next();
File testSet = null;
if (o instanceof File) {
testSet = (File)o;
}
- suite.addTest(TestW3CSchemaTestSet.suite(testSet));
+ suite.addTest(TestW3CSchemaTestSet.getSuite(testSet));
}
return suite;
}
- private static List getTestSetFiles(String testSetsLocation) throws Exception {
- File dir = new File(testSetsLocation);
+ private static List<File> getTestSetFiles(String aTestSetsLocation) throws Exception {
+ File dir = new File(aTestSetsLocation);
if (!dir.isDirectory()) {
throw new Exception("testSet files location must be a directory");
}
- ArrayList testSetFiles = new ArrayList();
+ List<File> testSetFiles = new ArrayList<File>();
File[] files = dir.listFiles();
for (File file : files) {
if (file.getAbsolutePath().endsWith("testSet")) {
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestW3CSchemaTestSet.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestW3CSchemaTestSet.java?rev=727246&r1=727245&r2=727246&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestW3CSchemaTestSet.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/w3c/TestW3CSchemaTestSet.java Tue Dec 16 18:39:50 2008
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,37 +18,38 @@
*/
package tests.w3c;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
+import junit.framework.Test;
+import junit.framework.TestSuite;
/**
* Class to represent a set of schema tests as described by a .testSet file When executed each of the schemas
* described in the .testSet file is round-trip tested. cmd line parms: arg0 - location of the .testSet file.
* Defaults to: ./target/xmlschema2002-01-16/NISTXMLSchema1-0-20020116.testSet
*/
-public class TestW3CSchemaTestSet extends TestSuite {
-
- private List schemaTests = null;
-
- private File testSetFile = null;
+public final class TestW3CSchemaTestSet extends TestSuite {
// If junit called from cmd line without any args, use the NIST test bucket
private static String testSetLocation = "./target/xmlschema2002-01-16/NISTXMLSchema1-0-20020116.testSet";
+ private List<SchemaTest> schemaTests;
+ private File testSetFile;
private TestW3CSchemaTestSet(String name, File testSetFile) {
super(name);
this.testSetFile = testSetFile;
@@ -59,7 +60,7 @@
if (args[0] != null) {
testSetLocation = args[0];
}
- junit.textui.TestRunner.run(TestW3CSchemaTestSet.suite(new File(testSetLocation)));
+ junit.textui.TestRunner.run(TestW3CSchemaTestSet.getSuite(new File(testSetLocation)));
} catch (Exception e) {
e.printStackTrace();
}
@@ -67,7 +68,7 @@
public static Test suite() throws Exception {
testSetLocation = System.getProperty("W3CTestLocation", testSetLocation);
- return suite(new File(testSetLocation));
+ return getSuite(new File(testSetLocation));
}
/**
@@ -77,17 +78,17 @@
* @param testSetFile the File object of the .testSet file
* @throws Exception
*/
- public static Test suite(File testSetFile) throws Exception {
+ public static Test getSuite(File testSetFile) throws Exception {
TestW3CSchemaTestSet suite = new TestW3CSchemaTestSet("Test for tests", testSetFile);
- String testSetLocation = suite.testSetFile.getPath();
- suite.schemaTests = getSchemaTests(testSetLocation);
- ListIterator li = suite.schemaTests.listIterator();
+ String aTestSetLocation = suite.testSetFile.getPath();
+ suite.schemaTests = getSchemaTests(aTestSetLocation);
+ ListIterator<SchemaTest> li = suite.schemaTests.listIterator();
while (li.hasNext()) {
- SchemaTest st = (SchemaTest)li.next();
+ SchemaTest st = li.next();
File f = new File(testSetFile.getParent(), st.schemaDocumentLink);
- if (st.currentStatus != null) {
- if (!st.currentStatus.equals("accepted")) {
+ if (st.getCurrentStatus() != null) {
+ if (!st.getCurrentStatus().equals("accepted")) {
System.out.println("Warning: SchemaTest which isn't accepted: " + st);
} else if (st.isValid()) {
// for now only test schemas that are valid
@@ -106,8 +107,8 @@
* @return List of SchemaTest objects describing the schema files to test
* @throws Exception
*/
- private static List getSchemaTests(String testSet) throws Exception {
- List schemaTests = new ArrayList();
+ private static List<SchemaTest> getSchemaTests(String testSet) throws Exception {
+ List<SchemaTest> schemaTests = new ArrayList<SchemaTest>();
Document doc = getDocument(new InputSource(testSet));
NodeList testGroups = doc.getElementsByTagName("testGroup");
for (int i = 0; i < testGroups.getLength(); i++) {
@@ -132,7 +133,7 @@
schemaTests.add(schemaTest);
}
} catch (Exception e) {
-
+ // ignore errors?
}
}
}