Package com.bubble.serializer.objects

Examples of com.bubble.serializer.objects.Pojo


  /*
   * Test method for 'com.bubble.serializer.FieldResolver.getField(Class, String)'
   */
  public void testGetField() {
    Pojo pojo = new Pojo(4);
    Field f = FieldResolver.getField(Pojo.class, "value");
    int val = FieldResolver.getInt(f, pojo);
    assertEquals(4, val);
    FieldResolver.setInt(f, pojo, 7);
    assertEquals(7, pojo.getValue());
  }
View Full Code Here


    buffer.flip();
    DeserializationContext context = new DeserializationContext();
    Object object = context.deserialize(buffer);
    assertNotNull("Object was null", object);
    assertTrue("Object is not a 'Pojo'", object instanceof Pojo);
    Pojo pojo = (Pojo)object;
    assertEquals("Value doesn't match", TEST_VALUE, pojo.getValue());
  }
View Full Code Here

    DeserializationContext dc = new DeserializationContext();
    Object object = dc.deserialize(buffer);
    assertNotNull("Object was null", object);
    assertTrue("Object is not a 'ObjectPojo'", object instanceof ObjectPojo);
    ObjectPojo result = (ObjectPojo)object;
    Pojo pojo = result.getPojo();
    assertNotNull("Field was null", pojo);   
    assertEquals("Value doesn't match", TEST_VALUE, pojo.getValue());
   
  }
View Full Code Here

    DeserializationContext dc = new DeserializationContext();
    Object object = dc.deserialize(buffer);
    assertNotNull("Object was null", object);
    assertTrue("Object is not a 'PrivateObjectPojo'", object instanceof PrivateObjectPojo);
    PrivateObjectPojo result = (PrivateObjectPojo)object;
    Pojo pojo = result.getPojo();
    assertNotNull("Field was null", pojo);   
    assertEquals("Value doesn't match", TEST_VALUE, pojo.getValue());
   
  }
View Full Code Here

    buffer.putInt(OTHER_TEST_VALUE);
    initRefBlock(buffer, SerializationConstants.FIRST_OBJECT_ID);
    initRefBlock(buffer, SerializationConstants.FIRST_OBJECT_ID+1);
    buffer.flip();
    DeserializationContext dc = new DeserializationContext();   
    Pojo pojo1 = retrievePojo(dc, buffer, TEST_VALUE);
    Pojo pojo2 = retrievePojo(dc, buffer, OTHER_TEST_VALUE);
    Pojo pojo3 = retrievePojo(dc, buffer, TEST_VALUE);
    Pojo pojo4 = retrievePojo(dc, buffer, OTHER_TEST_VALUE);
    assertSame(pojo1, pojo3);
    assertSame(pojo2, pojo4);   
  }
View Full Code Here

    buffer.putInt(FIRST_VALUE);
    initUpdateBlock(buffer, SerializationConstants.FIRST_OBJECT_ID);
    buffer.putInt(SECOND_VALUE);
    buffer.flip();
    DeserializationContext dc = new DeserializationContext();   
    Pojo pojo1 = retrievePojo(dc, buffer, FIRST_VALUE);
    Pojo pojo2 = retrievePojo(dc, buffer, SECOND_VALUE);
    assertSame(pojo1, pojo2);   
  }
View Full Code Here

 
  private Pojo retrievePojo(DeserializationContext context, ByteBuffer buffer, int pojoValue) {
    Object object = context.deserialize(buffer);
    assertNotNull("Object was null", object);
    assertTrue("Object is not a 'Pojo'", object instanceof Pojo);
    Pojo pojo = (Pojo)object;
    assertEquals("Value doesn't match", pojoValue, pojo.getValue());
    return pojo;
  }
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

      };
    };
   
    AbstractSerializeTest test3 = new AbstractSerializeTest(2000, 10) {
      protected Object createTestObject() {
        return new ObjectPojo(new Pojo(19));
      };
    };
   
    AbstractSerializeTest test4 = new AbstractSerializeTest(2000, 10) {
      protected Object createTestObject() {
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

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.