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=726576&r1=726575&r2=726576&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 Sun Dec 14 15:18:54 2008 @@ -35,38 +35,37 @@ */ public class CustomExtElementDeserializerTest 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/externalElementAnnotations.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); + // 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/externalElementAnnotations.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); - CustomElement customElt = (CustomElement)metaInfoMap.get(CustomElement.CUSTOM_ELT_QNAME); - assertNotNull(customElt); + CustomElement customElt = (CustomElement)metaInfoMap.get(CustomElement.CUSTOM_ELT_QNAME); + assertNotNull(customElt); - } + } - //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/elt/CustomExtElementSerializerTest.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementSerializerTest.java?rev=726576&r1=726575&r2=726576&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 Sun Dec 14 15:18:54 2008 @@ -33,17 +33,16 @@ import java.util.Map; /** - * Test class to run through the full cycle of build-serialize-build-check + * Test class to run through the full cycle of build-serialize-build-check */ public class CustomExtElementSerializerTest extends TestCase { - public void testSerialization() throws Exception { - //set the system property for the custom extension registry - System.setProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY, - CustomExtensionRegistry.class.getName()); + // set the system property for the custom extension registry + System.setProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY, CustomExtensionRegistry.class + .getName()); - //create a DOM document + // create a DOM document DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); @@ -51,30 +50,31 @@ if (documentBuilderFactory.getClass().toString().indexOf("crimson") != -1) { return; } - Document doc = documentBuilderFactory.newDocumentBuilder(). - parse(Resources.asURI("/external/externalElementAnnotations.xsd")); + Document doc = documentBuilderFactory.newDocumentBuilder() + .parse(Resources.asURI("/external/externalElementAnnotations.xsd")); XmlSchemaCollection schemaCol = new XmlSchemaCollection(); - XmlSchema schema = schemaCol.read(doc,null); + XmlSchema schema = schemaCol.read(doc, null); assertNotNull(schema); - //now serialize it to a byte stream - //and build a new document out of it + // now serialize it to a byte stream + // and build a new document out of it ByteArrayOutputStream baos = new ByteArrayOutputStream(); schema.write(baos); - Document doc2 = documentBuilderFactory.newDocumentBuilder(). - parse(new ByteArrayInputStream(baos.toByteArray())); + Document doc2 = documentBuilderFactory.newDocumentBuilder().parse( + new ByteArrayInputStream(baos + .toByteArray())); // we can't have two copies in the same collection. schemaCol = new XmlSchemaCollection(); - schema = schemaCol.read(doc2,null); + schema = schemaCol.read(doc2, 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(); + XmlSchemaElement elt = (XmlSchemaElement)values.next(); assertNotNull(elt); Map metaInfoMap = elt.getMetaInfoMap(); assertNotNull(metaInfoMap); @@ -84,7 +84,7 @@ } - //remove our system property + // remove our system property System.getProperties().remove(Constants.SystemConstants.EXTENSION_REGISTRY_KEY); } 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=726576&r1=726575&r2=726576&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 Sun Dec 14 15:18:54 2008 @@ -26,9 +26,9 @@ public class CustomExtensionRegistry extends ExtensionRegistry { public CustomExtensionRegistry() { - //register our custom type - registerDeserializer(CustomElement.CUSTOM_ELT_QNAME,new CustomElementDeserializer()); - registerSerializer(CustomElement.class,new CustomElementSerializer()); - } + // register our custom type + registerDeserializer(CustomElement.CUSTOM_ELT_QNAME, new CustomElementDeserializer()); + registerSerializer(CustomElement.class, new CustomElementSerializer()); + } } 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=726576&r1=726575&r2=726576&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 Sun Dec 14 15:18:54 2008 @@ -32,57 +32,55 @@ import javax.xml.parsers.DocumentBuilderFactory; /** - * Test the custom extension dserialization without any specialized - * hooks + * Test the custom extension dserialization without any specialized hooks */ public class PlainExtensionDeserializerTest extends TestCase { - public void testDeserialization() throws Exception { + public void testDeserialization() throws Exception { - //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); - - } - } + // 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); + } + } public void testDeserialization1() throws Exception { - //create a DOM document - DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); - documentBuilderFactory.setNamespaceAware(true); - Document doc = documentBuilderFactory.newDocumentBuilder(). - parse(Resources.asURI("/external/externalElementAnnotations.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); + // create a DOM document + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setNamespaceAware(true); + Document doc = documentBuilderFactory.newDocumentBuilder() + .parse(Resources.asURI("/external/externalElementAnnotations.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); - } - } + } + } } 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=726576&r1=726575&r2=726576&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 Sun Dec 14 15:18:54 2008 @@ -35,34 +35,33 @@ */ public class PlainExtensionSerializerTest extends TestCase { - public void testSerialization() throws Exception { + public void testSerialization() throws Exception { - //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); - - schema.write(new ByteArrayOutputStream()); - } + // 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); + schema.write(new ByteArrayOutputStream()); + } public void testSerialization1() throws Exception { - //create a DOM document - DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); - documentBuilderFactory.setNamespaceAware(true); - Document doc = documentBuilderFactory.newDocumentBuilder(). - parse(Resources.asURI("/external/externalElementAnnotations.xsd")); - - XmlSchemaCollection schemaCol = new XmlSchemaCollection(); - XmlSchema schema = schemaCol.read(doc,null); - assertNotNull(schema); + // create a DOM document + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setNamespaceAware(true); + Document doc = documentBuilderFactory.newDocumentBuilder() + .parse(Resources.asURI("/external/externalElementAnnotations.xsd")); + + XmlSchemaCollection schemaCol = new XmlSchemaCollection(); + XmlSchema schema = schemaCol.read(doc, null); + assertNotNull(schema); - schema.write(new ByteArrayOutputStream()); - } + schema.write(new ByteArrayOutputStream()); + } } 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=726576&r1=726575&r2=726576&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 Sun Dec 14 15:18:54 2008 @@ -24,7 +24,6 @@ /** * Class representing a single schema test as described in a .testSet file. - * */ public class SchemaTest { @@ -46,19 +45,19 @@ NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node c = nl.item(i); - if (!(c instanceof Element)) + if (!(c instanceof Element)) { continue; - Element elem = (Element) c; + } + Element elem = (Element)c; String elemName = elem.getNodeName(); if (elemName.equals(SCHEMA_DOCUMENT)) { - schemaDocumentLink = elem.getAttributeNS( - "http://www.w3.org/1999/xlink", "href"); - - // 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")) { - schemaDocumentLink = "./nisttest/NISTTestsAll/NISTSchema-anyURI-maxLength-1.xsd"; - } + schemaDocumentLink = elem.getAttributeNS("http://www.w3.org/1999/xlink", "href"); + + // 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")) { + schemaDocumentLink = "./nisttest/NISTTestsAll/NISTSchema-anyURI-maxLength-1.xsd"; + } } if (elemName.equals(EXPECTED)) { @@ -75,7 +74,7 @@ public boolean isValid() { return expectedValidity.equals("valid"); } - + public String toString() { StringBuffer sb = new StringBuffer("href="); sb.append(schemaDocumentLink); @@ -85,7 +84,7 @@ sb.append(currentStatus); sb.append(" currentDate="); sb.append(currentDate); - + return sb.toString(); } -} \ No newline at end of file +} 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=726576&r1=726575&r2=726576&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 Sun Dec 14 15:18:54 2008 @@ -28,35 +28,32 @@ import java.util.ListIterator; /** - * Class to test a single schema by roundtripping it using XMLUnit - * cmd line parms: arg0 - valid|invalid arg1 - path to xsd file - * + * Class to test a single schema by roundtripping it using XMLUnit cmd line parms: arg0 - valid|invalid arg1 - + * path to xsd file */ public class TestRoundTripXSD extends XMLTestCase { private static boolean debug; - + static { String debugString = System.getProperty("debug"); - debug = (debugString == null) ? false : debugString.equals("true"); + debug = debugString == null ? false : debugString.equals("true"); } - + private File fileToTest = null; private boolean valid = false; public final static void main(String[] args) { - junit.textui.TestRunner.run(new TestRoundTripXSD(new File(args[1]), - args[0].equals("valid"))); + junit.textui.TestRunner.run(new TestRoundTripXSD(new File(args[1]), args[0].equals("valid"))); } - public TestRoundTripXSD() { - this(new File(System.getProperty("W3CTestLocation")), - System.getProperty("W3CTestValidity").equals("valid")); - + this(new File(System.getProperty("W3CTestLocation")), System.getProperty("W3CTestValidity") + .equals("valid")); + } - + public TestRoundTripXSD(File f, boolean valid) { super(basename(f)); @@ -67,30 +64,27 @@ private static String basename(File f) { String path = f.getPath(); int i = path.lastIndexOf(System.getProperty("file.separator")); - String retval = path.substring(i+1); + String retval = path.substring(i + 1); return retval; } - + protected void runTest() throws Throwable { try { testRoundTrip(); - } - catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { e.fillInStackTrace(); throw e.getTargetException(); - } - catch (IllegalAccessException e) { + } catch (IllegalAccessException e) { e.fillInStackTrace(); throw e; } } - public void testRoundTrip() throws Exception { - + XmlSchema schema = null; DetailedDiff detaileddiffs = null; - + try { if (debug) { System.out.println("fileToTest=" + this.fileToTest); @@ -105,21 +99,23 @@ ByteArrayOutputStream baos = new ByteArrayOutputStream(); schema.write(baos); Diff diff = new Diff(new FileReader(fileToTest), - new InputStreamReader(new ByteArrayInputStream(baos - .toByteArray()))); + new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); detaileddiffs = new DetailedDiff(diff); detaileddiffs.overrideDifferenceListener(new SchemaAttrDiff()); boolean result = detaileddiffs.similar(); - if (!result && debug) printFailureDetail(schema, detaileddiffs); + if (!result && debug) { + printFailureDetail(schema, detaileddiffs); + } assertTrue("Serialized out schema not similar to original", result); } catch (Exception e) { if (this.valid) { - if (debug) printFailureDetail(schema, detaileddiffs); + if (debug) { + printFailureDetail(schema, detaileddiffs); + } throw new Exception(this.fileToTest.getPath(), e); } } - } @@ -130,35 +126,29 @@ return xmlSchema; } - static class SchemaAttrDiff extends - IgnoreTextAndAttributeValuesDifferenceListener { + static class SchemaAttrDiff extends IgnoreTextAndAttributeValuesDifferenceListener { public int differenceFound(Difference difference) { - if (difference.getId() == DifferenceConstants.ELEMENT_NUM_ATTRIBUTES - .getId()) { + 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(); + 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()); + 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(); + Element actualEl = (Element)difference.getControlNodeDetail().getNode(); if (actualEl.getLocalName().equals("schema")) { return RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR; @@ -182,5 +172,4 @@ } } - } 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=726576&r1=726575&r2=726576&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 Sun Dec 14 15:18:54 2008 @@ -27,19 +27,16 @@ import java.util.ListIterator; /** - * 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. - * Note: Subdirs are not traversed because the .testSet files in the top level - * of the xmlschema2002-01-16 bucket describe all the tests in the bucket. - * cmd line parms: arg0 - location of the directory containing .testSet files - * defaults to ./target/xmlschema2002-01-16 - * + * 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. + * Note: Subdirs are not traversed because the .testSet files in the top level of the xmlschema2002-01-16 + * bucket describe all the tests in the bucket. cmd line parms: arg0 - location of the directory containing + * .testSet files defaults to ./target/xmlschema2002-01-16 */ public class TestW3CSchemaBucket extends TestSuite { private static List allTestSetFiles; - + // If tests run from cmd line without any args, run the full suite private static String testSetsLocation = "./target/xmlschema2002-01-16"; @@ -55,9 +52,8 @@ } } - public static Test suite() throws Exception { - testSetsLocation = System.getProperty("W3CTestLocation", testSetsLocation); + testSetsLocation = System.getProperty("W3CTestLocation", testSetsLocation); TestSuite suite = new TestSuite("Test for tests"); allTestSetFiles = getTestSetFiles(testSetsLocation); ListIterator li = allTestSetFiles.listIterator(); @@ -65,7 +61,7 @@ Object o = li.next(); File testSet = null; if (o instanceof File) { - testSet = (File) o; + testSet = (File)o; } suite.addTest(TestW3CSchemaTestSet.suite(testSet)); } @@ -75,13 +71,13 @@ private static List getTestSetFiles(String testSetsLocation) throws Exception { File dir = new File(testSetsLocation); if (!dir.isDirectory()) { - throw new Exception ("testSet files location must be a directory"); + throw new Exception("testSet files location must be a directory"); } ArrayList testSetFiles = new ArrayList(); File[] files = dir.listFiles(); - for (int i = 0; i < files.length; i++) { - if (files[i].getAbsolutePath().endsWith("testSet")) { - testSetFiles.add(files[i]); + for (File file : files) { + if (file.getAbsolutePath().endsWith("testSet")) { + testSetFiles.add(file); } } return testSetFiles; 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=726576&r1=726575&r2=726576&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 Sun Dec 14 15:18:54 2008 @@ -35,21 +35,17 @@ import java.util.List; import java.util.ListIterator; - /** - * 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 - * + * 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; - + // 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"; @@ -57,11 +53,11 @@ super(name); this.testSetFile = testSetFile; } - + public static void main(String[] args) { try { if (args[0] != null) { - testSetLocation = args[0]; + testSetLocation = args[0]; } junit.textui.TestRunner.run(TestW3CSchemaTestSet.suite(new File(testSetLocation))); } catch (Exception e) { @@ -70,14 +66,15 @@ } public static Test suite() throws Exception { - testSetLocation = System.getProperty("W3CTestLocation", testSetLocation); + testSetLocation = System.getProperty("W3CTestLocation", testSetLocation); return suite(new File(testSetLocation)); } - + /** - * Returns a suite of TestRoundTripXSD test case instances. One for each of the tests - * described in the testSetFile - * @param testSetFile the File object of the .testSet file + * Returns a suite of TestRoundTripXSD test case instances. One for each of the tests described in the + * testSetFile + * + * @param testSetFile the File object of the .testSet file * @throws Exception */ public static Test suite(File testSetFile) throws Exception { @@ -86,13 +83,13 @@ suite.schemaTests = getSchemaTests(testSetLocation); ListIterator li = suite.schemaTests.listIterator(); while (li.hasNext()) { - SchemaTest st = (SchemaTest) li.next(); + SchemaTest st = (SchemaTest)li.next(); File f = new File(testSetFile.getParent(), st.schemaDocumentLink); - if (st.currentStatus!=null) { + if (st.currentStatus != null) { if (!st.currentStatus.equals("accepted")) { System.out.println("Warning: SchemaTest which isn't accepted: " + st); - } else if (st.isValid()){ + } else if (st.isValid()) { // for now only test schemas that are valid suite.addTest(new TestRoundTripXSD(f, true)); } @@ -102,8 +99,9 @@ } /** - * Returns a list of SchemaTest objects created from the .testSet xml file passed - * in to the testSet parameter + * Returns a list of SchemaTest objects created from the .testSet xml file passed in to the testSet + * parameter + * * @param testSet the filename of the .testSet file * @return List of SchemaTest objects describing the schema files to test * @throws Exception @@ -118,39 +116,43 @@ Element schemaTestElem = null; for (int j = 0; j < testGroupChildren.getLength(); j++) { Node n = testGroupChildren.item(j); - if (!(n instanceof Element)) + if (!(n instanceof Element)) { continue; - schemaTestElem = (Element) n; + } + schemaTestElem = (Element)n; if (schemaTestElem.getNodeName().equals("schemaTest")) { break; } } if (schemaTestElem != null) { try { - - SchemaTest schemaTest = new SchemaTest((Element) schemaTestElem); - if (schemaTest.schemaDocumentLink != null) schemaTests.add(schemaTest); + + SchemaTest schemaTest = new SchemaTest(schemaTestElem); + if (schemaTest.schemaDocumentLink != null) { + schemaTests.add(schemaTest); + } } catch (Exception e) { - + } } } - return schemaTests; + return schemaTests; } /** * Returns a DOM Document of the file passed in as the inputsource parameter + * * @param inputSource input to read in as DOM Document * @return DOM Document of the input source * @throws Exception can be IOException or SAXException */ - private static Document getDocument(InputSource inputSource) - throws ParserConfigurationException, SAXException, IOException { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware(true); - dbf.setValidating(false); + private static Document getDocument(InputSource inputSource) throws ParserConfigurationException, + SAXException, IOException { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + dbf.setValidating(false); - return dbf.newDocumentBuilder().parse(inputSource); + return dbf.newDocumentBuilder().parse(inputSource); } }