Search in sources :

Example 81 with Session

use of javax.jms.Session in project spring-framework by spring-projects.

the class MethodJmsListenerEndpointTests method resolveConvertedPayload.

@Test
public void resolveConvertedPayload() throws JMSException {
    MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class);
    Session session = mock(Session.class);
    listener.onMessage(createSimpleJmsTextMessage("33"), session);
    assertDefaultListenerMethodInvocation();
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) Session(javax.jms.Session) Test(org.junit.Test)

Example 82 with Session

use of javax.jms.Session in project spring-framework by spring-projects.

the class MethodJmsListenerEndpointTests method resolveMessageAndSession.

@Test
public void resolveMessageAndSession() throws JMSException {
    MessagingMessageListenerAdapter listener = createDefaultInstance(javax.jms.Message.class, Session.class);
    Session session = mock(Session.class);
    listener.onMessage(createSimpleJmsTextMessage("test"), session);
    assertDefaultListenerMethodInvocation();
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) Session(javax.jms.Session) Test(org.junit.Test)

Example 83 with Session

use of javax.jms.Session in project spring-framework by spring-projects.

the class DynamicDestinationResolverTests method resolveWithPointToPointQueueSession.

@Test
public void resolveWithPointToPointQueueSession() throws Exception {
    Queue expectedDestination = new StubQueue();
    Session session = mock(QueueSession.class);
    given(session.createQueue(DESTINATION_NAME)).willReturn(expectedDestination);
    testResolveDestination(session, expectedDestination, false);
}
Also used : StubQueue(org.springframework.jms.StubQueue) Queue(javax.jms.Queue) StubQueue(org.springframework.jms.StubQueue) Session(javax.jms.Session) QueueSession(javax.jms.QueueSession) TopicSession(javax.jms.TopicSession) Test(org.junit.Test)

Example 84 with Session

use of javax.jms.Session in project spring-framework by spring-projects.

the class DynamicDestinationResolverTests method resolveWithPointToPointVanillaSession.

@Test
public void resolveWithPointToPointVanillaSession() throws Exception {
    Queue expectedDestination = new StubQueue();
    Session session = mock(Session.class);
    given(session.createQueue(DESTINATION_NAME)).willReturn(expectedDestination);
    testResolveDestination(session, expectedDestination, false);
}
Also used : StubQueue(org.springframework.jms.StubQueue) Queue(javax.jms.Queue) StubQueue(org.springframework.jms.StubQueue) Session(javax.jms.Session) QueueSession(javax.jms.QueueSession) TopicSession(javax.jms.TopicSession) Test(org.junit.Test)

Example 85 with Session

use of javax.jms.Session in project spring-framework by spring-projects.

the class JndiDestinationResolverTests method testDoesNotUseCacheIfCachingIsTurnedOff.

@Test
public void testDoesNotUseCacheIfCachingIsTurnedOff() throws Exception {
    Session session = mock(Session.class);
    CountingCannedJndiDestinationResolver resolver = new CountingCannedJndiDestinationResolver();
    resolver.setCache(false);
    Destination destination = resolver.resolveDestinationName(session, DESTINATION_NAME, true);
    assertNotNull(destination);
    assertSame(DESTINATION, destination);
    assertEquals(1, resolver.getCallCount());
    destination = resolver.resolveDestinationName(session, DESTINATION_NAME, true);
    assertNotNull(destination);
    assertSame(DESTINATION, destination);
    assertEquals(2, resolver.getCallCount());
}
Also used : Destination(javax.jms.Destination) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

Session (javax.jms.Session)281 MessageProducer (javax.jms.MessageProducer)131 Connection (javax.jms.Connection)120 Test (org.junit.Test)110 Message (javax.jms.Message)86 TextMessage (javax.jms.TextMessage)84 JMSException (javax.jms.JMSException)80 MessageConsumer (javax.jms.MessageConsumer)64 Destination (javax.jms.Destination)46 Topic (javax.jms.Topic)40 ConnectionFactory (javax.jms.ConnectionFactory)37 ObjectMessage (javax.jms.ObjectMessage)28 Queue (javax.jms.Queue)26 StubTextMessage (org.springframework.jms.StubTextMessage)20 QueueSession (javax.jms.QueueSession)16 MessagingMessageListenerAdapter (org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter)16 MessageCreator (org.springframework.jms.core.MessageCreator)15 BytesMessage (javax.jms.BytesMessage)14 MapMessage (javax.jms.MapMessage)12 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)12