1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.convert1.format;
17
18 import junit.framework.TestCase;
19 import junit.framework.TestSuite;
20
21 import java.text.Format;
22 import java.text.SimpleDateFormat;
23 import java.text.DecimalFormat;
24
25 import java.util.Date;
26
27 import org.apache.commons.convert1.Converter;
28
29
30
31
32
33
34
35
36
37 public class FormatConverterTestCase extends TestCase {
38
39
40
41 public FormatConverterTestCase(String name) {
42 super(name);
43 }
44
45
46
47 public void setUp() throws Exception {
48 }
49
50 public static TestSuite suite() {
51 return new TestSuite(FormatConverterTestCase.class);
52 }
53
54 public void tearDown() throws Exception {
55 }
56
57
58
59 public void testNumberFormat() {
60 Format format = new DecimalFormat("0.0");
61 FormatConverter fc = new FormatConverter(format);
62 assertEquals( "5.4", fc.convert( String.class, new Double(5.43) ) );
63 }
64
65 public void testDateFormat() {
66 Format format = new SimpleDateFormat("dd MM yyyy");
67 FormatConverter fc = new FormatConverter(format);
68 assertEquals( "31 12 1969", fc.convert( String.class, new Date(0) ) );
69 }
70 }
71