Changeset 3142
- Timestamp:
- 02/07/12 10:30:06 (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
AnalyzerBeans/trunk/core/src/test/java/org/eobjects/analyzer/beans/transform/TimestampConverterTest.java
r2777 r3142 22 22 import java.text.SimpleDateFormat; 23 23 import java.util.Date; 24 import java.util.TimeZone; 24 25 25 26 import org.eobjects.analyzer.beans.transform.TimestampConverter.Unit; … … 31 32 public class TimestampConverterTest extends TestCase { 32 33 34 private TimeZone _defaultTimeZone; 35 36 protected void setUp() throws Exception { 37 _defaultTimeZone = TimeZone.getDefault(); 38 TimeZone.setDefault(TimeZone.getTimeZone("UTC")); 39 }; 40 41 @Override 42 protected void tearDown() throws Exception { 43 TimeZone.setDefault(_defaultTimeZone); 44 } 45 33 46 public void testTransform() throws Exception { 34 47 TimestampConverter trans = new TimestampConverter(); 35 MockInputColumn<Object> col = new MockInputColumn<Object>("my timestamps", Object.class); 48 MockInputColumn<Object> col = new MockInputColumn<Object>( 49 "my timestamps", Object.class); 36 50 trans.timestampColumn = col; 37 51 38 52 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 39 53 40 54 Date[] result; 41 55 result = trans.transform(new MockInputRow().put(col, "1320244696")); 42 56 assertEquals(1, result.length); 43 assertEquals("2011-11-02 1 5:38", dateFormat.format(result[0]));44 57 assertEquals("2011-11-02 14:38", dateFormat.format(result[0])); 58 45 59 result = trans.transform(new MockInputRow().put(col, 1234)); 46 60 assertEquals(1, result.length); 47 assertEquals("1970-01-01 0 1:20", dateFormat.format(result[0]));48 61 assertEquals("1970-01-01 00:20", dateFormat.format(result[0])); 62 49 63 result = trans.transform(new MockInputRow().put(col, null)); 50 64 assertEquals(1, result.length); 51 65 assertNull(result[0]); 52 66 53 67 result = trans.transform(new MockInputRow().put(col, "foobar")); 54 68 assertEquals(1, result.length); 55 69 assertNull(result[0]); 56 70 57 71 trans.unit = Unit.DAYS; 58 72 result = trans.transform(new MockInputRow().put(col, 20)); 59 73 assertEquals(1, result.length); 60 assertEquals("1970-01-21 0 1:00", dateFormat.format(result[0]));74 assertEquals("1970-01-21 00:00", dateFormat.format(result[0])); 61 75 } 62 76 }
Note: See TracChangeset
for help on using the changeset viewer.
