-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start adding integration tests, still an issue with resolving certain…
… groovy classes
- Loading branch information
1 parent
6a9e99d
commit 8f444f2
Showing
8 changed files
with
279 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>be.orbinson.aem</groupId> | ||
<artifactId>aem-groovy-console</artifactId> | ||
<version>19.0.9-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>aem-groovy-console-it-tests</artifactId> | ||
<name>AEM Groovy Console - IT Tests</name> | ||
|
||
<repositories> | ||
<!-- Be able to depend on the latest Sling feature releases --> | ||
<repository> | ||
<id>apache-snapshot</id> | ||
<url>https://repository.apache.org/content/groups/snapshots</url> | ||
</repository> | ||
</repositories> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>biz.aQute.bnd</groupId> | ||
<artifactId>bnd-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>bnd-process</id> | ||
<goals> | ||
<goal>bnd-process</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>it</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<executions> | ||
<execution> | ||
<id>reserve-network-port</id> | ||
<goals> | ||
<goal>reserve-network-port</goal> | ||
</goals> | ||
<phase>process-resources</phase> | ||
<configuration> | ||
<portNames> | ||
<portName>http.port</portName> | ||
</portNames> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.sling</groupId> | ||
<artifactId>slingfeature-maven-plugin</artifactId> | ||
<version>1.8.4</version> | ||
<extensions>true</extensions> | ||
<executions> | ||
<execution> | ||
<id>aggregate-features</id> | ||
<goals> | ||
<goal>aggregate-features</goal> | ||
</goals> | ||
<configuration> | ||
<aggregates> | ||
<aggregate> | ||
<includeArtifact> | ||
<groupId>org.apache.sling</groupId> | ||
<artifactId>org.apache.sling.starter</artifactId> | ||
<classifier>oak_tar</classifier> | ||
<type>slingosgifeature</type> | ||
<version>13-SNAPSHOT</version> | ||
</includeArtifact> | ||
<filesInclude>*.json</filesInclude> | ||
</aggregate> | ||
</aggregates> | ||
<replacePropertyVariables>groovy.version</replacePropertyVariables> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<goals> | ||
<goal>attach-features</goal> | ||
</goals> | ||
<id>attach-features</id> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.sling</groupId> | ||
<artifactId>feature-launcher-maven-plugin</artifactId> | ||
<version>0.1.6</version> | ||
<configuration> | ||
<launches> | ||
<launch> | ||
<id>model</id> | ||
<skip>${skipTests}</skip> | ||
<feature> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${project.artifactId}</artifactId> | ||
<version>${project.version}</version> | ||
<type>slingosgifeature</type> | ||
</feature> | ||
|
||
<launcherArguments> | ||
<frameworkProperties> | ||
<org.osgi.service.http.port>${http.port}</org.osgi.service.http.port> | ||
</frameworkProperties> | ||
<!-- Uncomment to enable debugging of IT tests --> | ||
<!--<vmOptions>--> | ||
<!-- <value>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5000</value>--> | ||
<!--</vmOptions>--> | ||
</launcherArguments> | ||
<startTimeoutSeconds>180</startTimeoutSeconds> | ||
</launch> | ||
</launches> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>start</goal> | ||
<goal>stop</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>3.3.1</version> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<HTTP_PORT>${http.port}</HTTP_PORT> | ||
<build.log.file>${project.build.directory}/../build.log</build.log.file> | ||
</systemPropertyVariables> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
<dependencies> | ||
<!-- Testing --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>5.10.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.5.14</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.11.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
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,8 @@ | ||
{ | ||
"bundles": [ | ||
{ | ||
"id": "org.apache.groovy:groovy-dateutil:${groovy.version}", | ||
"start-order": "20" | ||
} | ||
] | ||
} |
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,8 @@ | ||
create path /conf/groovyconsole/replication(sling:Folder) | ||
create path /var/groovyconsole/audit(sling:Folder) | ||
|
||
create service user aem-groovy-console-service with path system/aem-groovy-console | ||
set ACL for aem-groovy-console-service | ||
allow jcr:all on / | ||
allow jcr:all on /var/groovyconsole/audit | ||
end |
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,25 @@ | ||
|
||
{ | ||
"bundles":[ | ||
{ | ||
"id": "be.orbinson.aem:groovy-osgi:${project.version}", | ||
"start-order": "19" | ||
}, | ||
{ | ||
"id":"be.orbinson.aem:aem-groovy-console-api:${project.version}", | ||
"start-order":"20" | ||
}, | ||
{ | ||
"id":"be.orbinson.aem:aem-groovy-console-bundle:${project.version}", | ||
"start-order":"20" | ||
} | ||
], | ||
"configurations": { | ||
"org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~groovyconsole":{ | ||
"user.mapping":[ | ||
"aem-groovy-console-bundle=[aem-groovy-console-service]" | ||
] | ||
} | ||
}, | ||
"repoinit:TEXT|true":"@file" | ||
} |
44 changes: 44 additions & 0 deletions
44
it.tests/src/test/java/be/orbinson/aem/groovy/console/it/GroovyConsoleServiceIT.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,44 @@ | ||
package be.orbinson.aem.groovy.console.it; | ||
|
||
import com.google.gson.Gson; | ||
import org.apache.commons.codec.binary.Base64; | ||
import org.apache.http.client.entity.UrlEncodedFormEntity; | ||
import org.apache.http.client.methods.CloseableHttpResponse; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.impl.client.CloseableHttpClient; | ||
import org.apache.http.impl.client.HttpClients; | ||
import org.apache.http.message.BasicNameValuePair; | ||
import org.apache.http.util.EntityUtils; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class GroovyConsoleServiceIT { | ||
private static final int SLING_PORT = Integer.getInteger("HTTP_PORT", 8080); | ||
|
||
@Test | ||
void testScriptReturnsResult() throws Exception { | ||
String script = "print 'test'"; | ||
Map response = executeScript(script); | ||
assertEquals("test", response.get("output")); | ||
} | ||
|
||
private static Map executeScript(String script) throws IOException { | ||
try (CloseableHttpClient httpclient = HttpClients.createDefault()) { | ||
HttpPost executeScript = new HttpPost("http://localhost:" + SLING_PORT + "/bin/groovyconsole/post"); | ||
List<BasicNameValuePair> basicNameValuePairs = new java.util.ArrayList<>(); | ||
basicNameValuePairs.add(new BasicNameValuePair("script", script)); | ||
executeScript.setEntity(new UrlEncodedFormEntity(basicNameValuePairs, StandardCharsets.UTF_8)); | ||
executeScript.addHeader("Authorization", "Basic " + Base64.encodeBase64String("admin:admin".getBytes(StandardCharsets.UTF_8))); | ||
try (CloseableHttpResponse response = httpclient.execute(executeScript)) { | ||
String body = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); | ||
return new Gson().fromJson(body, Map.class); | ||
} | ||
} | ||
} | ||
} |
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