/**
*
* Copyright 2004 Protique Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/
package org.activemq.broker;
import javax.jms.JMSException;
import org.activemq.ActiveMQConnection;
import org.activemq.broker.impl.BrokerContainerImpl;
import org.activemq.message.ActiveMQQueue;
import org.activemq.service.MessageContainerAdmin;
import org.activemq.test.TestSupport;
/**
* @version $Revision: 1.1.1.1 $
*/
public class BrokerAdminTest extends TestSupport {
private static final String TEST_QUEUE_NAME = "TestQueue";
public static final String URL = ActiveMQConnection.DEFAULT_BROKER_URL;
protected BrokerContainer container;
protected void setUp() throws Exception {
container = new BrokerContainerImpl(URL);
container.start();
super.setUp();
}
protected void tearDown() throws Exception {
container.stop();
}
public void testInitialState() throws JMSException {
// The broker should start with zero destinations.
BrokerAdmin brokerAdmin = getBrokerAdmin();
MessageContainerAdmin[] admins = brokerAdmin.listMessageContainerAdmin();
assertEquals(0, admins.length);
}
public void testCreateQueue() throws JMSException {
// The broker should start with zero destinations.
BrokerAdmin brokerAdmin = getBrokerAdmin();
brokerAdmin.createMessageContainer(new ActiveMQQueue(TEST_QUEUE_NAME) );
MessageContainerAdmin[] admins = brokerAdmin.listMessageContainerAdmin();
assertEquals(1, admins.length);
assertEquals(admins[0].getDestinationName(), TEST_QUEUE_NAME);
}
public void testDeleteQueue() throws JMSException {
// The broker should start with zero destinations.
BrokerAdmin brokerAdmin = getBrokerAdmin();
brokerAdmin.createMessageContainer(new ActiveMQQueue(TEST_QUEUE_NAME) );
brokerAdmin.destoryMessageContainer(new ActiveMQQueue(TEST_QUEUE_NAME) );
MessageContainerAdmin[] admins = brokerAdmin.listMessageContainerAdmin();
assertEquals(0, admins.length);
}
/**
* @return
*
*/
private BrokerAdmin getBrokerAdmin() {
return container.getBroker().getBrokerAdmin();
}
}