//
// Copyright (c) 2016-2017 Eclipse Microprofile Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// 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.
//

= Running the MicroProfile Health TCK

The TCK uses `TestNG` and `Arquillian`.

== Health URL

Implementation of the MicroProfile Health TCK need to provide a reference to the `<HOST>` and `<PORT>` of their implementation, provided through an `@ArquillianResource`, i.e the tests leverage:

```
 @ArquillianResource
 private URI uri;
```

Arquillian has `URIResourceProvider` to inject test application root to `URI`.   Create a class that extends `URIResourceProvider` and override `lookup` method.  For example:

```
public class TCKURIResourceProvider extends URIResourceProvider {

    @Override
    public Object lookup(ArquillianResource arquillianResource, Annotation... annotations) {
        return URI.create("http://localhost:8080");
    }

}
```

Override `URIResourceProvider` with `TCKURIResourceProvider` using `LoadableExtension.ExtensionBuilder.override(ResourceProvider.class, URIResourceProvider.class, TCKURIResourceProvider.class);`

For any test runs, the TCK will append `/health`, so that a fully qualified URL to your health impoementation looks like `http://<HOST:<PORT>/health`

== Hardware Requirements

All systems should meet the following recommended hardware requirements:

* CPU running at 2.0 GHz or higher
* 4 GB of RAM or more

== Software Requirements

You can run this TCK on platforms running the Solaris, Linux, Windows, and Mac OS with the following software installed:

* Maven
* JDK8+

== Dependencies

To enable the tests in your project you need to add the following dependency to your build:

[source, xml]
----
    <dependency>
      <groupId>org.eclipse.microprofile.health</groupId>
      <artifactId>microprofile-health-tck</artifactId>
      <version>1.0-SNAPSHOT</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.microprofile.health</groupId>
      <artifactId>microprofile-health-api</artifactId>
      <version>1.0-SNAPSHOT</version>
      <scope>provided</scope>
    </dependency>
----

== Configuration in Apache Maven pom.xml

The TCK tests are provided by the `org.eclipse.microprofile.health:microprofile-health-tck` Jar file.

If you use Apache Maven then the tests are run via the `maven-surefire-plugin`, you need to add a `<dependenciesToScan>` configuration to scan the `org.eclipse.microprofile.health:microprofile-health-tck` and run its tests.

[source, xml]
----
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <dependenciesToScan>
                    <dependency>org.eclipse.microprofile.health:microprofile-health-tck</dependency>
                </dependenciesToScan>
            </configuration>
        </plugin>
    </plugins>
</build>
----

== Disabling default vendor procedures

As TCK asserts check also the number of returned health procedures, the TCK MUST run
with the configuration property `mp.health.disable-default-procedures` set to `true`.

== Examples

The https://github.com/jmesnil/wildfly-microprofile-health[WildFly implementation] of the MicroProfile Health runs the TCK in its https://github.com/jmesnil/wildfly-microprofile-health/tree/master/tck[tck module].
