embedded-influx

InfluxDB embedded server for unit tests

License

License

GroupId

GroupId

com.bendb.influx
ArtifactId

ArtifactId

embedded-influx
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

embedded-influx
InfluxDB embedded server for unit tests
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

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.0

test (5)

Group / Artifact Type Version
org.influxdb : influxdb-java jar 2.14
junit : junit jar 4.12
io.kotlintest : kotlintest-assertions jar 3.1.10
org.jetbrains.kotlin : kotlin-reflect jar 1.3.0
com.nhaarman.mockitokotlin2 : mockito-kotlin jar 2.0.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