Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Test Class which uses JNDI to test Queries and Entities  RSS feed

 
Kevin Olome
Ranch Hand
Posts: 44
1
Android Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
my current web project has entities and dao classes. I wanted to create a test class so I can test queries which are generated from eclipselink.

The web project is currently running on Wildfly 10.1 with a mysql database.

I can already use the database with the web project, e.g. I have a register form and I can store the user in the database.
However when I want to test if the user is really stored in the database (with a test class) I get an error.

So I started some research and found that I need to specify jndi properties for the test class. I did this and now I have a "NoInitialContextException": Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

I want to ask if I am on the right track or doing something wrong. I find it a bit strange to have some external jars just for some test cases (jboss-as-naming-7.0.0 final.jar, jboss-as-logging-3.3.0.Final.jar, jboss-modules.jar)

This is my testing class:



I also created the JNDI ressource on the wildfly server.

The complete project (without the updated persistence.xml) is also on github (i just use it as practice):
https://github.com/kolomu/audiobooklist (however there I was still using glassfish now I switched to wildfly but I get the same error)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!