0 Replies Latest reply on May 8, 2009 7:14 AM by Cesar Perez

    Help unit testing Spring + Seam

    Cesar Perez Newbie


      I am new to Seam and I am working in a web application using Seam, JPA and Spring. I have followed the Tutorial to integrate Spring and Seam in the Seam in Action Book - Chapter 15.

      I am able to start Seam and the Spring context but I actually have no idea how to create a simple unit test with either JUnit or TestNG. There are no examples available as far as I know in the book.

      I used to do all my testing with the Spring JUnit 4 runner:

      public class SomeTest{
          MyService service;
          public void testSomething(){

      now I am trying:

      public class IntTest extends SeamTest
          public PersistenceService<User, String> service;
          public void injectionTest() throws Exception{

      but I always get a NullPointerException because the service is not injected, I have also tried inserting an EntityManager with the @PersistenceContext annotation in the Test class but it has the same result. I have also tried the @In annotation without success. The service is a seam component as I need it in a conversation scope.

      My Spring configuration is fine as it is exactly a copy/paste from the book and I have no problems starting the context, I just have no idea how to test this.

      Any help would be appreciated.