Session session = mock(Session.class);
when(session.createObjectMessage()).thenReturn(new ActiveMQObjectMessage());
// Creates a test Map containing a serializable object
Map data = new HashMap();
data.put("orange", new Orange());
Message message = JmsMessageUtils.toMessage(data, session);
assertTrue(message instanceof ObjectMessage);
ObjectMessage objectMessage = (ObjectMessage) message;
Map values = (Map) objectMessage.getObject();
assertEquals(new Orange(), values.get("orange"));
}