6 Replies Latest reply: May 30, 2012 4:01 PM by Bill Murphy RSS

Is there an documented Managed Container example connecting to a different JVM?

Bill Murphy Newbie

Hi,

 

I'm looking for an example showing a managed container connecting to a different JVM.  The example in "Getting Started" for the managed container shows ShrinkWrap wrapping the test class (GreeterTest) and the class under test (Greeter) in the same war.  I need an example where the class under test is in war that is in the container's deploy area.  I've tried this with a simple modification to GreeterTest calling to public method in a separate war and the result is ClassNotFoundException.

 

Any help would be appreciated.

 

Thanks,

Bill

  • 1. Re: Is there an documented Managed Container example connecting to a different JVM?
    Gerhard Poul Newbie

    The class under test and the test class need to be in the same WAR if you want to have it run in the remote container. Otherwise we can't actually execute the test remotely if it's not in the deployed archive.

     

    Where the test is run depends on the annotations on the test class documented at https://docs.jboss.org/author/display/ARQ/Test+run+modes

  • 2. Re: Is there an documented Managed Container example connecting to a different JVM?
    Bill Murphy Newbie

    Thanks for the clarification Gerhard.

     

    Let's assume that my equivalent Greeter Class is part of complex app with other classes, that I also want to test, and supporting jar files packaged in a war.  Does this mean that I need to exploded my app's war, strip off the web resources (jsps etc..) and let ShrinkWrap repackage as a  new war?

     

    If so is there a good, efficient example of ShrinkWrap archiving dozens of classes and jar files?  In other words I'm trying to avoid writing a create statement that is pages long.

     

    Thanks,

    Bill

  • 3. Re: Is there an documented Managed Container example connecting to a different JVM?
    Gerhard Poul Newbie

    The idea is to only package what your test requires, but that might obviously include dependent libraries. I think it shouldn't be several pages long. If it is you might have to come up with a different way of achieving what you want. ShrinkWrap helps you build the archive you need very easily in Java code. You can package the .jar's you need and depending on the container you can also build EARs that contain several EJB or utility jars.

     

    Have you seen the introductory guide at http://arquillian.org/guides/shrinkwrap_introduction/#adding_content ?

     

    I'm not aware of any best practices for highly complex apps and I'm not the best person to answer that question. Maybe if you could describe the problem in more detail someone else might be able to help out.

  • 4. Re: Is there an documented Managed Container example connecting to a different JVM?
    Bill Murphy Newbie

    I think I have it.

     

    @Deployment

    public static WebArchive createDeployment() throws ArchiveImportException, IllegalArgumentException, ZipException, IOException {

              WebArchive war = ShrinkWrap.create(ZipImporter.class,"myTestWar.war").

                                         importFrom(newZipFile(newFile("C:"+File.separator+"viewer-web.war"))).

                                         as(WebArchive.class);

              System.out.println(war.toString(true));

              return war;

    }

     

     

    I don't get the ClassNotFoundException and the output confirmed the contents of "myTestWar.war" contained the contents of my original war "viewer-web.war".

     

    I know I get extra, but I can live with that since the code remains compact.

     

    I am now getting the error "ArquillianServletRunner not found", but that is another discussion.

     

    Thanks for your help Gerhard.

  • 5. Re: Is there an documented Managed Container example connecting to a different JVM?
    Gerhard Poul Newbie

    I think the problem with the ArquillianServletRunner might actually be related to the import of the WAR, but I might be wrong. - Is there really so much in the WAR that you need for this particular test that you need to do it this way?

     

    ShrinkWrap has APIs for adding dependent JARs and also whole packages of class files into the archive.

  • 6. Re: Is there an documented Managed Container example connecting to a different JVM?
    Bill Murphy Newbie

    My goal is to hand this to a the QA group to do minimum Java development. They will be testing a number of different Web apps.  Development group will drop a war into a repository and provide some JavaDoc for the API.  If QA can take something as simple as what I wrote above and write their tests based on the Javadoc so much the better, rather than having them do too much rewriting.

     

    Thanks again for your help.