99import com .github .dockerjava .api .command .InspectContainerResponse ;
1010import com .github .dockerjava .api .command .ListContainersCmd ;
1111import com .github .dockerjava .api .command .StartContainerCmd ;
12+ import com .github .dockerjava .api .model .Container ;
1213import com .github .dockerjava .core .command .CreateContainerCmdImpl ;
1314import com .github .dockerjava .core .command .InspectContainerCmdImpl ;
1415import com .github .dockerjava .core .command .ListContainersCmdImpl ;
1516import com .github .dockerjava .core .command .StartContainerCmdImpl ;
1617import lombok .RequiredArgsConstructor ;
1718import lombok .experimental .FieldDefaults ;
18- import org .junit .Rule ;
19- import org .junit .jupiter .api .Nested ;
2019import org .junit .jupiter .api .Test ;
20+ import org .junit .jupiter .api .extension .ExtendWith ;
2121import org .junit .jupiter .params .ParameterizedClass ;
2222import org .junit .jupiter .params .provider .MethodSource ;
23- import org .junit .runner .RunWith ;
24- import org .junit .runners .BlockJUnit4ClassRunner ;
2523import org .mockito .Answers ;
2624import org .mockito .Mockito ;
2725import org .mockito .stubbing .Answer ;
2826import org .testcontainers .DockerClientFactory ;
2927import org .testcontainers .TestImages ;
3028import org .testcontainers .containers .startupcheck .StartupCheckStrategy ;
29+ import org .testcontainers .containers .startupcheck .StartupCheckStrategy .StartupStatus ;
3130import org .testcontainers .containers .wait .strategy .AbstractWaitStrategy ;
32- import org .testcontainers .utility .MockTestcontainersConfigurationRule ;
31+ import org .testcontainers .utility .MockTestcontainersConfigurationExtension ;
3332import org .testcontainers .utility .MountableFile ;
3433import org .testcontainers .utility .TestcontainersConfiguration ;
3534
5554
5655public class ReusabilityUnitTests {
5756
58- @ Nested
5957 @ ParameterizedClass
6058 @ MethodSource ("data" )
6159 @ RequiredArgsConstructor
6260 @ FieldDefaults (makeFinal = true )
63- public class CanBeReusedTest {
64- public Object [][] data () {
61+ public static class CanBeReusedTest {
62+
63+ public static Object [][] data () {
6564 return new Object [][] {
6665 { "generic" , new GenericContainer <>(TestImages .TINY_IMAGE ), true },
6766 { "anonymous generic" , new GenericContainer (TestImages .TINY_IMAGE ) {}, true },
@@ -86,14 +85,14 @@ public void shouldBeReusable() {
8685 }
8786 }
8887
89- class CustomContainer extends GenericContainer <CustomContainer > {
88+ static class CustomContainer extends GenericContainer <CustomContainer > {
9089
9190 CustomContainer () {
9291 super (TestImages .TINY_IMAGE );
9392 }
9493 }
9594
96- class CustomContainerWithContainerIsCreated
95+ static class CustomContainerWithContainerIsCreated
9796 extends GenericContainer <CustomContainerWithContainerIsCreated > {
9897
9998 CustomContainerWithContainerIsCreated () {
@@ -107,10 +106,8 @@ protected void containerIsCreated(String containerId) {
107106 }
108107 }
109108
110- @ Nested
111- @ RunWith (BlockJUnit4ClassRunner .class )
112109 @ FieldDefaults (makeFinal = true )
113- public class HooksTest extends AbstractReusabilityTest {
110+ public static class HooksTest extends AbstractReusabilityTest {
114111
115112 List <String > script = new ArrayList <>();
116113
@@ -189,10 +186,8 @@ public void shouldNotCallHookIfNotReused() {
189186 }
190187 }
191188
192- @ Nested
193- @ RunWith (BlockJUnit4ClassRunner .class )
194189 @ FieldDefaults (makeFinal = true )
195- public class HashTest extends AbstractReusabilityTest {
190+ public static class HashTest extends AbstractReusabilityTest {
196191
197192 protected GenericContainer <?> container = makeReusable (
198193 new GenericContainer (TestImages .TINY_IMAGE ) {
@@ -304,22 +299,20 @@ public void shouldHashCopiedFiles() {
304299 }
305300 }
306301
307-
308- interface TestStrategy {
309- void withCopyFileToContainer (MountableFile mountableFile , String path );
310-
311- void clear ();
312- }
313-
314- @ Nested
315302 @ ParameterizedClass
316303 @ MethodSource ("strategies" )
317304 @ FieldDefaults (makeFinal = true )
318- public class CopyFilesHashTest {
305+ public static class CopyFilesHashTest {
319306
320307 private final TestStrategy strategy ;
321308
322- private class MountableFileTestStrategy implements TestStrategy {
309+ interface TestStrategy {
310+ void withCopyFileToContainer (MountableFile mountableFile , String path );
311+
312+ void clear ();
313+ }
314+
315+ private static class MountableFileTestStrategy implements TestStrategy {
323316
324317 private final GenericContainer <?> container ;
325318
@@ -338,7 +331,7 @@ public void clear() {
338331 }
339332 }
340333
341- private class TransferableTestStrategy implements TestStrategy {
334+ private static class TransferableTestStrategy implements TestStrategy {
342335
343336 private final GenericContainer <?> container ;
344337
@@ -357,7 +350,7 @@ public void clear() {
357350 }
358351 }
359352
360- public List <Function <GenericContainer <?>, TestStrategy >> strategies () {
353+ public static List <Function <GenericContainer <?>, TestStrategy >> strategies () {
361354 return Arrays .asList (MountableFileTestStrategy ::new , TransferableTestStrategy ::new );
362355 }
363356
@@ -508,11 +501,9 @@ public void folderPermissions() throws Exception {
508501 }
509502 }
510503
504+ @ ExtendWith (MockTestcontainersConfigurationExtension .class )
511505 @ FieldDefaults (makeFinal = true )
512- public abstract class AbstractReusabilityTest {
513-
514- @ Rule
515- public MockTestcontainersConfigurationRule configurationMock = new MockTestcontainersConfigurationRule ();
506+ public abstract static class AbstractReusabilityTest {
516507
517508 protected DockerClient client = Mockito .mock (DockerClient .class );
518509
0 commit comments