0 Replies Latest reply on Feb 10, 2009 11:06 AM by Riccardo Serafin

    Simulating event scope for SLSB in SeamTest

    Riccardo Serafin Newbie

      Hello,


      I have a SLSB that i like to test using SeamTest, in particular by making several ComponentTest calls and I expected that for each call a new instance of the bean would be created (the SLSB is event scoped). Unfortunately that doesn't happen. I've also tried to switch to a sequence of NonFacesRequest calls, in the hope that the life cycle would be simulated more properly, but I still had no luck: in each request the same instance was always returned.


      The code looks more or less like:


              new NonFacesRequest() {
                  @Override
                  protected void renderResponse() throws Exception {
                      processor = (IProcessor) Component.getInstance("statelessProcessor");
                      ...
                  }
      
              }.run();
      
              new NonFacesRequest() {
                  @Override
                  protected void renderResponse() throws Exception {
                      processor = (IProcessor) Component.getInstance("statelessProcessor");
                      ...
                  }
              }.run();
      



      and the SLSB:


      @Stateless
      @Name("statelessProcessor")
      @Scope(ScopeType.EVENT)
      public class StatelessProcessor extends AbstractProcessor implements IProcessor {
      ...
      



      So, any idea on how I could get seam to simulate the end of the event scope (or in any case destroy the previous bean within requests and create a new instance?