1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.betwixt;
18
19 import java.io.StringReader;
20
21 import junit.framework.TestCase;
22
23 import org.apache.commons.betwixt.io.BeanReader;
24
25 /***
26 * Tests conversions.
27 * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
28 * @version $Revision: 155402 $
29 */
30 public class TestConversion extends TestCase{
31
32 public TestConversion(String name) {
33 super(name);
34 }
35
36 /***
37 * Betwixt does not (by default) try to convert nulls and empty strings
38 * @throws Exception
39 */
40 public void testNullTimestampConversion() throws Exception {
41 String xml = "<?xml version='1.0'?>" +
42 "<EventBean>" +
43 "<type>WARNING</type>" +
44 "<start>2004-02-10 00:00:00.0</start>" +
45 "<end/>" +
46 "</EventBean>";
47
48 StringReader in = new StringReader(xml);
49 BeanReader reader = new BeanReader();
50 reader.registerBeanClass(EventBean.class);
51 EventBean bean = (EventBean) reader.parse(in);
52
53 assertNotNull("Parsing should work", bean);
54 assertEquals("Type property", "WARNING", bean.getType());
55 assertEquals("Start property", "2004-02-10 00:00:00.0", bean.getStart().toString());
56 assertNull("End property", bean.getEnd());
57 }
58
59 }