embedded-influx-junit4

JUnit 4 support for embedded InfluxDB

License

License

Categories

Categories

JUnit Unit Testing
GroupId

GroupId

com.bendb.influx
ArtifactId

ArtifactId

embedded-influx-junit4
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

embedded-influx-junit4
JUnit 4 support for embedded InfluxDB
Project URL

Project URL

https://github.com/benjamin-bader/embedded-influx
Source Code Management

Source Code Management

https://github.com/benjamin-bader/embedded-influx/

Download embedded-influx-junit4

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
com.bendb.influx : embedded-influx jar 0.2.0
junit : junit jar 4.12

test (3)

Group / Artifact Type Version
org.influxdb : influxdb-java jar 2.14
io.kotlintest : kotlintest-assertions jar 3.1.10
org.jetbrains.kotlin : kotlin-reflect jar 1.3.0

Project Modules

There are no modules declared in this project.

embedded-influx

Embedded InfluxDB Server for Tests

Build Status

The currently bundled version of influxd is 1.7.0.

Add to your project like so:

dependencies {
  // If you just want to use InfluxServer manually:
  testImplementation 'com.bendb.influx:embedded-influx:0.2.0'

  // Or...
  // If you want to use the JUnit 4 InfluxServerRule:
  testImplementation 'com.bendb.influx:embedded-influx-junit4:0.2.0'

  // Or...
  // If you want a JUnit 5 Extension:
  testImplementation 'com.bendb.influx:embedded-influx-junit5:0.2.0'
}

Use like so:

val server = InfluxServer.builder()
        .port(8086)
        .build()
        .start()


val client = InfluxDBFactory.connect(server.url)

client.ping() // etc

// When you're done, shut it down
server.close()

JUnit 4

We ship a @Rule that starts a local server before each test, and stops it afterwards:

class SomeTest {
  @get:Rule val serverRule = InfluxServerRule()

  @Test fun serverIsUp() {
    InfluxDBFactory.connect(serverRule.url).use { client ->
      val pong = client.ping()
      pong?.isGood shouldBe true
    }
  }
}

JUnit 5

We also ship a JUnit 5 extension, which does the same thing as the rule described above:

@ExtendWith(InfluxServerExtension::class)
class AnotherTest {
  private lateinit var server: InfluxServer
  
  @Test fun serverIsUp() {
    InfluxDBFactory.connect(serverRule.url).use { client ->
      val pong = client.ping()
      pong?.isGood shouldBe true
    }
  }
}

Copyright 2018-2019 Benjamin Bader Released under the Apache 2.0 License

Versions

Version
0.2.0
0.1.2
0.1.1
0.1.0