SubscriptionTestHelper.java
001 /*
002  *
003  * Licensed to the Apache Software Foundation (ASF) under one
004  * or more contributor license agreements.  See the NOTICE file
005  * distributed with this work for additional information
006  * regarding copyright ownership.  The ASF licenses this file
007  * to you under the Apache License, Version 2.0 (the
008  * "License"); you may not use this file except in compliance
009  * with the License.  You may obtain a copy of the License at
010  
011  *   http://www.apache.org/licenses/LICENSE-2.0
012  
013  * Unless required by applicable law or agreed to in writing,
014  * software distributed under the License is distributed on an
015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016  * KIND, either express or implied.  See the License for the
017  * specific language governing permissions and limitations
018  * under the License.
019  *
020  */
021 package org.apache.qpid.server.queue;
022 
023 import org.apache.qpid.server.AMQChannel;
024 import org.apache.qpid.server.subscription.Subscription;
025 import org.apache.qpid.framing.AMQShortString;
026 
027 import java.util.ArrayList;
028 import java.util.List;
029 import java.util.Queue;
030 
031 public class SubscriptionTestHelper implements Subscription
032 {
033     private final List<QueueEntry> messages;
034     private final Object key;
035     private boolean isSuspended;
036 
037     public SubscriptionTestHelper(Object key)
038     {
039         this(key, new ArrayList<QueueEntry>());
040     }
041 
042     public SubscriptionTestHelper(final Object key, final boolean isSuspended)
043     {
044         this(key);
045         setSuspended(isSuspended);
046     }
047 
048     SubscriptionTestHelper(Object key, List<QueueEntry> messages)
049     {
050         this.key = key;
051         this.messages = messages;
052     }
053 
054     List<QueueEntry> getMessages()
055     {
056         return messages;
057     }
058 
059     public void setQueue(AMQQueue queue)
060     {
061         
062     }
063 
064     public void send(QueueEntry msg)
065     {
066         messages.add(msg);
067     }
068 
069     public void setSuspended(boolean suspended)
070     {
071         isSuspended = suspended;
072     }
073 
074     public boolean isSuspended()
075     {
076         return isSuspended;
077     }
078 
079     public boolean wouldSuspend(QueueEntry msg)
080     {
081         return isSuspended;
082     }
083 
084     public void addToResendQueue(QueueEntry msg)
085     {
086         //no-op
087     }
088 
089     public void getSendLock()
090     {
091         return;
092     }
093 
094     public void releaseSendLock()
095     {
096         //To change body of implemented methods use File | Settings | File Templates.
097     }
098 
099     public void resend(final QueueEntry entry)
100     {
101         //To change body of implemented methods use File | Settings | File Templates.
102     }
103 
104     public void restoreCredit(final QueueEntry queueEntry)
105     {
106 
107     }
108 
109     public void setStateListener(final StateListener listener)
110     {
111         //To change body of implemented methods use File | Settings | File Templates.
112     }
113     
114     public State getState()
115     {
116         return null;  //To change body of implemented methods use File | Settings | File Templates.
117     }
118 
119     public QueueEntry getLastSeenEntry()
120     {
121         return null;  //To change body of implemented methods use File | Settings | File Templates.
122     }
123 
124     public boolean setLastSeenEntry(QueueEntry expected, QueueEntry newValue)
125     {
126         return false;  //To change body of implemented methods use File | Settings | File Templates.
127     }
128 
129     public AMQChannel getChannel()
130     {
131         return null;
132     }
133     
134     public void start()
135     {
136         //no-op
137     }
138 
139     public AMQShortString getConsumerTag()
140     {
141         return null;  //To change body of implemented methods use File | Settings | File Templates.
142     }
143 
144     public boolean isActive()
145     {
146         return false;  //To change body of implemented methods use File | Settings | File Templates.
147     }
148 
149     public AMQQueue getQueue()
150     {
151         return null;
152     }
153 
154     public QueueEntry.SubscriptionAcquiredState getOwningState()
155     {
156         return null;  //To change body of implemented methods use File | Settings | File Templates.
157     }
158 
159     public void queueDeleted(AMQQueue queue)
160     {
161     }
162 
163     public boolean filtersMessages()
164     {
165         return false;
166     }
167 
168     public boolean hasInterest(QueueEntry msg)
169     {
170         return true;
171     }
172 
173     public boolean isAutoClose()
174     {
175         return false;
176     }
177 
178     public Queue<QueueEntry> getPreDeliveryQueue()
179     {
180         return null;
181     }
182 
183     public Queue<QueueEntry> getResendQueue()
184     {
185         return null;
186     }
187 
188     public Queue<QueueEntry> getNextQueue(Queue<QueueEntry> messages)
189     {
190         return messages;
191     }
192 
193     public void enqueueForPreDelivery(QueueEntry msg, boolean deliverFirst)
194     {
195         //no-op
196     }
197 
198     public void close()
199     {
200         //no-op
201     }
202 
203     public boolean isClosed()
204     {
205         return false;
206     }
207 
208     public boolean isBrowser()
209     {
210         return false;
211     }
212 
213     public int hashCode()
214     {
215         return key.hashCode();
216     }
217 
218     public boolean equals(Object o)
219     {
220         return instanceof SubscriptionTestHelper && ((SubscriptionTestHelpero).key.equals(key);
221     }
222 
223     public String toString()
224     {
225         return key.toString();
226     }
227 }