package org.darkphoenixs.mq.common;

import org.darkphoenixs.mq.consumer.AbstractConsumer;
import org.darkphoenixs.mq.consumer.Consumer;
import org.darkphoenixs.mq.exception.MQException;
import org.darkphoenixs.mq.message.MessageBeanImpl;
import org.junit.Assert;
import org.junit.Test;

@SuppressWarnings("deprecation")
public class MessageConsumerFactoryTest {

	@Test
	public void test_0() throws Exception {

		MessageConsumerFactory factory = (MessageConsumerFactory) MessageConsumerFactory
				.getInstance();

		factory = (MessageConsumerFactory) MessageConsumerFactory
				.getInstance();
		
		factory.init();

		factory.destroy();

		ConsumerTest consumer1 = new ConsumerTest();
		consumer1.setConsumerKey("ProtocolId1");

		ConsumerTest consumer2 = new ConsumerTest();
		consumer2.setConsumerKey("ProtocolId2");
		
		factory.setConsumers(new Consumer[] { consumer1 });
		factory.addConsumer(consumer2);
		factory.init();
		
		Assert.assertEquals(consumer1, factory.getConsumer("ProtocolId1"));
		Assert.assertEquals(consumer2, factory.getConsumer("ProtocolId2"));
		Assert.assertNull(factory.getConsumer("ProtocolId3"));
		
		factory.destroy();
	}

	private class ConsumerTest extends AbstractConsumer<MessageBeanImpl> {

		@Override
		protected void doReceive(MessageBeanImpl message) throws MQException {
			
			System.out.println(message);
		}
	}
}

@@ -373,17 +373,23 @@
 %0D%0A%0D%0A
-%09
+    
 @Test%0D%0A
-%09
+    
 publ
@@ -427,18 +427,24 @@
 on %7B%0D%0A%0D%0A
-%09%09
+        
 MessageC
@@ -509,36 +509,48 @@
 onsumerFactory%0D%0A
-%09%09%09%09
+                
 .getInstance();%0D
@@ -548,26 +548,89 @@
 tance();%0D%0A%0D%0A
-%09%09
+        factory.init();%0D%0A%0D%0A        factory.destroy();%0D%0A%0D%0A        
 factory = (M
@@ -680,12 +680,24 @@
 ry%0D%0A
-%09%09%09%09
+                
 .get
@@ -705,30 +705,34 @@
 nstance();%0D%0A
-%09%09%0D%0A%09%09
+%0D%0A        
 factory.init
@@ -738,18 +738,24 @@
 t();%0D%0A%0D%0A
-%09%09
+        
 factory.
@@ -764,26 +764,32 @@
 stroy();%0D%0A%0D%0A
-%09%09
+        
 ConsumerTest
@@ -814,34 +814,40 @@
 onsumerTest();%0D%0A
-%09%09
+        
 consumer1.setCon
@@ -874,18 +874,24 @@
 1%22);%0D%0A%0D%0A
-%09%09
+        
 Consumer
@@ -928,18 +928,24 @@
 est();%0D%0A
-%09%09
+        
 consumer
@@ -974,30 +974,34 @@
 ocolId2%22);%0D%0A
-%09%09%0D%0A%09%09
+%0D%0A        
 factory.setC
@@ -1027,11 +1027,9 @@
 er%5B%5D
- %7B 
+%7B
 cons
@@ -1037,16 +1037,21 @@
 mer1
- 
 %7D);%0D%0A
-%09%09
+        
 fact
@@ -1079,18 +1079,24 @@
 mer2);%0D%0A
-%09%09
+        
 factory.
@@ -1104,22 +1104,26 @@
 nit();%0D%0A
-%09%09%0D%0A%09%09
+%0D%0A        
 Assert.a
@@ -1179,26 +1179,32 @@
 colId1%22));%0D%0A
-%09%09
+        
 Assert.asser
@@ -1260,18 +1260,24 @@
 d2%22));%0D%0A
-%09%09
+        
 Assert.a
@@ -1324,22 +1324,26 @@
 d3%22));%0D%0A
-%09%09%0D%0A%09%09
+%0D%0A        
 factory.
@@ -1358,15 +1358,21 @@
 );%0D%0A
-%09
+    
 %7D%0D%0A%0D%0A
-%09
+    
 priv
@@ -1441,18 +1441,24 @@
 l%3E %7B%0D%0A%0D%0A
-%09%09
+        
 @Overrid
@@ -1460,18 +1460,24 @@
 erride%0D%0A
-%09%09
+        
 protecte
@@ -1544,16 +1544,22 @@
  %7B%0D%0A
-%09%09%09%0D%0A%09%09%09
+%0D%0A            
 Syst
@@ -1588,14 +1588,23 @@
 );%0D%0A
-%09%09%7D%0D%0A%09
+        %7D%0D%0A    
 %7D%0D%0A%7D

fix issue.