You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by be...@apache.org on 2010/04/12 17:14:10 UTC
svn commit: r933270 - in
/incubator/empire-db/trunk/empire-db-codegen/src/test:
java/org/apache/empire/db/codegen/ resources/
Author: benniven
Date: Mon Apr 12 15:14:09 2010
New Revision: 933270
URL: http://svn.apache.org/viewvc?rev=933270&view=rev
Log:
added:
a unit test for the codegen, that checks if nested tables/views
are generated when no template folder has been specified (<templateFolder></templateFolder>)
fix: in all codegen testconf*.xml for the unit tests the wrong options
were changed
from <dbSchema>DBSAMPLE</dbSchema>
to <dbSchema></dbSchema>
Added:
incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_default_template_folder_nested.xml
Modified:
incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenAppTest.java
incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_invalid_template_folder.xml
incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_using_template_folder.xml
Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenAppTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenAppTest.java?rev=933270&r1=933269&r2=933270&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenAppTest.java (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenAppTest.java Mon Apr 12 15:14:09 2010
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTru
import static org.junit.Assert.fail;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import org.apache.empire.db.codegen.util.FileUtils;
@@ -54,6 +55,32 @@ public class CodeGenAppTest {
}
@Test
+ public void testMainDefaultTemplateFolderNested() {
+ String[] args = new String[]{"src/test/resources/testconfig_default_template_folder_nested.xml"};
+ CodeGenApp.main(args);
+ File expectedFile = new File("target/generated/dbsample/org/apache/empire/db/samples/dbsample/SampleDB.java");
+
+ // the string to be expected within the DB class file
+ String expectedContent = "addColumn(";
+
+
+ // this variable will hold the file's whole content
+ String fileContent="";
+ try{
+ FileInputStream fis = new FileInputStream(expectedFile);
+ byte[] buff=new byte[fis.available()];
+ fis.read(buff);
+ fileContent=new String(buff);
+ fis.close();
+ }
+ // IO Exception can be ignored here
+ catch(IOException e){}
+
+ // we expect that there is at least one nested table is within the DB class that has at leas one column.
+ assertTrue("missing generated code for nested table classes", fileContent.contains(expectedContent));
+ }
+
+ @Test
public void testMainUsingTemplateFolder() {
String[] args = new String[]{"src/test/resources/testconfig_using_template_folder.xml"};
Added: incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_default_template_folder_nested.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_default_template_folder_nested.xml?rev=933270&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_default_template_folder_nested.xml (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_default_template_folder_nested.xml Mon Apr 12 15:14:09 2010
@@ -0,0 +1,75 @@
+<?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.
+-->
+<config>
+
+ <properties>
+ <!-- provider name must match the property-section containing the connection data -->
+ <jdbcClass>org.hsqldb.jdbcDriver</jdbcClass>
+ <jdbcURL>jdbc:hsqldb:file:src/test/resources/hsqldb/sample;shutdown=true</jdbcURL>
+ <jdbcUser>sa</jdbcUser>
+ <jdbcPwd></jdbcPwd>
+ <packageName>org.apache.empire.db.example</packageName>
+
+ <!-- Schema options -->
+ <dbCatalog></dbCatalog>
+ <dbSchema></dbSchema>
+ <dbTablePattern></dbTablePattern>
+ <timestampColumn>CREATIONDATE</timestampColumn>
+
+ <!-- generation options -->
+ <templateFolder></templateFolder>
+ <targetFolder>target/generated/dbsample</targetFolder>
+ <packageName>org.apache.empire.db.samples.dbsample</packageName>
+ <dbClassName>SampleDB</dbClassName>
+ <tableBaseName>SampleTable</tableBaseName>
+ <viewBaseName>SampleView</viewBaseName>
+ <recordBaseName>SampleRecord</recordBaseName>
+ <tableClassPrefix>T</tableClassPrefix>
+ <tableClassSuffix>Table</tableClassSuffix>
+ <viewClassPrefix>V</viewClassPrefix>
+ <nestTables>true</nestTables>
+ <nestViews>true</nestViews>
+ <createRecordProperties>true</createRecordProperties>
+ </properties>
+
+ <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="default" class="org.apache.log4j.ConsoleAppender">
+ <!-- layout class="org.apache.log4j.TTCCLayout"/ -->
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- param name="ConversionPattern" value="NSB(%c) %-5p %m at %l%n"/ -->
+ <param name="ConversionPattern" value="%-5p [%d{yyyy/MM/dd HH:mm}]: %m at %l %n"/>
+ </layout>
+ </appender>
+
+ <!-- log detail configuration -->
+ <logger name="org.apache.empire.commons" additivity="false">
+ <level value="warn"/>
+ <appender-ref ref="default"/>
+ </logger>
+
+ <root>
+ <priority value="info"/>
+ <appender-ref ref="default"/>
+ </root>
+
+ </log4j:configuration>
+
+</config>
Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_invalid_template_folder.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_invalid_template_folder.xml?rev=933270&r1=933269&r2=933270&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_invalid_template_folder.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_invalid_template_folder.xml Mon Apr 12 15:14:09 2010
@@ -29,7 +29,7 @@
<!-- Schema options -->
<dbCatalog></dbCatalog>
- <dbSchema>DBSAMPLE</dbSchema>
+ <dbSchema></dbSchema>
<dbTablePattern></dbTablePattern>
<timestampColumn>CREATIONDATE</timestampColumn>
Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_using_template_folder.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_using_template_folder.xml?rev=933270&r1=933269&r2=933270&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_using_template_folder.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig_using_template_folder.xml Mon Apr 12 15:14:09 2010
@@ -29,7 +29,7 @@
<!-- Schema options -->
<dbCatalog></dbCatalog>
- <dbSchema>DBSAMPLE</dbSchema>
+ <dbSchema></dbSchema>
<dbTablePattern></dbTablePattern>
<timestampColumn>CREATIONDATE</timestampColumn>