3 Replies Latest reply on Mar 1, 2010 11:04 AM by daniell

    Seam doesn't inject members with ScopeType page




      We're using JSFUnit here to test our application from the backing-beans downwards. So we don't care about the HTML pages - we want to call the backing-bean methods directly from the JSFUnit-test-classes.

      So first we create a session by creating a new JSFSession with some URL (this is the only line which "depends" on the UI). Everything else is done without WebUI (and thus without HttpUnit).


      Many tests are already running, but now I came to a point where I don't know what to do. I've created a little example with 3 classes to show whats the problem:


      public class Bean1
          private String myString = "1234";
          public String getString() { return myString; }

      public class Bean2
          @In(create = true)
          private Bean1 bean1;
          public void someMethod() {
              System.out.println("bean returns " + bean1.getString());

      public class SomeTest extends ServletTestCase
          public void test1() throws IOException {
              WebClientSpec wcSpec = new WebClientSpec("/evaluations.seam");
              wcSpec.getWebClient().setCssErrorHandler(new SilentCssErrorHandler());
              // Send an HTTP request for the initial page
              JSFSession jsfSession = new JSFSession(wcSpec);


              Bean2 bean2 = (Bean2) Component.getInstance("bean2", true);


      When executing the test, seam throws an exception:

      org.jboss.seam.RequiredException: @In attribute requires non-null value: bean2.bean1


      But this only happens when the ScopeType of Bean1 is PAGE. When using finer or more coarse types like EVENT or CONVERSATION, everything is fine and there is no exception.


      So is there anything I am missing?





        • 1. Re: Seam doesn't inject members with ScopeType page

          Hi Daniel,


          Nice to see you using JSFUnit in a different way.  I've often wondered how far you can get with this type of testing if you use JSFUnit to start the session and then just do lots of fine-grained unit tests in-container.


          You might also take a look at the Arquillian which seems to have this kind of testing as its main goal.  So you would use Arquillian for fine-grained in-container tests and then use JSFUnit for course-grained tests where you need to test integrated application logic and UI.


          That being said, I'm not sure why you are getting that error.  I'm going to see if someone from the Seam team has any ideas.




          cross-posted: http://www.seamframework.org/Community/InjectionFailsWithScopeTypePAGEInJSFUnit

          1 of 1 people found this helpful
          • 2. Re: Seam doesn't inject members with ScopeType page

            Hi Stan!


            Thank you for your promt answer. And thanks for introducing Arquilian. I'll keep an eye on this project. But since it hasn't already reached alpha stage, I'll be loyal to JSFUnit


            In the meantime I've deactivated the problematic testcases. So it would be very nice if you could inform me if there are any news on this topic. Of course, I will check the seam-forum at regular intervals.


            Thanks again!

            • 3. Re: Seam doesn't inject members with ScopeType page

              Hello Stan!


              Do you have any new insights on this topic? I've seen, that there were no responses in the Seam forum up to now.