Package com.bubble.serializer.objects

Examples of com.bubble.serializer.objects.Pojo


  }
 
  private Pojo[] initPojos() {
    Pojo[] pojos = new Pojo[POJOS];
    for (int i = 0; i < pojos.length; i++) {
      pojos[i] = new Pojo(i);
    }
    return pojos;
  }
View Full Code Here


  }


 
  public void testBubbleSpeedSingle()  {
    Pojo pojo = new Pojo(TEST_VALUE);
    SerializationContext context = new SerializationContext();
    ByteBuffer buffer = ByteBuffer.allocate(1024);
    long startTime = System.currentTimeMillis();
    context.serialize(pojo, buffer);
    long endTime = System.currentTimeMillis();
View Full Code Here

 
  private static final int TEST_VALUE = 7;
  private static final int POJOS = 2048;
  private static final int PASSES = 100;
  public void testJavaSpeedSingle() throws IOException {
    Pojo pojo = new Pojo(TEST_VALUE);
    long startTime = System.currentTimeMillis();
    oos.writeObject(pojo);
    long endTime = System.currentTimeMillis();
    long delay = endTime-startTime;
    System.out.println("Java time: "+delay+"ms");
View Full Code Here

  }
 
  private Pojo[] initPojos() {
    Pojo[] pojos = new Pojo[POJOS];
    for (int i = 0; i < pojos.length; i++) {
      pojos[i] = new Pojo(i);
    }
    return pojos;
  }
View Full Code Here

  }


 
  public void testBubbleSpeedSingle()  {
    Pojo pojo = new Pojo(TEST_VALUE);
    SerializationContext context = new SerializationContext();
    ByteBuffer buffer = ByteBuffer.allocate(1024);
    long startTime = System.currentTimeMillis();
    context.serialize(pojo, buffer);
    long endTime = System.currentTimeMillis();
View Full Code Here

  }
 
  public void testUpdate() {
    final int FIRST_VALUE = generateIntTestValue();
    final int SECOND_VALUE = generateIntTestValue();
    Pojo pojo1 = new Pojo(FIRST_VALUE);
    Pojo pojo2 = new Pojo(SECOND_VALUE);
   
    SerializationContext ctx = new SerializationContext();
    DeserializationContext dctx = new DeserializationContext();
    ByteBuffer buffer = ByteBuffer.allocate(4096);
   
    ctx.serialize(pojo1, buffer);
    ctx.serialize(pojo2, buffer);
    pojo1.setValue(SECOND_VALUE);
    pojo2.setValue(FIRST_VALUE);
    ctx.update(pojo2, buffer);   
    ctx.update(pojo1, buffer);
   
    buffer.flip();
   
    Object obj = dctx.deserialize(buffer);
    assertTrue("Object must be a Pojo", obj instanceof Pojo);
    Pojo resp1 = (Pojo)obj;
    obj = dctx.deserialize(buffer);
    assertTrue("Object must be a Pojo", obj instanceof Pojo);
    Pojo resp2 = (Pojo)obj;
    assertEquals(FIRST_VALUE, resp1.getValue());
    assertEquals(SECOND_VALUE, resp2.getValue());
    obj = dctx.deserialize(buffer);
    assertTrue("Object must be a Pojo", obj instanceof Pojo);
    Pojo resp3 = (Pojo)obj;
    obj = dctx.deserialize(buffer);
    assertTrue("Object must be a Pojo", obj instanceof Pojo);
    Pojo resp4 = (Pojo)obj;
   
    assertEquals(FIRST_VALUE, resp3.getValue());
    assertEquals(SECOND_VALUE, resp4.getValue());
    assertEquals(SECOND_VALUE, resp1.getValue());
    assertEquals(FIRST_VALUE, resp2.getValue());
   
    assertSame(resp1, resp4);
    assertSame(resp2, resp3);
View Full Code Here

 
  public void testObjectArray() {
    int len = (int)generateTestValue(10, 20);
    Pojo[] pojoArray = new Pojo[len];
    for (int i = 0; i < pojoArray.length; i++) {
      pojoArray[i] = new Pojo(generateIntTestValue());
    }
    SerializationContext ctx = new SerializationContext();
    DeserializationContext dctx = new DeserializationContext();
    ByteBuffer buffer = ByteBuffer.allocate(4096);
View Full Code Here

  public void testJavaVector() {
    //NOTE: Only works with Vector because it uses default serialization underneath.
    // Other java.* objects that resort to "writeObject" will not work
    // in the current version.
    Vector v = new Vector();
    Pojo pojo = new Pojo(generateIntTestValue());
    v.add(pojo);
    SerializationContext ctx = new SerializationContext();
    DeserializationContext dctx = new DeserializationContext();
    ByteBuffer buffer = ByteBuffer.allocate(1048576);

    ctx.serialize(v, buffer);
    buffer.flip();
    Object obj = dctx.deserialize(buffer);
    assertTrue("Object must be a Vector", obj instanceof Vector);
    Vector response = (Vector)obj;
    assertEquals(v.size(), response.size());
    assertTrue(response.get(0) instanceof Pojo);   
    Pojo respojo = (Pojo)response.get(0);
    assertEquals(pojo.getValue(), respojo.getValue());
  }
View Full Code Here

  }
 
  public void testUpdate() {
    final int FIRST_VALUE = generateIntTestValue();
    final int SECOND_VALUE = generateIntTestValue();
    Pojo pojo1 = new Pojo(FIRST_VALUE);
    Pojo pojo2 = new Pojo(SECOND_VALUE);
   
    SerializationContext ctx = new SerializationContext();
    DeserializationContext dctx = new DeserializationContext();
    ByteBuffer buffer = ByteBuffer.allocate(4096);
   
    ctx.serialize(pojo1, buffer);
    ctx.serialize(pojo2, buffer);
    pojo1.setValue(SECOND_VALUE);
    pojo2.setValue(FIRST_VALUE);
    ctx.update(pojo2, buffer);   
    ctx.update(pojo1, buffer);
   
    buffer.flip();
   
    Object obj = dctx.deserialize(buffer);
    assertTrue("Object must be a Pojo", obj instanceof Pojo);
    Pojo resp1 = (Pojo)obj;
    obj = dctx.deserialize(buffer);
    assertTrue("Object must be a Pojo", obj instanceof Pojo);
    Pojo resp2 = (Pojo)obj;
    assertEquals(FIRST_VALUE, resp1.getValue());
    assertEquals(SECOND_VALUE, resp2.getValue());
    obj = dctx.deserialize(buffer);
    assertTrue("Object must be a Pojo", obj instanceof Pojo);
    Pojo resp3 = (Pojo)obj;
    obj = dctx.deserialize(buffer);
    assertTrue("Object must be a Pojo", obj instanceof Pojo);
    Pojo resp4 = (Pojo)obj;
   
    assertEquals(FIRST_VALUE, resp3.getValue());
    assertEquals(SECOND_VALUE, resp4.getValue());
    assertEquals(SECOND_VALUE, resp1.getValue());
    assertEquals(FIRST_VALUE, resp2.getValue());
   
    assertSame(resp1, resp4);
    assertSame(resp2, resp3);
View Full Code Here

  /*
   * Test method for 'com.bubble.serialization.SerializationContext.serializeObject(Serializable, ByteBuffer)'
   */
  public void testSerialize() {
    Pojo pojo = new Pojo(4);
    ByteBuffer buffer = ByteBuffer.allocate(1024);
    SerializationContext sc = new SerializationContext();
    sc.serialize(pojo, buffer);
    buffer.flip();
    checkClassDef(buffer, Pojo.class);
View Full Code Here

TOP

Related Classes of com.bubble.serializer.objects.Pojo

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.