Search in sources :

Example 1 with StubQueue

use of org.springframework.jms.StubQueue 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) StubQueue(org.springframework.jms.StubQueue) Queue(jakarta.jms.Queue) QueueSession(jakarta.jms.QueueSession) Session(jakarta.jms.Session) TopicSession(jakarta.jms.TopicSession) Test(org.junit.jupiter.api.Test)

Example 2 with StubQueue

use of org.springframework.jms.StubQueue 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) StubQueue(org.springframework.jms.StubQueue) Queue(jakarta.jms.Queue) QueueSession(jakarta.jms.QueueSession) Session(jakarta.jms.Session) TopicSession(jakarta.jms.TopicSession) Test(org.junit.jupiter.api.Test)

Example 3 with StubQueue

use of org.springframework.jms.StubQueue in project spring-framework by spring-projects.

the class JmsTransactionManagerTests method testTransactionCommitWithMessageProducer.

@Test
public void testTransactionCommitWithMessageProducer() throws JMSException {
    Destination dest = new StubQueue();
    ConnectionFactory cf = mock(ConnectionFactory.class);
    Connection con = mock(Connection.class);
    Session session = mock(Session.class);
    MessageProducer producer = mock(MessageProducer.class);
    final Message message = mock(Message.class);
    given(cf.createConnection()).willReturn(con);
    given(con.createSession(true, Session.AUTO_ACKNOWLEDGE)).willReturn(session);
    given(session.createProducer(dest)).willReturn(producer);
    given(session.getTransacted()).willReturn(true);
    JmsTransactionManager tm = new JmsTransactionManager(cf);
    TransactionStatus ts = tm.getTransaction(new DefaultTransactionDefinition());
    JmsTemplate jt = new JmsTemplate(cf);
    jt.send(dest, sess -> message);
    tm.commit(ts);
    verify(producer).send(message);
    verify(session).commit();
    verify(producer).close();
    verify(session).close();
    verify(con).close();
}
Also used : Destination(jakarta.jms.Destination) ConnectionFactory(jakarta.jms.ConnectionFactory) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Message(jakarta.jms.Message) Connection(jakarta.jms.Connection) TransactionStatus(org.springframework.transaction.TransactionStatus) JmsTemplate(org.springframework.jms.core.JmsTemplate) StubQueue(org.springframework.jms.StubQueue) MessageProducer(jakarta.jms.MessageProducer) Session(jakarta.jms.Session) Test(org.junit.jupiter.api.Test)

Example 4 with StubQueue

use of org.springframework.jms.StubQueue in project spring-framework by spring-projects.

the class DefaultJmsActivationSpecFactoryTests method webSphereResourceAdapterSetup.

@Test
public void webSphereResourceAdapterSetup() throws Exception {
    Destination destination = new StubQueue();
    DestinationResolver destinationResolver = mock(DestinationResolver.class);
    given(destinationResolver.resolveDestinationName(null, "destinationname", false)).willReturn(destination);
    DefaultJmsActivationSpecFactory activationSpecFactory = new DefaultJmsActivationSpecFactory();
    activationSpecFactory.setDestinationResolver(destinationResolver);
    StubWebSphereActivationSpecImpl spec = (StubWebSphereActivationSpecImpl) activationSpecFactory.createActivationSpec(new StubWebSphereResourceAdapterImpl(), activationSpecConfig);
    assertThat(spec.getDestination()).isEqualTo(destination);
    assertThat(spec.getMaxConcurrency()).isEqualTo(5);
    assertThat(spec.getMaxBatchSize()).isEqualTo(3);
}
Also used : Destination(jakarta.jms.Destination) DestinationResolver(org.springframework.jms.support.destination.DestinationResolver) StubQueue(org.springframework.jms.StubQueue) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 StubQueue (org.springframework.jms.StubQueue)4 Session (jakarta.jms.Session)3 Destination (jakarta.jms.Destination)2 Queue (jakarta.jms.Queue)2 QueueSession (jakarta.jms.QueueSession)2 TopicSession (jakarta.jms.TopicSession)2 Connection (jakarta.jms.Connection)1 ConnectionFactory (jakarta.jms.ConnectionFactory)1 Message (jakarta.jms.Message)1 MessageProducer (jakarta.jms.MessageProducer)1 JmsTemplate (org.springframework.jms.core.JmsTemplate)1 DestinationResolver (org.springframework.jms.support.destination.DestinationResolver)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)1