Exemplo n.º 1
0
  @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();
    }
  }
Exemplo n.º 2
0
  @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));

  }
Exemplo n.º 3
0
  @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();
    }
  }
Exemplo n.º 4
0
  public static void main(String args[]) {
    Test t = new Test();
    t.printHello();

    Test2 t2 = new Test2();
    t2.dumpObject("Ich bin ein String");
    t2.dumpObject(new Integer("0815"));
    t2.dumpObject(new Float("1.234"));
  }
Exemplo n.º 5
0
 public static void test(B b) {
   b.test();
   Test2 t = null; // +1 Ce for this package
   t.test(); // +0 Ce for this package
   Hello h = null; // +1 Ce for this package
   h.test(); // +0 Ce for this package
   System.out.println("Hello" + "a"); // +3 Ce for this package
   // System, PrintWriter, String.toString
 }
Exemplo n.º 6
0
  public void testQuerier() throws ParseException, EvaluationException {
    PathAnalyzer<ComplexContent> pathAnalyzer =
        new PathAnalyzer<ComplexContent>(new TypesOperationProvider());
    Operation<ComplexContent> operation =
        pathAnalyzer.analyze(QueryParser.getInstance().parse("(myDouble == 5.5)"));

    Test2 test2 = new Test2(new Test(5), 5.5);

    test2.getList().add(new Test(2));
    test2.getList().add(new Test(3));
    test2.getList().add(new Test(4));
    test2.getList().add(new Test(5));

    ComplexContent complex = new BeanInstance<Test2>(test2);

    assertTrue((Boolean) operation.evaluate(complex));

    operation =
        pathAnalyzer.analyze(QueryParser.getInstance().parse("test/myInteger + 2 - myDouble"));
    // because the left operand is integer, the result will be treated as an integer!
    assertEquals(2, operation.evaluate(complex));

    // left most operand is double
    operation =
        pathAnalyzer.analyze(QueryParser.getInstance().parse("myDouble - test/myInteger + 2"));
    assertEquals(2.5, operation.evaluate(complex));

    // precedence
    operation =
        pathAnalyzer.analyze(QueryParser.getInstance().parse("myDouble - (test/myInteger + 2)"));
    assertEquals(-1.5, operation.evaluate(complex));

    operation =
        pathAnalyzer.analyze(QueryParser.getInstance().parse("list[myInteger > 3]/myInteger"));
    assertEquals(Arrays.asList(new Integer[] {4, 5}), operation.evaluate(complex));

    operation = pathAnalyzer.analyze(QueryParser.getInstance().parse("list/myInteger"));
    assertEquals(Arrays.asList(new Integer[] {2, 3, 4, 5}), operation.evaluate(complex));

    operation =
        pathAnalyzer.analyze(
            QueryParser.getInstance()
                .parse("test/myInteger + 2 = 7 && (myDouble + test/myInteger)==10.5"));
    assertTrue((Boolean) operation.evaluate(complex));

    // check if test is in the list
    operation = pathAnalyzer.analyze(QueryParser.getInstance().parse("test#list"));
    assertTrue((Boolean) operation.evaluate(complex));
  }
Exemplo n.º 7
0
  @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();
  }
Exemplo n.º 8
0
  @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();
  }
Exemplo n.º 9
0
 /**
  * For our purposes, two Node2's are equal if every test in one has an equivalent test in the
  * other, and if the test vectors are the same size. The subclass NodeNot2 should never be shared,
  * so we'll report unequal always. This routine is used during network compilation, not at
  * runtime.
  */
 boolean equals(Node2 n) {
   if (this instanceof NodeNot2 || n instanceof NodeNot2 || n._tests.size() != _tests.size())
     return false;
   outer_loop:
   for (int i = 0; i < _tests.size(); i++) {
     // Test1 nodes hold function call tests. They're too
     // complicated to try to share.
     if (_tests.elementAt(i) instanceof Test1) return false;
     Test2 t1 = (Test2) _tests.elementAt(i);
     for (int j = 0; j < _tests.size(); j++) {
       if (t1.equals(n._tests.elementAt(j))) continue outer_loop;
     }
     return false;
   }
   return true;
 }
Exemplo n.º 10
0
  @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);
  }
Exemplo n.º 11
0
  @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();
    }
  }
Exemplo n.º 12
0
 /** @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();
 }
Exemplo n.º 13
0
 public static void main(String[] args) {
   String wurd = "bats";
   StringBuilder sb = new StringBuilder(wurd);
   System.out.println(sb);
   System.out.println(sb.reverse());
   System.out.println(sb);
   System.out.println("");
   ArrayList<StringBuilder> sbldrl = new ArrayList<>();
   sbldrl.add(new StringBuilder("One"));
   sbldrl.add(new StringBuilder("Two"));
   sbldrl.add(new StringBuilder("Three"));
   int i = 0;
   for (StringBuilder sbldr : sbldrl) {
     if (i == 1) {
       sbldrl.remove(1);
     }
     i++;
   }
   System.out.println(sbldrl);
   System.out.println("");
   if (true ^ false) {
     System.out.println("yay!");
   }
   System.out.println("");
   int hi = 0;
   one:
   for (int a = 0; a < 3; a++) {
     two:
     for (int b = 0; b < 6; b++) {
       three:
       for (int c = 0; c < b; c++) {
         hi++;
         if (c % 3 == 0) {
           continue two;
         }
       }
     }
   }
   System.out.println(hi);
   System.out.println("");
   Test2 test2 = new Test2();
   test2.testing2();
   System.out.println("");
   Sup classy = new Sub();
   classy.test();
 }
Exemplo n.º 14
0
 public void start() {
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest1.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest2.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest3.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest4.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest5.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest6.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest7.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest8.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest9.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest10.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest11.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest12.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest13.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest14.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest15.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest16.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest17.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest18.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest19.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest20.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest21.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest22.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest23.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest24.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest25.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest26.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest27.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest28.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest29.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest30.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest31.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest32.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest33.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest34.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest35.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest36.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest37.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest38.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest39.test());
   Log.d(TestManager12.class.getSimpleName(), "start: " + mTest40.test());
 }
Exemplo n.º 15
0
  @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();
    }
  }
Exemplo n.º 16
0
 public static Result index() {
   return ok(Test2.render());
 }
Exemplo n.º 17
0
  @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();
    }
  }