Skip to content

Commit

Permalink
issue eclipse#94: TCK refactoring for Arquillian
Browse files Browse the repository at this point in the history
Signed-off-by: Ondra Chaloupka <ochaloup@redhat.com>

Applying changes based on issue59
  • Loading branch information
ochaloup committed Feb 6, 2019
1 parent f761e3e commit 72f5d45
Show file tree
Hide file tree
Showing 14 changed files with 831 additions and 1,010 deletions.
35 changes: 34 additions & 1 deletion tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
91 changes: 72 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,90 @@

= 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.base.url`::
The URL where the TCK suite deployment is exposed at. The TCK suite will construct path based on this URL.
The default base URL is `http://localhost:8180`.
`lra.tck.timeout.factor`::
Timeout factor adjust timeout values used in the TCK suite. The default value is `1.0`.
When set bigger than `1.0` then timeout value will be bigger and waiting time is longer.
When set-up lower then the timeouts will be shorter.
Thus on slower machines it's expected longer timeouts will be needed. For example if test expects
some waiting time to be 10 seconds and this factor is set to `1.5` then the result waiting time is 15 seconds.
`lra.http.recovery.host`, `lra.http.recovery.port`, `lra.http.recovery.path`::
Hostname, port and path for the recovery endpoint that will be contacted in tests checking recovery capabilities.

== 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 are set-up
* the LRA TCK suite requires MicroProfile Config
* a default Arquillian container is configured in `arquillian.xml` (tests manually deploy with use of `@ArquillianResource Deployer`)
* implementation provides one implementation of `org.eclipse.microprofile.lra.client.LRAClient` as it's injected by TCK suite
* implementation has to provide one implementation of `org.eclipse.microprofile.lra.tck.spi.ManagementSPI`. This is an interface
with definition of util methods used by the TCK suite for its run.

=== 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

curl -XPUT http://localhost:8080/tck/all?verbose=false | jq
The testsuite uses configuration while expecting MicroProfile Config is available. The maven coordinates
of config are `org.eclipse.microprofile.config:microprofile-config-api`.

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.
=== Arquillian container

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`.
The `arquillian-*.xml` has to define a container that will be started and managed by Arquillian lifecycle
but that provide a way to deploy and undeploy deployments. That container to be expected with default type `suite`.


[source, xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<arquillian>
<container qualifier="lra-test-container" default="true" mode="suite">
<configuration>
...
</configuration>
</container>
<arquillian>
----
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 72f5d45

Please sign in to comment.