Skip to content

Commit f8b1fd8

Browse files
committed
✨ Added isLocal() method to AemInstance
This will come in handy when handling things like file paths for PDF rendering.
1 parent 5e386b4 commit f8b1fd8

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

rest-services/it.tests/src/test/java/com/_4point/aem/docservices/rest_services/it_tests/AemInstance.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
import org.testcontainers.utility.DockerImageName;
1717

1818
public 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());

rest-services/it.tests/src/test/java/com/_4point/aem/docservices/rest_services/it_tests/SamplesDeployer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
import com._4point.aem.package_manager.FormsAndDocumentsClient;
77
import com._4point.aem.package_manager.FormsAndDocumentsClientEx;
88

9+
/**
10+
* Used for deploying sample files to AEM for testing purposes. This includes the following files:
11+
* - SampleForm.xdp (deployed to remote file system for testing PDF rendering using a file reference)
12+
* - SampleForm.xdp (deployed to /content/dam/formsanddocuments/sample-forms for CRX testing0
13+
* - Sample0002test.zip (deployed to /content/dam/formsanddocuments for adaptive forms testing)
14+
*
15+
* Possible future things:
16+
* - Deploy ReaderExtensions credentials
17+
*/
918
public class SamplesDeployer {
1019
private final FormsAndDocumentsClientEx client;
1120

0 commit comments

Comments
 (0)