/** Tests the constructor and writeBytes(..) methods of {@link CallConstructorEvent}. */ @Test public void testSerializeDeserializeBinaryEquals() { final CallConstructorEvent event1 = new CallConstructorEvent( TSTAMP, TRACE_ID, ORDER_INDEX, FQ_CALLER_OPERATION_SIGNATURE, FQ_CALLER_CLASSNAME, FQ_CALLEE_OPERATION_SIGNATURE, FQ_CALLEE_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 caller operation name", FQ_CALLER_OPERATION_SIGNATURE, event1.getCallerOperationSignature()); Assert.assertEquals( "Unexpected caller class name", FQ_CALLER_CLASSNAME, event1.getCallerClassSignature()); Assert.assertEquals( "Unexpected callee operation name", FQ_CALLEE_OPERATION_SIGNATURE, event1.getCalleeOperationSignature()); Assert.assertEquals( "Unexpected callee class name", FQ_CALLEE_CLASSNAME, event1.getCalleeClassSignature()); final IRegistry<String> stringRegistry = new Registry<String>(); final ByteBuffer buffer = ByteBuffer.allocate(event1.getSize()); event1.writeBytes(buffer, stringRegistry); buffer.flip(); final CallConstructorEvent event2 = new CallConstructorEvent(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 CallConstructorEvent}. * * <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 CallConstructorEvent event1 = new CallConstructorEvent( TSTAMP, TRACE_ID, ORDER_INDEX, FQ_CALLER_OPERATION_SIGNATURE, FQ_CALLER_CLASSNAME, FQ_CALLEE_OPERATION_SIGNATURE, FQ_CALLEE_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 caller operation name", FQ_CALLER_OPERATION_SIGNATURE, event1.getCallerOperationSignature()); Assert.assertEquals( "Unexpected caller class name", FQ_CALLER_CLASSNAME, event1.getCallerClassSignature()); Assert.assertEquals( "Unexpected callee operation name", FQ_CALLEE_OPERATION_SIGNATURE, event1.getCalleeOperationSignature()); Assert.assertEquals( "Unexpected callee class name", FQ_CALLEE_CLASSNAME, event1.getCalleeClassSignature()); final Object[] event1Array = event1.toArray(); final CallConstructorEvent event2 = new CallConstructorEvent(event1Array); Assert.assertEquals(event1, event2); Assert.assertEquals(0, event1.compareTo(event2)); Assert.assertTrue(UtilityClass.refersToSameOperationAs(event1, event2)); }