Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions modules/pulsar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ description = "Testcontainers :: Pulsar"
dependencies {
api project(':testcontainers')

testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0'

testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.13.4'
testImplementation platform("org.apache.pulsar:pulsar-bom:4.0.5")
testImplementation 'org.apache.pulsar:pulsar-client'
testImplementation 'org.apache.pulsar:pulsar-client-admin'
Expand All @@ -14,3 +18,7 @@ tasks.japicmp {
"org.testcontainers.containers.PulsarContainer"
]
}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
package org.testcontainers.containers;

import org.apache.pulsar.client.admin.PulsarAdmin;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.testcontainers.utility.DockerImageName;

@RunWith(Parameterized.class)
public class CompatibleApachePulsarImageTest extends AbstractPulsar {
class CompatibleApachePulsarImageTest extends AbstractPulsar {

@Parameterized.Parameters(name = "{0}")
public static String[] params() {
return new String[] { "apachepulsar/pulsar:3.0.0", "apachepulsar/pulsar-all:3.0.0" };
}

@Parameterized.Parameter
public String imageName;

@Test
public void testUsage() throws Exception {
try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(this.imageName));) {
@ParameterizedTest
@MethodSource("params")
void testUsage(String imageName) throws Exception {
try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(imageName));) {
pulsar.start();
final String pulsarBrokerUrl = pulsar.getPulsarBrokerUrl();

testPulsarFunctionality(pulsarBrokerUrl);
}
}

@Test
public void testTransactions() throws Exception {
try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(this.imageName)).withTransactions();) {
@ParameterizedTest
@MethodSource("params")
void testTransactions(String imageName) throws Exception {
try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(imageName)).withTransactions();) {
pulsar.start();

try (PulsarAdmin pulsarAdmin = PulsarAdmin.builder().serviceHttpUrl(pulsar.getHttpServiceUrl()).build()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.admin.PulsarAdminException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.testcontainers.utility.DockerImageName;

import java.time.Duration;

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

public class PulsarContainerTest extends AbstractPulsar {
class PulsarContainerTest extends AbstractPulsar {

private static final DockerImageName PULSAR_IMAGE = DockerImageName.parse("apachepulsar/pulsar:3.0.0");

@Test
public void testUsage() throws Exception {
void testUsage() throws Exception {
try (
// do not use PULSAR_IMAGE to make the doc looks easier
// constructorWithVersion {
Expand All @@ -32,7 +32,7 @@ public void testUsage() throws Exception {
}

@Test
public void envVarsUsage() throws Exception {
void envVarsUsage() throws Exception {
try (
// constructorWithEnv {
PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)
Expand All @@ -45,7 +45,7 @@ public void envVarsUsage() throws Exception {
}

@Test
public void customClusterName() throws Exception {
void customClusterName() throws Exception {
try (
PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)
.withEnv("PULSAR_PREFIX_clusterName", "tc-cluster");
Expand All @@ -56,7 +56,7 @@ public void customClusterName() throws Exception {
}

@Test
public void shouldNotEnableFunctionsWorkerByDefault() throws Exception {
void shouldNotEnableFunctionsWorkerByDefault() throws Exception {
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)) {
pulsar.start();

Expand All @@ -68,7 +68,7 @@ public void shouldNotEnableFunctionsWorkerByDefault() throws Exception {
}

@Test
public void shouldWaitForFunctionsWorkerStarted() throws Exception {
void shouldWaitForFunctionsWorkerStarted() throws Exception {
try (
// constructorWithFunctionsWorker {
PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse("apachepulsar/pulsar:3.0.0"))
Expand All @@ -84,7 +84,7 @@ public void shouldWaitForFunctionsWorkerStarted() throws Exception {
}

@Test
public void testTransactions() throws Exception {
void testTransactions() throws Exception {
try (
// constructorWithTransactions {
PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE).withTransactions();
Expand All @@ -100,7 +100,7 @@ public void testTransactions() throws Exception {
}

@Test
public void testTransactionsAndFunctionsWorker() throws Exception {
void testTransactionsAndFunctionsWorker() throws Exception {
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE).withTransactions().withFunctionsWorker()) {
pulsar.start();

Expand All @@ -113,7 +113,7 @@ public void testTransactionsAndFunctionsWorker() throws Exception {
}

@Test
public void testClusterFullyInitialized() throws Exception {
void testClusterFullyInitialized() throws Exception {
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)) {
pulsar.start();

Expand All @@ -124,7 +124,7 @@ public void testClusterFullyInitialized() throws Exception {
}

@Test
public void testStartupTimeoutIsHonored() {
void testStartupTimeoutIsHonored() {
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE).withStartupTimeout(Duration.ZERO)) {
assertThatThrownBy(pulsar::start)
.hasRootCauseMessage("Precondition failed: timeout must be greater than zero");
Expand Down
Loading