001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: TestSimpleEnvMessageDrivenBean.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.environment.reference.simpleentry;
025:
026: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.ON_MESSAGE;
027: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_INJECTION_FIELD;
028: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_INJECTION_METHOD;
029: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_RESOURCES_DECLARATION;
030: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_RESOURCE_DECLARATION;
031: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.OVERRIDE_INJECTION_FIELD;
032: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.OVERRIDE_INJECTION_METHOD;
033: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_INJECTION_FIELD;
034: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_INJECTION_METHOD;
035: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_RESOURCE_DECLARATION;
036:
037: import org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType;
038: import org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.simpleentry.MDBSimpleEntryEnv;
039: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.OperationChecker;
040: import org.ow2.easybeans.tests.common.jms.JMSManager;
041: import org.testng.annotations.AfterClass;
042: import org.testng.annotations.BeforeClass;
043: import org.testng.annotations.BeforeMethod;
044: import org.testng.annotations.Test;
045:
046: /**
047: * Tests simple environment declaration and injection in Message-Driven beans.
048: * @reference JSR 220-PROPOSED FINAL - Enterprise Bean Environment - 16.4
049: * @requirement MDBs:<li>org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.simpleentry.MDBSimpleEntryEnv</li>
050: * (Ant task: install.jar.tests.simple.environment.messagedriven)
051: * @author Eduardo Studzinski Estima de Castro
052: * @author Gisele Pinheiro Souza
053: */
054: public class TestSimpleEnvMessageDrivenBean {
055:
056: /**
057: * JMS Manager.
058: */
059: private JMSManager jmsQueue;
060:
061: /**
062: * Log checker.
063: */
064: private OperationChecker checker;
065:
066: /**
067: * Configure the test.
068: * @throws Exception if there is a problem.
069: */
070: @BeforeClass
071: public void startUp00() throws Exception {
072: //Creates the queue
073: jmsQueue = new JMSManager(
074: JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY,
075: JMSManager.DEFAULT_QUEUE);
076: //Sends a message to run the test
077: jmsQueue.sendControlMessage(MDBSimpleEntryEnv.MESSAGE_TYPE,
078: OperationType.UNDEFINED);
079: }
080:
081: /**
082: * Gets a bean logger reference.
083: * @throws Exception if there is a problem.
084: */
085: @BeforeMethod
086: public void startUp01() throws Exception {
087: checker = new OperationChecker();
088: }
089:
090: /**
091: * Verifies declaration using annotation.
092: * @input a message
093: * @output a logged onMessage() event
094: * @throws Exception if a problem occurs.
095: */
096: @Test
097: public void test00() throws Exception {
098: checker.check(MDBSimpleEntryEnv.class.getName(), ON_MESSAGE,
099: ANNOTATION_RESOURCES_DECLARATION);
100: }
101:
102: /**
103: * Verifies declaration using annotation.
104: * @input a message
105: * @output a logged onMessage() event
106: * @throws Exception if a problem occurs.
107: */
108: @Test
109: public void test01() throws Exception {
110: checker.check(MDBSimpleEntryEnv.class.getName(), ON_MESSAGE,
111: ANNOTATION_RESOURCE_DECLARATION);
112: }
113:
114: /**
115: * Verifies declaration using XML.
116: * @input a message
117: * @output a logged onMessage() event
118: * @throws Exception if a problem occurs.
119: */
120: @Test
121: public void test02() throws Exception {
122: checker.check(MDBSimpleEntryEnv.class.getName(), ON_MESSAGE,
123: XML_RESOURCE_DECLARATION);
124: }
125:
126: /**
127: * Verifies injection in a field using annotation.
128: * @input a message
129: * @output a logged onMessage() event
130: * @throws Exception if a problem occurs.
131: */
132: @Test
133: public void test03() throws Exception {
134: checker.check(MDBSimpleEntryEnv.class.getName(), ON_MESSAGE,
135: ANNOTATION_INJECTION_FIELD);
136: }
137:
138: /**
139: * Verifies injection in a method using annotation.
140: * @input a message
141: * @output a logged onMessage() event
142: * @throws Exception if a problem occurs.
143: */
144: @Test
145: public void test04() throws Exception {
146: checker.check(MDBSimpleEntryEnv.class.getName(), ON_MESSAGE,
147: ANNOTATION_INJECTION_METHOD);
148: }
149:
150: /**
151: * Verifies injection in a field using XML.
152: * @input a message
153: * @output a logged onMessage() event
154: * @throws Exception if a problem occurs.
155: */
156: @Test
157: public void test05() throws Exception {
158: checker.check(MDBSimpleEntryEnv.class.getName(), ON_MESSAGE,
159: XML_INJECTION_FIELD);
160: }
161:
162: /**
163: * Verifies injection in a method using XML.
164: * @input a message
165: * @output a logged onMessage() event
166: * @throws Exception if a problem occurs.
167: */
168: @Test
169: public void test06() throws Exception {
170: checker.check(MDBSimpleEntryEnv.class.getName(), ON_MESSAGE,
171: XML_INJECTION_METHOD);
172: }
173:
174: /**
175: * Verifies an injection override in a field with a XML.
176: * @input a message
177: * @output a logged onMessage() event
178: * @throws Exception if a problem occurs.
179: */
180: @Test
181: public void test07() throws Exception {
182: checker.check(MDBSimpleEntryEnv.class.getName(), ON_MESSAGE,
183: OVERRIDE_INJECTION_FIELD);
184: }
185:
186: /**
187: * Verifies an injection override in a method with a XML.
188: * @input a message
189: * @output a logged onMessage() event
190: * @throws Exception if a problem occurs.
191: */
192: @Test
193: public void test08() throws Exception {
194: checker.check(MDBSimpleEntryEnv.class.getName(), ON_MESSAGE,
195: OVERRIDE_INJECTION_METHOD);
196: }
197:
198: /**
199: * Clears logs.
200: * @throws Exception if a problem occurs.
201: */
202: @AfterClass
203: public void tearDownClass() throws Exception {
204: jmsQueue.close();
205: checker.deleteAll();
206: }
207: }
|