System.out.println("unshared ..");
testOnHeapCoder0(false);
}
public void testOnHeapCoder0(boolean shared) throws Exception {
OnHeapCoder coder =new OnHeapCoder(shared,
CarBench.Car.class, CarBench.Engine.class, CarBench.Model.class,
CarBench.Accel.class, CarBench.PerformanceFigures.class,
CarBench.FueldData.class, CarBench.OptionalExtras.class);
byte arr[] = new byte[1000000];
int len = coder.toByteArray(original, arr, 0, (int) arr.length);
Object deser = coder.toObject(arr, 0, (int) arr.length);
assertTrue(DeepEquals.deepEquals(deser,original));
onhbench(original, coder, arr, 0);
onhbench(original, coder, arr, 0);
onhbench(original, coder, arr, 0);
onhbench(original, coder, arr, 0);
deser = onhbench(original, coder, arr, 0);
assertTrue(DeepEquals.deepEquals(original, deser));
System.out.println("-----");
deser = onhbench(smallClazz, coder, arr, 0);
deser = onhbench(smallClazz, coder, arr, 0);
deser = onhbench(smallClazz, coder, arr, 0);
deser = onhbench(smallClazz, coder, arr, 0);
deser = onhbench(smallClazz, coder, arr, 0);
assertTrue(DeepEquals.deepEquals(smallClazz, deser));
boolean lenEx = false;
try {
coder.toByteArray(original, arr, 0, 10);
} catch (Exception e) {
lenEx = true;
}
Assert.assertTrue(lenEx);