Skip to content

Commit

Permalink
Change server to runtime or instance (#134)
Browse files Browse the repository at this point in the history
* Change server to runtime or instance

* Update README.adoc

* Update README.adoc

* Change server to runtime or instance
  • Loading branch information
gkwan-ibm authored Aug 16, 2023
1 parent 7385590 commit 698d880
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019, 2022 IBM Corporation and others.
// Copyright (c) 2019, 2023 IBM Corporation and others.
// Licensed under Creative Commons Attribution-NoDerivatives
// 4.0 International (CC BY-ND 4.0)
// https://creativecommons.org/licenses/by-nd/4.0/
Expand Down Expand Up @@ -32,7 +32,7 @@ You will learn how to develop tests for your microservices by using the https://

You will develop Arquillian tests that use JUnit as the runner and build your tests with Maven using the Liberty Maven plug-in. This technique simplifies the process of managing Arquillian dependencies and the setup of your Arquillian managed container.

You will work with an `inventory` microservice, which stores information about various systems. The `inventory` service communicates with the `system` service on a particular host to retrieve its system properties and store them. You will develop functional and integration tests for the microservices. You will also learn about the Maven and server configurations so that you can run your tests on Open Liberty with the Arquillian Liberty Managed container.
You will work with an `inventory` microservice, which stores information about various systems. The `inventory` service communicates with the `system` service on a particular host to retrieve its system properties and store them. You will develop functional and integration tests for the microservices. You will also learn about the Maven and Liberty configurations so that you can run your tests on Open Liberty with the Arquillian Liberty Managed container.

[role="command"]
include::{common-includes}/gitclone.adoc[]
Expand Down Expand Up @@ -64,7 +64,7 @@ include::finish/src/test/java/it/io/openliberty/guides/inventory/InventoryArquil

Notice that the JUnit Arquillian runner runs the tests instead of the standard JUnit runner. The [hotspot=RunWith file=0]`@RunWith` annotation preceding the class tells JUnit to run the tests by using Arquillian.

The method annotated by [hotspot=Deployment file=0]`@Deployment` defines the content of the web archive, which is going to be deployed onto the Open Liberty server. The tests are either run on or against the server. The [hotspot=Testable file=0]`testable = true` attribute enables the deployment to run the tests "in container", that is the tests are run on the server.
The method annotated by [hotspot=Deployment file=0]`@Deployment` defines the content of the web archive, which is going to be deployed onto the Open Liberty. The tests are either run on or against the Liberty instance. The [hotspot=Testable file=0]`testable = true` attribute enables the deployment to run the tests "in container", that is the tests are run on the Liberty instance.

pom.xml
[source, xml, linenums, indent=0, role='code_column']
Expand All @@ -84,11 +84,11 @@ Contexts and Dependency Injection (CDI) is used to inject an instance of the [ho

The injected [hotspot=InventoryResource file=0]`InventoryResource` instance is then tested by the [hotspot=testInventoryResourceFunctions file=0]`testInventoryResourceFunctions` method. This test case calls the [hotspot=listContents file=0]`listContents()` method to get all systems that are stored in this inventory and verifies that `localhost` is the only system being found. Notice the functional test case doesn't store any system in the inventory, the `localhost` system is from the endpoint test case that ran before this test case. The [hotspot=InSequence1 hotspot=InSequence2 file=0]`@InSequence` Arquillian annotation guarantees the test sequence. The sequence is important for the two tests, as the results in the first test impact the second one.

The test cases are ready to run. You will configure the Maven build and the Liberty application server to run them.
The test cases are ready to run. You will configure the Maven build and the Liberty configuration to run them.

== Configuring Arquillian with Liberty

Configure your build to use the Arquillian Liberty Managed container and set up your Open Liberty server to run your test cases by configuring the `server.xml` file.
Configure your build to use the Arquillian Liberty Managed container and set up your Open Liberty to run your test cases by configuring the `server.xml` file.

=== Configuring your test build

Expand All @@ -110,16 +110,16 @@ Let's look into each of the required elements for this configuration.

You need the [hotspot=arquillian-bom]`arquillian-bom` Bill of Materials. It's a Maven artifact that defines the versions of Arquillian dependencies to make dependency management easier.

The [hotspot=arquillian-liberty-managed-junit]`arquillian-liberty-managed-junit` dependency bundle, which includes all the core dependencies, is required to run the Arquillian tests on a managed Liberty container that uses JUnit. You can learn more about the https://github.com/OpenLiberty/arquillian-liberty-dependencies[Arquillian Liberty dependency bundles^]. The [hotspot=shrinkwrap-api]`shrinkwrap-api` dependency allows you to create your test archive, which is packaged into a WAR file and deployed to the Open Liberty server.
The [hotspot=arquillian-liberty-managed-junit]`arquillian-liberty-managed-junit` dependency bundle, which includes all the core dependencies, is required to run the Arquillian tests on a managed Liberty container that uses JUnit. You can learn more about the https://github.com/OpenLiberty/arquillian-liberty-dependencies[Arquillian Liberty dependency bundles^]. The [hotspot=shrinkwrap-api]`shrinkwrap-api` dependency allows you to create your test archive, which is packaged into a WAR file and deployed to the Open Liberty.

The [hotspot=maven-failsafe-plugin]`maven-failsafe-plugin` artifact runs your Arquillian integration tests by using JUnit.

Lastly, specify the [hotspot=liberty-maven-plugin]`liberty-maven-plugin` configuration that defines your Open Liberty runtime configuration. When the application runs in an Arquillian Liberty managed container, the name of the war file is used as the context root of the application. You can pass context root information to the application and customize the container by using the [hotspot=arquillianProperties]`arquillianProperties` configuration. To learn more about the `arquillianProperties` configuration, see the https://github.com/OpenLiberty/liberty-arquillian/blob/main/liberty-managed/README.md#configuration[Arquillian Liberty Managed documentation^].


=== Configuring the server.xml file
=== Configuring Liberty's `server.xml` configuration file

Now that you're done configuring your Maven build, set up your Open Liberty server to run your test cases by configuring the [hotspot]`server.xml` file.
Now that you're done configuring your Maven build, set up your Open Liberty to run your test cases by configuring the [hotspot]`server.xml` configuration file.

Take a look at the [hotspot]`server.xml` file.

Expand All @@ -140,7 +140,7 @@ The [hotspot=localConnector]`localConnector` feature is required by the Arquilli

== Running the tests

It's now time to build and run your Arquillian tests. Navigate to the `start` directory. First, run the Maven command to package the application. Then, run the `liberty-maven-plugin` goals to create the application server, install the features, and deploy the application to the server. The `configure-arquillian` goal configures your Arquillian container. You can learn more about this goal in the https://github.com/OpenLiberty/ci.maven/blob/main/docs/configure-arquillian.md[configure-arquillian goal documentation^].
It's now time to build and run your Arquillian tests. Navigate to the `start` directory. First, run the Maven command to package the application. Then, run the `liberty-maven-plugin` goals to create the Liberty instance, install the features, and deploy the application to the instance. The `configure-arquillian` goal configures your Arquillian container. You can learn more about this goal in the https://github.com/OpenLiberty/ci.maven/blob/main/docs/configure-arquillian.md[configure-arquillian goal documentation^].

ifndef::cloud-hosted[]
[role="command"]
Expand All @@ -167,9 +167,9 @@ Now, you can run your Arquillian tests with the Maven `integration-test` goal:
mvn failsafe:integration-test
```

In the test output, you can see that the application server launched, and that the web archive, `arquillian-managed`, started as an application in the server. You can also see that the tests are running and that the results are reported.
In the test output, you can see that the Liberty instance launched, and that the web archive, `arquillian-managed`, started as an application in the instance. You can also see that the tests are running and that the results are reported.

After the tests stop running, the test application is automatically undeployed and the server shuts down. You should then get a message indicating that the build and tests are successful.
After the tests stop running, the test application is automatically undeployed and the instance shuts down. You should then get a message indicating that the build and tests are successful.

[source, role="no_copy"]
----
Expand Down
2 changes: 1 addition & 1 deletion finish/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.7.1</version>
<version>3.8.2</version>
<configuration>
<!-- tag::arquillianProperties[] -->
<arquillianProperties>
Expand Down
2 changes: 1 addition & 1 deletion start/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.7.1</version>
<version>3.8.2</version>
<configuration>
<!-- tag::arquillianProperties[] -->
<arquillianProperties>
Expand Down

0 comments on commit 698d880

Please sign in to comment.