db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r965166 [4/4] - in /db/torque/torque4/trunk/torque-generator: ./ src/main/java/org/apache/torque/generator/configuration/ src/main/java/org/apache/torque/generator/configuration/controller/ src/main/java/org/apache/torque/generator/configur...
Date Sun, 18 Jul 2010 06:10:57 GMT
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=965166&r1=965165&r2=965166&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 Sun Jul 18 06:10:55 2010
@@ -35,10 +35,6 @@ import java.util.Set;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.generator.BaseTest;
-import org.apache.torque.generator.configuration.ConfigurationHandlers;
-import org.apache.torque.generator.configuration.UnitConfiguration;
-import org.apache.torque.generator.configuration.UnitConfigurationReader;
-import org.apache.torque.generator.configuration.UnitDescriptor;
 import org.apache.torque.generator.configuration.controller.Loglevel;
 import org.apache.torque.generator.configuration.controller.OutletReference;
 import org.apache.torque.generator.configuration.controller.Output;
@@ -61,11 +57,14 @@ import org.apache.torque.generator.optio
 import org.apache.torque.generator.option.Options;
 import org.apache.torque.generator.outlet.Outlet;
 import org.apache.torque.generator.qname.QualifiedName;
-import org.apache.torque.generator.source.FileSourcesImpl;
-import org.apache.torque.generator.source.TransformerDefinition;
-import org.apache.torque.generator.source.properties.PropertiesSourceType;
-import org.apache.torque.generator.source.xml.XmlSourceType;
+import org.apache.torque.generator.source.SourceProcessConfiguration;
+import org.apache.torque.generator.source.SourceTransformerDefinition;
+import org.apache.torque.generator.source.jdbc.JdbcMetadataSourceProvider;
+import org.apache.torque.generator.source.stream.FileSourceProvider;
+import org.apache.torque.generator.source.stream.PropertiesSourceFormat;
+import org.apache.torque.generator.source.stream.XmlSourceFormat;
 import org.apache.torque.generator.template.velocity.VelocityOutlet;
+import org.junit.Before;
 import org.junit.Test;
 
 
@@ -74,8 +73,18 @@ import org.junit.Test;
  */
 public class ReadConfigurationTest extends BaseTest
 {
-    private ControllerState controllerState = new ControllerState();
-
+    private ControllerState controllerState;
+    
+    @Before
+    public void setUp()
+    {
+        controllerState = new ControllerState();
+        UnitConfiguration unitConfiguration = new UnitConfiguration();
+        controllerState.setUnitConfiguration(unitConfiguration);
+        Options options = new Options();
+        unitConfiguration.setOptions(options);
+    }
+    
     @Test
     public void testReadConfiguration() throws Exception
     {
@@ -93,7 +102,6 @@ public class ReadConfigurationTest exten
                 = configurationReader.read(
                         unitDescriptor,
                         configurationHandlers);
-
         {
             File newFileTargetDirectory
                     = unitConfiguration.getNewFileTargetDirectory();
@@ -112,88 +120,57 @@ public class ReadConfigurationTest exten
         assertEquals(Loglevel.DEBUG, unitConfiguration.getLoglevel());
 
         {
-            Options options = unitConfiguration.getOptions();
-
-            Map<QualifiedName, Option> globalScope = options.getGlobalScope();
-            assertEquals(4, globalScope.size());
-
-            // check normal options
-            {
-                QualifiedName optionWithNamespaceQName
-                        = new QualifiedName(
-                                "org.apache.torque.generator.optionWithNamespace");
-                Option optionWithNamespace
-                        = globalScope.get(optionWithNamespaceQName);
-                assertEquals(
-                        new OptionImpl(
-                                optionWithNamespaceQName,
-                                "optionWithNamespaceValue"),
-                        optionWithNamespace);
-            }
-            {
-                QualifiedName optionWithNamespaceQName
-                        = new QualifiedName(
-                                "org.apache.optionWithNamespace");
-                Option optionWithNamespace
-                        = globalScope.get(optionWithNamespaceQName);
-                assertEquals(
-                        new OptionImpl(
-                                optionWithNamespaceQName,
-                                "org.apache.optionWithNamespaceValue"),
-                        optionWithNamespace);
-            }
-            {
-                QualifiedName optionWithNamespaceQName
-                        = new QualifiedName(
-                                "optionWithoutNamespace", "");
-                Option optionWithNamespace
-                        = globalScope.get(optionWithNamespaceQName);
-                assertEquals(
-                        new OptionImpl(
-                                optionWithNamespaceQName,
-                                "optionWithoutNamespaceValue"),
-                        optionWithNamespace);
-            }
-            // check option from last file takes precedence
-            {
-                QualifiedName optionWithNamespaceQName
-                        = new QualifiedName(
-                                "optionPrecedenceLastFile");
-                Option optionWithNamespace
-                        = globalScope.get(optionWithNamespaceQName);
-                assertEquals(
-                        new OptionImpl(
-                                optionWithNamespaceQName,
-                                "value from xml"),
-                        optionWithNamespace);
-            }
+            Options expectedOptions = new Options();
+            Set<Option> expectedOptionSet = new HashSet<Option>();
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("org.apache.torque.generator.optionWithNamespace"),
+                    "optionWithNamespaceValue"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("org.apache.optionWithNamespace"),
+                    "org.apache.optionWithNamespaceValue"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("optionWithoutNamespace", ""),
+                    "optionWithoutNamespaceValue"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("optionPrecedenceLastFile"),
+                    "value from xml"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("jdbcUrl"),
+                    "jdbc.url.option.value"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("jdbcDriver"),
+                    "jdbc.driver.option.value"));
+            expectedOptions.addGlobalOptions(expectedOptionSet);
+            assertOptionsEquals(
+                    expectedOptions,
+                    unitConfiguration.getOptions());            
         }
 
         {
-            List<Output> outputFiles = unitConfiguration.getOutputFiles();
+            List<Output> outputFiles = unitConfiguration.getOutputList();
             assertEquals(3, outputFiles.size());
 
             {
-                Output outputFile = outputFiles.get(0);
+                Output output = outputFiles.get(0);
                 assertEquals(
-                        outputFile.getName(),
+                        output.getName(),
                         new QualifiedName("org.apache.torque.generator.firstOutput"));
 
                 {
                     OutletReference outletConfiguration
-                            = outputFile.getContentOutlet();
+                            = output.getContentOutlet();
                     assertEquals(
                             new QualifiedName(
                                 "org.apache.torque.generator.test.readConfiguration.javaOutlet"),
                             outletConfiguration.getName());
                 }
 
-                assertNull(outputFile.getFilename());
-                assertTrue(outputFile.isSkipIfExists());
+                assertNull(output.getFilename());
+                assertTrue(output.isSkipIfExists());
 
                 {
                     JavaOutlet filenameOutlet
-                            = (JavaOutlet) outputFile.getFilenameOutlet();
+                            = (JavaOutlet) output.getFilenameOutlet();
                     assertEquals("Foo", filenameOutlet.getFoo());
                     assertEquals("Bar", filenameOutlet.getBar());
                     assertEquals(
@@ -207,31 +184,33 @@ public class ReadConfigurationTest exten
                             projectPaths.getDefaultSourcePath(),
                             new HashSet<String>(),
                             new HashSet<String>());
-                    FileSourcesImpl sources = new FileSourcesImpl(
-                            new XmlSourceType(),
-                            sourceFileset,
-                            null,
-                            null,
-                            new ArrayList<TransformerDefinition>(),
-                            configurationHandlers);
-                    sources.init();
-                    outputFile.getSources().init();
-                    assertSourcesEquals(
-                            sources,
-                            (FileSourcesImpl) outputFile.getSources());
-                    // TODO: add source Transformers to config file & check here they are added
-                }
+                    FileSourceProvider sourceProvider = new FileSourceProvider(
+                            new XmlSourceFormat(),
+                            sourceFileset);
+                    sourceProvider.init(
+                            configurationHandlers,
+                            controllerState);
+                    output.getSourceProvider().init(
+                            configurationHandlers,
+                            controllerState);
+                    assertFileSourceProviderEquals(
+                            sourceProvider,
+                            (FileSourceProvider) output.getSourceProvider());
+                }
+                assertSourceProcessConfigurationEquals(
+                        new SourceProcessConfiguration(), 
+                        output.getSourceProcessConfiguration());
             }
 
             {
-                Output outputFile = outputFiles.get(1);
+                Output output = outputFiles.get(1);
                 assertEquals(
-                        outputFile.getName(),
+                        output.getName(),
                         new QualifiedName("secondOutput"));
 
                 {
                     OutletReference outletConfiguration
-                            = outputFile.getContentOutlet();
+                            = output.getContentOutlet();
                     assertEquals(
                             new QualifiedName(
                                 "org.apache.torque.generator.test.readConfiguration.anotherOutlet"),
@@ -239,12 +218,12 @@ public class ReadConfigurationTest exten
                 }
 
 
-                assertNull(outputFile.getFilename());
-                assertFalse(outputFile.isSkipIfExists());
+                assertNull(output.getFilename());
+                assertFalse(output.isSkipIfExists());
 
                 {
                     VelocityOutlet filenameOutlet
-                            = (VelocityOutlet) outputFile.getFilenameOutlet();
+                            = (VelocityOutlet) output.getFilenameOutlet();
                     String templateContent
                             = filenameOutlet.getContent(controllerState);
                     // remove License from template by comparing only
@@ -268,29 +247,53 @@ public class ReadConfigurationTest exten
                             projectPaths.getDefaultSourcePath(),
                             createSetFrom("second.source.path.properties"),
                             createSetFrom("second.excluded.properties"));
-                    FileSourcesImpl sources = new FileSourcesImpl(
-                            new PropertiesSourceType(),
-                            sourceFileset,
-                            "properties/entry",
-                            null,
-                            new ArrayList<TransformerDefinition>(),
-                            configurationHandlers);
-                    sources.init();
-                    outputFile.getSources().init();
-                    assertSourcesEquals(
-                            sources,
-                            (FileSourcesImpl) outputFile.getSources());
+                    FileSourceProvider sourceProvider = new FileSourceProvider(
+                            new PropertiesSourceFormat(),
+                            sourceFileset);
+                    sourceProvider.init(
+                            configurationHandlers,
+                            controllerState);
+                    output.getSourceProvider().init(
+                            configurationHandlers,
+                            controllerState);
+                    assertFileSourceProviderEquals(
+                            sourceProvider,
+                            (FileSourceProvider) output.getSourceProvider());
+                }
+                {
+                    SourceProcessConfiguration sourceProcessConfiguration
+                        = new SourceProcessConfiguration();
+                    sourceProcessConfiguration.setStartElementsPath(
+                            "properties/entry");
+                    List<SourceTransformerDefinition> transformerDefinitions
+                            = new ArrayList<SourceTransformerDefinition>();
+                    
+                    transformerDefinitions.add(
+                            new SourceTransformerDefinition(
+                                    new ConfigurationTestTransformer(), 
+                                    null));
+                    transformerDefinitions.add(
+                            new SourceTransformerDefinition(
+                                    new OtherConfigurationTestTransformer(), 
+                                    "database"));
+                    sourceProcessConfiguration.setSourceTransformerDefinitions(
+                            transformerDefinitions);
+                    sourceProcessConfiguration.setSkipDecider(
+                            "org.apache.torque.generator.configuration.ConfigurationTestSkipDecider");
+                    assertSourceProcessConfigurationEquals(
+                            sourceProcessConfiguration, 
+                            output.getSourceProcessConfiguration());
                 }
             }
             {
-                Output outputFile = outputFiles.get(2);
+                Output output = outputFiles.get(2);
                 assertEquals(
-                        outputFile.getName(),
+                        output.getName(),
                         new QualifiedName("thirdOutput"));
 
                 {
                     OutletReference outletConfiguration
-                            = outputFile.getContentOutlet();
+                            = output.getContentOutlet();
                     assertEquals(
                             new QualifiedName(
                                 "org.apache.torque.generator.test.readConfiguration.thirdOutlet"),
@@ -298,28 +301,31 @@ public class ReadConfigurationTest exten
                 }
 
 
-                assertEquals("outputFileName", outputFile.getFilename());
-                assertNull(outputFile.getFilenameOutlet());
-                assertFalse(outputFile.isSkipIfExists());
-
-                {
-                    Fileset sourceFileset = new Fileset(
-                            projectPaths.getDefaultSourcePath(),
-                            createSetFrom("third.source.path.properties"),
-                            createSetFrom("third.excluded.properties"));
-                    FileSourcesImpl sources = new FileSourcesImpl(
-                            null,
-                            sourceFileset,
-                            null,
-                            null,
-                            new ArrayList<TransformerDefinition>(),
-                            configurationHandlers);
-                    sources.init();
-                    outputFile.getSources().init();
-                    assertSourcesEquals(
-                            sources,
-                            (FileSourcesImpl) outputFile.getSources());
-                }
+                assertEquals("outputFileName", output.getFilename());
+                assertNull(output.getFilenameOutlet());
+                assertFalse(output.isSkipIfExists());
+
+                {
+                    JdbcMetadataSourceProvider sourceProvider 
+                            = new JdbcMetadataSourceProvider(
+                                "jdbcUrl",
+                                "jdbcDriver",
+                                "jdbcUsername",
+                                "jdbcPassword",
+                                "jdbcSchema");
+                    sourceProvider.init(
+                            configurationHandlers,
+                            controllerState);
+                    output.getSourceProvider().init(
+                            configurationHandlers,
+                            controllerState);
+                    assertJdbcMetadataSourceProviderEquals(
+                            sourceProvider,
+                            (JdbcMetadataSourceProvider) output.getSourceProvider());
+                }
+                assertSourceProcessConfigurationEquals(
+                        new SourceProcessConfiguration(), 
+                        output.getSourceProcessConfiguration());
             }
         }
 
@@ -554,69 +560,49 @@ public class ReadConfigurationTest exten
         }
 
         {
-            Options options = unitConfiguration.getOptions();
-            Map<QualifiedName, Option> globalScope = options.getGlobalScope();
-            assertEquals(6, globalScope.size());
-
-            {
-                QualifiedName optionWithoutNamespaceQName
-                        = new QualifiedName("optionWithoutNamespace", "");
-                Option optionWithoutNamespace
-                        = globalScope.get(optionWithoutNamespaceQName);
-                assertEquals(
-                        new OptionImpl(
-                                optionWithoutNamespaceQName,
-                                "optionWithoutNamespaceValue"),
-                        optionWithoutNamespace);
-            }
-            {
-                QualifiedName optionWithNamespaceQName
-                        = new QualifiedName(
-                                "org.apache.torque.generator.optionWithNamespace");
-                Option optionWithNamespace
-                        = globalScope.get(optionWithNamespaceQName);
-                assertEquals(
-                        new OptionImpl(
-                                optionWithNamespaceQName,
-                                "optionWithNamespaceValue"),
-                        optionWithNamespace);
-            }
-            {
-                QualifiedName optionWithoutNamespaceQName
-                        = new QualifiedName("parentOptionWithoutNamespace", "");
-                Option optionWithoutNamespace
-                        = globalScope.get(optionWithoutNamespaceQName);
-                assertEquals(
-                        new OptionImpl(
-                                optionWithoutNamespaceQName,
-                                "parentOptionWithoutNamespaceParentValue"),
-                        optionWithoutNamespace);
-            }
-            {
-                QualifiedName optionWithNamespaceQName
-                        = new QualifiedName(
-                                "org.apache.torque.generator.parentOptionWithNamespace");
-                Option optionWithNamespace
-                        = globalScope.get(optionWithNamespaceQName);
-                assertEquals(
-                        new OptionImpl(
-                                optionWithNamespaceQName,
-                                "parentOptionWithNamespaceParentValue"),
-                        optionWithNamespace);
-            }
+            Options expectedOptions = new Options();
+            Set<Option> expectedOptionSet = new HashSet<Option>();
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("org.apache.torque.generator.optionWithNamespace"),
+                    "optionWithNamespaceValue"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("org.apache.optionWithNamespace"),
+                    "org.apache.optionWithNamespaceValue"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("optionWithoutNamespace", ""),
+                    "optionWithoutNamespaceValue"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("optionPrecedenceLastFile"),
+                    "value from xml"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("jdbcUrl"),
+                    "jdbc.url.option.value"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("jdbcDriver"),
+                    "jdbc.driver.option.value"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("parentOptionWithoutNamespace", ""),
+                    "parentOptionWithoutNamespaceParentValue"));
+            expectedOptionSet.add(new OptionImpl(
+                    new QualifiedName("org.apache.torque.generator.parentOptionWithNamespace"),
+                    "parentOptionWithNamespaceParentValue"));
+            expectedOptions.addGlobalOptions(expectedOptionSet);
+            assertOptionsEquals(
+                    expectedOptions,
+                    unitConfiguration.getOptions());            
         }
         {
-            List<Output> outputFiles = unitConfiguration.getOutputFiles();
-            assertEquals(4, outputFiles.size());
+            List<Output> outputList = unitConfiguration.getOutputList();
+            assertEquals(4, outputList.size());
 
             {
-                Output outputFile = outputFiles.get(0);
+                Output output = outputList.get(0);
                 assertEquals(
-                        outputFile.getName(),
+                        output.getName(),
                         new QualifiedName("parentOutput"));
                 {
                     OutletReference outletConfiguration
-                            = outputFile.getContentOutlet();
+                            = output.getContentOutlet();
                     assertEquals(
                             new QualifiedName(
                                 "org.apache.torque.generator.test.readConfiguration.testParentOutlet"),
@@ -624,11 +610,11 @@ public class ReadConfigurationTest exten
                 }
 
 
-                assertNull(outputFile.getFilename());
+                assertNull(output.getFilename());
 
                 {
                     JavaOutlet filenameOutlet
-                            = (JavaOutlet) outputFile.getFilenameOutlet();
+                            = (JavaOutlet) output.getFilenameOutlet();
                     assertEquals("ParentFoo", filenameOutlet.getFoo());
                     assertEquals("ParentBar", filenameOutlet.getBar());
                     assertEquals(
@@ -642,29 +628,48 @@ public class ReadConfigurationTest exten
                             projectPaths.getDefaultSourcePath(),
                             createSetFrom("parentSource"),
                             new HashSet<String>());
-                    FileSourcesImpl sources = new FileSourcesImpl(
-                            new XmlSourceType(),
-                            sourceFileset,
-                            "parentSourceElement",
-                            null,
-                            new ArrayList<TransformerDefinition>(),
-                            configurationHandlers);
-                    sources.init();
-                    outputFile.getSources().init();
-                    assertSourcesEquals(
-                            sources,
-                            (FileSourcesImpl) outputFile.getSources());
+                    FileSourceProvider sourceProvider = new FileSourceProvider(
+                            new XmlSourceFormat(),
+                            sourceFileset);
+                    output.getSourceProvider().init(
+                            configurationHandlers,
+                            controllerState);
+                    sourceProvider.init(
+                            configurationHandlers, 
+                            controllerState);
+                    assertFileSourceProviderEquals(
+                            sourceProvider,
+                            (FileSourceProvider) output.getSourceProvider());
+                }
+                {
+                    SourceProcessConfiguration sourceProcessConfiguration
+                        = new SourceProcessConfiguration();
+                    sourceProcessConfiguration.setStartElementsPath("parentSourceElement");
+                    List<SourceTransformerDefinition> transformerDefinitions
+                            = new ArrayList<SourceTransformerDefinition>();
+                    
+                    transformerDefinitions.add(
+                            new SourceTransformerDefinition(
+                                    new OtherConfigurationTestTransformer(), 
+                                    "parent/database"));
+                    sourceProcessConfiguration.setSourceTransformerDefinitions(
+                            transformerDefinitions);
+                    sourceProcessConfiguration.setSkipDecider(
+                            "org.apache.torque.generator.configuration.OtherConfigurationTestSkipDecider");
+                    assertSourceProcessConfigurationEquals(
+                            sourceProcessConfiguration, 
+                            output.getSourceProcessConfiguration());
                 }
             }
             {
-                Output outputFile = outputFiles.get(1);
+                Output output = outputList.get(1);
                 assertEquals(
-                        outputFile.getName(),
+                        output.getName(),
                         new QualifiedName("org.apache.torque.generator.firstOutput"));
 
                 {
                     OutletReference outletConfiguration
-                            = outputFile.getContentOutlet();
+                            = output.getContentOutlet();
                     assertEquals(
                             new QualifiedName(
                                 "org.apache.torque.generator.test.readConfiguration.javaOutlet"),
@@ -672,11 +677,11 @@ public class ReadConfigurationTest exten
                 }
 
 
-                assertNull(outputFile.getFilename());
+                assertNull(output.getFilename());
 
                 {
                     JavaOutlet filenameOutlet
-                            = (JavaOutlet) outputFile.getFilenameOutlet();
+                            = (JavaOutlet) output.getFilenameOutlet();
                     assertEquals("Foo", filenameOutlet.getFoo());
                     assertEquals("Bar", filenameOutlet.getBar());
                     assertEquals(
@@ -690,31 +695,33 @@ public class ReadConfigurationTest exten
                             projectPaths.getDefaultSourcePath(),
                             new HashSet<String>(),
                             new HashSet<String>());
-                    FileSourcesImpl sources = new FileSourcesImpl(
-                            new XmlSourceType(),
-                            sourceFileset,
-                            null,
-                            null,
-                            new ArrayList<TransformerDefinition>(),
-                            configurationHandlers);
-                    sources.init();
-                    outputFile.getSources().init();
-                    assertSourcesEquals(
-                            sources,
-                            (FileSourcesImpl) outputFile.getSources());
-                    // TODO: add source Transformers to config file & check here they are added
-                }
+                    FileSourceProvider sourceProvider = new FileSourceProvider(
+                            new XmlSourceFormat(),
+                            sourceFileset);
+                    sourceProvider.init(
+                            configurationHandlers,
+                            controllerState);
+                    output.getSourceProvider().init(
+                            configurationHandlers,
+                            controllerState);
+                    assertFileSourceProviderEquals(
+                            sourceProvider,
+                            (FileSourceProvider) output.getSourceProvider());
+                }
+                assertSourceProcessConfigurationEquals(
+                        new SourceProcessConfiguration(), 
+                        output.getSourceProcessConfiguration());
             }
 
             {
-                Output outputFile = outputFiles.get(2);
+                Output output = outputList.get(2);
                 assertEquals(
-                        outputFile.getName(),
+                        output.getName(),
                         new QualifiedName("secondOutput"));
 
                 {
                     OutletReference outletConfiguration
-                            = outputFile.getContentOutlet();
+                            = output.getContentOutlet();
                     assertEquals(
                             new QualifiedName(
                                 "org.apache.torque.generator.test.readConfiguration.anotherOutlet"),
@@ -722,11 +729,11 @@ public class ReadConfigurationTest exten
                 }
 
 
-                assertNull(outputFile.getFilename());
+                assertNull(output.getFilename());
 
                 {
                     VelocityOutlet filenameOutlet
-                            = (VelocityOutlet) outputFile.getFilenameOutlet();
+                            = (VelocityOutlet) output.getFilenameOutlet();
                     String templateContent
                             = filenameOutlet.getContent(controllerState);
                     // remove License from template by comparing only
@@ -747,55 +754,80 @@ public class ReadConfigurationTest exten
                             projectPaths.getDefaultSourcePath(),
                             createSetFrom("second.source.path.properties"),
                             createSetFrom("second.excluded.properties"));
-                    FileSourcesImpl sources = new FileSourcesImpl(
-                            new PropertiesSourceType(),
-                            sourceFileset,
-                            "properties/entry",
-                            null,
-                            new ArrayList<TransformerDefinition>(),
-                            configurationHandlers);
-                    sources.init();
-                    outputFile.getSources().init();
-                    assertSourcesEquals(
-                            sources,
-                            (FileSourcesImpl) outputFile.getSources());
+                    FileSourceProvider sourceProvider = new FileSourceProvider(
+                            new PropertiesSourceFormat(),
+                            sourceFileset);
+                    sourceProvider.init(
+                            configurationHandlers,
+                            controllerState);
+                    output.getSourceProvider().init(
+                            configurationHandlers,
+                            controllerState);
+                    assertFileSourceProviderEquals(
+                            sourceProvider,
+                            (FileSourceProvider) output.getSourceProvider());
+                }
+                {
+                    SourceProcessConfiguration sourceProcessConfiguration
+                        = new SourceProcessConfiguration();
+                    sourceProcessConfiguration.setStartElementsPath("properties/entry");
+                    List<SourceTransformerDefinition> transformerDefinitions
+                            = new ArrayList<SourceTransformerDefinition>();
+                    transformerDefinitions.add(
+                            new SourceTransformerDefinition(
+                                    new ConfigurationTestTransformer(), 
+                                    null));
+                    transformerDefinitions.add(
+                            new SourceTransformerDefinition(
+                                    new OtherConfigurationTestTransformer(), 
+                                    "database"));
+                    sourceProcessConfiguration.setSourceTransformerDefinitions(
+                            transformerDefinitions);
+                    sourceProcessConfiguration.setSkipDecider(
+                        "org.apache.torque.generator.configuration.ConfigurationTestSkipDecider");
+                    assertSourceProcessConfigurationEquals(
+                            sourceProcessConfiguration, 
+                            output.getSourceProcessConfiguration());
                 }
             }
             {
-                Output outputFile = outputFiles.get(3);
+                Output output = outputList.get(3);
                 assertEquals(
-                        outputFile.getName(),
+                        output.getName(),
                         new QualifiedName("thirdOutput"));
 
                 {
                     OutletReference outletConfiguration
-                            = outputFile.getContentOutlet();
+                            = output.getContentOutlet();
                     assertEquals(
                             new QualifiedName(
                                 "org.apache.torque.generator.test.readConfiguration.thirdOutlet"),
                             outletConfiguration.getName());
                 }
 
-                assertEquals("outputFileName", outputFile.getFilename());
-                assertNull(outputFile.getFilenameOutlet());
+                assertEquals("outputFileName", output.getFilename());
+                assertNull(output.getFilenameOutlet());
                 {
-                    Fileset sourceFileset = new Fileset(
-                            projectPaths.getDefaultSourcePath(),
-                            createSetFrom("third.source.path.properties"),
-                            createSetFrom("third.excluded.properties"));
-                    FileSourcesImpl sources = new FileSourcesImpl(
-                            null,
-                            sourceFileset,
-                            null,
-                            null,
-                            new ArrayList<TransformerDefinition>(),
-                            configurationHandlers);
-                    sources.init();
-                    outputFile.getSources().init();
-                    assertSourcesEquals(
-                            sources,
-                            (FileSourcesImpl) outputFile.getSources());
-                }
+                    JdbcMetadataSourceProvider sourceProvider 
+                            = new JdbcMetadataSourceProvider(
+                                "jdbcUrl",
+                                "jdbcDriver",
+                                "jdbcUsername",
+                                "jdbcPassword",
+                                "jdbcSchema");
+                    sourceProvider.init(
+                            configurationHandlers,
+                            controllerState);
+                    output.getSourceProvider().init(
+                            configurationHandlers,
+                            controllerState);
+                    assertJdbcMetadataSourceProviderEquals(
+                            sourceProvider,
+                            (JdbcMetadataSourceProvider) output.getSourceProvider());
+                }
+                assertSourceProcessConfigurationEquals(
+                        new SourceProcessConfiguration(), 
+                        output.getSourceProcessConfiguration());
             }
         }
 
@@ -893,29 +925,13 @@ public class ReadConfigurationTest exten
         }
     }
 
-    private static void assertSourcesEquals(
-            FileSourcesImpl expected,
-            FileSourcesImpl actual)
+    private static void assertFileSourceProviderEquals(
+            FileSourceProvider expected,
+            FileSourceProvider actual)
     {
-        if (expected.getSourceFilter() != null)
-        {
-            assertEquals(
-                    expected.getSourceFilter().getClass(),
-                    actual.getSourceFilter().getClass());
-        }
-        else
-        {
-            assertNull(actual.getSourceFilter());
-        }
-        assertEquals(
-                expected.getStartElementsPath(),
-                actual.getStartElementsPath());
         assertEquals(
-                expected.getTransformerDefinitions(),
-                actual.getTransformerDefinitions());
-        assertEquals(
-                expected.getType(),
-                actual.getType());
+                expected.getSourceFormat(),
+                actual.getSourceFormat());
         assertEquals(
                 expected.getSourceFileset().getIncludes(),
                 actual.getSourceFileset().getIncludes());
@@ -930,6 +946,81 @@ public class ReadConfigurationTest exten
                 actual.getPaths());
     }
     
+    private static void assertJdbcMetadataSourceProviderEquals(
+            JdbcMetadataSourceProvider expected,
+            JdbcMetadataSourceProvider actual)
+    {
+        assertEquals(
+                expected.getDriverOption(),
+                actual.getDriverOption());
+        assertEquals(
+                expected.getPasswordOption(),
+                actual.getPasswordOption());
+        assertEquals(
+                expected.getSchemaOption(),
+                actual.getSchemaOption());
+        assertEquals(
+                expected.getUrlOption(),
+                actual.getUrlOption());
+        assertEquals(
+                expected.getUsernameOption(),
+                actual.getUsernameOption());
+        assertEquals(
+                expected.getDriver(),
+                actual.getDriver());
+        assertEquals(
+                expected.getPassword(),
+                actual.getPassword());
+        assertEquals(
+                expected.getSchema(),
+                actual.getSchema());
+        assertEquals(
+                expected.getUrl(),
+                actual.getUrl());
+        assertEquals(
+                expected.getUsername(),
+                actual.getUsername());
+    }
+    
+    private static void assertOptionsEquals(Options expected, Options actual)
+    {
+        Map<QualifiedName, Option> expectedMap 
+                = expected.getGlobalScope();
+        Map<QualifiedName, Option> actualMap 
+                = actual.getGlobalScope();
+        assertEquals(expectedMap.size(), actualMap.size());
+
+        for (QualifiedName expectedKey : expectedMap.keySet())
+        {
+            assertTrue(expectedMap.containsKey(expectedKey));
+            Object expectedValue = expectedMap.get(expectedKey).getValue();
+            Object actualValue = actualMap.get(expectedKey).getValue();
+            assertEquals(expectedValue, actualValue);
+        }
+    }
+    
+    private void assertSourceProcessConfigurationEquals(
+            SourceProcessConfiguration expected,
+            SourceProcessConfiguration actual)
+    {
+        if (expected.getSkipDecider() != null)
+        {
+            assertEquals(
+                    expected.getSkipDecider().getClass(),
+                    actual.getSkipDecider().getClass());
+        }
+        else
+        {
+            assertNull(actual.getSkipDecider());
+        }
+        assertEquals(
+                expected.getStartElementsPath(),
+                actual.getStartElementsPath());
+        assertEquals(
+                expected.getTransformerDefinitions(),
+                actual.getTransformerDefinitions());
+    }
+    
     /**
      * Creates as set containing the Strings in content.
      * 

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/file/FileTestUtils.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/file/FileTestUtils.java?rev=965166&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/file/FileTestUtils.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/file/FileTestUtils.java Sun Jul 18 06:10:55 2010
@@ -0,0 +1,71 @@
+package org.apache.torque.generator.file;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class FileTestUtils
+{
+    /**
+     * Checks that the file list of the Fileset contains all the 
+     * expected paths and no other paths. 
+     * 
+     * @param fileset The Fileset which file list should be checked.
+     * @param expectedPaths the paths which should be in the fileset.
+     * 
+     * @throws IOException if Fileset#getFiles() throws it.
+     */
+    public static void assertFileListEquals(
+                Fileset fileset,
+                File... expected)
+            throws IOException
+    {
+        List<File> fileList = fileset.getFiles();
+        assertFileListEquals(fileList, expected);
+    }
+
+    /**
+     * Checks that a file list contains all the 
+     * expected paths and no other paths. 
+     * 
+     * @param fileList The list of files which should be checked.
+     * @param expectedPaths the paths which should be in the file list.
+     */
+    public static void assertFileListEquals(
+                List<File> fileList,
+                File... expected)
+    {
+        Set<File> actualFiles = new HashSet<File>();
+        for (File file : fileList)
+        {
+            actualFiles.add(file);
+        }
+        Set<File> expectedFiles = new HashSet<File>();
+        for (File file : expected)
+        {
+            expectedFiles.add(file);
+        }
+        assertEquals(expectedFiles, actualFiles);
+    }
+
+    /**
+     * Creates as set containing the Strings in content.
+     * 
+     * @param content The Strings which should be in the set.
+     * 
+     * @return the Set containing all the strings.
+     */
+    public static Set<String> createSetFrom(String... content)
+    {
+        Set<String> result = new HashSet<String>();
+        for (String part : content)
+        {
+            result.add(part);
+        }
+        return result;
+    }
+}

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/file/FilesetTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/file/FilesetTest.java?rev=965166&r1=965165&r2=965166&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/file/FilesetTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/file/FilesetTest.java Sun Jul 18 06:10:55 2010
@@ -20,17 +20,23 @@ package org.apache.torque.generator.file
  */
 
 import static org.junit.Assert.assertEquals;
+import static org.apache.torque.generator.file.FileTestUtils.assertFileListEquals;
+import static org.apache.torque.generator.file.FileTestUtils.createSetFrom;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.torque.generator.file.Fileset;
 import org.junit.Test;
 
+/**
+ * Tests for the class Fileset.
+ * 
+ * @version $Id: $
+ */
 public class FilesetTest
 {
     private static File TEST_BASE_DIR = new File("src/test/file");
@@ -267,6 +273,7 @@ public class FilesetTest
                 new File(TEST_BASE_DIR, "subfolder/2.properties"),
                 new File(TEST_BASE_DIR, "subfolder/subsubfolder/3.properties"));
     }
+
     @Test
     public void testFilelistExcludeInBasedir() throws IOException
     {
@@ -365,62 +372,16 @@ public class FilesetTest
                 new File(TEST_BASE_DIR, "subfolder/../11.properties"));
     }
     
-    /**
-     * Checks that the file list of the Fileset contains all the 
-     * expected paths and no other paths. 
-     * 
-     * @param fileset The Fileset which file list should be checked.
-     * @param expectedPaths the paths which should be in the fileset.
-     * 
-     * @throws IOException if Fileset#getFiles() throws it.
-     */
-    private static void assertFileListEquals(
-                Fileset fileset,
-                File... expected)
-            throws IOException
-    {
-        List<File> fileList = fileset.getFiles();
-        assertFileListEquals(fileList, expected);
-    }
-
-    /**
-     * Checks that a file list contains all the 
-     * expected paths and no other paths. 
-     * 
-     * @param fileList The list of files which should be checked.
-     * @param expectedPaths the paths which should be in the file list.
-     */
-    private static void assertFileListEquals(
-                List<File> fileList,
-                File... expected)
+    @Test
+    public void testFilelistBasedirNul() throws IOException
     {
-        Set<File> actualFiles = new HashSet<File>();
-        for (File file : fileList)
-        {
-            actualFiles.add(file);
-        }
-        Set<File> expectedFiles = new HashSet<File>();
-        for (File file : expected)
-        {
-            expectedFiles.add(file);
-        }
-        assertEquals(expectedFiles, actualFiles);
+        Fileset fileset = new Fileset(
+                null,
+                createSetFrom(TEST_BASE_DIR + "/1.properties"),
+                null);
+        assertFileListEquals(
+                fileset,
+                new File(TEST_BASE_DIR, "/1.properties"));
     }
 
-    /**
-     * Creates as set containing the Strings in content.
-     * 
-     * @param content The Strings which should be in the set.
-     * 
-     * @return the Set containing all the strings.
-     */
-    private static Set<String> createSetFrom(String... content)
-    {
-        Set<String> result = new HashSet<String>();
-        for (String part : content)
-        {
-            result.add(part);
-        }
-        return result;
-    }
 }

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/XmlOutletTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/XmlOutletTest.java?rev=965166&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/XmlOutletTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/XmlOutletTest.java Sun Jul 18 06:10:55 2010
@@ -0,0 +1,50 @@
+package org.apache.torque.generator.outlet.java;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.qname.QualifiedName;
+import org.apache.torque.generator.source.SourceElement;
+import org.junit.Test;
+
+public class XmlOutletTest
+{
+    /**
+     * A basic test for the XML Outlet, where no id attributes are created.
+     *
+     * @throws Exception if an error occurs.
+     */
+    @Test
+    public void testXmlOutlet() throws Exception
+    {
+        SourceElement rootElement = new SourceElement("root");
+        rootElement.getChildren().add(new SourceElement("child"));
+        ControllerState controllerState = new ControllerState();
+        controllerState.setRootElement(rootElement);
+        XmlOutlet xmlOutlet = new XmlOutlet(new QualifiedName("test"));
+        String result = xmlOutlet.execute(controllerState);
+        assertEquals(
+                "<root>\n  <child/>\n</root>\n",
+                result);
+    }
+
+    /**
+     * A basic test for the XML Outlet, where id attributes are created.
+     *
+     * @throws Exception if an error occurs.
+     */
+    @Test
+    public void testXmlOutletCreateIdAttributes() throws Exception
+    {
+        SourceElement rootElement = new SourceElement("root");
+        rootElement.getChildren().add(new SourceElement("child"));
+        ControllerState controllerState = new ControllerState();
+        controllerState.setRootElement(rootElement);
+        XmlOutlet xmlOutlet = new XmlOutlet(new QualifiedName("test"));
+        xmlOutlet.setCreateIdAttributes(true);
+        String result = xmlOutlet.execute(controllerState);
+        assertEquals(
+                "<root id=\"1\">\n  <child id=\"2\"/>\n</root>\n",
+                result);
+    }
+}

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=965166&r1=965165&r2=965166&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 Sun Jul 18 06:10:55 2010
@@ -26,16 +26,13 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.Iterator;
 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.source.FileSource;
-import org.apache.torque.generator.source.SourceElement;
-import org.apache.torque.generator.source.TransformerDefinition;
-import org.apache.torque.generator.source.properties.PropertiesSourceType;
+import org.apache.torque.generator.source.stream.FileSource;
+import org.apache.torque.generator.source.stream.PropertiesSourceFormat;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -351,11 +348,8 @@ public class RichSourceElementImplTest
                     "propertiesData.properties");
         FileSource fileSource
                 = new FileSource(
-                        new PropertiesSourceType(),
-                        propertiesFile,
-                        null,
-                        null,
-                        new ArrayList<TransformerDefinition>());
+                        new PropertiesSourceFormat(),
+                        propertiesFile);
         SourceElement rootElement
                 = (SourceElement) fileSource.getRootElement();
 

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/jdbc/JdbcMetadataSourceTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/jdbc/JdbcMetadataSourceTest.java?rev=965166&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/jdbc/JdbcMetadataSourceTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/jdbc/JdbcMetadataSourceTest.java Sun Jul 18 06:10:55 2010
@@ -0,0 +1,247 @@
+package org.apache.torque.generator.source.jdbc;
+
+/*
+ * 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.
+ */
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Logger;
+import org.apache.torque.generator.source.SourceElement;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JdbcMetadataSourceTest
+{
+    private static Logger logger 
+            = Logger.getLogger(JdbcMetadataSourceTest.class);
+    
+    private static String SQL_FILENAME = "jdbcMetadataSourceTest.sql";
+
+    private static String SQL_CHARSET = "iso-8859-1";
+
+    private static String URL = "jdbc:derby:memory:myDb;create=true";
+
+    private static String DRIVER = "org.apache.derby.jdbc.ClientDriver";
+
+    @BeforeClass
+    public static void beforeClass() throws Exception
+    {
+        Class.forName(DRIVER).newInstance();
+    }
+
+    @Before
+    public void setUp() throws Exception
+    {
+        BasicConfigurator.configure();
+        Connection connection = DriverManager.getConnection(URL);
+        InputStream inputStream = getClass().getResourceAsStream(SQL_FILENAME);
+        BufferedReader bufferedReader = new BufferedReader(
+                new InputStreamReader(inputStream, SQL_CHARSET));
+        String line;
+        StringBuilder queryBuffer = new StringBuilder();
+        while ((line = bufferedReader.readLine()) != null)
+        {
+            if (line.trim().length() == 0 || line.trim().startsWith("--"))
+            {
+                continue;
+            }
+            queryBuffer.append(line);
+        }
+        StringTokenizer tokenizer
+            = new StringTokenizer(queryBuffer.toString(), ";", false);
+        while (tokenizer.hasMoreTokens())
+        {
+          String sqlQuery = tokenizer.nextToken();
+          Statement statement = connection.createStatement();
+          try
+          {
+            statement.execute(sqlQuery);
+          }
+          catch (SQLException e)
+          {
+            logger.info(e.getMessage());
+          }
+          statement.close();
+        }
+        connection.close();
+    }
+
+    @Test
+    public void testExecute() throws Exception
+    {
+        JdbcMetadataSource source
+                = new JdbcMetadataSource(DRIVER, URL, null, null, null);
+        SourceElement rootElement = source.createRootElement();
+        assertEquals("database", rootElement.getName());
+        List<SourceElement> tableElements = rootElement.getChildren();
+        assertEquals(2, tableElements.size());
+        for (SourceElement tableElement : tableElements)
+        {
+            assertEquals("table", tableElement.getName());
+            Object tableName = tableElement.getAttribute("name");
+            if ("AUTHOR".equals(tableName))
+            {
+                List<SourceElement> columnElements 
+                        = tableElement.getChildren();
+                assertEquals(2, columnElements.size());
+                for (SourceElement columnElement : columnElements)
+                {
+                    assertEquals("column", columnElement.getName());
+                    Object columnName = columnElement.getAttribute("name");
+                    if ("AUTHOR_ID".equals(columnName))
+                    {
+                        assertEquals(
+                                "true",
+                                columnElement.getAttribute("primaryKey"));
+                        assertNull(columnElement.getAttribute("required"));
+                        assertEquals(
+                                "INTEGER",
+                                columnElement.getAttribute("type"));
+                        assertNull(columnElement.getAttribute("size"));
+                        assertNull(columnElement.getAttribute("scale"));
+                        // do not check default value as it is currently
+                        // not generated correctly
+                        // assertNull(columnElement.getAttribute("default"));
+                    }
+                    else if ("NAME".equals(columnName))
+                    {
+                        assertNull(columnElement.getAttribute("primaryKey"));
+                        assertEquals(
+                                "true",
+                                columnElement.getAttribute("required"));
+                        assertEquals(
+                                "VARCHAR",
+                                columnElement.getAttribute("type"));
+                        assertEquals(
+                                "50",
+                                columnElement.getAttribute("size"));
+                        assertNull(columnElement.getAttribute("scale"));
+                        assertNull(columnElement.getAttribute("default"));
+                    }
+                    else
+                    {
+                        fail("Unknown column : " + columnName);
+                    }
+                }
+            }
+            else if ("BOOK".equals(tableName))
+            {
+                assertEquals(5, tableElement.getChildren().size());
+                List<SourceElement> columnElements
+                        = tableElement.getChildren("column");
+                assertEquals(4, columnElements.size());
+                for (SourceElement columnElement : columnElements)
+                {
+                    assertEquals("column", columnElement.getName());
+                    Object columnName = columnElement.getAttribute("name");
+                    if ("BOOK_ID".equals(columnName))
+                    {
+                        assertEquals(
+                                "true",
+                                columnElement.getAttribute("primaryKey"));
+                        assertNull(columnElement.getAttribute("required"));
+                        assertEquals(
+                                "INTEGER",
+                                columnElement.getAttribute("type"));
+                        assertNull(columnElement.getAttribute("size"));
+                        assertNull(columnElement.getAttribute("scale"));
+                        // do not check default value as it is currently
+                        // not generated correctly
+                        // assertNull(columnElement.getAttribute("default"));
+                    }
+                    else if ("ISBN".equals(columnName))
+                    {
+                        assertNull(columnElement.getAttribute("primaryKey"));
+                        assertNull(columnElement.getAttribute("required"));
+                        assertEquals(
+                                "VARCHAR",
+                                columnElement.getAttribute("type"));
+                        assertEquals(
+                                "15",
+                                columnElement.getAttribute("size"));
+                        assertNull(columnElement.getAttribute("scale"));
+                        assertNull(columnElement.getAttribute("default"));
+                    }
+                    else if ("AUTHOR_ID".equals(columnName))
+                    {
+                        assertNull(columnElement.getAttribute("primaryKey"));
+                        assertEquals(
+                                "true",
+                                columnElement.getAttribute("required"));
+                        assertEquals(
+                                "INTEGER",
+                                columnElement.getAttribute("type"));
+                        assertNull(columnElement.getAttribute("size"));
+                        assertNull(columnElement.getAttribute("scale"));
+                        assertNull(columnElement.getAttribute("default"));
+                    }
+                    else if ("TITLE".equals(columnName))
+                    {
+                        assertNull(columnElement.getAttribute("primaryKey"));
+                        assertEquals(
+                                "true",
+                                columnElement.getAttribute("required"));
+                        assertEquals(
+                                "VARCHAR",
+                                columnElement.getAttribute("type"));
+                        assertEquals(
+                                "255",
+                                columnElement.getAttribute("size"));
+                        assertNull(columnElement.getAttribute("scale"));
+                        assertEquals(
+                                "no title",
+                                columnElement.getAttribute("default"));
+                    }
+                    else
+                    {
+                        fail("Unknown column : " + columnName);
+                    }
+                }
+                List<SourceElement> foreignKeyElements
+                        = tableElement.getChildren("foreign-key");
+                assertEquals(1, foreignKeyElements.size());
+                SourceElement foreignKeyElement = foreignKeyElements.get(0);
+                assertEquals(
+                        "AUTHOR",
+                        foreignKeyElement.getAttribute("foreignTable"));
+            }
+            else
+            {
+                fail("Unknown table : " + tableName);
+            }
+        }
+//
+//        String xml = new SourceToXml().toXml(rootElement, false);
+//        System.out.println(xml);
+    }
+}

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=965166&r1=965165&r2=965166&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 Sun Jul 18 06:10:55 2010
@@ -22,14 +22,12 @@ package org.apache.torque.generator.sour
 import static org.junit.Assert.assertEquals;
 
 import java.io.File;
-import java.util.ArrayList;
 
 import org.apache.torque.generator.configuration.ConfigurationException;
-import org.apache.torque.generator.source.FileSource;
 import org.apache.torque.generator.source.SourceElement;
 import org.apache.torque.generator.source.SourceException;
-import org.apache.torque.generator.source.TransformerDefinition;
-import org.apache.torque.generator.source.properties.PropertiesSourceType;
+import org.apache.torque.generator.source.stream.FileSource;
+import org.apache.torque.generator.source.stream.PropertiesSourceFormat;
 import org.junit.Test;
 
 public class PropertiesParserTest
@@ -42,11 +40,8 @@ public class PropertiesParserTest
             = new File("src/test/resources/org/apache/torque/generator/source/properties/propertiesParserTest.properties");
         FileSource fileSource
                 = new FileSource(
-                        new PropertiesSourceType(),
-                        propertiesFile,
-                        null,
-                        null,
-                        new ArrayList<TransformerDefinition>());
+                        new PropertiesSourceFormat(),
+                        propertiesFile);
 
         SourceElement rootElement = fileSource.getRootElement();
         assertEquals("properties", rootElement.getName());
@@ -73,10 +68,7 @@ public class PropertiesParserTest
     public void testPathNull() throws ConfigurationException
     {
         new FileSource(
-                new PropertiesSourceType(),
-                null,
-                null,
-                null,
-                new ArrayList<TransformerDefinition>());
+                new PropertiesSourceFormat(),
+                null);
     }
 }

Added: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/FileSourceProviderTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/FileSourceProviderTest.java?rev=965166&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/FileSourceProviderTest.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/FileSourceProviderTest.java Sun Jul 18 06:10:55 2010
@@ -0,0 +1,77 @@
+package org.apache.torque.generator.source.stream;
+
+import static org.apache.torque.generator.file.FileTestUtils.createSetFrom;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.torque.generator.configuration.ConfigurationException;
+import org.apache.torque.generator.configuration.ConfigurationHandlers;
+import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.file.Fileset;
+import org.apache.torque.generator.source.Source;
+import org.apache.torque.generator.source.SourceException;
+import org.junit.Test;
+
+public class FileSourceProviderTest
+{
+    private static File TEST_BASE_DIR = new File("src/test/file");
+
+    @Test
+    public void testReadFiles() 
+            throws ConfigurationException, SourceException
+    {
+        Fileset fileset = new Fileset(
+                TEST_BASE_DIR,
+                createSetFrom("*.properties"),
+                null);
+        FileSourceProvider fileSourceProvider 
+                = new FileSourceProvider(null, fileset);
+        fileSourceProvider.init(
+                new ConfigurationHandlers(),
+                new ControllerState());
+        
+        // We read all sources and add the first property key to a hash set.
+        // As all the source files only have one key equal to the base filename
+        // we can make sure we have read the expected files correctly.
+        Set<String> resultKeys = new HashSet<String>();
+        {
+            assertTrue(fileSourceProvider.hasNext());
+            Source source = fileSourceProvider.next();
+            Object key = source.getRootElement().getChild("entry")
+                    .getAttribute("key");
+            resultKeys.add((String) key);
+        }
+        {
+            assertTrue(fileSourceProvider.hasNext());
+            Source source = fileSourceProvider.next();
+            Object key = source.getRootElement().getChild("entry")
+                    .getAttribute("key");
+            resultKeys.add((String) key);
+        }
+        assertFalse(fileSourceProvider.hasNext());
+        Set<String> expectedKeys = new HashSet<String>();
+        expectedKeys.add("1");
+        expectedKeys.add("11");
+        assertEquals(expectedKeys, resultKeys);
+    }
+    
+    @Test(expected = ConfigurationException.class)
+    public void testReadFilesBasedirNull() 
+            throws ConfigurationException, SourceException
+    {
+        Fileset fileset = new Fileset(
+                null,
+                createSetFrom("*.properties"),
+                null);
+        FileSourceProvider fileSourceProvider 
+                = new FileSourceProvider(null, fileset);
+        fileSourceProvider.init(
+                new ConfigurationHandlers(),
+                new ControllerState());
+    }
+}

Copied: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/SourceToXmlTest.java (from r944873, db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/xml/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?p2=db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/SourceToXmlTest.java&p1=db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/xml/SourceToXmlTest.java&r1=944873&r2=965166&rev=965166&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/xml/SourceToXmlTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/SourceToXmlTest.java Sun Jul 18 06:10:55 2010
@@ -1,4 +1,4 @@
-package org.apache.torque.generator.source.xml;
+package org.apache.torque.generator.source.stream;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -22,15 +22,13 @@ package org.apache.torque.generator.sour
 import static org.junit.Assert.assertEquals;
 
 import java.io.File;
-import java.util.ArrayList;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.torque.generator.source.FileSource;
 import org.apache.torque.generator.source.SourceElement;
-import org.apache.torque.generator.source.TransformerDefinition;
-import org.apache.torque.generator.source.xml.SourceToXml;
-import org.apache.torque.generator.source.xml.XmlSourceType;
+import org.apache.torque.generator.source.stream.FileSource;
+import org.apache.torque.generator.source.stream.SourceToXml;
+import org.apache.torque.generator.source.stream.XmlSourceFormat;
 import org.junit.Test;
 
 /**
@@ -46,14 +44,11 @@ public class SourceToXmlTest
         File xmlFile
             = new File("src/test/resources/org/apache/torque/generator/source/xml/source.xml");
         FileSource fileSource = new FileSource(
-                new XmlSourceType(),
-                xmlFile,
-                null,
-                null,
-                new ArrayList<TransformerDefinition>());
+                new XmlSourceFormat(),
+                xmlFile);
         SourceElement rootElement = fileSource.getRootElement();
 
-        String result = new SourceToXml().toXml(rootElement);
+        String result = new SourceToXml().toXml(rootElement, true);
         String expected = FileUtils.readFileToString(new File(
                 "src/test/resources/org/apache/torque/generator/source/xml/sourceToXmlResult.xml"));
         // remove license from expected file
@@ -67,16 +62,13 @@ public class SourceToXmlTest
         File xmlFile = new File(
                 "src/test/resources/org/apache/torque/generator/source/xml/source.xml");
         FileSource fileSource = new FileSource(
-                new XmlSourceType(),
-                xmlFile,
-                null,
-                null,
-                new ArrayList<TransformerDefinition>());
+                new XmlSourceFormat(),
+                xmlFile);
         SourceElement rootElement = fileSource.getRootElement();
         rootElement.getChildren().get(2).getChildren().add(
                 rootElement.getChildren().get(0).getChildren().get(0));
 
-        String result = new SourceToXml().toXml(rootElement);
+        String result = new SourceToXml().toXml(rootElement, true);
         String expected = FileUtils.readFileToString(new File(
                 "src/test/resources/org/apache/torque/generator/source/xml/sourceToXmlWithReferenceResult.xml"));
         // remove license from expected file
@@ -89,7 +81,7 @@ public class SourceToXmlTest
     {
         SourceElement rootElement = new SourceElement("root");
         rootElement.setAttribute((String) null, "X&<>Y'\"Z");
-        String result = new SourceToXml().toXml(rootElement);
+        String result = new SourceToXml().toXml(rootElement, true);
         assertEquals(
                 "<root id=\"1\">X&amp;&lt;&gt;Y&apo;&quot;Z</root>\n",
                 result);
@@ -100,10 +92,20 @@ public class SourceToXmlTest
     {
         SourceElement rootElement = new SourceElement("root");
         rootElement.setAttribute("attribute", "&<>'\"");
-        String result = new SourceToXml().toXml(rootElement);
+        String result = new SourceToXml().toXml(rootElement, true);
         assertEquals(
                 "<root attribute=\"&amp;&lt;&gt;&apo;&quot;\" id=\"1\"/>\n",
                 result);
     }
 
+    @Test
+    public void testSourceToXmlNoAutomaticIds() throws Exception
+    {
+        SourceElement rootElement = new SourceElement("root");
+        rootElement.getChildren().add(new SourceElement("child"));
+        String result = new SourceToXml().toXml(rootElement, false);
+        assertEquals(
+                "<root>\n  <child/>\n</root>\n",
+                result);
+    }
 }

Copied: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/XmlParserTest.java (from r944873, db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/xml/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?p2=db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/XmlParserTest.java&p1=db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/xml/XmlParserTest.java&r1=944873&r2=965166&rev=965166&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/xml/XmlParserTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/source/stream/XmlParserTest.java Sun Jul 18 06:10:55 2010
@@ -1,4 +1,4 @@
-package org.apache.torque.generator.source.xml;
+package org.apache.torque.generator.source.stream;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -22,12 +22,10 @@ package org.apache.torque.generator.sour
 import static org.junit.Assert.assertEquals;
 
 import java.io.File;
-import java.util.ArrayList;
 
-import org.apache.torque.generator.source.FileSource;
 import org.apache.torque.generator.source.SourceElement;
-import org.apache.torque.generator.source.TransformerDefinition;
-import org.apache.torque.generator.source.xml.XmlSourceType;
+import org.apache.torque.generator.source.stream.FileSource;
+import org.apache.torque.generator.source.stream.XmlSourceFormat;
 import org.junit.Test;
 
 public class XmlParserTest
@@ -38,11 +36,8 @@ public class XmlParserTest
         File xmlFile = new File(
             "src/test/resources/org/apache/torque/generator/source/xml/source.xml");
         FileSource fileSource = new FileSource(
-                new XmlSourceType(),
-                xmlFile,
-                null,
-                null,
-                new ArrayList<TransformerDefinition>());
+                new XmlSourceFormat(),
+                xmlFile);
         SourceElement rootElement = fileSource.getRootElement();
 
         assertEquals("root", rootElement.getName());

Modified: db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml?rev=965166&r1=965165&r2=965166&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml Sun Jul 18 06:10:55 2010
@@ -34,7 +34,7 @@
         <action xsi:type="optionAction" option="package" />
        </mergepoint>
     </filenameOutlet>
-    <source elements="properties">
+    <source xsi:type="fileSource" elements="properties">
       <include>propertiesData.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesToJava" />
@@ -49,13 +49,13 @@
         <action xsi:type="optionAction" option="package" />
        </mergepoint>
     </filenameOutlet>
-    <source elements="properties">
+    <source xsi:type="fileSource" elements="properties">
       <include>propertiesData.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesExtendedToJava" />
   </output>
   <output name="properties" file="Properties.properties">
-    <source elements="properties">
+    <source xsi:type="fileSource" elements="properties">
       <include>propertiesData.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesCopy"/>

Added: db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/generator/source/jdbc/jdbcMetadataSourceTest.sql
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/generator/source/jdbc/jdbcMetadataSourceTest.sql?rev=965166&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/generator/source/jdbc/jdbcMetadataSourceTest.sql (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/generator/source/jdbc/jdbcMetadataSourceTest.sql Sun Jul 18 06:10:55 2010
@@ -0,0 +1,38 @@
+-- -----------------------------------------------------------------------
+-- derby SQL script for schema bookstore
+-- -----------------------------------------------------------------------
+
+
+
+-- -----------------------------------------------------------------------
+-- book
+-- -----------------------------------------------------------------------
+CREATE TABLE book
+(
+    book_id INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+    isbn VARCHAR(15),
+    author_id INTEGER NOT NULL,
+    title VARCHAR(255) NOT NULL default 'no title',
+    PRIMARY KEY(book_id));
+
+
+
+
+-- -----------------------------------------------------------------------
+-- author
+-- -----------------------------------------------------------------------
+CREATE TABLE author
+(
+    author_id INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+    name VARCHAR(50) NOT NULL,
+    PRIMARY KEY(author_id));
+
+
+
+
+ALTER TABLE book
+    ADD CONSTRAINT book_FK_1 
+    FOREIGN KEY (author_id)
+    REFERENCES author (author_id);
+
+

Modified: db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/generator/test/readfromclasspath/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/generator/test/readfromclasspath/conf/control.xml?rev=965166&r1=965165&r2=965166&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/generator/test/readfromclasspath/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/generator/test/readfromclasspath/conf/control.xml Sun Jul 18 06:10:55 2010
@@ -23,7 +23,7 @@
     xmlns="http://db.apache.org/torque/4.0/generator/configuration">
   <options path="options.properties" xsi:type="propertiesOptions"/> 
   <output name="properties" file="Properties.properties">
-    <source elements="properties">
+    <source xsi:type="fileSource" elements="properties">
       <include>propertiesData.properties</include>
     </source>
     <outlet name="org.apache.torque.generator.velocity.PropertiesCopy"/>

Modified: db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gen/conf/control.xml?rev=965166&r1=965165&r2=965166&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gen/conf/control.xml Sun Jul 18 06:10:55 2010
@@ -25,7 +25,7 @@
     loglevel="debug">
   <output name="propertyKeys"
       file="org/apache/torque/generator/example/gettingstarted/PropertyKeys.java">
-    <source>
+    <source xsi:type="fileSource">
       <include>propertiesData.properties</include>
     </source>
     <outlet name="classFrame"/>



---------------------------------------------------------------------
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