|
3 | 3 | importorg.junit.Assert; |
4 | 4 | importorg.junit.Test; |
5 | 5 |
|
| 6 | +importjava.text.SimpleDateFormat; |
6 | 7 | importjava.util.ArrayList; |
7 | 8 | importjava.util.Properties; |
| 9 | +importjava.util.TimeZone; |
| 10 | + |
8 | 11 | importorg.apache.hadoop.conf.Configuration; |
9 | 12 | importorg.apache.hadoop.hive.serde2.AbstractSerDe; |
10 | 13 | importorg.apache.hadoop.hive.serde2.io.ByteWritable; |
@@ -61,26 +64,29 @@ public void TestIntWrite() throws Exception { |
61 | 64 |
|
62 | 65 | @Test |
63 | 66 | publicvoidTestEpochWrite()throwsException { |
64 | | -ArrayList<Object>stuff =newArrayList<Object>(); |
| 67 | +ArrayList<Object>stuff =newArrayList<Object>(); |
65 | 68 | Propertiesproptab =newProperties(); |
66 | 69 | proptab.setProperty(HiveShims.serdeConstants.LIST_COLUMNS,"when"); |
67 | 70 | proptab.setProperty(HiveShims.serdeConstants.LIST_COLUMN_TYPES,"date"); |
68 | 71 | AbstractSerDejserde =mkSerDe(proptab); |
69 | | -StructObjectInspectorrowOI = (StructObjectInspector)jserde.getObjectInspector(); |
| 72 | +StructObjectInspectorrowOI = (StructObjectInspector)jserde.getObjectInspector(); |
70 | 73 |
|
71 | | -// {"attributes":{"when":147147147147}} |
72 | | -longepoch =147147147147L; |
| 74 | +// {"attributes":{"when":147147147147}} |
| 75 | +longepoch =147147147147L; |
| 76 | +SimpleDateFormatsdf =newSimpleDateFormat("yyyy-MMM-dd"); |
| 77 | +sdf.setTimeZone(TimeZone.getTimeZone("America/New_York")); |
73 | 78 | java.sql.Dateexpected =newjava.sql.Date(epoch); |
| 79 | +StringexpString =sdf.format(expected); |
74 | 80 | //System.err.println(expected.getTime()); |
75 | | -addWritable(stuff,expected); |
| 81 | +addWritable(stuff,expected); |
76 | 82 | Writablejsw =jserde.serialize(stuff,rowOI); |
77 | 83 | JsonNodejn =newObjectMapper().readTree(((Text)jsw).toString()); |
78 | 84 | jn =jn.findValue("attributes"); |
79 | 85 | jn =jn.findValue("when"); |
80 | 86 | java.sql.Dateactual =newjava.sql.Date(jn.getLongValue()); |
81 | | -Assert.assertEquals(expected.toString(),actual.toString());// workaround DateWritable,j.s.Date |
| 87 | +StringactualDateString =sdf.format(actual); |
| 88 | +Assert.assertEquals(expString,actualDateString);// workaround DateWritable,j.s.Date |
82 | 89 | } |
83 | | - |
84 | 90 | @Test |
85 | 91 | publicvoidTestTimeWrite()throwsException { |
86 | 92 | ArrayList<Object>stuff =newArrayList<Object>(); |
|