Skip to content

Commit

Permalink
updates to openJDK 15
Browse files Browse the repository at this point in the history
  • Loading branch information
robfrank committed Jan 3, 2021
1 parent 200f2c8 commit 6fc57b4
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 98 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
VALIDATE_ALL_CODEBASE: true
DISABLE_ERRORS: true

- name: Set up JDK 14
- name: Set up JDK 15
uses: actions/setup-java@v1
with:
java-version: 14
java-version: 15

- name: Build support Docker images
run: |
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ before_install:
- cd ./src/main/docker/postgresql-dvdrental && ./build.sh && cd -

jdk:
- openjdk14
- openjdk15
12 changes: 4 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2018 - Arcade Analytics LTD (https://arcadeanalytics.com)
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Expand All @@ -15,9 +11,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
<maven.compiler.release>14</maven.compiler.release>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
<maven.compiler.release>15</maven.compiler.release>

<kotlin.version>1.4.21-2</kotlin.version>
<junit.jupiter.version>5.7.0</junit.jupiter.version>
Expand Down Expand Up @@ -80,7 +76,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<release>14</release>
<release>${maven.compiler.source}</release>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.testcontainers.junit.jupiter.Testcontainers;

import java.io.IOException;
import org.testcontainers.utility.DockerImageName;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -32,7 +33,7 @@ public class JavaCustomContainerTest {
private static final Logger LOGGER = LoggerFactory.getLogger(JavaCustomContainerTest.class);

@Container
public static OrientDBContainer container = new OrientDBContainer("robfrank/orientdb");
public static OrientDBContainer container = new OrientDBContainer(DockerImageName.parse("robfrank/orientdb").asCompatibleSubstituteFor("orientdb"));

@BeforeEach
public void setUp(TestInfo info) throws Exception {
Expand Down Expand Up @@ -110,7 +111,7 @@ public void shouldCountPersons(TestInfo info) {

@Test
@Order(2)
public void shouldCountPersonsOnAnotherdb(TestInfo info) {
public void shouldCountPersonsOnAnotherDb(TestInfo info) {
var testName = info.getTestMethod().get().getName();

var dbUrl = container.getServerUrl();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package it.robfrank.testcontainers;

import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.utility.DockerImageName;

public abstract class JavaSingletonContainerTemplate {

static final PostgreSQLContainer POSTGRE_SQL_CONTAINER;

static {
POSTGRE_SQL_CONTAINER = new PostgreSQLContainer();
POSTGRE_SQL_CONTAINER = new PostgreSQLContainer(DockerImageName.parse("postgres:11").asCompatibleSubstituteFor("postgres"));
POSTGRE_SQL_CONTAINER.start();
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package it.robfrank.testcontainers;

import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class JavaSingletonContainerTest extends JavaSingletonContainerTemplate {


@Test
void someTestMethod() throws SQLException {
var conn = DriverManager.getConnection(POSTGRE_SQL_CONTAINER.getJdbcUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class KotlinFromDockerFileTest {

@Container
private val container: GenericContainer<Nothing> = GenericContainer<Nothing>(
ImageFromDockerfile("robfrank/ngnix")
.withFileFromPath("Dockerfile", Paths.get("./src/main/docker/nginx/Dockerfile"))
ImageFromDockerfile("robfrank/ngnix")
.withFileFromPath("Dockerfile", Paths.get("./src/main/docker/nginx/Dockerfile"))
).apply {
withExposedPorts(80)
waitingFor(Wait.forListeningPort())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,42 @@ import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper
import org.assertj.core.api.Assertions.assertThat
import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.testcontainers.containers.GenericContainer
import org.testcontainers.containers.wait.strategy.Wait
import org.testcontainers.junit.jupiter.Container
import org.testcontainers.junit.jupiter.Testcontainers

class KGenericContainer(imageName: String) : GenericContainer<KGenericContainer>(imageName)

@Testcontainers
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class KotlinGenericContainerTest {

@Container
val container: KGenericContainer = KGenericContainer("janusgraph/janusgraph:0.5.0")
.apply {
withExposedPorts(8182)
waitingFor(Wait.defaultWaitStrategy())
}
val container: KGenericContainer = KGenericContainer("janusgraph/janusgraph:0.5")
.apply {
withExposedPorts(8182)
waitingFor(Wait.defaultWaitStrategy())
start()
}

lateinit var cluster: Cluster

@BeforeEach
@BeforeAll
internal fun setUp() {
cluster = Cluster.build(container.containerIpAddress)
.port(container.firstMappedPort)
.serializer(GryoMessageSerializerV3d0(GryoMapper.build()
.addRegistry(JanusGraphIoRegistry.getInstance())))
.credentials("", "")
.maxWaitForConnection(20000)
.create()
.port(container.firstMappedPort)
.serializer(
GryoMessageSerializerV3d0(
GryoMapper.build()
.addRegistry(JanusGraphIoRegistry.getInstance())
)
)
.credentials("", "")
.maxWaitForConnection(20000)
.create()


var client = cluster.connect<Client>().init()
Expand All @@ -45,17 +52,27 @@ internal class KotlinGenericContainerTest {

}

@Test
internal fun `should count all vertices`() {

val client = cluster.connect<Client>().init()

val resultSet = client.submit("g.V().count()")

assertThat(resultSet.one().int).isEqualTo(808)

}

@Test
internal fun `should fetch only ten elements`() {

val client = cluster.connect<Client>().init()

val resultSet = client.submit("g.V().limit(10)").toList()
val resultSet = client.submit("g.V().limit(10)")

assertThat(resultSet).hasSize(10)

}
}

class KGenericContainer(imageName: String) : GenericContainer<KGenericContainer>(imageName)

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.testcontainers.containers.OrientDBContainer
import org.testcontainers.containers.wait.strategy.Wait
import org.testcontainers.junit.jupiter.Container
import org.testcontainers.junit.jupiter.Testcontainers
import org.testcontainers.utility.DockerImageName


/**
Expand All @@ -23,11 +24,11 @@ import org.testcontainers.junit.jupiter.Testcontainers
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class KotlinOrientContainerTest {

private val container = OrientDBContainer("robfrank/orientdb")
.apply {
withDatabaseName("openbeer")
start()
}
private val container = OrientDBContainer( DockerImageName.parse("robfrank/orientdb").asCompatibleSubstituteFor("orientdb"))
.apply {
withDatabaseName("openbeer")
start()
}

private lateinit var db: ODatabaseSession

Expand All @@ -40,42 +41,42 @@ internal class KotlinOrientContainerTest {
internal fun `should select beers vertexes`() {

db.query("select from Beer limit 10")
.use { set ->
set.asSequence()
.toList()
.apply {
assertThat(this).hasSize(10)
}.map { result ->
assertThat(result.isVertex).isTrue()
assertThat(result.hasProperty("name")).isTrue()
assertThat(result.hasProperty("descript")).isTrue()
//map
result.vertex.get()
}.forEach { vertex: OVertex ->
assertThat(vertex.getEdges(ODirection.OUT)).isNotEmpty
}
.use { set ->
set.asSequence()
.toList()
.apply {
assertThat(this).hasSize(10)
}.map { result ->
assertThat(result.isVertex).isTrue()
assertThat(result.hasProperty("name")).isTrue()
assertThat(result.hasProperty("descript")).isTrue()
//map
result.vertex.get()
}.forEach { vertex: OVertex ->
assertThat(vertex.getEdges(ODirection.OUT)).isNotEmpty
}


}
}
}

@Test
internal fun `should select breweries`() {

db.query("select from Brewery limit 10")
.use { set ->
set.asSequence()
.toList()
.apply {
assertThat(this).hasSize(10)
}.map { result ->
assertThat(result.isVertex).isTrue()
assertThat(result.hasProperty("name")).isTrue()
assertThat(result.hasProperty("descript")).isTrue()
//map
result.vertex.get()
}
.use { set ->
set.asSequence()
.toList()
.apply {
assertThat(this).hasSize(10)
}.map { result ->
assertThat(result.isVertex).isTrue()
assertThat(result.hasProperty("name")).isTrue()
assertThat(result.hasProperty("descript")).isTrue()
//map
result.vertex.get()
}

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test
import org.testcontainers.containers.PostgreSQLContainer
import org.testcontainers.junit.jupiter.Container
import org.testcontainers.junit.jupiter.Testcontainers
import org.testcontainers.utility.DockerImageName
import java.sql.DriverManager


Expand All @@ -19,31 +20,32 @@ internal class KotlinPostgresDvdRentalTest {


@Container
val container = PostgreSQLContainer<Nothing>("robfrank/postgres-dvdrental")
.apply {
withUsername("postgres")
withPassword("postgres")
}
val container = PostgreSQLContainer<Nothing>(DockerImageName.parse("robfrank/postgres-dvdrental").asCompatibleSubstituteFor("postgres"))
.apply {
withUsername("postgres")
withPassword("postgres")
}

@Test
internal fun `should query movies`() {
container.withDatabaseName("dvdrental")

DriverManager.getConnection(container.jdbcUrl, container.username, container.password).use { conn ->
DriverManager.getConnection(container.jdbcUrl, container.username, container.password)
.use { conn ->

conn.createStatement().use { stmt ->

conn.createStatement().use { stmt ->
stmt.executeQuery("SELECT count(*) AS movies from Film").use { resultSet ->

stmt.executeQuery("SELECT count(*) AS movies from Film").use { resultSet ->
resultSet.next()

resultSet.next()
Assertions.assertThat(resultSet.getInt("movies")).isEqualTo(1000)

Assertions.assertThat(resultSet.getInt("movies")).isEqualTo(1000)
}

}

}

}

}
}
18 changes: 9 additions & 9 deletions src/test/kotlin/it/robfrank/testcontainers/KotlinSeleniumTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class KotlinSeleniumTest {

@Container
private val chrome: BrowserWebDriverContainer<Nothing> = BrowserWebDriverContainer<Nothing>()
.apply {
withDesiredCapabilities(DesiredCapabilities.chrome())
withRecordingMode(RECORD_ALL, File("target"))
start()
}
.apply {
withCapabilities(DesiredCapabilities.chrome())
withRecordingMode(RECORD_ALL, File("target"))
start()
}

@Test
fun simplePlainSeleniumTest() {
Expand All @@ -37,11 +37,11 @@ class KotlinSeleniumTest {
otherPage.click()

val expectedTextFound = driver.findElementsByCssSelector("p")
.asSequence()
.any { element -> "meme" in element.text }
.asSequence()
.any { element -> "meme" in element.text }

assertThat(expectedTextFound)
.`as`("The word 'meme' is found on a page about rickrolling")
.isTrue()
.`as`("The word 'meme' is found on a page about rickrolling")
.isTrue()
}
}
Loading

0 comments on commit 6fc57b4

Please sign in to comment.