/** Tests the constructor and writeBytes(..) methods of {@link AfterOperationEvent}. */ @Test public void testSerializeDeserializeBinaryEquals() { final AfterOperationEvent event1 = new AfterOperationEvent( TSTAMP, TRACE_ID, ORDER_INDEX, FQ_OPERATION_SIGNATURE, FQ_CLASSNAME); Assert.assertEquals("Unexpected timestamp", TSTAMP, event1.getTimestamp()); Assert.assertEquals("Unexpected trace ID", TRACE_ID, event1.getTraceId()); Assert.assertEquals("Unexpected order index", ORDER_INDEX, event1.getOrderIndex()); Assert.assertEquals("Unexpected class name", FQ_CLASSNAME, event1.getClassSignature()); Assert.assertEquals( "Unexpected operation signature", FQ_OPERATION_SIGNATURE, event1.getOperationSignature()); final IRegistry<String> stringRegistry = new Registry<String>(); final ByteBuffer buffer = ByteBuffer.allocate(event1.getSize()); event1.writeBytes(buffer, stringRegistry); buffer.flip(); final AfterOperationEvent event2 = new AfterOperationEvent(buffer, stringRegistry); Assert.assertEquals(event1, event2); Assert.assertEquals(0, event1.compareTo(event2)); Assert.assertTrue(UtilityClass.refersToSameOperationAs(event1, event2)); }
/** * Tests the constructor and toArray(..) methods of {@link AfterOperationEvent}. * * <p>Assert that a record instance event1 equals an instance event2 created by serializing event1 * to an array event1Array and using event1Array to construct event2. This ignores a set * loggingTimestamp! */ @Test public void testSerializeDeserializeEquals() { final AfterOperationEvent event1 = new AfterOperationEvent( TSTAMP, TRACE_ID, ORDER_INDEX, FQ_OPERATION_SIGNATURE, FQ_CLASSNAME); Assert.assertEquals("Unexpected timestamp", TSTAMP, event1.getTimestamp()); Assert.assertEquals("Unexpected trace ID", TRACE_ID, event1.getTraceId()); Assert.assertEquals("Unexpected order index", ORDER_INDEX, event1.getOrderIndex()); Assert.assertEquals("Unexpected class name", FQ_CLASSNAME, event1.getClassSignature()); Assert.assertEquals( "Unexpected operation signature", FQ_OPERATION_SIGNATURE, event1.getOperationSignature()); final Object[] event1Array = event1.toArray(); final AfterOperationEvent event2 = new AfterOperationEvent(event1Array); Assert.assertEquals(event1, event2); Assert.assertEquals(0, event1.compareTo(event2)); Assert.assertTrue(UtilityClass.refersToSameOperationAs(event1, event2)); }