1 22 package org.jboss.ejb3.test.consumer.unit; 23 24 import org.jboss.ejb3.mdb.ProducerManager; 25 import org.jboss.ejb3.mdb.ProducerObject; 26 import org.jboss.ejb3.test.consumer.QueueTestRemote; 27 import org.jboss.ejb3.test.consumer.DeploymentDescriptorQueueTestRemote; 28 import org.jboss.ejb3.test.consumer.TestStatus; 29 import org.jboss.test.JBossTestCase; 30 import junit.framework.Test; 31 32 38 39 public class ConsumerUnitTestCase 40 extends JBossTestCase 41 { 42 org.jboss.logging.Logger log = getLog(); 43 44 static boolean deployed = false; 45 static int test = 0; 46 47 public ConsumerUnitTestCase(String name) 48 { 49 50 super(name); 51 52 } 53 54 public void testQueue() throws Exception 55 { 56 TestStatus status = (TestStatus) getInitialContext().lookup("TestStatusBean/remote"); 57 status.clear(); 58 QueueTestRemote tester = (QueueTestRemote) getInitialContext().lookup("org.jboss.ejb3.test.consumer.QueueTestRemote"); 59 ProducerManager manager = (ProducerManager) ((ProducerObject) tester).getProducerManager(); 60 manager.connect(); 61 try 62 { 63 tester.method1("testQueue", 5); 64 Thread.sleep(1000); 65 assertEquals(status.queueFired(), "method1"); 66 assertEquals(status.interceptedQueue(), "method1"); 67 assertTrue(status.postConstruct()); 68 assertTrue(status.fieldMessage()); 69 assertTrue(status.setterMessage()); 70 71 status.clear(); 72 tester.method2("testQueue", 5.5F); 73 Thread.sleep(1000); 74 assertEquals(status.queueFired(), "method2"); 75 assertEquals(status.interceptedQueue(), "method2"); 76 assertTrue(status.fieldMessage()); 77 assertTrue(status.setterMessage()); 78 } 79 finally 80 { 81 manager.close(); 82 } 83 84 } 87 88 public void testQueueXA() throws Exception 89 { 90 TestStatus status = (TestStatus) getInitialContext().lookup("TestStatusBean/remote"); 91 status.clear(); 92 status.testXA(); 93 94 Thread.sleep(1000); 95 assertEquals(status.queueFired(), "method2"); 96 assertEquals(status.interceptedQueue(), "method2"); 97 } 98 99 public void testQueueLocal() throws Exception 100 { 101 TestStatus status = (TestStatus) getInitialContext().lookup("TestStatusBean/remote"); 102 status.clear(); 103 status.testLocal(); 104 105 Thread.sleep(1000); 106 assertEquals(status.queueFired(), "method2"); 107 assertEquals(status.interceptedQueue(), "method2"); 108 } 109 110 public void testDeploymentDescriptorQueue() throws Exception 111 { 112 TestStatus status = (TestStatus) getInitialContext().lookup("TestStatusBean/remote"); 113 status.clear(); 114 DeploymentDescriptorQueueTestRemote tester = (DeploymentDescriptorQueueTestRemote) getInitialContext().lookup("org.jboss.ejb3.test.consumer.DeploymentDescriptorQueueTestRemote"); 115 ProducerManager manager = (ProducerManager) ((ProducerObject) tester).getProducerManager(); 116 manager.connect(); 117 try 118 { 119 tester.method1("testQueue", 5); 120 Thread.sleep(1000); 121 assertEquals(status.queueFired(), "method1"); 122 assertEquals(status.interceptedQueue(), "method1"); 123 assertTrue(status.postConstruct()); 124 assertTrue(status.fieldMessage()); 125 assertTrue(status.setterMessage()); 126 127 status.clear(); 128 tester.method2("testQueue", 5.5F); 129 Thread.sleep(1000); 130 assertEquals(status.queueFired(), "method2"); 131 assertEquals(status.interceptedQueue(), "method2"); 132 assertTrue(status.fieldMessage()); 133 assertTrue(status.setterMessage()); 134 } 135 finally 136 { 137 manager.close(); 138 } 139 140 } 143 144 public void testDeploymentDescriptorQueueXA() throws Exception 145 { 146 TestStatus status = (TestStatus) getInitialContext().lookup("TestStatusBean/remote"); 147 status.clear(); 148 status.testDeploymentDescriptorXA(); 149 150 Thread.sleep(1000); 151 assertEquals(status.queueFired(), "method2"); 152 assertEquals(status.interceptedQueue(), "method2"); 153 } 154 155 public void testDeploymentDescriptorQueueLocal() throws Exception 156 { 157 TestStatus status = (TestStatus) getInitialContext().lookup("TestStatusBean/remote"); 158 status.clear(); 159 status.testDeploymentDescriptorLocal(); 160 161 Thread.sleep(1000); 162 assertEquals(status.queueFired(), "method2"); 163 assertEquals(status.interceptedQueue(), "method2"); 164 } 165 166 public static Test suite() throws Exception 167 { 168 return getDeploySetup(ConsumerUnitTestCase.class, "consumertest-service.xml, consumer-test.jar"); 169 } 170 171 } 172 | Popular Tags |