-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable copyFileToContainer feature during container startup
- Loading branch information
dharanpu
committed
Jun 14, 2018
1 parent
3b974e9
commit 0b78a2e
Showing
5 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
core/src/test/java/org/testcontainers/junit/CopyFileToContainerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.testcontainers.junit; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.startupcheck.MinimumDurationRunningStartupCheckStrategy; | ||
import org.testcontainers.utility.MountableFile; | ||
import java.io.File; | ||
import java.time.Duration; | ||
|
||
public class CopyFileToContainerTest { | ||
private static String folderPath = new File("./src/test/resources/mappable-resource/").getAbsolutePath(); | ||
private static String containerPath = "/opt"; | ||
private static String fileName = "test-resource.txt"; | ||
public static GenericContainer container; | ||
|
||
@Before | ||
public void before() { | ||
container = new GenericContainer("couchbase:latest") | ||
.withStartupCheckStrategy(new MinimumDurationRunningStartupCheckStrategy(Duration.ofSeconds(5))) | ||
.withCopyFileToContainer(MountableFile.forHostPath(folderPath), containerPath ); | ||
} | ||
|
||
|
||
@Test | ||
public void checkFileCopied() { | ||
container.start(); | ||
try { | ||
String filesList = container.execInContainer("ls","/opt/mappable-resource").getStdout(); | ||
|
||
Assert.assertTrue(filesList.contains(fileName)); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ | |
<Marker>PROFILER</Marker> | ||
<OnMatch>DENY</OnMatch> | ||
</turboFilter> | ||
</configuration> | ||
</configuration> |