发明名称 Unit testing an Enterprise Javabeans (EJB) bean class
摘要 An approach for unit testing an Enterprise JavaBeans® (EJB®) bean is presented. A test case for unit testing the EJB® bean is initiated. An indication of a JUnit or an in-container testing mode is received. The unit testing of the EJB® bean in the indicated mode is initiated by injecting the EJB® bean by an injection functionality included in a test framework if the JUnit testing mode is indicated, or by an EJB® container if the in-container testing mode is indicated. A test object in the injected EJB® bean operates business logic on business data by inserting, updating or deleting business data, or by selecting business data to send to a client, thereby generating a set of resulting business data. An assertion operation on the set of resulting business data against expected data determines whether the test case succeeds or fails.
申请公布号 US8972942(B2) 申请公布日期 2015.03.03
申请号 US201213552870 申请日期 2012.07.19
申请人 International Business Machines Corporation 发明人 Gu Geng Xian;Li Hai Dong
分类号 G06F9/44 主分类号 G06F9/44
代理机构 Schmeiser, Olsen & Watts 代理人 Schmeiser, Olsen & Watts ;Pivnichny John
主权项 1. A method of unit testing an enterprise javabeans (EJB) bean, the method comprising the steps of: a computer initiating a test case for a unit testing of the EJB bean with test data, the step of initiating the test case including a step of the computer receiving an indication that indicates a JUnit testing mode, which is a technique of unit testing any EJB bean by employing JUnit testing in a unit testing framework for Java programming language; the computer determining the indication does not indicate an in-container testing mode, which is a technique of unit testing any EJB bean on an EJB container of a Websphere application server by employing annotation and runtime injection provided by EJB architecture; based on the received indication indicating the JUnit testing mode and not indicating the in-container testing mode, the computer initiating the unit testing of the EJB bean by performing the unit testing of the EJB bean in the JUnit testing mode, but not in the in-container testing mode, by injecting the EJB bean at runtime by creating an instance of a Plain Old Java Object (POJO) of the EJB bean, which employs an injection functionality provided by a CommonTestCase class that integrates a base class of the in-container testing mode and a base class of the JUnit testing mode, and the CommonTestCase class being an extension of a TestCase class of the JUnit testing mode; a test object in the injected EJB bean operating business logic on business data by performing a step of inserting the business data into a database, updating the business data in the database, deleting the business data from the database, or selecting the business data to send to a client, an outcome of the step of operating the business logic being a set of resulting business data; the computer retrieving expected data corresponding to the test data and subsequently, the computer asserting the set of resulting business data against the retrieved expected data; based on the step of asserting the set of resulting business data against the retrieved expected data, the computer determining the test case is executed successfully in the JUnit testing mode; based on the test case being executed successfully, the computer determining a status of the test object changing from unstable to stable; and based on the status of the test object changing from unstable to stable, the computer receiving a second indication that indicates the in-container testing mode but not the JUnit testing mode, and in response, the computer continuing the unit testing of the EJB bean by performing the unit testing of the EJB bean in the in-container testing mode by (1) re-using the test case without a change to the test case, the test case having been employed in the unit testing of the EJB bean in the JUnit testing mode and (2) the EJB container injecting the EJB bean directly by the injection functionality provided by the CommonTestCase class.
地址 Armonk NY US