You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/11/07 17:06:32 UTC
cvs commit: jakarta-commons/betwixt/src/test/org/apache/commons/betwixt TestBeanReader.java AbstractTestCase.java CustomerBean.java customer.xml
jstrachan 2002/11/07 08:06:31
Modified: betwixt/src/test/org/apache/commons/betwixt
TestBeanReader.java AbstractTestCase.java
CustomerBean.java customer.xml
Log:
Added new unit test cases for SQL Date, Time and Timestamp properties which now work
Revision Changes Path
1.5 +8 -0 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanReader.java
Index: TestBeanReader.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanReader.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestBeanReader.java 29 Aug 2002 19:21:04 -0000 1.4
+++ TestBeanReader.java 7 Nov 2002 16:06:31 -0000 1.5
@@ -14,6 +14,9 @@
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
import java.util.List;
import junit.framework.Test;
@@ -21,6 +24,8 @@
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+import org.apache.commons.beanutils.ConvertUtils;
+
import org.apache.commons.betwixt.io.BeanReader;
import org.apache.commons.betwixt.io.BeanWriter;
@@ -142,6 +147,9 @@
assertEquals( "locations[0]", "London", locations.get(0) );
assertEquals( "locations[1]", "Bath", locations.get(1) );
+ assertEquals( ConvertUtils.convert("2002-03-17", Date.class), customer.getDate());
+ assertEquals( ConvertUtils.convert("20:30:40", Time.class), customer.getTime());
+ assertEquals( ConvertUtils.convert("2002-03-17 20:30:40.0", Timestamp.class), customer.getTimestamp());
}
1.4 +10 -0 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/AbstractTestCase.java
Index: AbstractTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/AbstractTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractTestCase.java 27 Oct 2002 00:39:00 -0000 1.3
+++ AbstractTestCase.java 7 Nov 2002 16:06:31 -0000 1.4
@@ -64,12 +64,17 @@
import java.io.File;
import java.io.StringWriter;
import java.net.MalformedURLException;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.commons.beanutils.ConvertUtils;
+
import org.apache.commons.betwixt.io.BeanWriter;
@@ -123,6 +128,11 @@
address.setCode( "N5" );
bean.setAddress( address );
+
+ bean.setDate((Date) ConvertUtils.convert("2002-03-17", Date.class));
+ bean.setTime((Time) ConvertUtils.convert("20:30:40", Time.class));
+ bean.setTimestamp((Timestamp) ConvertUtils.convert("2002-03-17 20:30:40.0", Timestamp.class));
+
return bean;
}
}
1.4 +56 -1 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/CustomerBean.java
Index: CustomerBean.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/CustomerBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CustomerBean.java 14 Aug 2002 20:26:22 -0000 1.3
+++ CustomerBean.java 7 Nov 2002 16:06:31 -0000 1.4
@@ -62,6 +62,10 @@
package org.apache.commons.betwixt;
import java.io.Serializable;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
@@ -91,7 +95,10 @@
private AddressBean address;
private Map projectMap;
private List locations = new ArrayList();
-
+ private Date date;
+ private Time time;
+ private Timestamp timestamp;
+
public CustomerBean() {
}
@@ -218,4 +225,52 @@
public String toString() {
return super.toString() + "[ID=" + id + ", name=" + name + ",address=" + address + "]";
}
+ /**
+ * Returns the date.
+ * @return Date
+ */
+ public Date getDate() {
+ return date;
+ }
+
+ /**
+ * Returns the time.
+ * @return Time
+ */
+ public Time getTime() {
+ return time;
+ }
+
+ /**
+ * Returns the timestamp.
+ * @return Timestamp
+ */
+ public Timestamp getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Sets the date.
+ * @param date The date to set
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ /**
+ * Sets the time.
+ * @param time The time to set
+ */
+ public void setTime(Time time) {
+ this.time = time;
+ }
+
+ /**
+ * Sets the timestamp.
+ * @param timestamp The timestamp to set
+ */
+ public void setTimestamp(Timestamp timestamp) {
+ this.timestamp = timestamp;
+ }
+
}
1.3 +4 -0 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/customer.xml
Index: customer.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/customer.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- customer.xml 13 Aug 2002 13:35:34 -0000 1.2
+++ customer.xml 7 Nov 2002 16:06:31 -0000 1.3
@@ -45,4 +45,8 @@
<location>London</location>
<location>Bath</location>
</locations>
+
+ <date>2002-03-17</date>
+ <time>20:30:40</time>
+ <timestamp>2002-03-17 20:30:40.0</timestamp>
</CustomerBean>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>