KickJava   Java API By Example, From Geeks To Geeks.

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


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.Arrays JavaDoc;
25 import java.util.List JavaDoc;
26
27 import junit.framework.Test;
28 import junit.framework.TestSuite;
29
30 import org.jacorb.notification.engine.AbstractFilterTask;
31 import org.jacorb.notification.engine.FilterProxyConsumerTask;
32 import org.jacorb.notification.interfaces.FilterStage;
33
34 /**
35  * @author Alphonse Bendt
36  * @version $Id: FilterProxyConsumerTaskTest.java,v 1.2 2005/04/27 10:50:49 alphonse.bendt Exp $
37  */

38 public class FilterProxyConsumerTaskTest extends AbstractFilterTaskTestCase
39 {
40     private FilterProxyConsumerTask objectUnderTest_;
41
42     protected AbstractFilterTask newObjectUnderTest()
43     {
44         objectUnderTest_ = new FilterProxyConsumerTask(mockTaskFactory_, mockTaskExecutor_);
45         
46         return objectUnderTest_;
47     }
48
49     public void testMatch() throws Exception JavaDoc
50     {
51         List JavaDoc list = Arrays.asList(new Object JavaDoc[] { mockNextFilterStage_ });
52
53         mockFilterStage_.hasLifetimeFilter();
54         controlFilterStage_.setReturnValue(false);
55         mockFilterStage_.hasPriorityFilter();
56         controlFilterStage_.setReturnValue(false);
57         mockFilterStage_.hasInterFilterGroupOperatorOR();
58         controlFilterStage_.setDefaultReturnValue(false);
59         mockFilterStage_.getSubsequentFilterStages();
60         controlFilterStage_.setReturnValue(list);
61         
62         mockFilterStage_.hasPriorityFilter();
63         controlFilterStage_.setDefaultReturnValue(false);
64
65         mockFilterStage_.hasLifetimeFilter();
66         controlFilterStage_.setDefaultReturnValue(false);
67         
68         controlFilterStage_.replay();
69         
70         mockMessage_.isInvalid();
71         controlMessage_.setDefaultReturnValue(false);
72         
73         mockMessage_.match(mockFilterStage_);
74         controlMessage_.setReturnValue(true);
75
76         mockMessage_.dispose();
77
78         controlMessage_.replay();
79
80         mockTaskFactory_.newFilterSupplierAdminTask(objectUnderTest_);
81         controlTaskFactory_.setReturnValue(mockSchedulable_);
82
83         controlTaskFactory_.replay();
84
85         mockSchedulable_.schedule();
86
87         controlSchedulable_.replay();
88
89         objectUnderTest_.setMessage(mockMessage_);
90         objectUnderTest_.setCurrentFilterStage(new FilterStage[] { mockFilterStage_ });
91         
92         objectUnderTest_.run();
93
94         controlFilterStage_.verify();
95
96         controlMessage_.verify();
97
98         controlTaskFactory_.verify();
99
100         controlSchedulable_.verify();
101     }
102
103     public void testNoMatch() throws Exception JavaDoc
104     {
105         mockFilterStage_.hasLifetimeFilter();
106         controlFilterStage_.setReturnValue(false);
107         mockFilterStage_.hasPriorityFilter();
108         controlFilterStage_.setReturnValue(false);
109         mockFilterStage_.hasInterFilterGroupOperatorOR();
110         controlFilterStage_.setDefaultReturnValue(false);
111         controlFilterStage_.replay();
112
113         mockMessage_.isInvalid();
114         controlMessage_.setDefaultReturnValue(false);
115         
116         mockMessage_.match(mockFilterStage_);
117         controlMessage_.setReturnValue(false);
118
119         mockMessage_.dispose();
120
121         controlMessage_.replay();
122
123         objectUnderTest_.setMessage(mockMessage_);
124         objectUnderTest_.setCurrentFilterStage(new FilterStage[] { mockFilterStage_ });
125         
126         objectUnderTest_.run();
127
128         controlFilterStage_.verify();
129
130         controlMessage_.verify();
131     }
132
133     /**
134      * Constructor for FilterProxyConsumerTaskTest.
135      *
136      * @param name
137      */

138     public FilterProxyConsumerTaskTest(String JavaDoc name)
139     {
140         super(name);
141     }
142
143     public static Test suite()
144     {
145         return new TestSuite(FilterProxyConsumerTaskTest.class);
146     }
147 }
Popular Tags