KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > notification > engine > FilterConsumerAdminTaskTest


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

21
22 package org.jacorb.test.notification.engine;
23
24 import java.util.Collections JavaDoc;
25
26 import junit.framework.Test;
27 import junit.framework.TestSuite;
28
29 import org.jacorb.notification.engine.AbstractFilterTask;
30 import org.jacorb.notification.engine.FilterConsumerAdminTask;
31 import org.jacorb.notification.interfaces.FilterStage;
32
33 /**
34  * @author Alphonse Bendt
35  * @version $Id: FilterConsumerAdminTaskTest.java,v 1.2 2005/04/27 10:50:49 alphonse.bendt Exp $
36  */

37 public class FilterConsumerAdminTaskTest extends AbstractFilterTaskTestCase
38 {
39     private FilterConsumerAdminTask objectUnderTest_;
40
41     /**
42      * Constructor for FilterConsumerAdminTaskTest.
43      *
44      * @param name
45      */

46     public FilterConsumerAdminTaskTest(String JavaDoc name)
47     {
48         super(name);
49     }
50
51     protected AbstractFilterTask newObjectUnderTest()
52     {
53         objectUnderTest_ = new FilterConsumerAdminTask(mockTaskFactory_, mockTaskExecutor_);
54         
55         return objectUnderTest_;
56     }
57
58     public void testNoConsumerAdminConnected() throws Exception JavaDoc
59     {
60         mockMessage_.isInvalid();
61         controlMessage_.setReturnValue(false);
62         mockMessage_.dispose();
63
64         controlMessage_.replay();
65
66         objectUnderTest_.setMessage(mockMessage_);
67
68         objectUnderTest_.run();
69
70         controlMessage_.verify();
71     }
72
73     public void testFilter() throws Exception JavaDoc
74     {
75         mockMessage_.isInvalid();
76         controlMessage_.setDefaultReturnValue(false);
77
78         mockMessage_.match(mockFilterStage_);
79         controlMessage_.setReturnValue(true);
80         
81         mockMessage_.dispose();
82
83         controlMessage_.replay();
84
85         objectUnderTest_.setMessage(mockMessage_);
86
87         mockFilterStage_.isDisposed();
88         controlFilterStage_.setReturnValue(false);
89         
90         mockFilterStage_.hasInterFilterGroupOperatorOR();
91         controlFilterStage_.setReturnValue(false);
92         
93         mockFilterStage_.getSubsequentFilterStages();
94         controlFilterStage_.setReturnValue(Collections.singletonList(mockNextFilterStage_));
95         
96         controlFilterStage_.replay();
97
98         mockTaskFactory_.newFilterProxySupplierTask(objectUnderTest_);
99         controlTaskFactory_.setReturnValue(mockSchedulable_);
100         
101         controlTaskFactory_.replay();
102         
103         mockSchedulable_.schedule();
104         controlSchedulable_.replay();
105         
106         objectUnderTest_.setCurrentFilterStage(new FilterStage[] { mockFilterStage_ });
107
108         objectUnderTest_.run();
109
110         controlFilterStage_.verify();
111         controlMessage_.verify();
112         controlTaskFactory_.verify();
113         controlSchedulable_.verify();
114     }
115
116     public static Test suite()
117     {
118         return new TestSuite(FilterConsumerAdminTaskTest.class);
119     }
120 }
Popular Tags