4 Replies Latest reply on Jul 2, 2013 1:09 PM by lukas lukasz

    Arquillian integration test with solr

    lukas lukasz Newbie

      Hello

       

      I need to write tests for sorl and glassfish integration. So i must load that server and using solrj for connecting that technology.

      I can not found any example for that test case. Its possible create that test?

        • 1. Re: Arquillian integration test with solr
          Bartosz Majsak Master

          Dunno that much about this combination, but if you share how you do the deployment and how you configure GF for Solr maybe I will be albe to help. I'm not aware if such an example exist but we can always figure it out and contribute back to the showcase project

          • 2. Re: Arquillian integration test with solr
            lukas lukasz Newbie

            As the spec:

            http://wiki.apache.org/solr/SolrGlassfish

             

            I need only set java properties solr.solr.home and deploy solr.war.

             

            First of all i must set properties for solr home. So its possible to do it with embedded glassfish ? Maybe some arquillian configuration....

            And also i need deploy solr.war into container and that is all.

            • 3. Re: Arquillian integration test with solr
              Bartosz Majsak Master

              I would rather avoid using GF Embedded for this given case, as it can give you classpath headaches. Try with remote or managed Glassfish to have properly isolated environment. Now, back to the real stuff

               

              Setting up solr.solr.home property is possible in several ways

              1. In Maven (just remember to propagate it for surefire). If you run it from IDE you will need to adjust your run configuration probably to also include this property

              2. Adding to server startup (I know this should work for JBoss as simple as adding -D to bootstrap command, not sure how it could work with Glassfish though, but one of these options should work (custom domain.xml in particular))

               

              That's only part of the story. What you really need is support for multiple deployments. Luckily it's quite easy with Arquillian, here's the snippet:

               

              {code:java}

              @Deployment(name = "solr", testable = false, order = 1)

              public static Archive<?> deploySolr() {

                   return  ShrinkWrap.create(ZipImporter.class, "solr.war")

                                     .importFrom(new File("/location/of/solr/package/solr.war"))

                                     .as(WebArchive.class);

              }

               

              @Deployment(name = "test", order = 2)

              public static Archive<?> deployTest() {

                  // your test deployment

              }

               

              @Test @OperateOnDeployment("test")

              public void should_do_sth() {

                 // your test code

              }

              {code}

               

              However you might also consider pre-deploying your Solr when using remote container, if there is nothing to clean-up there between the tests execution. Approach presented in the snippet above will result in redeploying solr for each and every test class you run.

               

              Hope that helps.

              • 4. Re: Arquillian integration test with solr
                lukas lukasz Newbie

                Yea this is it what i  am need . Thanks very much.