assertNull("Credentials must not be created for endpoints without a password.", credentials);
}
public void testEventSerialization() throws Exception
{
Transformer trans1 = new TestEventTransformer();
trans1.setName("OptimusPrime");
Transformer trans2 = new TestEventTransformer();
trans2.setName("Bumblebee");
List<Transformer> transformers = new ArrayList<Transformer>();
transformers.add(trans1);
transformers.add(trans2);
InboundEndpoint endpoint = getTestInboundEndpoint("Test", null, transformers,
new PayloadTypeFilter(Object.class), null);
MuleEvent event = RequestContext.setEvent(getTestEvent("payload", endpoint));
Serializable serialized = (Serializable) new SerializableToByteArray().transform(event);
assertNotNull(serialized);
ByteArrayToObject trans = new ByteArrayToObject();
trans.setMuleContext(muleContext);
MuleEvent deserialized = (MuleEvent) trans.transform(serialized);
// Assert that deserialized event is not null and has muleContext
assertNotNull(deserialized);
assertNotNull(deserialized.getMuleContext());
// Assert that deserialized event has session with same id
assertNotNull(deserialized.getSession());
assertEquals(event.getSession().getId(), deserialized.getSession().getId());
// Assert that deserialized event has service and that the service is the same instance
assertNotNull(deserialized.getSession().getFlowConstruct());
assertEquals(event.getSession().getFlowConstruct(), deserialized.getSession().getFlowConstruct());
assertSame(event.getSession().getFlowConstruct(), deserialized.getSession().getFlowConstruct());
// Assert that deserialized event has endpoint and that the endpoint is the same instance
assertNotNull(deserialized.getEndpoint());
assertEquals(endpoint, deserialized.getEndpoint());
List deserializedTransformers = deserialized.getEndpoint().getTransformers();
assertEquals(2, deserializedTransformers.size());
assertEquals(trans1.getName(), ((Transformer) deserializedTransformers.get(0)).getName());
assertEquals(trans2.getName(), ((Transformer) deserializedTransformers.get(1)).getName());
assertEquals(PayloadTypeFilter.class, deserialized.getEndpoint().getFilter().getClass());
}