private void checkBytes(byte[] expected, byte[] actual) { StringBuffer msg = new StringBuffer("Actual output: "); for (byte val : actual) { msg.append(val + ", "); } msg.append("\nExpected output: "); for (byte val : expected) { msg.append(val + ", "); } if (actual.length != expected.length) { System.out.println(msg.toString()); } assertTrue("Mismatch in length, actual.length: " + actual.length + " and expected length: " + expected.length, actual.length == expected.length); for(int i = 0; i<actual.length; i++) { if (actual[i] != expected[i]) { System.out.println(msg.toString()); } assertTrue("Mismatch at index " + i, actual[i] == expected[i]); } }
private void checkBytes(Byte[] expected, byte[] actual) { StringBuffer msg = new StringBuffer("Actual output: "); for (byte val : actual) { msg.append(val + ", "); } msg.append("\nExpected output: "); for (byte val : expected) { msg.append(val + ", "); } if (actual.length != expected.length) { System.out.println(msg.toString()); } assertTrue("Mismatch in length, actual.length: " + actual.length + " and expected length: " + expected.length, actual.length == expected.length); for(int i = 0; i<actual.length; i++) { if (actual[i] != expected[i]) { System.out.println(msg.toString()); } assertTrue("Mismatch at index " + i, actual[i] == expected[i]); } } private void checkBytes(byte[] expected, byte[] actual) {
msg.append(val + ", "); assertTrue("Mismatch in length, actual.length: " + actual.length + " and expected length: " + expected.length, actual.length == expected.length); for(int i = 0; i<actual.length; i++) { if (actual[i] != expected[i]) { System.out.println(msg.toString()); assertTrue("Mismatch at index " + i, actual[i] == expected[i]); SimpleClass actualVal = (SimpleClass)DataSerializer.readObject(in); assertTrue("Mismatch in write and read value: Value Write..." + object + " Value Read..." + actualVal, object.equals(actualVal));
public void testObjectArrayPdxInstance() throws IOException, ClassNotFoundException { DefaultQuery.setPdxReadSerialized(true); PdxReaderImpl.TESTHOOK_TRACKREADS = true; try { LongFieldHolder[] v = new LongFieldHolder[]{new LongFieldHolder(1), new LongFieldHolder(2)}; PdxInstance pi = (PdxInstance) serializeAndDeserialize(new ObjectArrayHolder(v)); ObjectArrayHolder oah = (ObjectArrayHolder) pi.getObject(); LongFieldHolder[] nv = (LongFieldHolder[])oah.getObjectArray(); if (!Arrays.equals(v, nv)) { fail("expected " + Arrays.toString(v) + " but had " + Arrays.toString(nv)); } Object[] oa = (Object[]) pi.getField("f1"); assertTrue(oa[0] instanceof PdxInstance); assertTrue(oa[1] instanceof PdxInstance); LongFieldHolder[] nv2 = new LongFieldHolder[2]; nv2[0] = (LongFieldHolder)((PdxInstance)oa[0]).getObject(); nv2[1] = (LongFieldHolder)((PdxInstance)oa[1]).getObject(); if (!Arrays.equals(v, nv2)) { fail("expected " + Arrays.toString(v) + " but had " + Arrays.toString(nv2)); } } finally { DefaultQuery.setPdxReadSerialized(false); PdxReaderImpl.TESTHOOK_TRACKREADS = false; } } public void testLongField() throws IOException, ClassNotFoundException {
msg.append(val + ", "); assertTrue("Mismatch in length, actual.length: " + actual.length + " and expected length: " + expected.length, actual.length == expected.length); for(int i = 0; i<actual.length; i++) { if (actual[i] != expected[i]) { System.out.println(msg.toString()); assertTrue("Mismatch at index " + i, actual[i] == expected[i]); DSInsidePdx actualVal = (DSInsidePdx)DataSerializer.readObject(in); assertTrue("Mismatch in write and read value: Value Write..." + pdx + " Value Read..." + actualVal, pdx.equals(actualVal)); System.out.println("\n");
System.out.println(msg.toString()); assertTrue("Mismatch in length, actual.length: " + actual.length + " and expected length: " + expected.length, actual.length == expected.length); System.out.println(msg.toString()); assertTrue("Mismatch at index " + i, actual[i] == expected[i]); NestedPdx actualVal = (NestedPdx)DataSerializer.readObject(in); assertTrue("Mismatch in write and read value: Value Write..." + pdx + " Value Read..." + actualVal, pdx.equals(actualVal)); System.out.println("\n");
PdxInsideDS actualVal = (PdxInsideDS)DataSerializer.readObject(in); assertTrue("Mismatch in write and read value: Value Write..." + ds + " Value Read..." + actualVal, ds.equals(actualVal));
System.out.println(msg.toString()); assertTrue("Mismatch in length, actual.length: " + actual.length + " and expected length: " + expected.length, actual.length == expected.length); for(int i = 0; i < actual.length; i++) { if (actual[i] != expected[i]) { System.out.println(msg.toString()); assertTrue("Mismatch at index " + i, actual[i] == expected[i]); SimpleClass1 actualVal = (SimpleClass1)DataSerializer.readObject(in); assertTrue("Mismatch in write and read value: Value Write..." + pdx + " Value Read..." + actualVal, pdx.equals(actualVal)); PdxInstance pi = (PdxInstance)DataSerializer.readObject(in); actualVal = (SimpleClass1)pi.getObject(); assertTrue("Mismatch in write and read value: Value Write..." + pdx + " Value Read..." + actualVal, pdx.equals(actualVal)); assertTrue(pi.hasField("myFlag")); assertTrue(pi.hasField("myShort")); assertTrue(pi.hasField("myString1")); assertTrue(pi.hasField("myLong")); assertTrue(pi.hasField("myString2")); assertTrue(pi.hasField("myString3")); assertTrue(pi.hasField("myInt")); assertTrue(pi.hasField("myFloat")); assertEquals(pdx.isMyFlag(), pi.getField("myFlag")); assertEquals(pdx.getMyShort(), pi.getField("myShort"));
System.out.println(msg.toString()); assertTrue("Mismatch in length, actual.length: " + actual.length + " and expected length: " + expected.length, actual.length == expected.length); for(int i = 0; i<actual.length; i++) { if (actual[i] != expected[i]) { System.out.println(msg.toString()); assertTrue("Mismatch at index " + i, actual[i] == expected[i]); assertTrue("Mismatch in write and read value: Value Write..." + pdx + " Value Read..." + actualVal, pdx.equals(actualVal)); c.setReadSerialized(true); PdxInstance pi = (PdxInstance)DataSerializer.readObject(in); actualVal = (SimpleClass1)pi.getObject(); assertTrue("Mismatch in write and read value: Value Write..." + pdx + " Value Read..." + actualVal, pdx.equals(actualVal)); assertTrue(pi.hasField("myFlag")); assertTrue(pi.hasField("myShort")); assertTrue(pi.hasField("myString1")); assertTrue(pi.hasField("myLong")); assertTrue(pi.hasField("myString2")); assertTrue(pi.hasField("myString3")); assertTrue(pi.hasField("myInt")); assertTrue(pi.hasField("myFloat")); assertEquals(pdx.isMyFlag(), pi.getField("myFlag")); assertEquals(pdx.getMyShort(), pi.getField("myShort"));
PdxType mergedType = tr.getType(mergedTypeId); assertFalse(mergedType.equals(v3Type)); assertTrue(mergedType.compatible(v3Type));