db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r992442 - in /db/torque/torque4/trunk/torque-generator/src/test: configuration/src/main/torque-gen-parent/conf/ configuration/src/main/torque-gen-parent/resources/ configuration/src/main/torque-gen/conf/ configuration/src/main/torque-gen/re...
Date Fri, 03 Sep 2010 19:55:52 GMT
Author: tfischer
Date: Fri Sep  3 19:55:51 2010
New Revision: 992442

URL: http://svn.apache.org/viewvc?rev=992442&view=rev
Log:
Adjusted tests for schema validation for source xml files

Added:
    db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/resources/
    db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/resources/parent.xsd
    db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/
    db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/new.xsd
    db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/override.xsd
Modified:
    db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/conf/control.xml
    db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/conf/control.xml
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/RichSourceElementImplTest.java
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/properties/PropertiesParserTest.java
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/SourceToXmlTest.java
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/XmlParserTest.java

Modified: db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/conf/control.xml?rev=992442&r1=992441&r2=992442&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/conf/control.xml
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/conf/control.xml
Fri Sep  3 19:55:51 2010
@@ -24,6 +24,14 @@
     loglevel="warn">
 
   <options path="parent-options.properties" xsi:type="propertiesOptions"/>
+
+  <entityReference 
+      systemId="http://db.apache.org/torque/some.xsd"
+      resource="parent.xsd" />
+  <entityReference 
+      systemId="http://db.apache.org/torque/parent.xsd"
+      resource="parent.xsd" />
+
   <output name="parentOutput">
     <filenameOutlet xsi:type="javaOutlet" 
         class="org.apache.torque.generator.java.JavaOutlet">

Added: db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/resources/parent.xsd
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/resources/parent.xsd?rev=992442&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/resources/parent.xsd
(added)
+++ db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen-parent/resources/parent.xsd
Fri Sep  3 19:55:51 2010
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" 
+    targetNamespace="http://db.apache.org/torque/4.0/test/parent"
+    elementFormDefault="qualified"
+    attributeFormDefault="unqualified">
+
+  <element name="parent">
+    <complexType>
+    </complexType>
+  </element>
+</schema>
\ No newline at end of file

Modified: db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/conf/control.xml?rev=992442&r1=992441&r2=992442&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/conf/control.xml
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/conf/control.xml
Fri Sep  3 19:55:51 2010
@@ -25,6 +25,15 @@
     loglevel="debug">
   <options path="options.properties" xsi:type="propertiesOptions"/> 
   <options path="options.xml" xsi:type="xmlOptions"/>
+
+  <entityReference 
+      systemId="http://db.apache.org/torque/new.xsd"
+      resource="new.xsd" />
+  <entityReference 
+      systemId="http://db.apache.org/torque/some.xsd"
+      resource="override.xsd" />
+
+
   <output name="org.apache.torque.generator.firstOutput" skipIfExists="true">
     <filenameOutlet xsi:type="javaOutlet" class="org.apache.torque.generator.java.JavaOutlet">
       <foo>Foo</foo>

Added: db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/new.xsd
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/new.xsd?rev=992442&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/new.xsd
(added)
+++ db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/new.xsd
Fri Sep  3 19:55:51 2010
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" 
+    targetNamespace="http://db.apache.org/torque/test/new"
+    elementFormDefault="qualified"
+    attributeFormDefault="unqualified">
+
+  <element name="new">
+    <complexType>
+    </complexType>
+  </element>
+</schema>
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/override.xsd
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/override.xsd?rev=992442&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/override.xsd
(added)
+++ db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gen/resources/override.xsd
Fri Sep  3 19:55:51 2010
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" 
+    targetNamespace="http://db.apache.org/torque/test/override"
+    elementFormDefault="qualified"
+    attributeFormDefault="unqualified">
+
+  <element name="override">
+    <complexType>
+    </complexType>
+  </element>
+</schema>
\ No newline at end of file

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java?rev=992442&r1=992441&r2=992442&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/ReadConfigurationTest.java
Fri Sep  3 19:55:51 2010
@@ -19,6 +19,7 @@ package org.apache.torque.generator.conf
  * under the License.
  */
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -33,6 +34,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.generator.BaseTest;
 import org.apache.torque.generator.configuration.controller.Loglevel;
@@ -46,6 +48,7 @@ import org.apache.torque.generator.confi
 import org.apache.torque.generator.configuration.paths.DefaultTorqueGeneratorPaths;
 import org.apache.torque.generator.configuration.paths.Maven2DirectoryProjectPaths;
 import org.apache.torque.generator.configuration.paths.ProjectPaths;
+import org.apache.torque.generator.configuration.source.EntityReferences;
 import org.apache.torque.generator.control.ControllerState;
 import org.apache.torque.generator.control.action.ApplyAction;
 import org.apache.torque.generator.control.action.MergepointAction;
@@ -147,6 +150,21 @@ public class ReadConfigurationTest exten
         }
 
         {
+            EntityReferences entityReferences 
+                    = unitConfiguration.getEntityReferences();
+            Map<String, byte[]> actual = entityReferences.getEntityReferences();
+            assertEquals(2, actual.size());
+            assertArrayEquals(
+                    FileUtils.readFileToByteArray(
+                            new File("src/test/configuration/src/main/torque-gen/resources/override.xsd")),
+                    actual.get("http://db.apache.org/torque/some.xsd"));
+            assertArrayEquals(
+                    FileUtils.readFileToByteArray(
+                            new File("src/test/configuration/src/main/torque-gen/resources/new.xsd")),
+                    actual.get("http://db.apache.org/torque/new.xsd"));
+        }
+        
+        {
             List<Output> outputFiles = unitConfiguration.getOutputList();
             assertEquals(3, outputFiles.size());
 
@@ -591,6 +609,26 @@ public class ReadConfigurationTest exten
                     expectedOptions,
                     unitConfiguration.getOptions());            
         }
+
+        {
+            EntityReferences entityReferences 
+                    = unitConfiguration.getEntityReferences();
+            Map<String, byte[]> actual = entityReferences.getEntityReferences();
+            assertEquals(3, actual.size());
+            assertArrayEquals(
+                    FileUtils.readFileToByteArray(
+                            new File("src/test/configuration/src/main/torque-gen-parent/resources/parent.xsd")),
+                    actual.get("http://db.apache.org/torque/parent.xsd"));
+            assertArrayEquals(
+                    FileUtils.readFileToByteArray(
+                            new File("src/test/configuration/src/main/torque-gen/resources/override.xsd")),
+                    actual.get("http://db.apache.org/torque/some.xsd"));
+            assertArrayEquals(
+                    FileUtils.readFileToByteArray(
+                            new File("src/test/configuration/src/main/torque-gen/resources/new.xsd")),
+                    actual.get("http://db.apache.org/torque/new.xsd"));
+        }
+
         {
             List<Output> outputList = unitConfiguration.getOutputList();
             assertEquals(4, outputList.size());

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/RichSourceElementImplTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/RichSourceElementImplTest.java?rev=992442&r1=992441&r2=992442&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/RichSourceElementImplTest.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/RichSourceElementImplTest.java
Fri Sep  3 19:55:51 2010
@@ -31,6 +31,7 @@ import java.util.List;
 
 import org.apache.torque.generator.configuration.paths.Maven2DirectoryProjectPaths;
 import org.apache.torque.generator.configuration.paths.ProjectPaths;
+import org.apache.torque.generator.control.ControllerState;
 import org.apache.torque.generator.source.stream.FileSource;
 import org.apache.torque.generator.source.stream.PropertiesSourceFormat;
 import org.junit.Before;
@@ -349,7 +350,8 @@ public class RichSourceElementImplTest
         FileSource fileSource
                 = new FileSource(
                         new PropertiesSourceFormat(),
-                        propertiesFile);
+                        propertiesFile,
+                        new ControllerState());
         SourceElement rootElement
                 = (SourceElement) fileSource.getRootElement();
 

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/properties/PropertiesParserTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/properties/PropertiesParserTest.java?rev=992442&r1=992441&r2=992442&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/properties/PropertiesParserTest.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/properties/PropertiesParserTest.java
Fri Sep  3 19:55:51 2010
@@ -24,6 +24,9 @@ import static org.junit.Assert.assertEqu
 import java.io.File;
 
 import org.apache.torque.generator.configuration.ConfigurationException;
+import org.apache.torque.generator.configuration.UnitConfiguration;
+import org.apache.torque.generator.configuration.source.EntityReferences;
+import org.apache.torque.generator.control.ControllerState;
 import org.apache.torque.generator.source.SourceElement;
 import org.apache.torque.generator.source.SourceException;
 import org.apache.torque.generator.source.stream.FileSource;
@@ -32,6 +35,15 @@ import org.junit.Test;
 
 public class PropertiesParserTest
 {
+    private ControllerState controllerState = new ControllerState();
+    
+    public PropertiesParserTest()
+    {
+        UnitConfiguration unitConfiguration = new UnitConfiguration();
+        unitConfiguration.setEntityReferences(new EntityReferences());
+        controllerState.setUnitConfiguration(unitConfiguration);
+    }
+
     @Test
     public void testParsePropertiesFile()
             throws ConfigurationException, SourceException
@@ -41,7 +53,8 @@ public class PropertiesParserTest
         FileSource fileSource
                 = new FileSource(
                         new PropertiesSourceFormat(),
-                        propertiesFile);
+                        propertiesFile,
+                        controllerState);
 
         SourceElement rootElement = fileSource.getRootElement();
         assertEquals("properties", rootElement.getName());
@@ -69,6 +82,7 @@ public class PropertiesParserTest
     {
         new FileSource(
                 new PropertiesSourceFormat(),
-                null);
+                null,
+                controllerState);
     }
 }

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/SourceToXmlTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/SourceToXmlTest.java?rev=992442&r1=992441&r2=992442&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/SourceToXmlTest.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/SourceToXmlTest.java
Fri Sep  3 19:55:51 2010
@@ -25,6 +25,9 @@ import java.io.File;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.torque.generator.configuration.UnitConfiguration;
+import org.apache.torque.generator.configuration.source.EntityReferences;
+import org.apache.torque.generator.control.ControllerState;
 import org.apache.torque.generator.source.SourceElement;
 import org.apache.torque.generator.source.stream.FileSource;
 import org.apache.torque.generator.source.stream.SourceToXml;
@@ -38,6 +41,15 @@ import org.junit.Test;
  */
 public class SourceToXmlTest
 {
+    private ControllerState controllerState = new ControllerState();
+    
+    public SourceToXmlTest()
+    {
+        UnitConfiguration unitConfiguration = new UnitConfiguration();
+        unitConfiguration.setEntityReferences(new EntityReferences());
+        controllerState.setUnitConfiguration(unitConfiguration);
+    }
+
     @Test
     public void testSourceToXml() throws Exception
     {
@@ -45,7 +57,8 @@ public class SourceToXmlTest
             = new File("src/test/resources/org/apache/torque/generator/source/xml/source.xml");
         FileSource fileSource = new FileSource(
                 new XmlSourceFormat(),
-                xmlFile);
+                xmlFile,
+                controllerState);
         SourceElement rootElement = fileSource.getRootElement();
 
         String result = new SourceToXml().toXml(rootElement, true);
@@ -63,7 +76,8 @@ public class SourceToXmlTest
                 "src/test/resources/org/apache/torque/generator/source/xml/source.xml");
         FileSource fileSource = new FileSource(
                 new XmlSourceFormat(),
-                xmlFile);
+                xmlFile,
+                controllerState);
         SourceElement rootElement = fileSource.getRootElement();
         rootElement.getChildren().get(2).getChildren().add(
                 rootElement.getChildren().get(0).getChildren().get(0));

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/XmlParserTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/XmlParserTest.java?rev=992442&r1=992441&r2=992442&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/XmlParserTest.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/XmlParserTest.java
Fri Sep  3 19:55:51 2010
@@ -23,6 +23,9 @@ import static org.junit.Assert.assertEqu
 
 import java.io.File;
 
+import org.apache.torque.generator.configuration.UnitConfiguration;
+import org.apache.torque.generator.configuration.source.EntityReferences;
+import org.apache.torque.generator.control.ControllerState;
 import org.apache.torque.generator.source.SourceElement;
 import org.apache.torque.generator.source.stream.FileSource;
 import org.apache.torque.generator.source.stream.XmlSourceFormat;
@@ -30,6 +33,15 @@ import org.junit.Test;
 
 public class XmlParserTest
 {
+    private ControllerState controllerState = new ControllerState();
+    
+    public XmlParserTest()
+    {
+        UnitConfiguration unitConfiguration = new UnitConfiguration();
+        unitConfiguration.setEntityReferences(new EntityReferences());
+        controllerState.setUnitConfiguration(unitConfiguration);
+    }
+
     @Test
     public void testReadXmlSource() throws Exception
     {
@@ -37,7 +49,8 @@ public class XmlParserTest
             "src/test/resources/org/apache/torque/generator/source/xml/source.xml");
         FileSource fileSource = new FileSource(
                 new XmlSourceFormat(),
-                xmlFile);
+                xmlFile,
+                controllerState);
         SourceElement rootElement = fileSource.getRootElement();
 
         assertEquals("root", rootElement.getName());



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message