1 /*
2 * Copyright (c) 2004 International Decision Systems, Inc. All Rights Reserved.
3 *
4 * By using this Software, You acknowledge that the Software is a valuable asset
5 * and trade secret of either International Decision Systems, Inc. ("IDSI") or a
6 * third party supplier of IDSI and constitutes confidential and proprietary
7 * information.
8 *
9 * NEITHER IDSI NOR ANY AGENT OR PERSON ACTING FOR OR WITH IDSI HAS MADE OR DOES
10 * MAKE ANY STATEMENTS, AFFIRMATIONS, REPRESENTATIONS OR WARRANTIES WHATSOEVER
11 * TO YOU, WHETHER EXPRESS OR IMPLIED, AS TO THE SOFTWARE, THE QUALITY OR
12 * CONDITION OF THE SOFTWARE, OR THE OPERATING CHARACTERISTICS OR RELIABILITY OF
13 * THE SOFTWARE, OR ITS SUITABILITY FOR ANY GENERAL OR PARTICULAR PURPOSE, OR AS
14 * TO ANY OTHER MATTER WHATSOEVER; ANY AND ALL OTHER WARRANTIES INCLUDING
15 * WITHOUT LIMITATION ANY WARRANTIES IMPLIED BY LAW, SUCH AS THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND TITLE,
17 * USE AND NON-INFRINGEMENT; ARE HEREBY EXPRESSLY DISCLAIMED AND EXCLUDED.
18 */
19 package net.sourceforge.addam.impexp;
20
21 import junit.framework.TestCase;
22
23 import java.sql.Timestamp;
24
25 import net.sourceforge.addam.impexp.DataCodec;
26
27 /**
28 * @author TIM3
29 * @since Mar 31, 2005 12:22:26 PM
30 */
31 public class DataCodecUTEST extends TestCase {
32
33 public void testExpectedUsage() throws Exception {
34 DataCodec codec = DataCodec.getCodec("java.sql.Timestamp");
35 Timestamp ts1 = new Timestamp(System.currentTimeMillis());
36 String encoded = codec.encode(ts1);
37 Timestamp ts2 = (Timestamp) codec.decode(encoded);
38 assertEquals(ts1, ts2);
39 }
40
41 public void testNullValue() throws Exception {
42 DataCodec codec = DataCodec.getCodec("java.sql.Timestamp");
43 Timestamp ts1 = null;
44 String encoded = codec.encode(ts1);
45 Timestamp ts2 = (Timestamp) codec.decode(encoded);
46 assertEquals(ts1, ts2);
47 }
48
49 public void testDateOnly() throws Exception {
50 DataCodec codec = DataCodec.getCodec("java.sql.Timestamp");
51 Timestamp ts1 = new Timestamp(System.currentTimeMillis());
52 Timestamp ts2 = (Timestamp) codec.decode("2004-12-22");
53 assertEquals(ts1, ts2);
54 }
55 }