KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > notification > bugs > MultipleDeliveryBugTest


1 package org.jacorb.test.notification.bugs;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2003 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import junit.framework.Test;
24
25 import org.jacorb.test.notification.StructuredPushReceiver;
26 import org.jacorb.test.notification.StructuredPushSender;
27 import org.jacorb.test.notification.common.NotifyServerTestCase;
28 import org.jacorb.test.notification.common.NotifyServerTestSetup;
29 import org.omg.CORBA.Any JavaDoc;
30 import org.omg.CosNotification.EventHeader;
31 import org.omg.CosNotification.EventType;
32 import org.omg.CosNotification.FixedEventHeader;
33 import org.omg.CosNotification.Property;
34 import org.omg.CosNotification.StructuredEvent;
35 import org.omg.CosNotifyChannelAdmin.EventChannel;
36
37 /**
38  * Test to reveal bug reported by Matthew Leahy
39  * (news://news.gmane.org:119/3FBE2F7D.6090503@ll.mit.edu) Under high load Messages were delivered
40  * multiple times.
41  *
42  * @author Alphonse Bendt
43  */

44 public class MultipleDeliveryBugTest extends NotifyServerTestCase
45 {
46     private EventChannel objectUnderTest_;
47     
48     public MultipleDeliveryBugTest(String JavaDoc name, NotifyServerTestSetup setup)
49     {
50         super(name, setup);
51     }
52
53     public void setUpTest() throws Exception JavaDoc
54     {
55         objectUnderTest_ = getDefaultChannel();
56     }
57
58     public void testMultipleSendUnderHighLoad() throws Exception JavaDoc
59     {
60         int testSize = 200;
61
62         StructuredEvent[] events = new StructuredEvent[testSize];
63
64         FixedEventHeader fixedHeader = new FixedEventHeader();
65         fixedHeader.event_name = "TEST";
66         fixedHeader.event_type = new EventType("TESTING", "TESTING");
67         EventHeader header = new EventHeader(fixedHeader, new Property[0]);
68
69         StructuredPushReceiver _receiver = new StructuredPushReceiver(getClientORB(), testSize);
70         StructuredPushSender _sender = new StructuredPushSender(getClientORB());
71         
72         _receiver.setTimeOut(testSize * 100);
73
74         _sender.connect(objectUnderTest_, false);
75         _receiver.connect(objectUnderTest_, false);
76
77         _receiver.start();
78
79         for (int x = 0; x < events.length; ++x)
80         {
81             Any JavaDoc any = getClientORB().create_any();
82             any.insert_long(x);
83             events[x] = new StructuredEvent(header, new Property[0], any);
84         }
85         
86         _sender.pushEvents(events);
87
88         _receiver.join();
89
90         assertTrue(_receiver.isEventHandled());
91     }
92
93     public static Test suite() throws Exception JavaDoc
94     {
95         return NotifyServerTestCase.suite(MultipleDeliveryBugTest.class);
96     }
97 }
98
Popular Tags