### Question:
AmqpJmsMessageFactory implements JmsMessageFactory { @Override public JmsObjectMessage createObjectMessage() throws JMSException { return createObjectMessage(null); } AmqpJmsMessageFactory(AmqpConnection connection); AmqpConnection getAmqpConnection(); @Override JmsMessage createMessage(); @Override JmsTextMessage createTextMessage(); @Override JmsTextMessage createTextMessage(String payload); @Override JmsBytesMessage createBytesMessage(); @Override JmsMapMessage createMapMessage(); @Override JmsStreamMessage createStreamMessage(); @Override JmsObjectMessage createObjectMessage(); @Override JmsObjectMessage createObjectMessage(Serializable payload);  }### Answer:
@Test public void testCreateObjectMessage() throws JMSException, ClassNotFoundException, IOException { AmqpJmsMessageFactory factory = new AmqpJmsMessageFactory(createMockAmqpConnection()); JmsObjectMessage message = factory.createObjectMessage(); JmsObjectMessageFacade facade = (JmsObjectMessageFacade) message.getFacade(); assertTrue(facade instanceof AmqpJmsObjectMessageFacade); AmqpJmsObjectMessageFacade amqpMessage = (AmqpJmsObjectMessageFacade) facade; assertEquals(JMS_OBJECT_MESSAGE, amqpMessage.getJmsMsgType()); assertFalse(amqpMessage.isAmqpTypedEncoding()); assertNull(amqpMessage.getObject()); }
@Test public void testCreateObjectMessageHonorsAmqpTypeConfig() throws JMSException, ClassNotFoundException, IOException { AmqpJmsMessageFactory factory = new AmqpJmsMessageFactory(createMockAmqpConnectionAmqpTypes()); JmsObjectMessage message = factory.createObjectMessage(); JmsObjectMessageFacade facade = (JmsObjectMessageFacade) message.getFacade(); assertTrue(facade instanceof AmqpJmsObjectMessageFacade); AmqpJmsObjectMessageFacade amqpMessage = (AmqpJmsObjectMessageFacade) facade; assertEquals(JMS_OBJECT_MESSAGE, amqpMessage.getJmsMsgType()); assertTrue(amqpMessage.isAmqpTypedEncoding()); assertNull(amqpMessage.getObject()); }
@Test public void testCreateObjectMessageSerializable() throws JMSException, ClassNotFoundException, IOException { AmqpJmsMessageFactory factory = new AmqpJmsMessageFactory(createMockAmqpConnection()); JmsObjectMessage message = factory.createObjectMessage(new ArrayList<Boolean>()); JmsObjectMessageFacade facade = (JmsObjectMessageFacade) message.getFacade(); assertTrue(facade instanceof AmqpJmsObjectMessageFacade); AmqpJmsObjectMessageFacade amqpMessage = (AmqpJmsObjectMessageFacade) facade; assertEquals(JMS_OBJECT_MESSAGE, amqpMessage.getJmsMsgType()); assertFalse(amqpMessage.isAmqpTypedEncoding()); assertNotNull(amqpMessage.getObject()); }
@Test public void testCreateObjectMessageWithBadTypeThrowsJMSException() throws JMSException { AmqpJmsMessageFactory factory = new AmqpJmsMessageFactory(createMockAmqpConnection()); try { factory.createObjectMessage(new NotSerializable()); fail("Should have thrown an exception"); } catch (JMSException e) { } }