Skip to content

Commit

Permalink
TCK refactoring and cleaning for Arquillian usage
Browse files Browse the repository at this point in the history
Signed-off-by: Ondra Chaloupka <[email protected]>
  • Loading branch information
ochaloup committed Feb 4, 2019
1 parent 57f127f commit b986f0f
Show file tree
Hide file tree
Showing 17 changed files with 870 additions and 1,003 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- This is just for now and will not work if the API has a separate release cycle than the rest. -->
<groupId>org.eclipse.microprofile.lra</groupId>
<artifactId>microprofile-lra-parent</artifactId>
<version>1.0-ARQ-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>microprofile-lra-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<groupId>org.eclipse.microprofile.lra</groupId>
<artifactId>microprofile-lra-parent</artifactId>
<name>MicroProfile Long Running Actions</name>
<version>1.0-ARQ-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
<description>Eclipse MicroProfile LRA Feature - Parent POM</description>
<packaging>pom</packaging>

Expand Down
2 changes: 1 addition & 1 deletion spec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<!-- This is just for now and will not work if the API has a separate release cycle than the rest. -->
<groupId>org.eclipse.microprofile.lra</groupId>
<artifactId>microprofile-lra-parent</artifactId>
<version>1.0-ARQ-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
</parent>

<groupId>org.eclipse.microprofile.lra</groupId>
Expand Down
37 changes: 35 additions & 2 deletions tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.eclipse.microprofile.lra</groupId>
<artifactId>microprofile-lra-parent</artifactId>
<version>1.0-ARQ-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand All @@ -34,11 +34,24 @@

<failOnMissingWebXml>false</failOnMissingWebXml>

<version.cdi-api>1.0-SP1</version.cdi-api>
<version.arquillian>1.4.1.Final</version.arquillian>
<version.json>1.0</version.json>
<version.junit>4.12</version.junit>
<version.microprofile.config>1.3</version.microprofile.config>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.arquillian}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.eclipse.microprofile.lra</groupId>
Expand All @@ -49,10 +62,12 @@
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
Expand All @@ -62,10 +77,28 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>${version.microprofile.config}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>

Expand Down
120 changes: 101 additions & 19 deletions tck/running_the_tck.asciidoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// Copyright (c) 2018 Contributors to the Eclipse Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,38 +15,119 @@

= Running the Microprofile LRA TCK

The TCK provides a JAX-RS participant resource together with a resource for invoking the test sutie.
The TCK uses `JUnit 4` and `Arquillian`.

== Configuration

The LRA TCK suite can be parametrized by following properties, handled in the suite with MicroProfile Config

`lra.tck.timeout.factor`::
timeout factor of default value `1.0`. When set bigger than `1.0` then timeout value will be bigger and waiting time are longer.
When set-up lower then the timeouts will be shorter.
`lra.tck.coordinator.waiting`::
time that the tests waits for the coordinator start-up
`lra.tck.coordinator.hostname`::
hostname where coordinator is available at for TCK suite can run the LRA status from the coordinator
`lra.tck.coordinator.port`::
port where coordinator is available at for TCK suite can run the LRA status from the coordinator

== Dependencies
== Prerequisites for the MicroProfile LRA TCK implementation

To enable the tests in your implementation of this specification you need to add the
following dependency to your build:
* `pom.xml` dependencies set-up
* MicroProfile Config being available in container for the TCK to run
* Arquillian container configured in `arquillian.xml` (tests could manually deploy with `@ArquillianResource Deployer`)
* `ResourceProvider` implemented and registered providing base URL where container starts the deployments

=== Setting-up pom.xml dependencies and running the tests

To enable the tests in your implementation of this specification you need to add the following dependency to your build:

[source, xml]
----
<dependency>
<groupId>org.eclipse.microprofile.lra</groupId>
<artifactId>microprofile-lra-tck</artifactId>
<version>${version.microprofile-lra-tck-to-test}
</version>
<version>${version.microprofile-lra-tck-to-test}</version>
<scope>test</scope>
</dependency>
----

and then start a MicroProfile enabled container that scans this dependency for the JAX-RS resources
that comrise the TCK. The TCK relies upon an instance of `org.eclipse.microprofile.lra.client.LRAClient`
to be injected, via CDI, into the test suite. Your own dependencies should provide an already configured implementation
of LRAClient that can be used by CDI to satisfy the injection point.
Next you need to specify what are tests to be run. You need to inject the TCK suite tests to be run automatically.
Here we use integration tests with `maven failsafe` where dependency to scan is set to include particular test classes.

With this set up, you may trigger the TCK by sending a PUT request to the path tck/all:
[source, xml]
----
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<dependenciesToScan>
<dependency>org.eclipse.microprofile.lra:microprofile-lra-tck</dependency>
</dependenciesToScan>
<includes>
<include>**/*Test*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
----

=== MicroProfile Config being available

The testsuite uses uses configuration while expecting MicroProfile Config is available. The maven coordinates
of config are `org.eclipse.microprofile.config:microprofile-config-api`.

=== Arquillian container

curl -XPUT http://localhost:8080/tck/all?verbose=false | jq
The `arquillian-*.xml` has to define a container that will be starated and managed by Arquillian lifecycle
but that provide a way to deploy and undeploy deployments. That container to be expected with default type `suite`.

where jq is a json pretty printer such as https://stedolan.github.io/jq and the `tck/all` path runs
all tests in the TCK. Setting verbose=true will include the full stack trace of any test failures.

If you want to run a single test replace `all` with the name of the test you wish to run chosen from:
`timeLimit`, `startLRA`, `cancelLRA`, `closeLRA`, `getActiveLRAs`, `getAllLRAs`, `isActiveLRA,
`nestedActivity`, `completeMultiLevelNestedActivity`, `compensateMultiLevelNestedActivity`,
`mixedMultiLevelNestedActivity`, `joinLRAViaHeader`, `join`, `leaveLRA`, `leaveLRAViaAPI`,
`dependentLRA`, `cancelOn`, `cancelOnFamily` or `acceptTest`.
[source, xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<arquillian>
<container qualifier="lra-test-container" default="true" mode="suite">
<configuration>
...
</configuration>
</container>
<arquillian>
----

=== ResourceProvider of base URL endpoint

As TCK deployment provides LRA annotated JAX-RS classes which exposes REST endpoints. The TCK suite needs to call them.
The implementation has to provide the base URL that the endpoint paths can be constructed with.
The implementation does it by using Arquillian `ResoruceProvider` which returns the base `URL`.

The LRA TCK suite uses injection

[source, java]
----
@ArquillianResource
private URL url;
----

The implementation has to define

[source, java]
----
public class TCKImplementationUrlProvider implements io.narayana.lra.tck.arquillian.ResourceProvider {
@Override
public Object lookup(ArquillianResource arquillianResource, Annotation... annotations) {
return new URL("http://localhost:8080");
}
public boolean canProvide(Class<?> type) {
return type.isAssignableFrom(URL.class);
}
}
----

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/package org.eclipse.microprofile.lra.tck;
*******************************************************************************/
package org.eclipse.microprofile.lra.tck;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit b986f0f

Please sign in to comment.