@Before public void setUp() throws Exception { initialize(); }
@Test public void testTimestampDeSerializeNumericTimestampWithNanoseconds() throws Exception { // Test that timestamp object can be deserialized Writable w = new Text("{\"one\":true,\"five\":1367801925.123}"); // JSONObject result = (JSONObject) instance.deserialize(w); StructObjectInspector soi = (StructObjectInspector) instance.getObjectInspector(); JavaStringTimestampObjectInspector jstOi = (JavaStringTimestampObjectInspector) soi.getStructFieldRef("five").getFieldObjectInspector(); assertEquals(getDate("2013-05-05 17:58:45.123"), jstOi.getPrimitiveJavaObject(result.get("five")) ); }
@Test public void testTimestampDeSerializeNumericTimestampWithMilliseconds() throws Exception { // Test that timestamp object can be deserialized Writable w = new Text("{\"one\":true,\"five\":1367801925123}"); // JSONObject result = (JSONObject) instance.deserialize(w); StructObjectInspector soi = (StructObjectInspector) instance.getObjectInspector(); JavaStringTimestampObjectInspector jstOi = (JavaStringTimestampObjectInspector) soi.getStructFieldRef("five").getFieldObjectInspector(); assertEquals(getDate("2013-05-05 17:58:45.123"), jstOi.getPrimitiveJavaObject(result.get("five")) ); }
@Test public void testTimestampDeSerializeNumericTimestamp() throws Exception { // Test that timestamp object can be deserialized Writable w = new Text("{\"one\":true,\"five\":1367801925}"); JSONObject result = (JSONObject) instance.deserialize(w); StructObjectInspector soi = (StructObjectInspector) instance.getObjectInspector(); JavaStringTimestampObjectInspector jstOi = (JavaStringTimestampObjectInspector) soi.getStructFieldRef("five").getFieldObjectInspector(); assertEquals(getDate("2013-05-05 17:58:45.0" ), jstOi.getPrimitiveJavaObject(result.get("five")) ); }