Skip to content

CrateTestServer and CrateTestCluster classes for use as JUnit external resources.

License

Notifications You must be signed in to change notification settings

crate/crate-java-testing

Repository files navigation

CrateDB Java Testing Classes

CrateTestServer and CrateTestCluster classes for use as JUnit external resources.

Both classes download and start CrateDB before test execution and stop CrateDB afterwards.

Setup

JAR files are hosted on Maven Central.

...
<dependencies>
    ...
    <dependency>
        <groupId>io.crate</groupId>
        <artifactId>crate-testing</artifactId>
        <version>...</version>
    </dependency>
</dependencies>
...

You can integrate with Gradle like so:

repositories {
    ...
    mavenCentral()
}

dependencies {
    compile 'io.crate:crate-testing:...'
    ...
}

CrateTestCluster

The CrateTestCluster class is io.crate.testing.CrateTestCluster and extends org.junit.rules.ExternalResources.

Once it's initalized as a JUnit ClassRule, CrateTestCluster will start CrateDB at the beginning of the test run. If CrateDB is not already downloaded, it will be downloaded and extracted.

To start CrateTestCluster, use static factory methods fromURL, fromFile, fromSysProperties or fromVersion.

Example usage in a Java test:

@ClassRule
public static final CrateTestCluster TEST_CLUSTER =
    CrateTestCluster.fromVersion("3.3.2")
    .clusterName("with-builder")
    .numberOfNodes(3)
    .build();

When using the fromSysProperties static factory method, either the crate.testing.from_version or crate.testing.from_url system property must be set. If both system properties are provided, the crate.testing.from_version property is used.

Contributing

This project is primarily maintained by Crate.io, but we welcome community contributions!

See the developer docs and the contribution docs for more information.

Help

Looking for more help?

About

CrateTestServer and CrateTestCluster classes for use as JUnit external resources.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published