5 Replies Latest reply on Nov 29, 2010 9:21 AM by aslak

    Weld SE junit test with Request/Session Contexts, Request/Session Mocks, is this possible with Arquillian?

    mtaal

      Hi,

      I am using Weld in a tomcat servlet environment. To run tests I have created a Junit Runner using Weld SE with support of Request/Session contexts using mock Request/Session objects. I would prefer however to use something out of the box. Is there something like this available?

       

      I would like something which re-uses Weld SE adding support for Request/Session contexts. Is something like this provided by Arquillian?

       

      If so, what jars or parts of Arquillian do I need and where can I download? (I am not a maven user, which makes it pretty hard to find all the required dependencies I must say).

       

      gr. Martin

        • 1. Re: Weld SE junit test with Request/Session Contexts, Request/Session Mocks, is this possible with Arquillian?
          aslak

          If you use Weld EE instead of Weld SE container, you should have Request / Session scopes..

           

          http://docs.jboss.org/arquillian/reference/latest/en-US/html_single/#container.weld-ee-embedded-11

          • 2. Re: Weld SE junit test with Request/Session Contexts, Request/Session Mocks, is this possible with Arquillian?
            mtaal

            Thanks for your answer!

             

            I understand, but this would force me to use an EE container (with all its additional dependencies etc.) which I don't use normally. I am looking for a solution which uses Weld SE (which i think is great as it feels quite light and easy to use).

             

            gr. Martin

            • 3. Re: Weld SE junit test with Request/Session Contexts, Request/Session Mocks, is this possible with Arquillian?
              aslak

              weld-ee-embedded is weld-se with some Servlet/EE mock APIs + Request/Sesison contexts activated.

               

              The extra dependencies are just APIs, no EE container implementation needed.

               

              The different versions are there to simulate the different use cases for Weld, SE for a pure SE environment and EE for a Servlet/EE environment.

              • 4. Re: Weld SE junit test with Request/Session Contexts, Request/Session Mocks, is this possible with Arquillian?
                mtaal

                Ha great, sorry for my confusion!

                 

                I have it working now with adding the dependencies to my web project manually. It all works, setting up the ShrinkWrapper creation was actually quite easy (although I was at first a bit reluctant with this additional dependency).

                 

                For someone elses references, I have these dependencies (do I need them all you think?):

                arquillian-api-1.0.0.Alpha4.jar

                arquillian-impl-base-1.0.0.Alpha4.jar

                arquillian-junit-1.0.0.Alpha4.jar

                arquillian-protocol-local-1.0.0.Alpha4.jar

                arquillian-spi-1.0.0.Alpha4.jar

                arquillian-testenricher-cdi-1.0.0.Alpha4.jar

                arquillian-weld-ee-embedded-1.1-1.0.0.Alpha4.jar

                jboss-ejb3-api-3.1.0.jar

                shrinkwrap-api-1.0.0-alpha-11.jar

                shrinkwrap-extension-classloader-1.0.0-alpha-11.jar

                shrinkwrap-impl-base-1.0.0-alpha-11.jar

                shrinkwrap-spi-1.0.0-alpha-11.jar

                validation-api-1.0.0.GA.jar

                 

                gr. Martin

                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/arquillian-api-1.0.0.Alpha4.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/arquillian-impl-base-1.0.0.Alpha4.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/arquillian-junit-1.0.0.Alpha4.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/arquillian-protocol-local-1.0.0.Alpha4.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/arquillian-spi-1.0.0.Alpha4.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/arquillian-testenricher-cdi-1.0.0.Alpha4.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/arquillian-weld-ee-embedded-1.1-1.0.0.Alpha4.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/jboss-ejb3-api-3.1.0.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/shrinkwrap-api-1.0.0-alpha-11.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/shrinkwrap-extension-classloader-1.0.0-alpha-11.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/shrinkwrap-impl-base-1.0.0-alpha-11.jar
                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/shrinkwrap-spi-1.0.0-alpha-11.jar

                /home/mtaal/mydata/dev/openbravo/projects/pi/modules/org.openbravo.base.weld/lib/test/validation-api-1.0.0.GA.ja

                 

                 

                • 5. Re: Weld SE junit test with Request/Session Contexts, Request/Session Mocks, is this possible with Arquillian?
                  aslak

                  if your using maven, you only need to add arquillian-junit, arquillian-weld-ee-embedded and junit + the ee api libs needed by weld-ee-embedded described in the docs.

                   

                  The rest should be pulled in via transitive deps.