View Javadoc
1   package edu.internet2.middleware.grouperMessagingRabbitmq;
2   
3   import java.io.IOException;
4   import java.net.InetAddress;
5   import java.util.Arrays;
6   import java.util.HashMap;
7   import java.util.List;
8   import java.util.Map;
9   import java.util.concurrent.TimeoutException;
10  
11  import com.rabbitmq.client.AMQP.Basic.RecoverOk;
12  import com.rabbitmq.client.AMQP.BasicProperties;
13  import com.rabbitmq.client.AMQP.Confirm.SelectOk;
14  import com.rabbitmq.client.AMQP.Exchange.BindOk;
15  import com.rabbitmq.client.AMQP.Exchange.DeclareOk;
16  import com.rabbitmq.client.AMQP.Exchange.DeleteOk;
17  import com.rabbitmq.client.AMQP.Exchange.UnbindOk;
18  import com.rabbitmq.client.AMQP.Queue.PurgeOk;
19  import com.rabbitmq.client.AMQP.Tx.CommitOk;
20  import com.rabbitmq.client.AMQP.Tx.RollbackOk;
21  import com.rabbitmq.client.BlockedListener;
22  import com.rabbitmq.client.BuiltinExchangeType;
23  import com.rabbitmq.client.Channel;
24  import com.rabbitmq.client.Command;
25  import com.rabbitmq.client.ConfirmListener;
26  import com.rabbitmq.client.Connection;
27  import com.rabbitmq.client.Consumer;
28  import com.rabbitmq.client.ExceptionHandler;
29  import com.rabbitmq.client.FlowListener;
30  import com.rabbitmq.client.GetResponse;
31  import com.rabbitmq.client.Method;
32  import com.rabbitmq.client.ReturnListener;
33  import com.rabbitmq.client.ShutdownListener;
34  import com.rabbitmq.client.ShutdownSignalException;
35  
36  public enum RabbitMQConnectionFactoryFake implements RabbitMQConnectionFactory {
37    
38    INSTANACE {
39      
40      @Override
41      public Connection getConnection(String messagingSystemName) {
42        return new FakeConnection();
43      }
44  
45      @Override
46      public void closeConnection(String messagingSystemName) {
47        
48      }
49      
50    };
51  
52  }
53  
54  class FakeConnection implements com.rabbitmq.client.Connection {
55    
56    public static final Map<String, List<? extends Object>> recordedValues = new HashMap<String, List<? extends Object>>();
57    
58    @Override
59    public void addShutdownListener(ShutdownListener arg0) {
60      // TODO Auto-generated method stub
61      
62    }
63  
64    @Override
65    public ShutdownSignalException getCloseReason() {
66      // TODO Auto-generated method stub
67      return null;
68    }
69  
70    @Override
71    public boolean isOpen() {
72      // TODO Auto-generated method stub
73      return false;
74    }
75  
76    @Override
77    public void notifyListeners() {
78      // TODO Auto-generated method stub
79      
80    }
81  
82    @Override
83    public void removeShutdownListener(ShutdownListener arg0) {
84      // TODO Auto-generated method stub
85      
86    }
87  
88    @Override
89    public void abort() {
90      // TODO Auto-generated method stub
91      
92    }
93  
94    @Override
95    public void abort(int arg0) {
96      // TODO Auto-generated method stub
97      
98    }
99  
100   @Override
101   public void abort(int arg0, String arg1) {
102     // TODO Auto-generated method stub
103     
104   }
105 
106   @Override
107   public void abort(int arg0, String arg1, int arg2) {
108     // TODO Auto-generated method stub
109     
110   }
111 
112   @Override
113   public void addBlockedListener(BlockedListener arg0) {
114     // TODO Auto-generated method stub
115     
116   }
117 
118   @Override
119   public void clearBlockedListeners() {
120     // TODO Auto-generated method stub
121     
122   }
123 
124   @Override
125   public void close() throws IOException {
126     // TODO Auto-generated method stub
127     
128   }
129 
130   @Override
131   public void close(int arg0) throws IOException {
132     // TODO Auto-generated method stub
133     
134   }
135 
136   @Override
137   public void close(int arg0, String arg1) throws IOException {
138     // TODO Auto-generated method stub
139     
140   }
141 
142   @Override
143   public void close(int arg0, String arg1, int arg2) throws IOException {
144     // TODO Auto-generated method stub
145     
146   }
147 
148   @Override
149   public Channel createChannel() throws IOException {
150     return new FakeChannel();
151   }
152 
153   @Override
154   public Channel createChannel(int arg0) throws IOException {
155     // TODO Auto-generated method stub
156     return null;
157   }
158 
159   @Override
160   public InetAddress getAddress() {
161     // TODO Auto-generated method stub
162     return null;
163   }
164 
165   @Override
166   public int getChannelMax() {
167     // TODO Auto-generated method stub
168     return 0;
169   }
170 
171   @Override
172   public Map<String, Object> getClientProperties() {
173     // TODO Auto-generated method stub
174     return null;
175   }
176 
177   @Override
178   public String getClientProvidedName() {
179     // TODO Auto-generated method stub
180     return null;
181   }
182 
183   @Override
184   public ExceptionHandler getExceptionHandler() {
185     // TODO Auto-generated method stub
186     return null;
187   }
188 
189   @Override
190   public int getFrameMax() {
191     // TODO Auto-generated method stub
192     return 0;
193   }
194 
195   @Override
196   public int getHeartbeat() {
197     // TODO Auto-generated method stub
198     return 0;
199   }
200 
201   @Override
202   public String getId() {
203     // TODO Auto-generated method stub
204     return null;
205   }
206 
207   @Override
208   public int getPort() {
209     // TODO Auto-generated method stub
210     return 0;
211   }
212 
213   @Override
214   public Map<String, Object> getServerProperties() {
215     // TODO Auto-generated method stub
216     return null;
217   }
218 
219   @Override
220   public boolean removeBlockedListener(BlockedListener arg0) {
221     // TODO Auto-generated method stub
222     return false;
223   }
224 
225   @Override
226   public void setId(String arg0) {
227     // TODO Auto-generated method stub
228     
229   }
230   
231 }
232 
233 class FakeChannel implements Channel {
234 
235   @Override
236   public void addShutdownListener(ShutdownListener arg0) {
237     // TODO Auto-generated method stub
238     
239   }
240 
241   @Override
242   public ShutdownSignalException getCloseReason() {
243     // TODO Auto-generated method stub
244     return null;
245   }
246 
247   @Override
248   public boolean isOpen() {
249     // TODO Auto-generated method stub
250     return false;
251   }
252 
253   @Override
254   public void notifyListeners() {
255     // TODO Auto-generated method stub
256     
257   }
258 
259   @Override
260   public void removeShutdownListener(ShutdownListener arg0) {
261     // TODO Auto-generated method stub
262     
263   }
264 
265   @Override
266   public void abort() throws IOException {
267     // TODO Auto-generated method stub
268     
269   }
270 
271   @Override
272   public void abort(int arg0, String arg1) throws IOException {
273     // TODO Auto-generated method stub
274     
275   }
276 
277   @Override
278   public void addConfirmListener(ConfirmListener arg0) {
279     // TODO Auto-generated method stub
280     
281   }
282 
283   @Override
284   public void addFlowListener(FlowListener arg0) {
285     // TODO Auto-generated method stub
286     
287   }
288 
289   @Override
290   public void addReturnListener(ReturnListener arg0) {
291     // TODO Auto-generated method stub
292     
293   }
294 
295   @Override
296   public void asyncRpc(Method arg0) throws IOException {
297     // TODO Auto-generated method stub
298     
299   }
300 
301   @Override
302   public void basicAck(long arg0, boolean arg1) throws IOException {
303     // TODO Auto-generated method stub
304     
305   }
306 
307   @Override
308   public void basicCancel(String arg0) throws IOException {
309     // TODO Auto-generated method stub
310     
311   }
312 
313   @Override
314   public String basicConsume(String arg0, Consumer arg1) throws IOException {
315     // TODO Auto-generated method stub
316     return null;
317   }
318 
319   @Override
320   public String basicConsume(String arg0, boolean arg1, Consumer arg2) throws IOException {
321     // TODO Auto-generated method stub
322     return null;
323   }
324 
325   @Override
326   public String basicConsume(String arg0, boolean arg1, Map<String, Object> arg2, Consumer arg3) throws IOException {
327     // TODO Auto-generated method stub
328     return null;
329   }
330 
331   @Override
332   public String basicConsume(String arg0, boolean arg1, String arg2, Consumer arg3) throws IOException {
333     // TODO Auto-generated method stub
334     return null;
335   }
336 
337   @Override
338   public String basicConsume(String arg0, boolean arg1, String arg2, boolean arg3, boolean arg4,
339       Map<String, Object> arg5, Consumer arg6) throws IOException {
340     // TODO Auto-generated method stub
341     return null;
342   }
343 
344   @Override
345   public GetResponse basicGet(String arg0, boolean arg1) throws IOException {
346     // TODO Auto-generated method stub
347     return null;
348   }
349 
350   @Override
351   public void basicNack(long arg0, boolean arg1, boolean arg2) throws IOException {
352     // TODO Auto-generated method stub
353     
354   }
355 
356   @Override
357   public void basicPublish(String arg0, String arg1, BasicProperties arg2, byte[] arg3) throws IOException {
358     // TODO Auto-generated method stub
359     FakeConnection.recordedValues.put("basicPublish", Arrays.asList(arg0, arg1, arg2, arg3));
360   }
361 
362   @Override
363   public void basicPublish(String arg0, String arg1, boolean arg2, BasicProperties arg3, byte[] arg4)
364       throws IOException {
365     // TODO Auto-generated method stub
366     
367   }
368 
369   @Override
370   public void basicPublish(String arg0, String arg1, boolean arg2, boolean arg3, BasicProperties arg4, byte[] arg5)
371       throws IOException {
372     // TODO Auto-generated method stub
373     
374   }
375 
376   @Override
377   public void basicQos(int arg0) throws IOException {
378     // TODO Auto-generated method stub
379     
380   }
381 
382   @Override
383   public void basicQos(int arg0, boolean arg1) throws IOException {
384     // TODO Auto-generated method stub
385     
386   }
387 
388   @Override
389   public void basicQos(int arg0, int arg1, boolean arg2) throws IOException {
390     // TODO Auto-generated method stub
391     
392   }
393 
394   @Override
395   public RecoverOk basicRecover() throws IOException {
396     // TODO Auto-generated method stub
397     return null;
398   }
399 
400   @Override
401   public RecoverOk basicRecover(boolean arg0) throws IOException {
402     // TODO Auto-generated method stub
403     return null;
404   }
405 
406   @Override
407   public void basicReject(long arg0, boolean arg1) throws IOException {
408     // TODO Auto-generated method stub
409     
410   }
411 
412   @Override
413   public void clearConfirmListeners() {
414     // TODO Auto-generated method stub
415     
416   }
417 
418   @Override
419   public void clearFlowListeners() {
420     // TODO Auto-generated method stub
421     
422   }
423 
424   @Override
425   public void clearReturnListeners() {
426     // TODO Auto-generated method stub
427     
428   }
429 
430   @Override
431   public void close() throws IOException, TimeoutException {
432     FakeConnection.recordedValues.put("close", Arrays.asList());
433   }
434 
435   @Override
436   public void close(int arg0, String arg1) throws IOException, TimeoutException {
437     // TODO Auto-generated method stub
438     
439   }
440 
441   @Override
442   public SelectOk confirmSelect() throws IOException {
443     // TODO Auto-generated method stub
444     return null;
445   }
446 
447   @Override
448   public long consumerCount(String arg0) throws IOException {
449     // TODO Auto-generated method stub
450     return 0;
451   }
452 
453   @Override
454   public BindOk exchangeBind(String arg0, String arg1, String arg2) throws IOException {
455     // TODO Auto-generated method stub
456     return null;
457   }
458 
459   @Override
460   public BindOk exchangeBind(String arg0, String arg1, String arg2, Map<String, Object> arg3) throws IOException {
461     // TODO Auto-generated method stub
462     return null;
463   }
464 
465   @Override
466   public void exchangeBindNoWait(String arg0, String arg1, String arg2, Map<String, Object> arg3) throws IOException {
467     // TODO Auto-generated method stub
468     
469   }
470 
471   @Override
472   public DeclareOk exchangeDeclare(String arg0, String arg1) throws IOException {
473     // TODO Auto-generated method stub
474     return null;
475   }
476 
477   @Override
478   public DeclareOk exchangeDeclare(String arg0, BuiltinExchangeType arg1) throws IOException {
479     // TODO Auto-generated method stub
480     return null;
481   }
482 
483   @Override
484   public DeclareOk exchangeDeclare(String arg0, String arg1, boolean arg2) throws IOException {
485     // TODO Auto-generated method stub
486     return null;
487   }
488 
489   @Override
490   public DeclareOk exchangeDeclare(String arg0, BuiltinExchangeType arg1, boolean arg2) throws IOException {
491     FakeConnection.recordedValues.put("exchangeDeclare", Arrays.asList(arg0, arg1, arg2));
492     return null;
493   }
494 
495   @Override
496   public DeclareOk exchangeDeclare(String arg0, String arg1, boolean arg2, boolean arg3, Map<String, Object> arg4)
497       throws IOException {
498     // TODO Auto-generated method stub
499     return null;
500   }
501 
502   @Override
503   public DeclareOk exchangeDeclare(String arg0, BuiltinExchangeType arg1, boolean arg2, boolean arg3,
504       Map<String, Object> arg4) throws IOException {
505     // TODO Auto-generated method stub
506     return null;
507   }
508 
509   @Override
510   public DeclareOk exchangeDeclare(String arg0, String arg1, boolean arg2, boolean arg3, boolean arg4,
511       Map<String, Object> arg5) throws IOException {
512     // TODO Auto-generated method stub
513     return null;
514   }
515 
516   @Override
517   public DeclareOk exchangeDeclare(String arg0, BuiltinExchangeType arg1, boolean arg2, boolean arg3, boolean arg4,
518       Map<String, Object> arg5) throws IOException {
519     // TODO Auto-generated method stub
520     return null;
521   }
522 
523   @Override
524   public void exchangeDeclareNoWait(String arg0, String arg1, boolean arg2, boolean arg3, boolean arg4,
525       Map<String, Object> arg5) throws IOException {
526     // TODO Auto-generated method stub
527     
528   }
529 
530   @Override
531   public void exchangeDeclareNoWait(String arg0, BuiltinExchangeType arg1, boolean arg2, boolean arg3, boolean arg4,
532       Map<String, Object> arg5) throws IOException {
533     // TODO Auto-generated method stub
534     
535   }
536 
537   @Override
538   public DeclareOk exchangeDeclarePassive(String arg0) throws IOException {
539     FakeConnection.recordedValues.put("exchangeDeclarePassive", Arrays.asList(arg0));
540     return null;
541   }
542 
543   @Override
544   public DeleteOk exchangeDelete(String arg0) throws IOException {
545     // TODO Auto-generated method stub
546     return null;
547   }
548 
549   @Override
550   public DeleteOk exchangeDelete(String arg0, boolean arg1) throws IOException {
551     // TODO Auto-generated method stub
552     return null;
553   }
554 
555   @Override
556   public void exchangeDeleteNoWait(String arg0, boolean arg1) throws IOException {
557   }
558 
559   @Override
560   public UnbindOk exchangeUnbind(String arg0, String arg1, String arg2) throws IOException {
561     return null;
562   }
563 
564   @Override
565   public UnbindOk exchangeUnbind(String arg0, String arg1, String arg2, Map<String, Object> arg3) throws IOException {
566     return null;
567   }
568 
569   @Override
570   public void exchangeUnbindNoWait(String arg0, String arg1, String arg2, Map<String, Object> arg3) throws IOException {
571   }
572 
573   @Override
574   public boolean flowBlocked() {
575     return false;
576   }
577 
578   @Override
579   public int getChannelNumber() {
580     return 0;
581   }
582 
583   @Override
584   public Connection getConnection() {
585     return null;
586   }
587 
588   @Override
589   public Consumer getDefaultConsumer() {
590     return null;
591   }
592 
593   @Override
594   public long getNextPublishSeqNo() {
595     return 0;
596   }
597 
598   @Override
599   public long messageCount(String arg0) throws IOException {
600     return 0;
601   }
602 
603   @Override
604   public com.rabbitmq.client.AMQP.Queue.BindOk queueBind(String arg0, String arg1, String arg2) throws IOException {
605     return null;
606   }
607 
608   @Override
609   public com.rabbitmq.client.AMQP.Queue.BindOk queueBind(String arg0, String arg1, String arg2,
610       Map<String, Object> arg3) throws IOException {
611     return null;
612   }
613 
614   @Override
615   public void queueBindNoWait(String arg0, String arg1, String arg2, Map<String, Object> arg3) throws IOException {}
616 
617   @Override
618   public com.rabbitmq.client.AMQP.Queue.DeclareOk queueDeclare() throws IOException {
619     return null;
620   }
621 
622   @Override
623   public com.rabbitmq.client.AMQP.Queue.DeclareOk queueDeclare(String arg0, boolean arg1, boolean arg2, boolean arg3,
624       Map<String, Object> arg4) throws IOException {
625     FakeConnection.recordedValues.put("queueDeclare", Arrays.asList(arg0, arg1, arg2, arg3, arg4));
626     return null;
627   }
628 
629   @Override
630   public void queueDeclareNoWait(String arg0, boolean arg1, boolean arg2, boolean arg3, Map<String, Object> arg4)
631       throws IOException {
632   }
633 
634   @Override
635   public com.rabbitmq.client.AMQP.Queue.DeclareOk queueDeclarePassive(String arg0) throws IOException {
636     FakeConnection.recordedValues.put("queueDeclarePassive", Arrays.asList(arg0));
637     return null;
638   }
639 
640   @Override
641   public com.rabbitmq.client.AMQP.Queue.DeleteOk queueDelete(String arg0) throws IOException {
642     return null;
643   }
644 
645   @Override
646   public com.rabbitmq.client.AMQP.Queue.DeleteOk queueDelete(String arg0, boolean arg1, boolean arg2)
647       throws IOException {
648     return null;
649   }
650 
651   @Override
652   public void queueDeleteNoWait(String arg0, boolean arg1, boolean arg2) throws IOException {
653   }
654 
655   @Override
656   public PurgeOk queuePurge(String arg0) throws IOException {
657     return null;
658   }
659 
660   @Override
661   public com.rabbitmq.client.AMQP.Queue.UnbindOk queueUnbind(String arg0, String arg1, String arg2) throws IOException {
662     return null;
663   }
664 
665   @Override
666   public com.rabbitmq.client.AMQP.Queue.UnbindOk queueUnbind(String arg0, String arg1, String arg2,
667       Map<String, Object> arg3) throws IOException {
668     return null;
669   }
670 
671   @Override
672   public boolean removeConfirmListener(ConfirmListener arg0) {
673     return false;
674   }
675 
676   @Override
677   public boolean removeFlowListener(FlowListener arg0) {
678     return false;
679   }
680 
681   @Override
682   public boolean removeReturnListener(ReturnListener arg0) {
683     return false;
684   }
685 
686   @Override
687   public Command rpc(Method arg0) throws IOException {
688     return null;
689   }
690 
691   @Override
692   public void setDefaultConsumer(Consumer arg0) {}
693 
694   @Override
695   public CommitOk txCommit() throws IOException {
696     return null;
697   }
698 
699   @Override
700   public RollbackOk txRollback() throws IOException {
701     return null;
702   }
703 
704   @Override
705   public com.rabbitmq.client.AMQP.Tx.SelectOk txSelect() throws IOException {
706     return null;
707   }
708 
709   @Override
710   public boolean waitForConfirms() throws InterruptedException {
711     return false;
712   }
713 
714   @Override
715   public boolean waitForConfirms(long arg0) throws InterruptedException, TimeoutException {
716     return false;
717   }
718 
719   @Override
720   public void waitForConfirmsOrDie() throws IOException, InterruptedException {}
721 
722   @Override
723   public void waitForConfirmsOrDie(long arg0) throws IOException, InterruptedException, TimeoutException {}
724   
725 }