You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2021/12/15 20:38:43 UTC
[sling-org-apache-sling-caconfig-integration-tests] branch master updated: update integration tests to Sling 11
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-caconfig-integration-tests.git
The following commit(s) were added to refs/heads/master by this push:
new ad45186 update integration tests to Sling 11
ad45186 is described below
commit ad451868ee8fd5d3226d4f88d7928d69797f62f7
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Wed Dec 15 21:37:09 2021 +0100
update integration tests to Sling 11
---
bnd.bnd | 3 +
pom.xml | 235 ++++++++++++---------
.../sling/caconfig/it/example/SimpleConfig.java | 0
.../sling/caconfig/it/example/package-info.java | 21 ++
.../sling/caconfig/it/AdaptToConfigClassIT.java | 28 +--
.../sling/caconfig/it/ConfigurationManagerIT.java | 44 ++--
.../it/ConfigurationResolverConfigClassIT.java | 29 +--
.../it/ConfigurationResolverValueMapIT.java | 27 +--
.../junit/teleporter/customizers/ITCustomizer.java | 33 ++-
.../provisioning/sling-caconfig..txt} | 19 +-
src/test/provisioning/sling.txt | 40 ++++
11 files changed, 299 insertions(+), 180 deletions(-)
diff --git a/bnd.bnd b/bnd.bnd
new file mode 100644
index 0000000..230cd3e
--- /dev/null
+++ b/bnd.bnd
@@ -0,0 +1,3 @@
+Sling-Test-Regexp: .*Test
+
+-plugin.slingcaconfig: org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 80b69fc..5404116 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,99 +22,147 @@
<parent>
<groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
- <version>36</version>
+ <artifactId>sling-bundle-parent</artifactId>
+ <version>46</version>
<relativePath/>
</parent>
<artifactId>org.apache.sling.caconfig.integration-tests</artifactId>
- <packaging>slingstart</packaging>
<version>1-SNAPSHOT</version>
+
<name>Apache Sling Context-Aware Configuration Integration Tests</name>
<description>Integration tests for the Apache Sling Context-Aware Configuration Implementation</description>
<properties>
- <!-- hostname for integration tests -->
- <test.host>localhost</test.host>
-
- <!--
- Set this to true to stop mvn once the integration test Jetty instance is
- started. Useful to manually test the integration testing webapp.
- -->
- <launchpad.keep.running>false</launchpad.keep.running>
-
- <!--
- If set to "true" this will start the launchpad with standard debug options,
- or set to a string to provide custom debug settings
- -->
- <launchpad.debug/>
+ <sling.java.version>8</sling.java.version>
+ <!-- start with -DkeepITServerRunning=true to allow to rerun ITs or inspect the server after the ITs have been executed there -->
+ <keepITServerRunning>false</keepITServerRunning>
+ <project.build.outputTimestamp>2021-12-15T00:00:00Z</project.build.outputTimestamp>
</properties>
-
+
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>reserve-network-port</id>
- <goals>
- <goal>reserve-network-port</goal>
- </goals>
- <phase>process-resources</phase>
- <configuration>
- <portNames>
- <portName>http.port</portName>
- <portName>sling.control.port</portName>
- </portNames>
- </configuration>
- </execution>
- </executions>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.caconfig.bnd-plugin</artifactId>
+ <version>1.0.2</version>
+ </dependency>
+ </dependencies>
</plugin>
<plugin>
- <artifactId>maven-failsafe-plugin</artifactId>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-baseline-maven-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <!-- Find free ports to run our server -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
+ <id>reserve-server-port</id>
<goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
+ <goal>reserve-network-port</goal>
</goals>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <portNames>
+ <!-- reserved port must be stored in property because it must be passed to the slingstart-maven-plugin -->
+ <portName>http.port</portName>
+ </portNames>
+ </configuration>
</execution>
</executions>
- <configuration>
- <runOrder>alphabetical</runOrder>
- <systemPropertyVariables>
- <launchpad.http.server.url>http://${test.host}:${http.port}/</launchpad.http.server.url>
- <launchpad.webdav.server.url>http://${test.host}:${http.port}/${webdav.workspace.path}</launchpad.webdav.server.url>
- </systemPropertyVariables>
- </configuration>
</plugin>
<plugin>
+ <!-- the Sling instance is provisioned from the model in src/main/provisioning/model.txt -->
<groupId>org.apache.sling</groupId>
<artifactId>slingstart-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
- <id>start-container</id>
+ <id>prepare-launchpad-package</id>
+ <goals>
+ <goal>prepare-package</goal>
+ </goals>
+ <phase>pre-integration-test</phase>
+ </execution>
+ <execution>
+ <id>build-launchpad-package</id>
+ <goals>
+ <goal>package</goal>
+ </goals>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <attachArtifact>false</attachArtifact>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start-container-before-IT</id>
<goals>
<goal>start</goal>
+ </goals>
+ <configuration>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-container-after-IT</id>
+ <goals>
<goal>stop</goal>
</goals>
+ <configuration>
+ <shouldBlockUntilKeyIsPressed>${keepITServerRunning}</shouldBlockUntilKeyIsPressed>
+ </configuration>
</execution>
</executions>
<configuration>
- <usePomDependencies>true</usePomDependencies>
<servers>
+ <!-- this configuration applies to both 'start' and 'stop' -->
<server>
+ <id>singleinstance</id>
<port>${http.port}</port>
- <controlPort>${sling.control.port}</controlPort>
- <contextPath>${http.base.path}</contextPath>
- <debug>${launchpad.debug}</debug>
+ <vmOpts>${sling.vm.options}</vmOpts>
+ <stdOutFile>sling/logs/stdout.log</stdOutFile>
</server>
- </servers>
+ </servers>
+ <!-- this configuration only applies to 'prepare-package' and 'package' -->
+ <disableExtendingMavenClasspath>true</disableExtendingMavenClasspath>
+ <usePomDependencies>true</usePomDependencies>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <http.port>${http.port}</http.port>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <systemPropertyVariables>
+ <launchpad.http.server.url>http://localhost:${http.port}</launchpad.http.server.url>
+ <server.ready.timeout.seconds>120</server.ready.timeout.seconds>
+ <server.ready.path.1>/starter/index.html:Getting Started</server.ready.path.1>
+ </systemPropertyVariables>
</configuration>
</plugin>
@@ -141,7 +189,6 @@
</build>
<dependencies>
-
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.caconfig.api</artifactId>
@@ -162,6 +209,28 @@
</dependency>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.annotation.versioning</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.16.4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
@@ -177,26 +246,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.testing</artifactId>
- <version>2.1.0</version>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit-dep</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </exclusion>
- <exclusion>
- <groupId>asm</groupId>
- <artifactId>asm</artifactId>
- </exclusion>
- </exclusions>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
@@ -206,16 +255,24 @@
<artifactId>jcr</artifactId>
<scope>test</scope>
</dependency>
+
+ <!-- Additional bundles needed by the Sling instance under test -->
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.junit.core</artifactId>
+ <version>1.0.28</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.teleporter</artifactId>
- <version>1.0.14</version>
+ <version>1.0.20</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.junit.core</artifactId>
- <version>1.0.26</version>
+ <artifactId>org.apache.sling.testing.rules</artifactId>
+ <version>1.0.8</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -223,6 +280,12 @@
<artifactId>org.apache.sling.testing.tools</artifactId>
<version>1.0.16</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
@@ -230,26 +293,6 @@
<version>1.0.2</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.launchpad</artifactId>
- <version>9</version>
- <type>slingfeature</type>
- <classifier>slingfeature</classifier>
- <scope>provided</scope>
- </dependency>
</dependencies>
-
- <profiles>
- <!-- Start on port 8080 and keep running -->
- <profile>
- <id>run8080</id>
- <properties>
- <launchpad.keep.running>true</launchpad.keep.running>
- <launchpad.debug>true</launchpad.debug>
- <http.port>8080</http.port>
- </properties>
- </profile>
- </profiles>
-
+
</project>
diff --git a/src/test/java/org/apache/sling/caconfig/it/example/SimpleConfig.java b/src/main/java/org/apache/sling/caconfig/it/example/SimpleConfig.java
similarity index 100%
rename from src/test/java/org/apache/sling/caconfig/it/example/SimpleConfig.java
rename to src/main/java/org/apache/sling/caconfig/it/example/SimpleConfig.java
diff --git a/src/main/java/org/apache/sling/caconfig/it/example/package-info.java b/src/main/java/org/apache/sling/caconfig/it/example/package-info.java
new file mode 100644
index 0000000..1217c94
--- /dev/null
+++ b/src/main/java/org/apache/sling/caconfig/it/example/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@Version("1.0")
+package org.apache.sling.caconfig.it.example;
+
+import org.osgi.annotation.versioning.Version;
diff --git a/src/test/java/org/apache/sling/caconfig/it/AdaptToConfigClassIT.java b/src/test/java/org/apache/sling/caconfig/it/AdaptToConfigClassIT.java
index cf1ee47..cdcbe4f 100644
--- a/src/test/java/org/apache/sling/caconfig/it/AdaptToConfigClassIT.java
+++ b/src/test/java/org/apache/sling/caconfig/it/AdaptToConfigClassIT.java
@@ -37,32 +37,33 @@ import org.junit.Rule;
import org.junit.Test;
public class AdaptToConfigClassIT {
-
+
@Rule
public TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "IT");
-
+
private ResourceResolver resourceResolver;
private ResourceBuilder resourceBuilder;
-
+
private static final String PAGE_PATH = CONTENT_ROOT_PATH + "/page1";
private static final String CONFIG_PATH = CONFIG_ROOT_PATH + "/page1";
-
+
@Before
public void setUp() throws Exception {
- resourceResolver = teleporter.getService(ResourceResolverFactory.class).getAdministrativeResourceResolver(null);
+ resourceResolver = teleporter.getService(ResourceResolverFactory.class).getServiceResourceResolver(null);
resourceBuilder = teleporter.getService(ResourceBuilderFactory.class).forResolver(resourceResolver);
}
-
+
@After
public void tearDown() {
cleanUp(resourceResolver);
resourceResolver.close();
}
-
+
@Test
+ @SuppressWarnings("null")
public void testNonExistingConfig() throws Exception {
Resource resourcePage1 = resourceBuilder.resource(PAGE_PATH).getCurrentParent();
-
+
SimpleConfig config = resourcePage1.adaptTo(ConfigurationBuilder.class).as(SimpleConfig.class);
assertNotNull(config);
@@ -70,8 +71,9 @@ public class AdaptToConfigClassIT {
assertEquals(0, config.intParam());
assertEquals(false, config.boolParam());
}
-
+
@Test
+ @SuppressWarnings("null")
public void testExistingConfig() throws Exception {
resourceBuilder.resource(CONFIG_PATH + "/sling:configs/org.apache.sling.caconfig.it.example.SimpleConfig",
"stringParam", "value1",
@@ -80,13 +82,13 @@ public class AdaptToConfigClassIT {
.resource(PAGE_PATH, "sling:configRef", CONFIG_PATH);
Resource resourcePage1 = resourceResolver.getResource(PAGE_PATH);
-
+
SimpleConfig config = resourcePage1.adaptTo(ConfigurationBuilder.class).as(SimpleConfig.class);
assertNotNull(config);
-
+
assertEquals("value1", config.stringParam());
- assertEquals(123, (int)config.intParam());
+ assertEquals(123, config.intParam());
assertEquals(true, config.boolParam());
}
-
+
}
diff --git a/src/test/java/org/apache/sling/caconfig/it/ConfigurationManagerIT.java b/src/test/java/org/apache/sling/caconfig/it/ConfigurationManagerIT.java
index 597041a..354c86c 100644
--- a/src/test/java/org/apache/sling/caconfig/it/ConfigurationManagerIT.java
+++ b/src/test/java/org/apache/sling/caconfig/it/ConfigurationManagerIT.java
@@ -49,37 +49,37 @@ import org.junit.Rule;
import org.junit.Test;
public class ConfigurationManagerIT {
-
+
@Rule
public TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "IT");
-
+
private ResourceResolver resourceResolver;
private ResourceBuilder resourceBuilder;
private ConfigurationManager configManager;
private ConfigurationResolver configResolver;
-
+
private static final String PAGE_PATH = CONTENT_ROOT_PATH + "/page1";
private static final String CONFIG_PATH = CONFIG_ROOT_PATH + "/page1";
private static final String CONFIG_NAME = SimpleConfig.class.getName();
-
+
private Resource resourcePage1;
-
+
@Before
public void setUp() throws Exception {
- resourceResolver = teleporter.getService(ResourceResolverFactory.class).getAdministrativeResourceResolver(null);
+ resourceResolver = teleporter.getService(ResourceResolverFactory.class).getServiceResourceResolver(null);
resourceBuilder = teleporter.getService(ResourceBuilderFactory.class).forResolver(resourceResolver);
configManager = teleporter.getService(ConfigurationManager.class);
configResolver = teleporter.getService(ConfigurationResolver.class);
-
+
resourcePage1 = resourceBuilder.resource(PAGE_PATH, "sling:configRef", CONFIG_PATH).getCurrentParent();
}
-
+
@After
public void tearDown() {
cleanUp(resourceResolver);
resourceResolver.close();
}
-
+
@Test
public void testNonExistingConfig() throws Exception {
ConfigurationData config = configManager.getConfiguration(resourcePage1, CONFIG_NAME);
@@ -91,24 +91,24 @@ public class ConfigurationManagerIT {
assertEquals(0, (int)props.get("intParam", 0));
assertEquals(false, props.get("boolParam", false));
}
-
+
@Test
public void testExistingConfig() throws Exception {
resourceBuilder.resource(CONFIG_PATH + "/sling:configs/" + CONFIG_NAME,
"stringParam", "value1",
"intParam", 123,
"boolParam", true);
-
+
ConfigurationData config = configManager.getConfiguration(resourcePage1, CONFIG_NAME);
assertNotNull(config);
-
+
ValueMap props = config.getEffectiveValues();
assertEquals("value1", props.get("stringParam", String.class));
assertEquals("defValue", props.get("stringParamDefault", String.class));
assertEquals(123, (int)props.get("intParam", 0));
assertEquals(true, props.get("boolParam", false));
}
-
+
@Test
public void testWriteConfig() throws Exception {
// write configuration data via configuration manager
@@ -119,17 +119,17 @@ public class ConfigurationManagerIT {
values.put("boolParam", true);
configManager.persistConfiguration(resourcePage1, CONFIG_NAME, new ConfigurationPersistData(values));
resourceResolver.commit();
-
+
// read config via configuration resolver
SimpleConfig config = configResolver.get(resourcePage1).as(SimpleConfig.class);
assertNotNull(config);
-
+
assertEquals("valueA", config.stringParam());
assertEquals("valueB", config.stringParamDefault());
- assertEquals(55, (int)config.intParam());
+ assertEquals(55, config.intParam());
assertEquals(true, config.boolParam());
}
-
+
@Test
public void testWriteConfigCollection() throws Exception {
// write configuration data via configuration manager
@@ -144,19 +144,19 @@ public class ConfigurationManagerIT {
items.add(new ConfigurationPersistData(values2).collectionItemName("item2"));
configManager.persistConfigurationCollection(resourcePage1, CONFIG_NAME, new ConfigurationCollectionPersistData(items));
resourceResolver.commit();
-
+
// read config via configuration resolver
Collection<SimpleConfig> config = configResolver.get(resourcePage1).asCollection(SimpleConfig.class);
assertEquals(2, config.size());
-
+
Iterator<SimpleConfig> configIterator = config.iterator();
SimpleConfig config1 = configIterator.next();
SimpleConfig config2 = configIterator.next();
-
+
assertEquals("valueA", config1.stringParam());
assertEquals("valueB", config1.stringParamDefault());
- assertEquals(55, (int)config2.intParam());
+ assertEquals(55, config2.intParam());
assertEquals(true, config2.boolParam());
}
-
+
}
diff --git a/src/test/java/org/apache/sling/caconfig/it/ConfigurationResolverConfigClassIT.java b/src/test/java/org/apache/sling/caconfig/it/ConfigurationResolverConfigClassIT.java
index 44a668d..09a69fd 100644
--- a/src/test/java/org/apache/sling/caconfig/it/ConfigurationResolverConfigClassIT.java
+++ b/src/test/java/org/apache/sling/caconfig/it/ConfigurationResolverConfigClassIT.java
@@ -37,32 +37,32 @@ import org.junit.Rule;
import org.junit.Test;
public class ConfigurationResolverConfigClassIT {
-
+
@Rule
public TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "IT");
-
+
private ResourceResolver resourceResolver;
private ResourceBuilder resourceBuilder;
-
+
private static final String PAGE_PATH = CONTENT_ROOT_PATH + "/page1";
private static final String CONFIG_PATH = CONFIG_ROOT_PATH + "/page1";
-
+
@Before
public void setUp() throws Exception {
- resourceResolver = teleporter.getService(ResourceResolverFactory.class).getAdministrativeResourceResolver(null);
+ resourceResolver = teleporter.getService(ResourceResolverFactory.class).getServiceResourceResolver(null);
resourceBuilder = teleporter.getService(ResourceBuilderFactory.class).forResolver(resourceResolver);
}
-
+
@After
public void tearDown() {
cleanUp(resourceResolver);
resourceResolver.close();
}
-
+
@Test
public void testNonExistingConfig() throws Exception {
Resource resourcePage1 = resourceBuilder.resource(PAGE_PATH).getCurrentParent();
-
+
ConfigurationResolver configResolver = teleporter.getService(ConfigurationResolver.class);
SimpleConfig config = configResolver.get(resourcePage1).name("test").as(SimpleConfig.class);
assertNotNull(config);
@@ -72,25 +72,26 @@ public class ConfigurationResolverConfigClassIT {
assertEquals(0, config.intParam());
assertEquals(false, config.boolParam());
}
-
+
@Test
+ @SuppressWarnings("null")
public void testExistingConfig() throws Exception {
resourceBuilder.resource(CONFIG_PATH + "/sling:configs/test",
"stringParam", "value1",
"intParam", 123,
"boolParam", true)
.resource(PAGE_PATH, "sling:configRef", CONFIG_PATH);
-
+
Resource resourcePage1 = resourceResolver.getResource(PAGE_PATH);
-
+
ConfigurationResolver configResolver = teleporter.getService(ConfigurationResolver.class);
SimpleConfig config = configResolver.get(resourcePage1).name("test").as(SimpleConfig.class);
assertNotNull(config);
-
+
assertEquals("value1", config.stringParam());
assertEquals("defValue", config.stringParamDefault());
- assertEquals(123, (int)config.intParam());
+ assertEquals(123, config.intParam());
assertEquals(true, config.boolParam());
}
-
+
}
diff --git a/src/test/java/org/apache/sling/caconfig/it/ConfigurationResolverValueMapIT.java b/src/test/java/org/apache/sling/caconfig/it/ConfigurationResolverValueMapIT.java
index 39f09ba..195eb55 100644
--- a/src/test/java/org/apache/sling/caconfig/it/ConfigurationResolverValueMapIT.java
+++ b/src/test/java/org/apache/sling/caconfig/it/ConfigurationResolverValueMapIT.java
@@ -37,32 +37,32 @@ import org.junit.Rule;
import org.junit.Test;
public class ConfigurationResolverValueMapIT {
-
+
@Rule
public TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "IT");
-
+
private ResourceResolver resourceResolver;
private ResourceBuilder resourceBuilder;
-
+
private static final String PAGE_PATH = CONTENT_ROOT_PATH + "/page1";
private static final String CONFIG_PATH = CONFIG_ROOT_PATH + "/page1";
-
+
@Before
public void setUp() throws Exception {
- resourceResolver = teleporter.getService(ResourceResolverFactory.class).getAdministrativeResourceResolver(null);
+ resourceResolver = teleporter.getService(ResourceResolverFactory.class).getServiceResourceResolver(null);
resourceBuilder = teleporter.getService(ResourceBuilderFactory.class).forResolver(resourceResolver);
}
-
+
@After
public void tearDown() {
cleanUp(resourceResolver);
resourceResolver.close();
}
-
+
@Test
public void testNonExistingConfig() throws Exception {
Resource resourcePage1 = resourceBuilder.resource(PAGE_PATH).getCurrentParent();
-
+
ConfigurationResolver configResolver = teleporter.getService(ConfigurationResolver.class);
ValueMap props = configResolver.get(resourcePage1).name("test").asValueMap();
assertNotNull(props);
@@ -71,24 +71,25 @@ public class ConfigurationResolverValueMapIT {
assertEquals(0, (int)props.get("intParam", 0));
assertEquals(false, props.get("boolParam", false));
}
-
+
@Test
+ @SuppressWarnings("null")
public void testExistingConfig() throws Exception {
resourceBuilder.resource(CONFIG_PATH + "/sling:configs/test",
"stringParam", "value1",
"intParam", 123,
"boolParam", true)
.resource(PAGE_PATH, "sling:configRef", CONFIG_PATH);
-
+
Resource resourcePage1 = resourceResolver.getResource(PAGE_PATH);
-
+
ConfigurationResolver configResolver = teleporter.getService(ConfigurationResolver.class);
ValueMap props = configResolver.get(resourcePage1).name("test").asValueMap();
assertNotNull(props);
-
+
assertEquals("value1", props.get("stringParam", String.class));
assertEquals(123, (int)props.get("intParam", 0));
assertEquals(true, props.get("boolParam", false));
}
-
+
}
diff --git a/src/test/java/org/apache/sling/junit/teleporter/customizers/ITCustomizer.java b/src/test/java/org/apache/sling/junit/teleporter/customizers/ITCustomizer.java
index 9526d47..c90081b 100644
--- a/src/test/java/org/apache/sling/junit/teleporter/customizers/ITCustomizer.java
+++ b/src/test/java/org/apache/sling/junit/teleporter/customizers/ITCustomizer.java
@@ -16,25 +16,42 @@
*/
package org.apache.sling.junit.teleporter.customizers;
+import java.net.URI;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.sling.caconfig.impl.ConfigurationBuilderAdapterFactory;
import org.apache.sling.junit.rules.TeleporterRule;
+import org.apache.sling.testing.clients.ClientException;
+import org.apache.sling.testing.clients.osgi.OsgiConsoleClient;
import org.apache.sling.testing.teleporter.client.ClientSideTeleporter;
+import org.apache.sling.testing.tools.sling.SlingTestBase;
import org.apache.sling.testing.tools.sling.TimeoutsProvider;
public class ITCustomizer implements TeleporterRule.Customizer {
- public static final String BASE_URL_PROP = "launchpad.http.server.url";
+ private final static SlingTestBase S = new SlingTestBase();
+
+ private static final Class[] EXPECTED_COMPONENTS = new Class[] {
+ ConfigurationBuilderAdapterFactory.class
+ };
@Override
public void customize(TeleporterRule t, String options) {
final ClientSideTeleporter cst = (ClientSideTeleporter)t;
- cst.setBaseUrl(System.getProperty(BASE_URL_PROP, BASE_URL_PROP + "_IS_NOT_SET"));
- cst.setServerCredentials("admin", "admin");
+ cst.setBaseUrl(S.getServerBaseUrl());
+ cst.setServerCredentials(S.getServerUsername(), S.getServerPassword());
+ cst.setTestReadyTimeoutSeconds(TimeoutsProvider.getInstance().getTimeout(5));
cst.includeDependencyPrefix("org.apache.sling.caconfig.it");
- cst.setTestReadyTimeoutSeconds(TimeoutsProvider.getInstance().getTimeout(10));
-
- // list all configuration annotation classes here (separated by ",")
- cst.getAdditionalBundleHeaders().put("Sling-ContextAware-Configuration-Classes",
- "org.apache.sling.caconfig.it.example.SimpleConfig");
+
+ // additionally check for the registration of mandatory sling models components
+ try {
+ OsgiConsoleClient osgiClient = new OsgiConsoleClient(URI.create(S.getServerBaseUrl()), S.getServerUsername(), S.getServerPassword());
+ for (Class clazz : EXPECTED_COMPONENTS) {
+ osgiClient.waitComponentRegistered(clazz.getName(), 20000, 200);
+ }
+ } catch (ClientException | TimeoutException | InterruptedException ex) {
+ throw new RuntimeException("Error waiting for expected components.", ex);
+ }
}
}
diff --git a/src/main/provisioning/integration-tests.txt b/src/test/provisioning/sling-caconfig..txt
similarity index 70%
rename from src/main/provisioning/integration-tests.txt
rename to src/test/provisioning/sling-caconfig..txt
index 366fb5a..1505e7e 100644
--- a/src/main/provisioning/integration-tests.txt
+++ b/src/test/provisioning/sling-caconfig..txt
@@ -16,19 +16,14 @@
# specific language governing permissions and limitations
# under the License.
#
-[feature name=integration-tests]
+#
+[feature name=sling-caconfig]
[artifacts]
- org.apache.sling/org.apache.sling.launchpad//slingfeature/slingfeature
+ org.apache.sling/org.apache.sling.caconfig.api
+ org.apache.sling/org.apache.sling.caconfig.spi
+ org.apache.sling/org.apache.sling.caconfig.impl
-[artifacts startLevel=15]
- org.apache.sling/org.apache.sling.junit.core
- org.apache.sling/org.apache.sling.testing.tools
- org.apache.sling/org.apache.sling.resourcebuilder
- org.apache.sling/org.apache.sling.caconfig.api
- org.apache.sling/org.apache.sling.caconfig.spi
- org.apache.sling/org.apache.sling.caconfig.impl
-
[configurations]
org.apache.sling.commons.log.LogManager.factory.config-slingconfig.log
org.apache.sling.commons.log.names=["org.apache.sling.caconfig"]
@@ -40,10 +35,6 @@
"org.apache.sling.caconfig.impl\=sling-caconfig"
]
- org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-junitcore
- whitelist.name="junitcore"
- whitelist.bundles=["org.apache.sling.junit.core"]
-
[:repoinit]
create service user sling-caconfig
diff --git a/src/test/provisioning/sling.txt b/src/test/provisioning/sling.txt
new file mode 100644
index 0000000..ff79119
--- /dev/null
+++ b/src/test/provisioning/sling.txt
@@ -0,0 +1,40 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# must be the same feature name as the feature defined in slingstart to allow merging
+[feature name=sling]
+
+[artifacts]
+ org.apache.sling/org.apache.sling.starter/11/slingstart
+
+ # Additional test bundles
+ org.apache.sling/org.apache.sling.junit.core
+ org.apache.sling/org.apache.sling.resourcebuilder
+ org.apache.sling/org.apache.sling.caconfig.integration-tests
+
+[configurations]
+ # configure service user mapping for junit core (being used in the IT itself)
+ org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-junit
+ user.mapping=["org.apache.sling.junit.core\=caconfig-it"]
+
+[:repoinit]
+ create service user caconfig-it
+ set ACL for caconfig-it
+ allow jcr:all on /
+ end