@@ -26,7 +26,7 @@ public abstract class ContainerizedKernelCase {
2626
2727 private static final Logger LOGGER = LoggerFactory .getLogger (ContainerizedKernelCase .class );
2828
29- protected static GenericContainer <?> container ;
29+ protected static final GenericContainer <?> container ;
3030 protected static final String WORKING_DIRECTORY = "/test" ;
3131 protected static final String CONTAINER_KERNELSPEC = "/usr/share/jupyter/kernels/java" ;
3232 protected static final String CONTAINER_RESOURCES = WORKING_DIRECTORY + "/resources" ;
@@ -36,10 +36,20 @@ public abstract class ContainerizedKernelCase {
3636 private static final String FS_KERNELSPEC = "../kernelspec/java" ;
3737 private static final String FS_RESOURCES = "src/test/resources" ;
3838
39+ static {
40+ container = new GenericContainer <>(BASE_IMAGE )
41+ .withWorkingDirectory (WORKING_DIRECTORY )
42+ .withCopyToContainer (MountableFile .forHostPath (FS_KERNELSPEC ), CONTAINER_KERNELSPEC )
43+ .withCopyToContainer (MountableFile .forHostPath (FS_RESOURCES ), CONTAINER_RESOURCES )
44+ .withCommand ("bash" , "-c" , getStartupCommand ())
45+ .withLogConsumer (new Slf4jLogConsumer (LOGGER ))
46+ .waitingFor (Wait .forSuccessfulCommand (getSuccessfulCommand ()))
47+ .withStartupTimeout (Duration .ofMinutes (1 ));
48+ container .start ();
49+ }
50+
3951 @ BeforeAll
4052 static void setUp () throws IOException , InterruptedException {
41- initializeContainer ();
42-
4353 String source = "$(find " + CONTAINER_RESOURCES + "/src -name '*.java')" ;
4454 Container .ExecResult compileResult = executeInContainer ("javac -d " + TEST_CLASSPATH + " " + source );
4555
@@ -97,18 +107,6 @@ protected static Container.ExecResult executeInKernel(String snippet, Map<String
97107 return execResult ;
98108 }
99109
100- private static void initializeContainer () {
101- container = new GenericContainer <>(BASE_IMAGE )
102- .withWorkingDirectory (WORKING_DIRECTORY )
103- .withCopyToContainer (MountableFile .forHostPath (FS_KERNELSPEC ), CONTAINER_KERNELSPEC )
104- .withCopyToContainer (MountableFile .forHostPath (FS_RESOURCES ), CONTAINER_RESOURCES )
105- .withCommand ("bash" , "-c" , getStartupCommand ())
106- .withLogConsumer (new Slf4jLogConsumer (LOGGER ))
107- .waitingFor (Wait .forSuccessfulCommand (getSuccessfulCommand ()))
108- .withStartupTimeout (Duration .ofMinutes (1 ));
109- container .start ();
110- }
111-
112110 private static String getStartupCommand () {
113111 return String .join (" && " ,
114112 "apt-get update" ,
0 commit comments