Session session = mock(Session.class);
when(session.createObjectMessage()).thenReturn(new ActiveMQObjectMessage());
// Creates a test Map containing a non serializable object
Map data = new HashMap();
data.put("notserializable", new BananaFactory());
try
{
JmsMessageUtils.toMessage(data, session);
fail("Attempt to send a non-serializable object in a map should fail");