//
// 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;
```

An example provider for that resource:

```
public class URIProvider implements ResourceProvider {

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

    @Override
    public boolean canProvide(Class<?> type) {
        return type.isAssignableFrom(URI.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`


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

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