/** * @throws Exception If failed. */ private void testCollection(Collection<Integer> col) throws Exception { col.add(1); col.add(2); col.add(3); assertEquals(col, marshalUnmarshal(col)); }
/** * @throws Exception If failed. */ @Test public void testTimestamp() throws Exception { Timestamp ts = new Timestamp(System.currentTimeMillis()); ts.setNanos(999999999); assertEquals(ts, marshalUnmarshal(ts)); }
/** * @throws Exception If failed. */ @Test public void testUuidArray() throws Exception { UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()}; assertArrayEquals(arr, marshalUnmarshal(arr)); }
/** * @throws Exception If failed. */ @Test public void testTimeArray() throws Exception { Time[] times = new Time[]{new Time(System.currentTimeMillis()), new Time(123456789)}; assertArrayEquals(times, marshalUnmarshal(times)); }
/** * @throws Exception If failed. */ @Test public void testException() throws Exception { Exception ex = new RuntimeException(); // Checks that Optimize marshaller will be used, because Throwable has writeObject method. // Exception's stacktrace equals to zero-length array by default and generates at Throwable's writeObject method. assertNotEquals(0, marshalUnmarshal(ex).getStackTrace().length); }
/** * @throws Exception If failed. */ @Test public void testChar() throws Exception { assertEquals((char)100, marshalUnmarshal((char)100).charValue()); }
/** * @throws Exception If failed. */ @Test public void testUuid() throws Exception { UUID uuid = UUID.randomUUID(); assertEquals(uuid, marshalUnmarshal(uuid)); }
/** * @throws Exception If failed. */ @Test public void testLong() throws Exception { assertEquals(100L, marshalUnmarshal(100L).longValue()); }
/** * @throws Exception If failed. */ @Test public void testFloat() throws Exception { assertEquals(100.001f, marshalUnmarshal(100.001f), 0); }
/** * @throws Exception If failed. */ @Test public void testFloatArray() throws Exception { float[] arr = new float[] {10.1f, 20.1f, 30.1f}; assertArrayEquals(arr, marshalUnmarshal(arr), 0); }
/** * @throws Exception If failed. */ @Test public void testBooleanArray() throws Exception { boolean[] arr = new boolean[] {true, false, true}; assertBooleanArrayEquals(arr, marshalUnmarshal(arr)); }
/** * @throws Exception If failed. */ @Test public void testIntArray() throws Exception { int[] arr = new int[] {10, 20, 30}; assertArrayEquals(arr, marshalUnmarshal(arr)); }
/** * @throws Exception If failed. */ @Test public void testLongArray() throws Exception { long[] arr = new long[] {10, 20, 30}; assertArrayEquals(arr, marshalUnmarshal(arr)); }
/** * @throws Exception If failed. */ @Test public void testObjectArray() throws Exception { Object[] arr = new Object[] {1, 2, 3}; assertArrayEquals(arr, marshalUnmarshal(arr)); }
/** * @throws Exception If failed. */ @Test public void testNull() throws Exception { assertNull(marshalUnmarshal(null)); }
/** * @throws Exception If failed. */ @Test public void testShortArray() throws Exception { short[] arr = new short[] {10, 20, 30}; assertArrayEquals(arr, marshalUnmarshal(arr)); }
/** * @throws Exception If failed. */ @Test public void testDecimalArray() throws Exception { BigDecimal[] arr = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN}; assertArrayEquals(arr, marshalUnmarshal(arr)); }
/** * @throws Exception If failed. */ @Test public void testEnum() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(TestEnum.class.getName()))); assertEquals(TestEnum.B, marshalUnmarshal(TestEnum.B, marsh)); }
/** * @throws Exception If failed. */ @Test public void testExternalizableInEnclosing() throws Exception { SimpleEnclosingObject obj = new SimpleEnclosingObject(); obj.simpl = new SimpleExternalizable("field"); SimpleEnclosingObject other = marshalUnmarshal(obj); assertEquals(((SimpleExternalizable)obj.simpl).field, ((SimpleExternalizable)other.simpl).field); }
/** * @throws IgniteCheckedException If failed. */ @Test public void testFinalField() throws IgniteCheckedException { BinaryMarshaller marsh = binaryMarshaller(); SimpleObjectWithFinal obj = new SimpleObjectWithFinal(); SimpleObjectWithFinal po0 = marshalUnmarshal(obj, marsh); assertEquals(obj.time, po0.time); }