This is an automated email from the ASF dual-hosted git repository. jgallimore pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/master by this push: new 1a4b3d9 TOMEE-2390: Added README.adoc for the multiple-tomee-arquillian example. new e100555 Merge pull request #359 from cotnic/TOMEE-2390 1a4b3d9 is described below commit 1a4b3d9ea870fb6c8b49bc3fad7502cff7e7f949 Author: cotnic <mi...@cotnic.com> AuthorDate: Sun Jan 6 10:49:31 2019 +0100 TOMEE-2390: Added README.adoc for the multiple-tomee-arquillian example. --- examples/multiple-tomee-arquillian/README.adoc | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/examples/multiple-tomee-arquillian/README.adoc b/examples/multiple-tomee-arquillian/README.adoc new file mode 100644 index 0000000..adfdae1 --- /dev/null +++ b/examples/multiple-tomee-arquillian/README.adoc @@ -0,0 +1,57 @@ += Multiple TomEE Arquillian +:index-group: Arquillian +:jbake-type: page +:jbake-status: published + +This example shows how to deploy two different applications if the need for it shows. +That sometimes happens if we need communication between two different web applications. In our +example we will deploy two applications web resources and test their content. + +== Run the application: + +[source, bash] +---- +mvn clean test +---- + +This command runs the test where we have specified the two deployments we want to +test. The test deploys two applications on which we test their content +that we defined as web resource in our `createDep1()` and createDep2()` method. + +== @Deployment annotation + +If we want to have two different applications running in the same test it's as +simple as adding two different `@Deployment` annotated methods to our test class. + +[source,java] +---- +@Deployment(name = "war1", testable = false) +@TargetsContainer("tomee-1") +public static WebArchive createDep1() { + return ShrinkWrap.create(WebArchive.class, "application1.war") + .addAsWebResource(new StringAsset("Hello from TomEE 1"), "index.html"); +} + +@Deployment(name = "war2", testable = false) +@TargetsContainer("tomee-2") +public static WebArchive createDep2() { + return ShrinkWrap.create(WebArchive.class, "application2.war") + .addAsWebResource(new StringAsset("Hello from TomEE 2"), "index.html"); +} +---- + +== Define `Deployment` context + +For each test method we have to define on which `Deployment` context the tests +should be run. For that we use the `@OperateOnDeployment("war2")` annotation on our +test method. + +[source,java] +---- +@Test +@OperateOnDeployment("war2") +public void testRunningInDep2(@ArquillianResource final URL url) throws IOException { + final String content = IO.slurp(url); + assertEquals("Hello from TomEE 2", content); +} +---- \ No newline at end of file