SimpleSerDe extends BaseSerDe { @Override public List<Object[]> deSerialize(Object data) throws StreamSerDeException { if (data == null) { LOG.info("Input raw data is null."); return nullResults; } String sData = data.toString(); if (Strings.isNullOrEmpty(sData)) { LOG.info("Input raw data is null."); return nullResults; } List<Object[]> splitResults = Lists.newArrayList(); Object[] values = StreamingUtils.splitByWholeSeparator(sData, separator, -1, true); splitResults.add(values); return createAllInstance(splitResults); }  @Override void setConfig(StreamingConfig conf); @Override void initialize(); @Override List<Object[]> deSerialize(Object data); @Override Object serialize(List<Object[]> event); static final String LINE_SEPARATOR_UNIX; }
@Test public void testDeserialize3() throws StreamSerDeException, IOException { SimpleSerDe deser = new SimpleSerDe(); deser.setSchema(schema); String s = "a,b,c,"; int len = deser.deSerialize(s).get(0).length; assertTrue(len == SupportConst.I_FOUR); }
@Test public void testDeserialize4() throws StreamSerDeException, IOException { SimpleSerDe deser = new SimpleSerDe(); deser.setSchema(schema); String s = ""; assertTrue(deser.deSerialize(s).size() == SupportConst.I_ZERO); }
@Test public void testDeserialize5() throws StreamSerDeException, IOException { SimpleSerDe deser = new SimpleSerDe(); deser.setSchema(schema2); assertTrue((Boolean)deser.deSerialize("true").get(0)[0]); assertTrue((Boolean)deser.deSerialize("TRUE").get(0)[0]); assertTrue((Boolean)deser.deSerialize("tRue").get(0)[0]); assertFalse((Boolean)deser.deSerialize("false").get(0)[0]); assertFalse((Boolean)deser.deSerialize("FALSE").get(0)[0]); assertFalse((Boolean)deser.deSerialize("fAlse").get(0)[0]); assertNull(deser.deSerialize("a").get(0)[0]); assertNull(deser.deSerialize(" ").get(0)[0]); }
@Ignore @Test public void testDeserialize1() throws StreamSerDeException, IOException { SimpleSerDe deser = new SimpleSerDe(); deser.setSchema(schema); String s = "0,USER4,1379927089198,,USER4,RETL0,TERM_RETL0,2,RETL0,,CN,GZ,XA,02," + "29539.825183043013,29539.825183043013,CNY,4923.304197173836," + "2759854263445,null,null,false,,6,10,002,0210,000,,,903,,,,,,,,,,,,,," + "710076,,00,20164.96066506037,0,,,,,,,0,0,,,,null,0,,0.0,,,,"; int len = deser.deSerialize(s).get(0).length; assertTrue(len == I_68); }
@Test public void testDeserialize2() throws StreamSerDeException, IOException { SimpleSerDe deser = new SimpleSerDe(); deser.setSchema(schema); String s = ",,,"; int len = deser.deSerialize(s).get(0).length; assertTrue(len == SupportConst.I_FOUR); }