AssortmentOfJUnitRules

Useful assortment of JUnit rules for integration testing

License

License

Modified BSD License
Categories

Categories

JUnit Unit Testing
GroupId

GroupId

com.github.mlk
ArtifactId

ArtifactId

assortmentofjunitrules
Last Version

Last Version

1.5.39
Release Date

Release Date

Type

Type

jar
Description

Description

AssortmentOfJUnitRules
Useful assortment of JUnit rules for integration testing
Project URL

Project URL

http://github.com/mlk/AssortmentOfJUnitRules
Source Code Management

Source Code Management

http://github.com/mlk/AssortmentOfJUnitRules/

Download assortmentofjunitrules

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.mlk/assortmentofjunitrules/ -->
<dependency>
    <groupId>com.github.mlk</groupId>
    <artifactId>assortmentofjunitrules</artifactId>
    <version>1.5.39</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mlk/assortmentofjunitrules/
implementation 'com.github.mlk:assortmentofjunitrules:1.5.39'
// https://jarcasting.com/artifacts/com.github.mlk/assortmentofjunitrules/
implementation ("com.github.mlk:assortmentofjunitrules:1.5.39")
'com.github.mlk:assortmentofjunitrules:jar:1.5.39'
<dependency org="com.github.mlk" name="assortmentofjunitrules" rev="1.5.39">
  <artifact name="assortmentofjunitrules" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mlk', module='assortmentofjunitrules', version='1.5.39')
)
libraryDependencies += "com.github.mlk" % "assortmentofjunitrules" % "1.5.39"
[com.github.mlk/assortmentofjunitrules "1.5.39"]

Dependencies

compile (1)

Group / Artifact Type Version
junit : junit jar 4.12

test (12)

Group / Artifact Type Version
org.postgresql : postgresql jar 9.4.1212
org.apache.hadoop : hadoop-minicluster jar 2.8.0
de.flapdoodle.embed : de.flapdoodle.embed.mongo jar 2.0.0
org.mongodb : mongodb-driver jar 3.0.2
org.apache.spark : spark-core_2.11 jar 2.1.1
org.apache.hadoop : hadoop-client jar 2.8.0
com.hierynomus : sshj jar 0.21.1
io.findify : s3mock_2.11 jar 0.2.0
com.amazonaws » DynamoDBLocal jar 1.11.0.1
org.apache.sshd : sshd-core jar 1.4.0
ru.yandex.qatools.embed : postgresql-embedded jar 2.2
com.amazonaws : aws-java-sdk-s3 jar 1.11.123

Project Modules

There are no modules declared in this project.

AssortmentOfJUnitRules

Build Status Maven Central

This is a small selection of useful (for me) rules for building integration tests with AWS, Hadoop, Spark and Mongo. These rules can be used together to start up a mini environment required for a test.

The package has only one hard dependency - JUnit. All sub-rules will expect their requirements to be provided.

Each rule has a JUnit test which also serves as an example.

How to use

Utilizing your dependency framework of choice (Maven shown below) include both it and the rules dependencies in your applications build system.

<dependency>
  <groupId>com.github.mlk</groupId>
  <artifactId>assortmentofjunitrules</artifactId>
  <version>1.5.**</version>
</dependency>

Check above for the most recent release.

SparkRule

Starts up and shuts down a local Spark context between JUnit tests. Required spark-core.

Maven example:

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.11</artifactId>
            <version>1.4.1</version>
        </dependency>

Example

HadoopDFSRule

Starts up and shuts down a local Hadoop DFS cluster between JUnit tests. Requires hadoop-minicluster.

Maven example:

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-minicluster</artifactId>
            <version>2.8.0</version>
        </dependency>

Example

HadoopYarnRule

Starts up and shuts down a local Hadoop DFS and YARN cluster between JUnit tests. Requires hadoop-minicluster.

Example

MongoRule

Uses Flapdoodles' Embed Mongo to start up a Mongo server before each test and shut it down after each test. Requires de.flapdoodle.embed.mongo

Maven Example:

        <dependency>
            <groupId>de.flapdoodle.embed</groupId>
            <artifactId>de.flapdoodle.embed.mongo</artifactId>
            <version>2.0.0</version>
        </dependency>

Example

SftpRule

Uses Apache Mina SSHd to start up a SFTP server before each test and shut it down after each test. Requires org.apache.sshd.sshd-core

Maven Example:

        <dependency>
            <groupId>org.apache.sshd</groupId>
            <artifactId>sshd-core</artifactId>
            <version>1.4.0</version>
        </dependency>

Example

S3MockRule

Use S3Mock to create a S3 mock server at before each test and shut it down after each test. Requires io.findify.s3mock_2.11

Maven Example:

      <dependency>
          <groupId>io.findify</groupId>
          <artifactId>s3mock_2.11</artifactId>
          <version>0.2.0</version>
      </dependency>

Example

LocalDynamoDbRule

Uses the Local Amazon DynamoDB to create a in-memory, local DynamoDB instance. This rule handles all the SQLite native libraries stuff for you.

Maven Example:

<!--Dependency:-->
<dependencies>
    <dependency>
       <groupId>com.amazonaws</groupId>
       <artifactId>DynamoDBLocal</artifactId>
       <version>[1.11,2.0)</version>
    </dependency>
</dependencies>
<!--Custom repository:-->
<repositories>
    <repository>
       <id>dynamodb-local-oregon</id>
       <name>DynamoDB Local Release Repository</name>
       <url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</url>
    </repository>
</repositories>

Example

HttpDynamoDbRule

Uses the Local Amazon DynamoDB to create a in-memory, local DynamoDB instance running over HTTP. This rule handles all the SQLite native libraries stuff for you.

Maven Example:

<!--Dependency:-->
<dependencies>
    <dependency>
       <groupId>com.amazonaws</groupId>
       <artifactId>DynamoDBLocal</artifactId>
       <version>[1.11,2.0)</version>
    </dependency>
</dependencies>
<!--Custom repository:-->
<repositories>
    <repository>
       <id>dynamodb-local-oregon</id>
       <name>DynamoDB Local Release Repository</name>
       <url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</url>
    </repository>
</repositories>

Example Example of it in use

PostgresRule

Uses Embedded PostgreSQL Server to start up a Postgres server during each test.

Maven Example:

      <dependency>
          <groupId>ru.yandex.qatools.embed</groupId>
          <artifactId>postgresql-embedded</artifactId>
          <version>2.2</version>
      </dependency>

Example

ElasticSearchRule

Uses Embedded ElasticSearch to start up a ElasticSearch server during each test.

Maven Example:

    <dependency>
        <groupId>pl.allegro.tech</groupId>
        <artifactId>embedded-elasticsearch</artifactId>
        <version>2.7.0</version>
        <scope>test</scope>
    </dependency>

Example

Helper Rules

SpringDatabaseRule

Sets up all the Spring Boot stuff when using Spring Boot and a supported database. This must be a @ClassRule.

SpringElasticSearchRule

Sets up all the Spring Boot stuff when using Spring Boot and a Elastic Search. This must be a @ClassRule.

NativeLibraryRule

Finds native libraries in your classpath and moves them to a single folder. See the DynamoDB rules for an example.

Versions

Version
1.5.39
1.5.38
1.5.37
1.5.36
1.5.35
1.5.34
1.5.33
1.5.32
1.5.29
1.5.28
1.5.25
1.5.24
1.5.23
1.5.22
1.2.1
1.2
1.1
1.0