db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r464324 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/io/converters/TimeConverter.java test/org/apache/ddlutils/io/RoundtripTestBase.java test/org/apache/ddlutils/io/TestDatatypes.java
Date Sun, 15 Oct 2006 23:49:30 GMT
Author: tomdz
Date: Sun Oct 15 16:49:28 2006
New Revision: 464324

URL: http://svn.apache.org/viewvc?view=rev&rev=464324
Log:
Fixed error in the time converter
Enhanced datatypes tests to also test data import from/export to XML

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/TimeConverter.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/RoundtripTestBase.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/TimeConverter.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/TimeConverter.java?view=diff&rev=464324&r1=464323&r2=464324
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/TimeConverter.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/TimeConverter.java Sun Oct
15 16:49:28 2006
@@ -87,7 +87,7 @@
                 }
 
                 _calendar.clear();
-                _calendar.set(Calendar.HOUR, hours);
+                _calendar.set(Calendar.HOUR_OF_DAY, hours);
                 _calendar.set(Calendar.MINUTE, minutes);
                 _calendar.set(Calendar.SECOND, seconds);
                 return new Time(_calendar.getTimeInMillis());

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/RoundtripTestBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/RoundtripTestBase.java?view=diff&rev=464324&r1=464323&r2=464324
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/RoundtripTestBase.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/RoundtripTestBase.java Sun Oct 15 16:49:28
2006
@@ -323,7 +323,7 @@
             dbIo.write(expected, writer);
 
             getLog().error("Expected model:\n" + writer.toString());
-            
+
             writer = new StringWriter();
             dbIo.write(actual, writer);
 

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java?view=diff&rev=464324&r1=464323&r2=464324
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java Sun Oct 15 16:49:28
2006
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import java.io.StringReader;
+import java.io.StringWriter;
 import java.math.BigDecimal;
 import java.sql.Date;
 import java.sql.Time;
@@ -29,6 +31,7 @@
 import java.util.TreeSet;
 
 import org.apache.ddlutils.model.Database;
+import org.apache.ddlutils.model.Table;
 
 import junit.framework.Test;
 
@@ -114,6 +117,45 @@
 
         assertEquals("",
         		     alterTablesSql);
+
+        StringWriter stringWriter = new StringWriter();
+        DataWriter   dataWriter   = new DataWriter(stringWriter, "UTF-8");
+
+        dataWriter.writeDocumentStart();
+        for (int idx = 0; idx < getModel().getTableCount(); idx++)
+        {
+            Table[] tables = { (Table)getModel().getTable(idx) };
+
+            dataWriter.write(getPlatform().query(getModel(), "select * from " + tables[0].getName(),
tables));
+        }
+        dataWriter.writeDocumentEnd();
+
+        String dataSql = stringWriter.toString();
+        
+        getPlatform().dropTables(getModel(), false);
+
+        createDatabase(modelXml);
+
+        DataToDatabaseSink sink   = new DataToDatabaseSink(getPlatform(), getModel());
+        DataReader         reader = new DataReader();
+
+        sink.setEnsureForeignKeyOrder(true);
+        sink.setUseBatchMode(false);
+        reader.setModel(getModel());
+        reader.setSink(sink);
+        try
+        {
+            reader.parse(new StringReader(dataSql));
+        }
+        catch (Exception ex)
+        {
+            throw new RuntimeException(ex);
+        }
+
+        beans = getRows("roundtrip");
+
+        assertEquals(expected1, beans.get(0), "avalue");
+        assertEquals(expected2, beans.get(1), "avalue");
     }
 
     /**



Mime
View raw message