KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > TopicSubscriptionTest


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.broker;
19
20 public class TopicSubscriptionTest extends QueueSubscriptionTest {
21
22     protected void setUp() throws Exception JavaDoc {
23         super.setUp();
24         durable = true;
25         topic = true;
26     }
27
28     public void testManyProducersManyConsumers() throws Exception JavaDoc {
29         consumerCount = 40;
30         producerCount = 20;
31         messageCount = 100;
32         messageSize = 1;
33         prefetchCount = 10;
34
35         doMultipleClientsTest();
36
37         assertTotalMessagesReceived(messageCount * producerCount * consumerCount);
38     }
39
40     public void testOneProducerTwoConsumersLargeMessagesOnePrefetch() throws Exception JavaDoc {
41         consumerCount = 2;
42         producerCount = 1;
43         messageCount = 10;
44         messageSize = 1024 * 1024 * 1; // 1 MB
45
prefetchCount = 1;
46
47         doMultipleClientsTest();
48
49         assertTotalMessagesReceived(messageCount * consumerCount * producerCount);
50     }
51
52     public void testOneProducerTwoConsumersSmallMessagesOnePrefetch() throws Exception JavaDoc {
53         consumerCount = 2;
54         producerCount = 1;
55         prefetchCount = 1;
56         messageSize = 1024;
57         messageCount = 1000;
58
59         doMultipleClientsTest();
60
61         assertTotalMessagesReceived(messageCount * consumerCount * producerCount);
62     }
63
64     public void testOneProducerTwoConsumersSmallMessagesLargePrefetch() throws Exception JavaDoc {
65         consumerCount = 2;
66         producerCount = 1;
67         messageCount = 1000;
68         messageSize = 1024;
69         prefetchCount = messageCount * 2;
70
71         doMultipleClientsTest();
72
73         assertTotalMessagesReceived(messageCount * consumerCount * producerCount);
74     }
75
76     public void testOneProducerTwoConsumersLargeMessagesLargePrefetch() throws Exception JavaDoc {
77         consumerCount = 2;
78         producerCount = 1;
79         messageCount = 10;
80         messageSize = 1024 * 1024 * 1; // 1 MB
81
prefetchCount = messageCount * 2;
82
83         doMultipleClientsTest();
84
85         assertTotalMessagesReceived(messageCount * consumerCount * producerCount);
86     }
87
88     public void testOneProducerManyConsumersFewMessages() throws Exception JavaDoc {
89         consumerCount = 50;
90         producerCount = 1;
91         messageCount = 10;
92         messageSize = 1; // 1 byte
93
prefetchCount = 10;
94
95         doMultipleClientsTest();
96
97         assertTotalMessagesReceived(messageCount * consumerCount * producerCount);
98     }
99
100     public void testOneProducerManyConsumersManyMessages() throws Exception JavaDoc {
101         consumerCount = 50;
102         producerCount = 1;
103         messageCount = 100;
104         messageSize = 1; // 1 byte
105
prefetchCount = 10;
106
107         doMultipleClientsTest();
108
109         assertTotalMessagesReceived(messageCount * consumerCount * producerCount);
110     }
111
112
113     public void testManyProducersOneConsumer() throws Exception JavaDoc {
114         consumerCount = 1;
115         producerCount = 20;
116         messageCount = 100;
117         messageSize = 1; // 1 byte
118
prefetchCount = 10;
119
120         doMultipleClientsTest();
121
122         assertTotalMessagesReceived(messageCount * producerCount * consumerCount);
123     }
124 }
125
Popular Tags