测试类:
public class TestClass extends TestCase
{
private static final String TEXT_MESSAGE_VALUE = "<test>Me</test>";
private static final String JMS_MESSAGE_ID = "This is the correlation id.";
private Serializable xmlSerializable;
@Test
public void testCreateMessage() throws Exception
{
Session mockSession = createMock(Session.class);
TextMessage mockTextMessage = createMock(TextMessage.class);
expect(mockSession.createTextMessage(TEXT_MESSAGE_VALUE)).andReturn(mockTextMessage);
mockTextMessage.setJMSCorrelationID(JMS_MESSAGE_ID);
replay(mockSession, mockTextMessage);
test.createMessage(mockSession);
}
}