Search in sources :

Example 1 with Topic

use of jakarta.jms.Topic in project spring-framework by spring-projects.

the class DynamicDestinationResolverTests method resolveWithPubSubTopicSession.

@Test
public void resolveWithPubSubTopicSession() throws Exception {
    Topic expectedDestination = new StubTopic();
    TopicSession session = mock(TopicSession.class);
    given(session.createTopic(DESTINATION_NAME)).willReturn(expectedDestination);
    testResolveDestination(session, expectedDestination, true);
}
Also used : StubTopic(org.springframework.jms.StubTopic) TopicSession(jakarta.jms.TopicSession) Topic(jakarta.jms.Topic) StubTopic(org.springframework.jms.StubTopic) Test(org.junit.jupiter.api.Test)

Example 2 with Topic

use of jakarta.jms.Topic in project spring-framework by spring-projects.

the class MessagingMessageListenerAdapterTests method replyPayloadToTopic.

@Test
public void replyPayloadToTopic() throws JMSException {
    Session session = mock(Session.class);
    Topic replyDestination = mock(Topic.class);
    given(session.createTopic("topicOut")).willReturn(replyDestination);
    MessageProducer messageProducer = mock(MessageProducer.class);
    TextMessage responseMessage = mock(TextMessage.class);
    given(session.createTextMessage("Response")).willReturn(responseMessage);
    given(session.createProducer(replyDestination)).willReturn(messageProducer);
    MessagingMessageListenerAdapter listener = getPayloadInstance("Response", "replyPayloadToTopic", Message.class);
    listener.onMessage(mock(jakarta.jms.Message.class), session);
    verify(session).createTopic("topicOut");
    verify(session).createTextMessage("Response");
    verify(messageProducer).send(responseMessage);
    verify(messageProducer).close();
}
Also used : StubTextMessage(org.springframework.jms.StubTextMessage) Message(org.springframework.messaging.Message) TextMessage(jakarta.jms.TextMessage) MessageProducer(jakarta.jms.MessageProducer) Topic(jakarta.jms.Topic) StubTextMessage(org.springframework.jms.StubTextMessage) TextMessage(jakarta.jms.TextMessage) Session(jakarta.jms.Session) Test(org.junit.jupiter.api.Test)

Example 3 with Topic

use of jakarta.jms.Topic in project spring-framework by spring-projects.

the class DynamicDestinationResolverTests method resolveWithPubSubVanillaSession.

@Test
public void resolveWithPubSubVanillaSession() throws Exception {
    Topic expectedDestination = new StubTopic();
    Session session = mock(Session.class);
    given(session.createTopic(DESTINATION_NAME)).willReturn(expectedDestination);
    testResolveDestination(session, expectedDestination, true);
}
Also used : StubTopic(org.springframework.jms.StubTopic) Topic(jakarta.jms.Topic) StubTopic(org.springframework.jms.StubTopic) QueueSession(jakarta.jms.QueueSession) Session(jakarta.jms.Session) TopicSession(jakarta.jms.TopicSession) Test(org.junit.jupiter.api.Test)

Aggregations

Topic (jakarta.jms.Topic)3 Test (org.junit.jupiter.api.Test)3 Session (jakarta.jms.Session)2 TopicSession (jakarta.jms.TopicSession)2 StubTopic (org.springframework.jms.StubTopic)2 MessageProducer (jakarta.jms.MessageProducer)1 QueueSession (jakarta.jms.QueueSession)1 TextMessage (jakarta.jms.TextMessage)1 StubTextMessage (org.springframework.jms.StubTextMessage)1 Message (org.springframework.messaging.Message)1