@Test public void testXMLTest1Len() { Test1 test1 = new Test1(); Test2 test2 = new Test2(); Test3 test3 = new Test3(); test2.setTest1(test1); test1.setTest2(test2); test1.setTest3(test3); test3.setTest2(test2); try { String bigcontent = FileUtil.getFileContent( new File( "F:\\workspace\\bbossgroups-3.5\\bboss-core\\test\\org\\frameworkset\\soa\\testxstream.xml"), "UTF-8"); // 预热bboss和xstream test1.setXmlvalue(bigcontent); String xml = ObjectSerializable.toXML(test1); System.out.println("bboss:" + xml.getBytes().length); Test1 test1_ = (Test1) ObjectSerializable.toBean(xml, Test1.class); String xmlXstream = xStream.toXML(test1); Test1 p = (Test1) xStream.fromXML(xmlXstream); System.out.println("xmlXstream:" + xmlXstream.getBytes().length); // 测试用例结束 } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Test public void testDupJAVASerializable() throws Exception { Test1 test1 = new Test1(); Test2 test2 = new Test2(); Test3 test3 = new Test3(); test2.setTest1(test1); test1.setTest2(test2); test1.setTest3(test3); test3.setTest2(test2); try { String bigcontent = FileUtil.getFileContent( new File( "F:\\workspace\\bbossgroups-3.5\\bboss-core\\test\\org\\frameworkset\\soa\\testxstream.xml"), "UTF-8"); // 预热bboss和xstream test1.setXmlvalue(bigcontent); String xml = ObjectSerializable.toXML(test1); System.out.println("bboss:" + xml.getBytes().length); Test1 test1_ = (Test1) ObjectSerializable.toBean(xml, Test1.class); byte[] cs = oldObjectToByteBuffer(test1); System.out.println("java:" + cs.length); long s = System.currentTimeMillis(); test1_ = (Test1) oldObjectFromByteBuffer(cs, 0, cs.length); long e = System.currentTimeMillis(); System.out.println("java de times:" + (e - s)); // 测试用例结束 } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Test public void testBBossSerializableException() throws Exception { Test1 test1 = new Test1(); Test2 test2 = new Test2(); Test3 test3 = new Test3(); test2.setTest1(test1); test1.setTest2(test2); test1.setTest3(test3); test3.setTest2(test2); Exception e = new Exception("asdfasdf"); test3.setE(e); String ss = ObjectSerializable.toXML(test1); long starttime = System.currentTimeMillis(); ss = ObjectSerializable.toXML(test1); long endtime = System.currentTimeMillis(); System.out.println("bboss:" + ss.getBytes().length + "\r\n" + ss); System.out.println("bboss time:" + (endtime - starttime)); Test1 test1_ = (Test1) ObjectSerializable.toBean(ss, Test1.class); String xmlXstream = xStream.toXML(test1); // starttime = System.currentTimeMillis(); // xmlXstream = xStream.toXML(test1); // endtime = System.currentTimeMillis(); //// System.out.println(xmlXstream); // test1 = (Test1) xStream.fromXML(xmlXstream); // System.out.println("xStream time:"+(endtime -starttime)); }
@Test public void testBBossSerializable() throws Exception { Test1 test1 = new Test1(); Test2 test2 = new Test2(); Test3 test3 = new Test3(); test2.setTest1(test1); test1.setTest2(test2); test1.setTest3(test3); test3.setTest2(test2); String ss = ObjectSerializable.toXML(test1); System.out.println("bboss:" + ss.getBytes().length + "\r\n" + ss); Test1 test1_ = (Test1) ObjectSerializable.toBean(ss, Test1.class); String xmlXstream = xStream.toXML(test1); System.out.println(xmlXstream); }
@Test public void testXSTreamSerializable() throws Exception { Test1 test1 = new Test1(); Test2 test2 = new Test2(); Test3 test3 = new Test3(); test2.setTest1(test1); test1.setTest2(test2); test1.setTest3(test3); test3.setTest2(test2); // byte[] cs = oldObjectToByteBuffer(test1) ; String ss = xStream.toXML(test1); System.out.println("xstream:" + ss.getBytes().length); Test1 test1_ = (Test1) xStream.fromXML(ss); System.out.println(); }
@Test public void testJAVASerializable() throws Exception { Test1 test1 = new Test1(); Test2 test2 = new Test2(); Test3 test3 = new Test3(); test2.setTest1(test1); test1.setTest2(test2); test1.setTest3(test3); test3.setTest2(test2); byte[] cs = oldObjectToByteBuffer(test1); System.out.println("java:" + cs.length); Test1 test1_ = (Test1) oldObjectFromByteBuffer(cs, 0, cs.length); System.out.println(); }
@Test public void testHessianSerializable() throws Exception { Test1 test1 = new Test1(); Test2 test2 = new Test2(); Test3 test3 = new Test3(); test2.setTest1(test1); test1.setTest2(test2); test1.setTest3(test3); test3.setTest2(test2); try { String bigcontent = FileUtil.getFileContent( new File( "F:\\workspace\\bbossgroups-3.5\\bboss-core\\test\\org\\frameworkset\\soa\\testxstream.xml"), "UTF-8"); // 预热bboss和xstream test1.setXmlvalue(bigcontent); long s = System.currentTimeMillis(); String xml = ObjectSerializable.toXML(test1); long e = System.currentTimeMillis(); System.out.println("bboss:" + xml.getBytes().length + ",times:" + (e - s)); s = System.currentTimeMillis(); Test1 test1_ = (Test1) ObjectSerializable.toBean(xml, Test1.class); e = System.currentTimeMillis(); System.out.println("bboss de times:" + (e - s)); s = System.currentTimeMillis(); ByteArrayOutputStream os = new ByteArrayOutputStream(); HessianOutput ho = new HessianOutput(os); ho.writeObject(test1); byte[] cs = os.toByteArray(); e = System.currentTimeMillis(); System.out.println("hessian:" + cs.length + ",times:" + (e - s)); s = System.currentTimeMillis(); ByteArrayInputStream is = new ByteArrayInputStream(cs); HessianInput hi = new HessianInput(is); test1_ = (Test1) hi.readObject(); e = System.currentTimeMillis(); System.out.println("hessian de times:" + (e - s)); // 测试用例结束 } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** @throws Exception */ @Test public void testJsonSerializable() throws Exception { Test1 test1 = new Test1(); Test2 test2 = new Test2(); Test3 test3 = new Test3(); test2.setTest1(test1); test1.setTest2(test2); test1.setTest3(test3); test3.setTest2(test2); ObjectMapper objectMapper = new ObjectMapper(); StringWriter wt = new StringWriter(); objectMapper.writeValue(wt, test1); String ss = wt.toString(); System.out.println("json:" + ss.getBytes().length); Test1 test1_ = objectMapper.readValue(new StringReader(ss), Test1.class); System.out.println(); }
@Test public void testXMLTest1() { Test1 test1 = new Test1(); Test2 test2 = new Test2(); Test3 test3 = new Test3(); test2.setTest1(test1); test1.setTest2(test2); test1.setTest3(test3); test3.setTest2(test2); try { String bigcontent = FileUtil.getFileContent( new File( "F:\\workspace\\bbossgroups-3.5\\bboss-core\\test\\org\\frameworkset\\soa\\testxstream.xml"), "UTF-8"); // 预热bboss和xstream test1.setXmlvalue(bigcontent); String xml = ObjectSerializable.toXML(test1); Test1 test1_ = (Test1) ObjectSerializable.toBean(xml, Test1.class); String xmlXstream = xStream.toXML(test1); Test1 p = (Test1) xStream.fromXML(xmlXstream); System.out.println(xmlXstream); System.out.println(); System.out.println("bboss序列化测试用例开始"); System.out.println(); long start = System.currentTimeMillis(); ObjectSerializable.toXML(test1); long end = System.currentTimeMillis(); System.out.println("执行bboss beantoxml 1次,耗时:" + (end - start) + "毫秒"); convertBeanToXml(10, test1); convertBeanToXml(100, test1); convertBeanToXml(1000, test1); convertBeanToXml(10000, test1); System.out.println(); System.out.println("xstream序列化测试用例开始"); System.out.println(); start = System.currentTimeMillis(); xStream.toXML(test1); end = System.currentTimeMillis(); System.out.println("执行XStream beantoxml 1次,耗时:" + (end - start) + "毫秒"); convertBeanToXStreamXml(10, test1); convertBeanToXStreamXml(100, test1); convertBeanToXStreamXml(1000, test1); convertBeanToXStreamXml(10000, test1); System.out.println(); System.out.println("bboss反序列化测试用例开始"); System.out.println(); start = System.currentTimeMillis(); test1 = ObjectSerializable.toBean(xml, Test1.class); end = System.currentTimeMillis(); System.out.println("执行bboss xmltobean 1次,耗时:" + (end - start) + "豪秒"); convertXMLToBean(10, xml); convertXMLToBean(100, xml); convertXMLToBean(1000, xml); convertXMLToBean(10000, xml); System.out.println(); System.out.println("xstream反序列化测试用例开始"); System.out.println(); start = System.currentTimeMillis(); xStream.fromXML(xmlXstream); end = System.currentTimeMillis(); System.out.println("执行XStream xmltobean 1次,耗时:" + (end - start) + "豪秒"); convertXStreamXMLToBean(10, xmlXstream); convertXStreamXMLToBean(100, xmlXstream); convertXStreamXMLToBean(1000, xmlXstream); convertXStreamXMLToBean(10000, xmlXstream); // 测试用例结束 } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Test public void testTest1() { Test1 test1 = new Test1(); Test2 test2 = new Test2(); Test3 test3 = new Test3(); test2.setTest1(test1); test1.setTest2(test2); test1.setTest3(test3); test3.setTest2(test2); try { // 预热bboss和xstream String xml = ObjectSerializable.toXML(test1); Test1 test1_ = (Test1) ObjectSerializable.toBean(xml, Test1.class); String xmlXstream = xStream.toXML(test1); Test1 p = (Test1) xStream.fromXML(xmlXstream); System.out.println(xmlXstream); System.out.println(); System.out.println("bboss序列化测试用例开始"); System.out.println(); long start = System.currentTimeMillis(); ObjectSerializable.toXML(test1); long end = System.currentTimeMillis(); System.out.println("执行bboss beantoxml 1次,耗时:" + (end - start) + "毫秒"); convertBeanToXml(10, test1); convertBeanToXml(100, test1); convertBeanToXml(1000, test1); convertBeanToXml(10000, test1); System.out.println(); System.out.println("xstream序列化测试用例开始"); System.out.println(); start = System.currentTimeMillis(); xStream.toXML(test1); end = System.currentTimeMillis(); System.out.println("执行XStream beantoxml 1次,耗时:" + (end - start) + "毫秒"); convertBeanToXStreamXml(10, test1); convertBeanToXStreamXml(100, test1); convertBeanToXStreamXml(1000, test1); convertBeanToXStreamXml(10000, test1); System.out.println(); System.out.println("bboss反序列化测试用例开始"); System.out.println(); start = System.currentTimeMillis(); test1 = ObjectSerializable.toBean(xml, Test1.class); end = System.currentTimeMillis(); System.out.println("执行bboss xmltobean 1次,耗时:" + (end - start) + "豪秒"); convertXMLToBean(10, xml); convertXMLToBean(100, xml); convertXMLToBean(1000, xml); convertXMLToBean(10000, xml); System.out.println(); System.out.println("xstream反序列化测试用例开始"); System.out.println(); start = System.currentTimeMillis(); xStream.fromXML(xmlXstream); end = System.currentTimeMillis(); System.out.println("执行XStream xmltobean 1次,耗时:" + (end - start) + "豪秒"); convertXStreamXMLToBean(10, xmlXstream); convertXStreamXMLToBean(100, xmlXstream); convertXStreamXMLToBean(1000, xmlXstream); convertXStreamXMLToBean(10000, xmlXstream); // 测试用例结束 } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }