Testing JPA controllers in IDE

View: New views
1 Messages — Rating Filter:   Alert me  

Testing JPA controllers in IDE

by bajith :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Guys,



I have created netbeans project that uses hibernate and Jsf libraries. The following steps are taken to create project.



1. Created user table (id,firstname,lastname)

2. Created entity class for this table using "Netbeans IDE wizard for creating entities from database"

3. Created JPA controller for this class using "Netbeans IDE wizard for creating JAP controller from entities"

4. Created JSF pages from entities using wizard

5. Project RUN on app server and ran successfully on browser

6. I have created Test class for User JPA controller by rightclick->tools->create JUnit tests



I have the following test case,



 @Test

    public void testCreate() throws Exception {

        System.out.println("create");

        User user= new USer();

        user.setFirstName("Rob");

        user.setFirstName("Martin");

        UserJpaController instance = new UserJpaController();

        instance.create(user);

       

    }





When I ran the above test case it keep complaining that it can not get Entitymanager from controller. I dont how to  configure Junit in Netbeans to obtain persistence environment.\



Could you please assist me how to validate all test cases for JPA controller classes with in IDE?



It is taking a lot of time to verify in browser for all the changes made to controller classes.



Any help would be greatly appreciated.