×

Unit testing an Enterprise Javabeans (EJB) bean class

  • US 8,972,942 B2
  • Filed: 07/19/2012
  • Issued: 03/03/2015
  • Est. Priority Date: 07/19/2012
  • Status: Active Grant
First Claim
Patent Images

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.

View all claims
  • 1 Assignment
Timeline View
Assignment View
    ×
    ×