Package org.apache.niolex.commons.test.Benchmark

Examples of org.apache.niolex.commons.test.Benchmark.Bean


    public A() {
      map.put(1, "Good");
      smap.put("test", "but");
      smap.put("this.[is].good", "See You!");
      bmap.put("b", new Bean(3, "Bean", 12212, new Date()));
      bmap.put("c", Benchmark.makeBenchmark());
      bmap.put("invoke", new B());
      bmap.put("os", new OSInfo());
      imap.put(new Date(), new Bean(3, "Bean", 12212, new Date()));
      set.add("Goog Morning");
      set.add("This is Good");
      set.add("中文");
    }
View Full Code Here


   * @throws JsonGenerationException
   */
  @Test
  public void testReadObject() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Bean t = new Bean(3, "Qute", 12212, new Date(1338008328709L));
    Bean q = new Bean(5, "Another", 523212, new Date(1338008328334L));
    writeObj(out, t);
    writeObj(out, q);
    out.close();
    System.out.println("s => " + StringUtil.utf8ByteToStr(out.toByteArray()));
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    SmileProxy proxy = new SmileProxy(in);
    Bean r = proxy.readObject(Bean.class);
    Bean s = proxy.readObject(new TypeReference<Bean>(){});
    assertEquals(t, r);
    assertEquals(q, s);
    System.out.println("q => " + r.getLikely() + ", " + s.getLikely());
  }
View Full Code Here

   * @throws JsonGenerationException
   */
  @Test
  public void testReadObject() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Bean t = new Bean(3, "Qute", 12212, new Date(1338008328709L));
    Bean q = new Bean(5, "Another", 523212, new Date(1338008328334L));
    writeObj(out, t);
    writeObj(out, q);
    out.close();
    System.out.println("s => " + StringUtil.utf8ByteToStr(out.toByteArray()));
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    JsonProxy proxy = new JsonProxy(in);
    Bean r = proxy.readObject(Bean.class);
    Bean s = proxy.readObject(new TypeReference<Bean>(){});
    assertEquals(t, r);
    assertEquals(q, s);
    System.out.println("q => " + r.getLikely() + ", " + s.getLikely());
  }
View Full Code Here

   */
  @Test
  public void testReadObject() throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    KryoOutstream ooo = new KryoOutstream(bos);
    Bean q = new Bean(5, "Another", 523212, new Date(1338008328334L));
    Benchmark bench = Benchmark.makeBenchmark();
    ooo.writeObject(bench);
    ooo.writeObject(q);
    ooo.close();
    byte[] bs = bos.toByteArray();
    System.out.println("L " + bs.length);
    // ----------
    KryoInstream iii = new KryoInstream(new ByteArrayInputStream(bs));
    Benchmark cp = iii.readObject(Benchmark.class);
    Bean t = iii.readObject(Bean.class);
    System.out.println("I " + t.getId());
    assertEquals(t.getBirth(), q.getBirth());
    assertEquals(bench, cp);
    iii.close();
  }
View Full Code Here

  public void testWriteObject() {
    Kryo kryo = new Kryo();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    KryoOutstream ooo = new KryoOutstream(kryo, bos);
    One<Long> o = One.<Long>create(8743244964238596L);
    Bean p = new Bean(324, "One", 8967, new Date(8743244964238596L));
    Bean q = new Bean(5, "Another", 523212, new Date(1338008328334L));
    ooo.writeObject(o);
    ooo.writeObject(p);
    ooo.writeObject(q);
    ooo.close();
    byte[] bs = bos.toByteArray();
    System.out.println("L " + bs.length);
    // --------------------
    KryoInstream iii = new KryoInstream(kryo, new ByteArrayInputStream(bs));
    @SuppressWarnings("unchecked")
        One<Long> r = (One<Long>)iii.readObject(One.class);
    Bean s = iii.readObject(Bean.class);
    Bean t = iii.readObject(Bean.class);
    iii.close();
    assertEquals(8743244964238596L, r.a.longValue());
    assertEquals(523212, t.getId());
    assertEquals(t.getBirth(), q.getBirth());
    assertEquals(p, s);
    assertEquals(q, t);
  }
View Full Code Here

        System.out.println(other);
    }

  @Test
  public void testBean() {
    Bean bean = new Bean();
    bean.setId(3);
    assertEquals("Not yet implemented", bean.getId(), 3);
    bean.setLikely(5);
    assertEquals("Not yet implemented", bean.getLikely(), 5);
    bean.setName("G");
    assertEquals("Not yet implemented", bean.getName(), "G");
    bean.setBirth(new Date(12345));
    assertEquals("Not yet implemented", bean.getBirth().getTime(), 12345);
  }
View Full Code Here

    assertEquals("Not yet implemented", bean.getBirth().getTime(), 12345);
  }

  @Test
    public void testBeanEqual() {
      Bean other = new Bean();
      Bean ben = Bean.makeBean();
      assertEquals("Not yet implemented", ben, ben);
      assertNotEquals("Not yet implemented", ben, "String");
      assertNotEquals("Not yet implemented", ben, other);
      other.setBirth(ben.getBirth());
      assertNotEquals("Not yet implemented", ben, other);
      other.setName(ben.getName());
      assertNotEquals("Not yet implemented", ben, other);
      other.setId(ben.getId());
      assertNotEquals("Not yet implemented", ben, other);
      other.setLikely(ben.getLikely());
      assertEquals("Not yet implemented", other, ben);
        System.out.println(other);
  }
View Full Code Here

      ooo.writeObject(q);
      ooo.close();
      byte[] bs = bos.toByteArray();
      KryoInstream iii = new KryoInstream(new ByteArrayInputStream(bs));
      Benchmark cp = iii.readObject(Benchmark.class);
      Bean t = iii.readObject(Bean.class);
      assertTrue(t.getId() != 0);
      assertTrue(t.getBirth().getTime() == 1338008328334L);
      assertTrue(bench.equals(cp));
    }
View Full Code Here

        SmileUtil.writeObj(bos, bench);
        SmileUtil.writeObj(bos, q);
        byte[] bs = bos.toByteArray();
        SmileProxy iii = new SmileProxy(new ByteArrayInputStream(bs));
        Benchmark cp = iii.readObject(Benchmark.class);
        Bean t = iii.readObject(Bean.class);
        assertTrue(t.getId() != 0);
        assertTrue(t.getBirth().getTime() == 1338008328334L);
        assertTrue(bench.equals(cp));
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
View Full Code Here

        JacksonUtil.writeObj(bos, bench);
        JacksonUtil.writeObj(bos, q);
        byte[] bs = bos.toByteArray();
        JsonProxy iii = new JsonProxy(new ByteArrayInputStream(bs));
        Benchmark cp = iii.readObject(Benchmark.class);
        Bean t = iii.readObject(Bean.class);
        assertTrue(t.getId() != 0);
        assertTrue(t.getBirth().getTime() == 1338008328334L);
        assertTrue(bench.equals(cp));
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.niolex.commons.test.Benchmark.Bean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.