0 Replies Latest reply on Mar 18, 2015 2:56 AM by satishlk

    Liferay maven multimodule project using arquillian

    satishlk

      Hi

       

      I am working multi-module liferay maven project.I have 5 projects 4 portlets and 1 hook,all are having service builder classes.Some portlets are having service layer,this service layer is used by other portlets as dependency.I want to run junit on portlets using arquillian at single shot.I want to load portlets in order .

       

      I have requirement to first load login-portlet with service layer ,then Shopping cart and at last user-profile-portlet.

       

      1)login-portlet

      2)shopping-cart-portlet

      3)profile-portlet

      4)users-list

      5)logout-hook

       

      I want load service layer in order shown below

      1)login-portlet

      2)shopping-cart-portlet

      3)profile-portlet

      4)users-list

      5)logout-hook

      When i am making archive using shrinkwrap,the service builder is working in corresponding (for ex in xyz,abc ) portlet but failing when i am trying to load

      xyz service and making archive in abc portlet  it is failing

      by throwing "BeanLocator is null for servlet context  xyz-portlet" from abc portlet

       

       

      @Deployment(testable=true,name="xyz",order=2)

          public static Archive<?> createDeployment()

          {

              WebArchive war=null;

               try

                {

                   PomEquippedResolveStage mavenResolver = Maven.resolver().loadPomFromFile("../xyz-portlet/pom.xml");

                   File[] libs = mavenResolver.importDependencies(ScopeType.TEST).resolve().withTransitivity().asFile();

                   war = ShrinkWrap.create(WebArchive.class, "xyz-portlet.war")

                           .addAsWebInfResource(new File("../xyz-portlet/docroot/WEB-INF", "portlet.xml"))

                          .addAsWebInfResource(new File("../xyz-portlet/docroot/WEB-INF", "liferay-plugin-package.properties"))

                          .addAsWebInfResource(new File("../xyz-portlet/docroot/WEB-INF", "liferay-display.xml"))

                          .addAsWebInfResource(new File("../xyz-portlet/docroot/WEB-INF", "liferay-portlet.xml")).addAsWebInfResource(EmptyAsset.INSTANCE, "portlet.properties")

                          .addAsResource(new File("../xyz-portlet/docroot/WEB-INF/src/META-INF/"), "META-INF/")

                          .addAsResource(new File("../xyz-portlet/docroot/WEB-INF/src/META-INF/"));

                

                   for (File file : libs)

                   {

                       war.addAsLibrary(file);

                   }

                 

                 

      //             Print war contents

                   log.info(war.toString(true));

                }

               catch (Throwable exception)

               {

                   log.info("Error in Creating archive due to :"+exception.getLocalizedMessage());

               }

              return war;

          }

        

          @Deployment(testable=true,name="abc",order=1)

          public static Archive<?> createDeployment2()

          {

              WebArchive war=null;

              try

               {

                  PomEquippedResolveStage mavenResolver = Maven.resolver().loadPomFromFile("pom.xml");

                  File[] libs = mavenResolver.importDependencies(ScopeType.TEST).resolve().withTransitivity().asFile();

                  war = ShrinkWrap.create(WebArchive.class, "test_abc-portlet.war").addPackages(true,"com.liferay.abc").addAsWebInfResource(new File("docroot/WEB-INF", "portlet.xml"))

                          .addAsWebInfResource(new File("docroot/WEB-INF", "liferay-plugin-package.properties")).addAsWebInfResource(new File("docroot/WEB-INF", "liferay-display.xml"))

                          .addAsWebInfResource(new File("docroot/WEB-INF", "liferay-portlet.xml"));

                  File[] files = Maven.resolver().resolve("com.netacad.portlet.62:salesforce-portlet-service:1.0").withTransitivity().asFile();

                   war.addAsLibraries(files);

                    for (File file : libs)

                    {

                        war.addAsLibrary(file);

                    }

                    //  Print war contents

                    log.info(war.toString(true));

                }

              catch (Throwable exception)

              {

                    log.error("Error in Creating archive due to :"+exception.getLocalizedMessage());

              }

              return war;

           }

        

        

        

           @Test

           @InSequence(1)

           @OperateOnDeployment("abc")

           public void testXYZService() throws SystemException

           {

                //code ti test xyzService

           }

          @Test

              @OperateOnDeployment("xyz")

               @InSequence(2)

              public void testPluginType() throws SystemException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, PortalException

              {

                        //code ti test abcService

              }

              }

            

              I want to load all portlets and then run tests on it.Am i doing anything wrong.Can anyone help me out how to load portlets with service and run tests on it.