|
5 | 5 | import org.junit.jupiter.api.Assertions; |
6 | 6 | import org.testcontainers.containers.BindMode; |
7 | 7 | import org.testcontainers.containers.GenericContainer; |
| 8 | +import org.testcontainers.containers.startupcheck.OneShotStartupCheckStrategy; |
8 | 9 | import org.testcontainers.junit.jupiter.Container; |
9 | 10 | import org.testcontainers.junit.jupiter.Testcontainers; |
10 | 11 | import org.testcontainers.utility.MountableFile; |
|
13 | 14 | import java.io.FileInputStream; |
14 | 15 | import java.io.IOException; |
15 | 16 | import java.nio.file.Paths; |
| 17 | +import java.time.Duration; |
16 | 18 | import java.util.Properties; |
17 | 19 |
|
18 | 20 |
|
@@ -41,13 +43,10 @@ public class CodeAnalyzerIntegrationTest { |
41 | 43 | } |
42 | 44 |
|
43 | 45 | @Container |
44 | | - static final GenericContainer<?> container = new GenericContainer<>("openjdk:17-jdk") |
| 46 | + static final GenericContainer<?> container = new GenericContainer<>("ubuntu:latest") |
45 | 47 | .withCreateContainerCmdModifier(cmd -> cmd.withEntrypoint("sh")) |
46 | 48 | .withCommand("-c", "while true; do sleep 1; done") |
47 | | - .withFileSystemBind( |
48 | | - String.valueOf(Paths.get(System.getProperty("user.dir")).resolve("build/libs")), |
49 | | - "/opt/jars", |
50 | | - BindMode.READ_WRITE) |
| 49 | + .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("build/libs")), "/opt/jars") |
51 | 50 | .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("build/libs")), "/opt/jars") |
52 | 51 | .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/mvnw-corrupt-test")), "/test-applications/mvnw-corrupt-test") |
53 | 52 | .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/plantsbywebsphere")), "/test-applications/plantsbywebsphere") |
@@ -107,6 +106,10 @@ void shouldBeAbleToRunCodeAnalyzer() throws Exception { |
107 | 106 |
|
108 | 107 | @Test |
109 | 108 | void callGraphShouldHaveKnownEdges() throws Exception { |
| 109 | + var listContentsOfTestApplicationDirectory = container.execInContainer("ls", "/test-applications/call-graph-test"); |
| 110 | + Assertions.assertFalse(listContentsOfTestApplicationDirectory.getStdout().isEmpty(), "Directory listing should not be empty"); |
| 111 | + var runGradlew = container.execInContainer("sh", "-c", "/test-applications/call-graph-test/gradlew", "-v"); |
| 112 | + Assertions.assertEquals(0, runGradlew.getExitCode(), "Failed to run gradlew"); |
110 | 113 | var runCodeAnalyzerOnCallGraphTest = container.withWorkingDirectory("/test-applications/call-graph-test") |
111 | 114 | .execInContainer( |
112 | 115 | "java", |
@@ -177,6 +180,10 @@ void shouldBeAbleToGenerateAnalysisArtifactForDaytrader8() throws Exception { |
177 | 180 |
|
178 | 181 | @Test |
179 | 182 | void shouldBeAbleToDetectCRUDOperationsAndQueriesForPlantByWebsphere() throws Exception { |
| 183 | + container.execInContainer("apt-get", "update"); |
| 184 | + var installFindUtils = container.execInContainer("apt-get", "install", "-y", "openjdk-17-jdk", "findutils"); |
| 185 | + var printJavaVersion = container.execInContainer("java", "-version"); |
| 186 | + var printGradleVersion = container.execInContainer("/test-applications/plantsbywebsphere/gradlew", "-v"); |
180 | 187 | var runCodeAnalyzerOnPlantsByWebsphere = container.execInContainer( |
181 | 188 | "java", |
182 | 189 | "-jar", |
|
0 commit comments