Skip to content

Commit ec95b8f

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 1630f95 + c7622b4 commit ec95b8f

File tree

149 files changed

+1516
-1838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+1516
-1838
lines changed

core/build.gradle

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ shadowJar {
3030
}
3131

3232
task jarFileTest(type: Test) {
33+
useJUnitPlatform()
3334
testClassesDirs = sourceSets.jarFileTest.output.classesDirs
3435
classpath = sourceSets.jarFileTest.runtimeClasspath
3536

@@ -48,13 +49,33 @@ tasks.japicmp {
4849

4950
classExcludes = [
5051
"org.testcontainers.utility.RyukResourceReaper",
52+
"org.testcontainers.containers.FailureDetectingExternalResource",
53+
"org.testcontainers.containers.ComposeContainer",
54+
"org.testcontainers.containers.DockerComposeContainer",
55+
"org.testcontainers.containers.GenericContainer"
5156
]
5257

5358
methodExcludes = [
5459
"org.testcontainers.containers.Container#getDockerClient()",
5560
"org.testcontainers.containers.ContainerState#getDockerClient()",
5661
"org.testcontainers.containers.ContainerState#execInContainer(org.testcontainers.containers.ExecConfig)",
57-
"org.testcontainers.containers.ContainerState#execInContainer(java.nio.charset.Charset,org.testcontainers.containers.ExecConfig)"
62+
"org.testcontainers.containers.ContainerState#execInContainer(java.nio.charset.Charset,org.testcontainers.containers.ExecConfig)",
63+
"org.testcontainers.containers.ComposeContainer#apply(org.junit.runners.model.Statement, org.junit.runner.Description)",
64+
"org.testcontainers.containers.ComposeContainer#failed(java.lang.Throwable, org.junit.runner.Description)",
65+
"org.testcontainers.containers.ComposeContainer#finished(org.junit.runner.Description)",
66+
"org.testcontainers.containers.ComposeContainer#starting(org.junit.runner.Description)",
67+
"org.testcontainers.containers.ComposeContainer#succeeded(org.junit.runner.Description)",
68+
"org.testcontainers.containers.DockerComposeContainer#apply(org.junit.runners.model.Statement, org.junit.runner.Description)",
69+
"org.testcontainers.containers.DockerComposeContainer#failed(java.lang.Throwable, org.junit.runner.Description)",
70+
"org.testcontainers.containers.DockerComposeContainer#finished(org.junit.runner.Description)",
71+
"org.testcontainers.containers.DockerComposeContainer#starting(org.junit.runner.Description)",
72+
"org.testcontainers.containers.DockerComposeContainer#succeeded(org.junit.runner.Description)",
73+
"org.testcontainers.containers.GenericContainer#apply(org.junit.runners.model.Statement, org.junit.runner.Description)",
74+
"org.testcontainers.containers.GenericContainer#failed(java.lang.Throwable, org.junit.runner.Description)",
75+
"org.testcontainers.containers.GenericContainer#finished(org.junit.runner.Description)",
76+
"org.testcontainers.containers.GenericContainer#starting(org.junit.runner.Description)",
77+
"org.testcontainers.containers.GenericContainer#succeeded(org.junit.runner.Description)",
78+
'org.testcontainers.containers.Network$NetworkImpl#after()'
5879
]
5980

6081
fieldExcludes = []
@@ -68,7 +89,6 @@ configurations.all {
6889
}
6990

7091
dependencies {
71-
api 'junit:junit:4.13.2'
7292
api 'org.slf4j:slf4j-api:1.7.36'
7393
compileOnly 'org.jetbrains:annotations:26.0.2-1'
7494
testCompileOnly 'org.jetbrains:annotations:26.0.2-1'
@@ -105,6 +125,9 @@ dependencies {
105125

106126
shaded 'org.zeroturnaround:zt-exec:1.12'
107127

128+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0'
129+
130+
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
108131
testImplementation('com.google.cloud.tools:jib-core:0.27.3') {
109132
exclude group: 'com.google.guava', module: 'guava'
110133
}
@@ -124,8 +147,9 @@ dependencies {
124147

125148
jarFileTestCompileOnly "org.projectlombok:lombok:${lombok.version}"
126149
jarFileTestAnnotationProcessor "org.projectlombok:lombok:${lombok.version}"
127-
jarFileTestImplementation 'junit:junit:4.13.2'
128-
jarFileTestImplementation 'org.assertj:assertj-core:3.27.6'
150+
jarFileTestRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0'
151+
jarFileTestImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
152+
jarFileTestImplementation 'org.assertj:assertj-core:3.27.4'
129153
jarFileTestImplementation 'org.ow2.asm:asm-debug-all:5.2'
130154
}
131155

@@ -135,3 +159,14 @@ tasks.generatePomFileForMavenJavaPublication.finalizedBy(
135159
]
136160
}
137161
)
162+
163+
compileTestJava {
164+
javaCompiler = javaToolchains.compilerFor {
165+
languageVersion = JavaLanguageVersion.of(17)
166+
}
167+
options.release.set(17)
168+
}
169+
170+
test {
171+
useJUnitPlatform()
172+
}

core/src/jarFileTest/java/org/testcontainers/JarFileShadingTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
package org.testcontainers;
22

33
import org.assertj.core.api.ListAssert;
4-
import org.junit.Test;
4+
import org.junit.jupiter.api.Test;
55

66
import java.io.IOException;
77
import java.nio.file.Files;
88
import java.nio.file.Path;
99

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

12-
public class JarFileShadingTest extends AbstractJarFileTest {
12+
class JarFileShadingTest extends AbstractJarFileTest {
1313

1414
@Test
15-
public void testPackages() throws Exception {
15+
void testPackages() throws Exception {
1616
assertThatFileList(root).containsOnly("org", "META-INF");
1717

1818
assertThatFileList(root.resolve("org")).containsOnly("testcontainers");
1919
}
2020

2121
@Test
22-
public void testMetaInf() throws Exception {
22+
void testMetaInf() throws Exception {
2323
assertThatFileList(root.resolve("META-INF"))
2424
.containsOnly(
2525
"MANIFEST.MF",
@@ -33,7 +33,7 @@ public void testMetaInf() throws Exception {
3333
}
3434

3535
@Test
36-
public void testMetaInfServices() throws Exception {
36+
void testMetaInfServices() throws Exception {
3737
assertThatFileList(root.resolve("META-INF").resolve("services"))
3838
.allMatch(it -> it.startsWith("org.testcontainers."));
3939
}

core/src/jarFileTest/java/org/testcontainers/PublicBinaryAPITest.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import lombok.RequiredArgsConstructor;
44
import org.assertj.core.api.Assertions;
5-
import org.junit.Assume;
6-
import org.junit.Before;
7-
import org.junit.Test;
8-
import org.junit.runner.RunWith;
9-
import org.junit.runners.Parameterized;
10-
import org.junit.runners.Parameterized.Parameters;
5+
import org.junit.jupiter.api.Assumptions;
6+
import org.junit.jupiter.api.BeforeEach;
7+
import org.junit.jupiter.api.Test;
8+
import org.junit.jupiter.params.Parameter;
9+
import org.junit.jupiter.params.ParameterizedClass;
10+
import org.junit.jupiter.params.provider.MethodSource;
1111
import org.objectweb.asm.ClassReader;
1212
import org.objectweb.asm.Opcodes;
1313
import org.objectweb.asm.Type;
@@ -30,23 +30,22 @@
3030

3131
/**
3232
* This test checks that we don't expose any shaded class in our public API.
33-
* We use {@link Parameterized} runner here to create a test per public class in Testcontainers' JAR file.
3433
*/
35-
@RunWith(Parameterized.class)
34+
@ParameterizedClass
35+
@MethodSource("data")
3636
@RequiredArgsConstructor
3737
public class PublicBinaryAPITest extends AbstractJarFileTest {
3838

39-
private static String SHADED_PACKAGE = "org.testcontainers.shaded.";
39+
private static final String SHADED_PACKAGE = "org.testcontainers.shaded.";
4040

41-
private static String SHADED_PACKAGE_PATH = SHADED_PACKAGE.replaceAll("\\.", "/");
41+
private static final String SHADED_PACKAGE_PATH = SHADED_PACKAGE.replaceAll("\\.", "/");
4242

4343
static {
4444
Assertions.registerFormatterForType(ClassNode.class, it -> it.name);
4545
Assertions.registerFormatterForType(FieldNode.class, it -> it.name);
4646
Assertions.registerFormatterForType(MethodNode.class, it -> it.name + it.desc);
4747
}
4848

49-
@Parameters(name = "{0}")
5049
public static List<Object[]> data() throws Exception {
5150
List<Object[]> result = new ArrayList<>();
5251

@@ -85,41 +84,43 @@ public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IO
8584
return result;
8685
}
8786

88-
private final String fileName;
87+
@Parameter(0)
88+
private String fileName;
8989

90-
private final ClassNode classNode;
90+
@Parameter(1)
91+
private ClassNode classNode;
9192

92-
@Before
93+
@BeforeEach
9394
public void setUp() {
9495
switch (classNode.name) {
9596
// Necessary evil
9697
case "org/testcontainers/dockerclient/UnixSocketClientProviderStrategy":
9798
case "org/testcontainers/dockerclient/DockerClientProviderStrategy":
9899
case "org/testcontainers/dockerclient/WindowsClientProviderStrategy":
99100
case "org/testcontainers/utility/DynamicPollInterval":
100-
Assume.assumeTrue(false);
101+
Assumptions.assumeTrue(false);
101102
}
102103
}
103104

104105
@Test
105-
public void testSuperClass() {
106+
void testSuperClass() {
106107
assertThat(classNode.superName).doesNotStartWith(SHADED_PACKAGE_PATH);
107108
}
108109

109110
@Test
110-
public void testInterfaces() {
111+
void testInterfaces() {
111112
assertThat(classNode.interfaces).allSatisfy(it -> assertThat(it).doesNotStartWith(SHADED_PACKAGE_PATH));
112113
}
113114

114115
@Test
115-
public void testMethodReturnTypes() {
116+
void testMethodReturnTypes() {
116117
assertThat(classNode.methods)
117118
.filteredOn(it -> (it.access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) != 0)
118119
.allSatisfy(it -> assertThat(Type.getReturnType(it.desc).getClassName()).doesNotStartWith(SHADED_PACKAGE));
119120
}
120121

121122
@Test
122-
public void testMethodArguments() {
123+
void testMethodArguments() {
123124
assertThat(classNode.methods)
124125
.filteredOn(it -> (it.access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) != 0)
125126
.allSatisfy(method -> {
@@ -130,7 +131,7 @@ public void testMethodArguments() {
130131
}
131132

132133
@Test
133-
public void testFields() {
134+
void testFields() {
134135
assertThat(classNode.fields)
135136
.filteredOn(it -> (it.access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) != 0)
136137
.allSatisfy(it -> assertThat(Type.getType(it.desc).getClassName()).doesNotStartWith(SHADED_PACKAGE));

core/src/main/java/org/testcontainers/containers/ComposeContainer.java

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import lombok.NonNull;
66
import lombok.extern.slf4j.Slf4j;
77
import org.apache.commons.lang3.SystemUtils;
8-
import org.junit.runner.Description;
9-
import org.junit.runners.model.Statement;
108
import org.testcontainers.containers.output.OutputFrame;
119
import org.testcontainers.containers.wait.strategy.Wait;
1210
import org.testcontainers.containers.wait.strategy.WaitStrategy;
@@ -31,7 +29,7 @@
3129
* It uses either Compose V2 contained within the Docker binary, or a containerised version of Compose V2.
3230
*/
3331
@Slf4j
34-
public class ComposeContainer extends FailureDetectingExternalResource implements Startable {
32+
public class ComposeContainer implements Startable {
3533

3634
private final Map<String, Integer> scalingPreferences = new HashMap<>();
3735

@@ -93,32 +91,6 @@ public ComposeContainer(String identifier, List<File> composeFiles) {
9391
this.project = this.composeDelegate.getProject();
9492
}
9593

96-
@Override
97-
@Deprecated
98-
public Statement apply(Statement base, Description description) {
99-
return super.apply(base, description);
100-
}
101-
102-
@Override
103-
@Deprecated
104-
public void starting(Description description) {
105-
start();
106-
}
107-
108-
@Override
109-
@Deprecated
110-
protected void succeeded(Description description) {}
111-
112-
@Override
113-
@Deprecated
114-
protected void failed(Throwable e, Description description) {}
115-
116-
@Override
117-
@Deprecated
118-
public void finished(Description description) {
119-
stop();
120-
}
121-
12294
@Override
12395
public void start() {
12496
synchronized (MUTEX) {

core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import lombok.NonNull;
66
import lombok.extern.slf4j.Slf4j;
77
import org.apache.commons.lang3.SystemUtils;
8-
import org.junit.runner.Description;
9-
import org.junit.runners.model.Statement;
108
import org.testcontainers.containers.output.OutputFrame;
119
import org.testcontainers.containers.wait.strategy.Wait;
1210
import org.testcontainers.containers.wait.strategy.WaitStrategy;
@@ -30,9 +28,7 @@
3028
* Container which launches Docker Compose, for the purposes of launching a defined set of containers.
3129
*/
3230
@Slf4j
33-
public class DockerComposeContainer<SELF extends DockerComposeContainer<SELF>>
34-
extends FailureDetectingExternalResource
35-
implements Startable {
31+
public class DockerComposeContainer<SELF extends DockerComposeContainer<SELF>> implements Startable {
3632

3733
private final Map<String, Integer> scalingPreferences = new HashMap<>();
3834

@@ -99,32 +95,6 @@ public DockerComposeContainer(String identifier, List<File> composeFiles) {
9995
this.project = this.composeDelegate.getProject();
10096
}
10197

102-
@Override
103-
@Deprecated
104-
public Statement apply(Statement base, Description description) {
105-
return super.apply(base, description);
106-
}
107-
108-
@Override
109-
@Deprecated
110-
public void starting(Description description) {
111-
start();
112-
}
113-
114-
@Override
115-
@Deprecated
116-
protected void succeeded(Description description) {}
117-
118-
@Override
119-
@Deprecated
120-
protected void failed(Throwable e, Description description) {}
121-
122-
@Override
123-
@Deprecated
124-
public void finished(Description description) {
125-
stop();
126-
}
127-
12898
@Override
12999
public void start() {
130100
synchronized (MUTEX) {

core/src/main/java/org/testcontainers/containers/FailureDetectingExternalResource.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)