public void XtestWildCardSubscriptionPreservedOnRestart() throws Exception {
  ActiveMQDestination dest1=new ActiveMQTopic("TEST.A");
  ActiveMQDestination dest2=new ActiveMQTopic("TEST.B");
  ActiveMQDestination dest3=new ActiveMQTopic("TEST.C");
  ActiveMQDestination wildDest=new ActiveMQTopic("TEST.>");
  ArrayList<MessageId> sentBeforeRestart=new ArrayList<>();
  ArrayList<MessageId> sentBeforeCreateConsumer=new ArrayList<>();
  ArrayList<MessageId> sentAfterCreateConsumer=new ArrayList<>();
{
    StubConnection connection1=createConnection();
    ConnectionInfo connectionInfo1=createConnectionInfo();
    connectionInfo1.setClientId("A");
    SessionInfo sessionInfo1=createSessionInfo(connectionInfo1);
    ProducerInfo producerInfo1=createProducerInfo(sessionInfo1);
    connection1.send(connectionInfo1);
    connection1.send(sessionInfo1);
    connection1.send(producerInfo1);
    ConsumerInfo consumerInfo1=createConsumerInfo(sessionInfo1,wildDest);
    consumerInfo1.setSubscriptionName("test");
    consumerInfo1.setPrefetchSize(100);
    connection1.send(consumerInfo1);
    connection1.send(closeConsumerInfo(consumerInfo1));
    for (int i=0; i < 4; i++) {
      Message m=createMessage(producerInfo1,dest1,DeliveryMode.PERSISTENT);
      connection1.send(m);
      sentBeforeRestart.add(m.getMessageId());
    }
    connection1.request(closeConnectionInfo(connectionInfo1));
    connection1.stop();
  }
  restartBroker();
{
    StubConnection connection2=createConnection();
    ConnectionInfo connectionInfo2=createConnectionInfo();
    connectionInfo2.setClientId("A");
    SessionInfo sessionInfo2=createSessionInfo(connectionInfo2);
    connection2.send(connectionInfo2);
    connection2.send(sessionInfo2);
    ProducerInfo producerInfo2=createProducerInfo(sessionInfo2);
    connection2.send(producerInfo2);
    for (int i=0; i < 4; i++) {
      Message m=createMessage(producerInfo2,dest2,DeliveryMode.PERSISTENT);
      connection2.send(m);
      sentBeforeCreateConsumer.add(m.getMessageId());
    }
    ConsumerInfo consumerInfo2=createConsumerInfo(sessionInfo2,wildDest);
    consumerInfo2.setSubscriptionName("test");
    consumerInfo2.setPrefetchSize(100);
    connection2.send(consumerInfo2);
    for (int i=0; i < 4; i++) {
      Message m=createMessage(producerInfo2,dest3,DeliveryMode.PERSISTENT);
      connection2.send(m);
      sentAfterCreateConsumer.add(m.getMessageId());
    }
    for (int i=0; i < 4; i++) {
      Message m2=receiveMessage(connection2);
      assertNotNull("Recovered message missing: " + i,m2);
      assertEquals(sentBeforeRestart.get(i),m2.getMessageId());
    }
    for (int i=0; i < 4; i++) {
      Message m2=receiveMessage(connection2);
      assertNotNull("Before activated message missing: " + i,m2);
      assertEquals(sentBeforeCreateConsumer.get(i),m2.getMessageId());
    }
    for (int i=0; i < 4; i++) {
      Message m2=receiveMessage(connection2);
      assertNotNull("After activated message missing: " + i,m2);
      assertEquals("" + i,sentAfterCreateConsumer.get(i),m2.getMessageId());
    }
    assertNoMessagesLeft(connection2);
  }
}

public void XtestWildCardSubscriptionPreservedOnRestart ( ) throws Exception { ActiveMQDestination dest1 = new ActiveMQTopic ( "TEST.A" ) ; ActiveMQDestination dest2 = new ActiveMQTopic ( "TEST.B" ) ; ActiveMQDestination dest3 = new ActiveMQTopic ( "TEST.C" ) ; ActiveMQDestination wildDest = new ActiveMQTopic ( "TEST.>" ) ; ArrayList < MessageId > sentBeforeRestart = new ArrayList < > ( ) ; ArrayList < MessageId > sentBeforeCreateConsumer = new ArrayList < > ( ) ; ArrayList < MessageId > sentAfterCreateConsumer = new ArrayList < > ( ) ; { StubConnection connection1 = createConnection ( ) ; ConnectionInfo connectionInfo1 = createConnectionInfo ( ) ; connectionInfo1 . setClientId ( "A" ) ; SessionInfo sessionInfo1 = createSessionInfo ( connectionInfo1 ) ; ProducerInfo producerInfo1 = createProducerInfo ( sessionInfo1 ) ; connection1 . send ( connectionInfo1 ) ; connection1 . send ( sessionInfo1 ) ; connection1 . send ( producerInfo1 ) ; ConsumerInfo consumerInfo1 = createConsumerInfo ( sessionInfo1 , wildDest ) ; consumerInfo1 . setSubscriptionName ( "test" ) ; consumerInfo1 . setPrefetchSize ( 100 ) ; connection1 . send ( consumerInfo1 ) ; connection1 . send ( closeConsumerInfo ( consumerInfo1 ) ) ; for ( int i = 0 ; i < 4 ; i ++ ) { Message m = createMessage ( producerInfo1 , dest1 , DeliveryMode . PERSISTENT ) ; connection1 . send ( m ) ; sentBeforeRestart . add ( m . getMessageId ( ) ) ; } connection1 . request ( closeConnectionInfo ( connectionInfo1 ) ) ; connection1 . stop ( ) ; } restartBroker ( ) ; { StubConnection connection2 = createConnection ( ) ; ConnectionInfo connectionInfo2 = createConnectionInfo ( ) ; connectionInfo2 . setClientId ( "A" ) ; SessionInfo sessionInfo2 = createSessionInfo ( connectionInfo2 ) ; connection2 . send ( connectionInfo2 ) ; connection2 . send ( sessionInfo2 ) ; ProducerInfo producerInfo2 = createProducerInfo ( sessionInfo2 ) ; connection2 . send ( producerInfo2 ) ; for ( int i = 0 ; i < 4 ; i ++ ) { Message m = createMessage ( producerInfo2 , dest2 , DeliveryMode . PERSISTENT ) ; connection2 . send ( m ) ; sentBeforeCreateConsumer . add ( m . getMessageId ( ) ) ; } ConsumerInfo consumerInfo2 = createConsumerInfo ( sessionInfo2 , wildDest ) ; consumerInfo2 . setSubscriptionName ( "test" ) ; consumerInfo2 . setPrefetchSize ( 100 ) ; connection2 . send ( consumerInfo2 ) ; for ( int i = 0 ; i < 4 ; i ++ ) { Message m = createMessage ( producerInfo2 , dest3 , DeliveryMode . PERSISTENT ) ; connection2 . send ( m ) ; sentAfterCreateConsumer . add ( m . getMessageId ( ) ) ; } for ( int i = 0 ; i < 4 ; i ++ ) { Message m2 = receiveMessage ( connection2 ) ; assertNotNull ( "Recovered message missing: " + i , m2 ) ; assertEquals ( sentBeforeRestart . get ( i ) , m2 . getMessageId ( ) ) ; } for ( int i = 0 ; i < 4 ; i ++ ) { Message m2 = receiveMessage ( connection2 ) ; assertNotNull ( "Before activated message missing: " + i , m2 ) ; assertEquals ( sentBeforeCreateConsumer . get ( i ) , m2 . getMessageId ( ) ) ; } for ( int i = 0 ; i < 4 ; i ++ ) { Message m2 = receiveMessage ( connection2 ) ; assertNotNull ( "After activated message missing: " + i , m2 ) ; assertEquals ( "" + i , sentAfterCreateConsumer . get ( i ) , m2 . getMessageId ( ) ) ; } assertNoMessagesLeft ( connection2 ) ; } }
used to verify that after a broker restart durable subscriptions that use wild cards are still wild card subscription after broker restart .
