jstrachan 2002/10/28 08:17:36 Modified: sql/src/test/org/apache/commons/sql/model TestColumn.java Added: sql/src/test/org/apache/commons/sql/task JdbcToSchemaTaskTest.java Log: applied J. Russell Smyth 's patches various new test cases Revision Changes Path 1.3 +89 -9 jakarta-commons-sandbox/sql/src/test/org/apache/commons/sql/model/TestColumn.java Index: TestColumn.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/test/org/apache/commons/sql/model/TestColumn.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestColumn.java 23 Sep 2002 16:57:26 -0000 1.2 +++ TestColumn.java 28 Oct 2002 16:17:36 -0000 1.3 @@ -1,15 +1,69 @@ -package org.apache.commons.sql.model; - /* - * Copyright (C) The Apache Software Foundation. All rights reserved. + * $Header$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact [EMAIL PROTECTED] * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * * $Id$ */ +package org.apache.commons.sql.model; + +import java.sql.Types; + import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -64,10 +118,36 @@ public void testColumn() throws Exception { - Column column = new Column("Test1","INTEGER",255,true,true,true,""); + Column column = new Column("Test1",Types.INTEGER,255,true,true,true,""); assertTrue("Column is null", column != null); assertTrue("Column toString does not end with [name=Test1;type=INTEGER]", ((String)column.toString()).endsWith("[name=Test1;type=INTEGER]")); + + assertEquals("INTEGER", column.getType()); + } + + public void testTypeName() + throws Exception + { + Column column = new Column("Test1","INTEGER",0, true,true,true,""); + + assertEquals("INTEGER", column.getType()); + assertEquals(Types.INTEGER, column.getTypeCode()); + + column = new Column(); + column.setName("foo"); + column.setType("INTEGER"); + + assertEquals("INTEGER", column.getType()); + assertEquals(Types.INTEGER, column.getTypeCode()); + + column = new Column(); + column.setName("foo"); + column.setTypeCode(Types.INTEGER); + + assertEquals("INTEGER", column.getType()); + assertEquals(Types.INTEGER, column.getTypeCode()); + } } 1.1 jakarta-commons-sandbox/sql/src/test/org/apache/commons/sql/task/JdbcToSchemaTaskTest.java Index: JdbcToSchemaTaskTest.java =================================================================== /* * $Header: $ * $Revision: $ * $Date: $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.commons.sql.task; import java.io.FileOutputStream; import java.io.IOException; import java.io.FileWriter; import java.io.PrintWriter; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Types; import java.sql.SQLException; import java.util.Hashtable; import java.util.List; import java.util.Vector; import java.util.Collection; import java.util.Iterator; import junit.framework.*; import org.apache.commons.sql.io.DatabaseWriter; import org.apache.commons.sql.io.JdbcModelReader; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; import org.apache.commons.sql.model.*; /** * A JUnit test for JdbcToSchemaTask.java * * @author <a href="mailto:drfish@;cox.net">J. Russell Smyth</a> * @version $Revision: $ */ public class JdbcToSchemaTaskTest extends TestCase { public JdbcToSchemaTaskTest(java.lang.String testName) { super(testName); } public static void main(java.lang.String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { TestSuite suite = new TestSuite(JdbcToSchemaTaskTest.class); return suite; } /** Test of execute method, of class test.JdbcToSchemaTask. */ public void testExecute() { System.out.println("testExecute"); JdbcToSchemaTask t = createTask(); t.execute(); } // Add test methods here, they have to start with 'test' name. // for example: // public void testHello() {} private JdbcToSchemaTask createTask(){ JdbcToSchemaTask task = new JdbcToSchemaTask(); task.setDbDriver("com.sap.dbtech.jdbc.DriverSapDB"); task.setDbUrl("jdbc:sapdb://localhost/TST"); task.setDbUser("TEST"); task.setDbPassword("TEST"); task.setDbSchema("TEST"); // task.setDbDriver("org.hsqldb.jdbcDriver"); // task.setDbUrl("jdbc:hsqldb:/data/ext-cvs/jakarta-ojb/target/test/OJB"); // task.setDbUser("sa"); // task.setDbPassword(""); // //task.setDbSchema("TEST"); task.setOutputFile("/home/drfish/working/commons-sql/test.xml"); return task; } }
-- To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>