1616import org .testcontainers .utility .DockerImageName ;
1717
1818public enum AemInstance {
19- AEM_1 (TestUtils .USE_TESTCONTAINERS ); // Change parameter to false to disable TestContainers and use local AEM instance..
19+ AEM_1 (TestUtils .USE_TESTCONTAINERS ); // Change parameter to false to disable TestContainers and use local AEM instance..,
20+
21+ private static final String LOCALHOST = "localhost" ;
2022
2123 // These tests require an AEM container image with AEM forms installed. Since AEM is proprietary, it is not possible to obtain this
2224 // through public images. By default, this uses a private image hosted in the 4PointSolutions-PS GitHub organization. If you are not
@@ -76,7 +78,7 @@ private static void startAem(Integer mappedPort) {
7678 public static void deploySampleFiles (Integer mappedPort ) {
7779 System .out .println ("Deploying sample files..." );
7880
79- SamplesDeployer deployer = new SamplesDeployer ("localhost" , mappedPort , TestUtils .TEST_USER , TestUtils .TEST_USER_PASSWORD );
81+ SamplesDeployer deployer = new SamplesDeployer (LOCALHOST , mappedPort , TestUtils .TEST_USER , TestUtils .TEST_USER_PASSWORD );
8082
8183 deployer .deployXdp (Paths .get ("src" , "test" , "resources" , "SampleForm.xdp" ), "sample-forms" );
8284 deployer .deployAf (Paths .get ("src" , "test" , "resources" , "sample00002test.zip" ));
@@ -85,12 +87,25 @@ public static void deploySampleFiles(Integer mappedPort) {
8587 }
8688
8789 public String aemHost () {
88- return aemContainer != null ? "localhost" : TestUtils .TEST_MACHINE_NAME ;
90+ return aemContainer != null ? LOCALHOST : TestUtils .TEST_MACHINE_NAME ;
8991 }
92+
9093 public Integer aemPort () {
9194 return aemContainer != null ? aemContainer .getMappedPort (4502 ) : Integer .parseInt (TestUtils .TEST_MACHINE_PORT_STR ) ;
9295 }
9396
97+ /**
98+ * Is AEM running locally or remotely?
99+ *
100+ * If is is running in a container, then it is considered remote (because it does not have access to the local file system).
101+ * If AEM is running locally, then local file paths can be used, otherwise remote file paths will need to be used for some tests.
102+ *
103+ * @return
104+ */
105+ public boolean isLocal () {
106+ return aemContainer == null && aemHost ().equalsIgnoreCase (LOCALHOST );
107+ }
108+
94109 private static boolean aemIsUp (HttpClient restClient , HttpRequest request ) {
95110 try {
96111 HttpResponse <Void > result = restClient .send (request , BodyHandlers .discarding ());
0 commit comments