KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > policy > DestinationCursorConfigTest


1 /**
2  *
3  * Copyright 2005-2006 The Apache Software Foundation
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 package org.apache.activemq.broker.policy;
18
19 import org.apache.activemq.TestSupport;
20 import org.apache.activemq.broker.BrokerService;
21 import org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy;
22 import org.apache.activemq.broker.region.policy.PendingSubscriberMessageStoragePolicy;
23 import org.apache.activemq.broker.region.policy.PolicyEntry;
24 import org.apache.activemq.broker.region.policy.VMPendingQueueMessageStoragePolicy;
25 import org.apache.activemq.broker.region.policy.VMPendingSubscriberMessageStoragePolicy;
26 import org.apache.activemq.command.ActiveMQDestination;
27 import org.apache.activemq.xbean.BrokerFactoryBean;
28 import org.springframework.core.io.ClassPathResource;
29
30 /**
31  * @version $Revision: 2765 $
32  */

33 public class DestinationCursorConfigTest extends TestSupport {
34     protected BrokerService broker;
35
36     @Override JavaDoc
37     protected void setUp() throws Exception JavaDoc {
38         broker = createBroker();
39         super.setUp();
40     }
41
42     @Override JavaDoc
43     protected void tearDown() throws Exception JavaDoc {
44         broker.stop();
45         super.tearDown();
46     }
47
48     protected BrokerService createBroker() throws Exception JavaDoc {
49         BrokerFactoryBean factory = new BrokerFactoryBean(new ClassPathResource("org/apache/activemq/broker/policy/cursor.xml"));
50         factory.afterPropertiesSet();
51         BrokerService answer = factory.getBroker();
52         return answer;
53     }
54
55     public void testQueueConfiguration() throws Exception JavaDoc {
56         super.topic = false;
57         ActiveMQDestination destination = (ActiveMQDestination) createDestination("org.apache.foo");
58         PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(destination);
59         PendingQueueMessageStoragePolicy policy = entry.getPendingQueuePolicy();
60         assertNotNull(policy);
61         assertTrue("Policy is: " + policy, policy instanceof VMPendingQueueMessageStoragePolicy);
62     }
63
64     public void testTopicConfiguration() throws Exception JavaDoc {
65         super.topic = true;
66         ActiveMQDestination destination = (ActiveMQDestination) createDestination("org.apache.foo");
67         PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(destination);
68         PendingSubscriberMessageStoragePolicy policy = entry.getPendingSubscriberPolicy();
69         assertNotNull(policy);
70         assertTrue("subscriberPolicy is: " + policy, policy instanceof VMPendingSubscriberMessageStoragePolicy);
71     }
72 }
73
Popular Tags