Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/activemq/broker/BrokerAdminTest.java


1   /** 
2    * 
3    * Copyright 2004 Protique Ltd
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License"); 
6    * you may not use this file except in compliance with the License. 
7    * You may obtain a copy of the License at 
8    * 
9    * http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License. 
16   * 
17   **/
18  package org.activemq.broker;
19  
20  import javax.jms.JMSException;
21  
22  import org.activemq.ActiveMQConnection;
23  import org.activemq.broker.impl.BrokerContainerImpl;
24  import org.activemq.message.ActiveMQQueue;
25  import org.activemq.service.MessageContainerAdmin;
26  import org.activemq.test.TestSupport;
27  
28  /**
29   * @version $Revision: 1.1.1.1 $
30   */
31  public class BrokerAdminTest extends TestSupport {
32      
33      private static final String TEST_QUEUE_NAME = "TestQueue";
34      
35      public static final String URL = ActiveMQConnection.DEFAULT_BROKER_URL;
36      protected BrokerContainer container;
37  
38      protected void setUp() throws Exception {
39          container = new BrokerContainerImpl(URL);
40          container.start();
41          super.setUp();
42      }
43  
44      protected void tearDown() throws Exception {
45          container.stop();
46      }
47      
48      public void testInitialState() throws JMSException {
49          
50          // The broker should start with zero destinations.
51          BrokerAdmin brokerAdmin = getBrokerAdmin();
52          MessageContainerAdmin[] admins = brokerAdmin.listMessageContainerAdmin();
53          assertEquals(0, admins.length);
54          
55      }
56  
57      public void testCreateQueue() throws JMSException {
58          
59          // The broker should start with zero destinations.
60          BrokerAdmin brokerAdmin = getBrokerAdmin();
61          brokerAdmin.createMessageContainer(new ActiveMQQueue(TEST_QUEUE_NAME)  );
62          
63          MessageContainerAdmin[] admins = brokerAdmin.listMessageContainerAdmin();
64          assertEquals(1, admins.length);
65          
66          assertEquals(admins[0].getDestinationName(), TEST_QUEUE_NAME);        
67      }
68      
69      public void testDeleteQueue() throws JMSException {
70          
71          // The broker should start with zero destinations.
72          BrokerAdmin brokerAdmin = getBrokerAdmin();
73          brokerAdmin.createMessageContainer(new ActiveMQQueue(TEST_QUEUE_NAME)  );
74          brokerAdmin.destoryMessageContainer(new ActiveMQQueue(TEST_QUEUE_NAME)  );
75          
76          MessageContainerAdmin[] admins = brokerAdmin.listMessageContainerAdmin();
77          assertEquals(0, admins.length);
78      }
79      
80  
81      /**
82       * @return
83       * 
84       */
85      private BrokerAdmin getBrokerAdmin() {
86          return container.getBroker().getBrokerAdmin();
87      }
88  }