コード例 #1
0
  @Test(timeout = 30000)
  public void testSessionUnsubscribePassthrough() throws Exception {
    JmsConnectionFactory factory = new JmsConnectionFactory("failover:(mock://localhost)");

    Connection connection = factory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    session.unsubscribe("some-subscription");
    connection.close();

    assertEquals(1, mockPeer.getContextStats().getUnsubscribeCalls());
  }
コード例 #2
0
  @Test(timeout = 30000)
  public void testSessionLifeCyclePassthrough() throws Exception {
    JmsConnectionFactory factory = new JmsConnectionFactory("failover:(mock://localhost)");

    Connection connection = factory.createConnection();
    connection.start();
    connection.createSession(false, Session.AUTO_ACKNOWLEDGE).close();
    connection.close();

    assertEquals(1, mockPeer.getContextStats().getCreateResourceCalls(JmsSessionInfo.class));
    assertEquals(1, mockPeer.getContextStats().getDestroyResourceCalls(JmsSessionInfo.class));
  }
コード例 #3
0
  @Test(timeout = 30000)
  public void testFailureOnCloseIsSwallowed() throws Exception {
    JmsConnectionFactory factory =
        new JmsConnectionFactory("failover:(mock://localhost?mock.failOnClose=true)");

    Connection connection = factory.createConnection();
    connection.start();
    connection.close();

    assertEquals(1, mockPeer.getContextStats().getProvidersCreated());
    assertEquals(1, mockPeer.getContextStats().getConnectionAttempts());
    assertEquals(1, mockPeer.getContextStats().getCloseAttempts());
  }
コード例 #4
0
  @Test(timeout = 30000)
  public void testProducerLifeCyclePassthrough() throws Exception {
    JmsConnectionFactory factory = new JmsConnectionFactory("failover:(mock://localhost)");

    Connection connection = factory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Destination destination = session.createTopic(_testName.getMethodName());
    session.createProducer(destination).close();
    connection.close();

    assertEquals(1, mockPeer.getContextStats().getCreateResourceCalls(JmsProducerInfo.class));
    assertEquals(1, mockPeer.getContextStats().getDestroyResourceCalls(JmsProducerInfo.class));
  }
コード例 #5
0
  @Test(timeout = 30000)
  public void testSendMessagePassthrough() throws Exception {
    JmsConnectionFactory factory = new JmsConnectionFactory("failover:(mock://localhost)");

    Connection connection = factory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    Queue queue = session.createQueue(getTestName());
    MessageProducer producer = session.createProducer(queue);
    producer.send(session.createMessage());

    connection.close();

    assertEquals(1, mockPeer.getContextStats().getSendCalls());
  }
コード例 #6
0
  @Test(timeout = 30000)
  public void testMaxReconnectAttempts() throws Exception {
    JmsConnectionFactory factory =
        new JmsConnectionFactory(
            "failover:(mock://localhost?mock.failOnConnect=true)"
                + "?failover.maxReconnectAttempts=5"
                + "&failover.useReconnectBackOff=false");

    Connection connection = factory.createConnection();

    try {
      connection.start();
      fail("Should have stopped after five retries.");
    } catch (JMSException ex) {
    } finally {
      connection.close();
    }

    assertEquals(5, mockPeer.getContextStats().getProvidersCreated());
    assertEquals(5, mockPeer.getContextStats().getConnectionAttempts());
    assertEquals(5, mockPeer.getContextStats().getCloseAttempts());
  }