3232import java .nio .file .Paths ;
3333import java .time .Duration ;
3434import java .util .ArrayList ;
35+ import java .util .Collections ;
3536import java .util .List ;
3637import java .util .Map ;
3738import java .util .Objects ;
@@ -201,18 +202,21 @@ protected void runContainerAndCopyInputIntoContainer(ImageFromDockerfile image,
201202 * It will write the given {@code content} into a temporary file. The
202203 * temporary file requires a {@code prefix} and {@code suffix}.
203204 * Copies the data from {@code copyMappings}. Additionally, it will
204- * set environment variables based on {@code environmentMappings}.
205+ * set environment variables based on {@code environmentMappings}. The {@code copyFromContainerToHost}
206+ * can be used to define mappings between host and guest system.
205207 *
206- * @param image is the docker image for the {@link GenericContainer}.
207- * @param copyMappings is a list where each {@link Pair} indicates what should be copied
208- * from the host to the container.
209- * @param environmentMappings is a list where each entry defines an environment variable which
210- * will be set in the container.
211- * @param cmd is the command which is executed.
208+ * @param image is the docker image for the {@link GenericContainer}.
209+ * @param copyMappings is a list where each {@link Pair} indicates what should be copied
210+ * from the host to the container.
211+ * @param environmentMappings is a list where each entry defines an environment variable which
212+ * will be set in the container.
213+ * @param copyFromContainerToHost copies from guest to host.
214+ * @param cmd is the command which is executed.
212215 */
213216 protected void runContainerAndCopyInputIntoContainer (ImageFromDockerfile image ,
214217 List <Pair <Path , String >> copyMappings ,
215218 Map <String , String > environmentMappings ,
219+ List <Pair <String , String >> copyFromContainerToHost ,
216220 String cmd ) {
217221 runContainer (image , (container ) -> {
218222 for (var mapping : copyMappings ) {
@@ -233,9 +237,37 @@ protected void runContainerAndCopyInputIntoContainer(ImageFromDockerfile image,
233237
234238 return container ;
235239 }, (container ) -> {
240+ for (var mapping : copyFromContainerToHost ) {
241+ container .copyFileFromContainer (mapping .left (), mapping .right ());
242+ }
236243 });
237244 }
238245
246+ /**
247+ * Starts a container and checks the status code for the exited container.
248+ * It will write the given {@code content} into a temporary file. The
249+ * temporary file requires a {@code prefix} and {@code suffix}.
250+ * Copies the data from {@code copyMappings}. Additionally, it will
251+ * set environment variables based on {@code environmentMappings}.
252+ *
253+ * @param image is the docker image for the {@link GenericContainer}.
254+ * @param copyMappings is a list where each {@link Pair} indicates what should be copied
255+ * from the host to the container.
256+ * @param environmentMappings is a list where each entry defines an environment variable which
257+ * will be set in the container.
258+ * @param cmd is the command which is executed.
259+ */
260+ protected void runContainerAndCopyInputIntoContainer (ImageFromDockerfile image ,
261+ List <Pair <Path , String >> copyMappings ,
262+ Map <String , String > environmentMappings ,
263+ String cmd ) {
264+ runContainerAndCopyInputIntoContainer (image ,
265+ copyMappings ,
266+ environmentMappings ,
267+ Collections .emptyList (),
268+ cmd );
269+ }
270+
239271 /**
240272 * Starts a container and checks the status code for the exited container.
241273 * It will assert that the status code is zero. If the check takes longer
0 commit comments