.

Sunday, January 17, 2016

Newbie Eclipselink/ADF: Testing Your JPA With a Runnable Class

Testing your entities with a runnable class isn't really a problem at all, there are just somethings that can be missed depending on your JPA vendor. In our case, it is Eclipselink.

Assuming we have experience here in making JPA-enabled projects, here is a sample persistence.xml unit:

To test with a main class, we use a RESOURCE_LOCAL transaction type, with the required javax.persistence.jdbc... properties, as seen above. In addition I also included some eclipselink parameters that define logging and performance profiling to help, if not enable at all, testing and debugging efforts.

Oh, make sure to import the Oracle JDBC library (ADF) or another library where it exists if you are to use oracle.jdbc.OracleDriver as your driver.

And then, to make sure that my entities are woven (since we can't make use of dynamic weaving in this context), I open the project properties of where the test class would be placed, and configure its Run/Debug options:


For the Java Options(as encircled above), I add the option -javaagent:, and append the path to my eclipselink.jar. In my case, the resulting option is -javaagent:C:\Oracle\Middleware\Oracle_Home\oracle_common\modules\oracle.toplink_12.1.3\eclipselink.jar.

Now we have added weaving. This enables change tracking, fetch groups, indirection, and some other Eclipselink magic that wouldn't be available otherwise.

After that, we are ready to create our class for (unit) testing!

Here's a sample class that runs a main method, along with some formal transaction demarcation:

An that's it for this post. Hope this helped!

3 comments:

  1. While making a deposit in your Binance account through verified MasterCard do you encounter any trouble that panic as well as annoys you? Most of the Binance users are unable to deal with the errors due to less information about the Binance features. Under such situations, you can speak to the team of Binance Support Number elite professionals via dialing Binance support number which is the gateway to submit your queries in front of the experts who will fix all your queries in the least possible time.

    ReplyDelete
  2. Do you face hardship while selling the bitcoin in your Blockchain account? To resolve such errors, you can always contact the team of professionals who are there to assist you. Dial Blockchain support number and avail the best solution from the professionals who are there to handle your queries. Talking to the team is the best decision as they are always occupied with Blockchain Support NUmber plenty of solutions that are difficult to resolve. Connect with the team and get the verified answers from professionals who are there to listen to your queries and give accessible remedies.

    ReplyDelete
  3. Do you face hardship while selling the bitcoin in your Gemini account? To resolve such errors, you can always contact the team of professionals who are there to assist you. Dial Gemini support number and avail the best solution from the professionals who are there to handle your queries. Talking to the team is the best decision as they are always occupied with plenty Gemini Support Number of solutions that are difficult to resolve. Connect with the team and get the verified answers from professionals who are there to listen to your queries and give accessible remedies.

    ReplyDelete