0 Replies Latest reply on Jan 15, 2013 10:07 AM by abendt

    Testing @RequestScoped Beans

    abendt

      Hi,

       

      i want to test two beans using Arquillian

       

      @Stateless 
      public class Bean1 {
      
        @Inject Bean2 bean2;
        
        public void operation1(...) {
          bean2.operation2(...);
        } 
      
      }
      
      @RequestScoped
      public class Bean2 {
        public void operation2() {...}
      }
      
      @RunWith(Arquillian.class)
      public class BeanTest {
      
        @Deployment ...
      
        @Inject Bean1 bean1;
      
        @Test
        public void test() {
          bean1.operation1(...);
        }
      
        @Test
        public void test2() {
          bean2.operation1(...);
        }
      }
      

       

      i expect that every test execution gets a new Bean2 instance. However it looks like the same instance is reused across the tests.

       

      I found this post at stackoverflow: http://stackoverflow.com/questions/13179180/isolated-testing-of-backing-bean-that-uses-requestparam-without-jsf-pages and changed the protocol arquillian should use. However this did not help.

       

      should this work using arquillian?

       

      any help appreciated.

       

      regards,

        Alphonse Bendt

       

      environment:

      jboss-as 7.1.1

      arquillian 1.0.3