You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2020/03/07 14:10:26 UTC
[sling-org-apache-sling-installer-it] branch master updated: Update
it tests to latest pax exam,
fix blacklist tests and update to test latest installer core and config
factory
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-it.git
The following commit(s) were added to refs/heads/master by this push:
new beb0cdb Update it tests to latest pax exam, fix blacklist tests and update to test latest installer core and config factory
beb0cdb is described below
commit beb0cdbff02595f07f69185a76a0e7495faa8eaf
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sat Mar 7 15:10:00 2020 +0100
Update it tests to latest pax exam, fix blacklist tests and update to test latest installer core and config factory
---
pom.xml | 25 +--
.../installer/it/BundleInstallBlackListTest.java | 174 +++++++--------------
.../sling/installer/it/OsgiInstallerTestBase.java | 24 ++-
.../blacklisttestempty/sling_bootstrap.txt | 0
4 files changed, 86 insertions(+), 137 deletions(-)
diff --git a/pom.xml b/pom.xml
index 6be1e6d..16ea99d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,23 +21,23 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>33</version>
+ <version>38</version>
<relativePath/>
</parent>
<artifactId>org.apache.sling.installer.it</artifactId>
- <version>3.8.13-SNAPSHOT</version>
+ <version>3.10.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Apache Sling Installer Integration Tests</name>
<description>Integration tests of the Sling installer bundle</description>
<properties>
- <exam.version>3.0.3</exam.version>
- <url.version>2.5.2</url.version>
+ <exam.version>4.13.1</exam.version>
+ <url.version>2.6.1</url.version>
<pax.exam.log.level>INFO</pax.exam.log.level>
<pax.vm.options>-Xmx256M -XX:MaxPermSize=256m</pax.vm.options>
- <installer.configuration.version>1.1.3-SNAPSHOT</installer.configuration.version>
+ <installer.configuration.version>1.3.1-SNAPSHOT</installer.configuration.version>
<argLine>${pax.vm.options}</argLine>
@@ -451,6 +451,12 @@
<dependencies>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.cm</artifactId>
+ <version>1.6.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.installer.factory.configuration</artifactId>
<version>${installer.configuration.version}</version>
@@ -463,12 +469,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.cm</artifactId>
- <version>1.6.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.log</artifactId>
<version>2.1.2</version>
@@ -477,6 +477,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <version>4.13</version>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
@@ -510,7 +511,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
- <version>5.6.1</version>
+ <version>6.0.3</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/src/test/java/org/apache/sling/installer/it/BundleInstallBlackListTest.java b/src/test/java/org/apache/sling/installer/it/BundleInstallBlackListTest.java
index 864ff17..26ce2e4 100644
--- a/src/test/java/org/apache/sling/installer/it/BundleInstallBlackListTest.java
+++ b/src/test/java/org/apache/sling/installer/it/BundleInstallBlackListTest.java
@@ -18,10 +18,10 @@ package org.apache.sling.installer.it;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
import java.io.File;
-import org.apache.sling.installer.api.OsgiInstaller;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -29,13 +29,16 @@ import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
@RunWith(PaxExam.class)
public class BundleInstallBlackListTest extends OsgiInstallerTestBase {
final String symbolicName = "osgi-installer-testbundle";
+ final String BLACKLIST = "src/test/resources/blacklisttest";
+
+ final String PROPERTY_LAUNCHPAD = "sling.launchpad";
+
@Override
protected String requiredServices() {
return "";
@@ -43,28 +46,23 @@ public class BundleInstallBlackListTest extends OsgiInstallerTestBase {
@org.ops4j.pax.exam.Configuration
public Option[] config() {
- return defaultConfiguration();
+ final Option[] parentOpts = defaultConfiguration();
+ final Option[] options = new Option[parentOpts.length + 1];
+ System.arraycopy(parentOpts, 0, options, 0, parentOpts.length);
+ options[parentOpts.length] = frameworkProperty(PROPERTY_LAUNCHPAD).value(new File(BLACKLIST).getAbsolutePath());
+ return options;
}
@Override
@Before
public void setup() {
- // switch to system bundle context
- bundleContext = bundleContext.getBundle(0).getBundleContext();
- super.setup();
- System.setProperty("sling.launchpad",new File("src/test/resources/blacklisttest").getAbsolutePath());
- try {
- updateInstallerBundle();
- } catch ( BundleException be) {
- throw new RuntimeException(be);
- }
+ setupInstaller();
}
@Override
@After
public void tearDown() {
super.tearDown();
- System.clearProperty("sling.launchpad");
}
@Test
@@ -75,7 +73,6 @@ public class BundleInstallBlackListTest extends OsgiInstallerTestBase {
// Install first test bundle and check version
long bundleId = 0;
{
- assertNull("Test bundle must be absent before installing", findBundle(symbolicName));
final Object listener = this.startObservingBundleEvents();
installer.updateResources(URL_SCHEME, getInstallableResource(
getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar")), null);
@@ -97,158 +94,101 @@ public class BundleInstallBlackListTest extends OsgiInstallerTestBase {
final Bundle b = assertBundle("After updating to 1.1", symbolicName, "1.0", Bundle.ACTIVE);
assertEquals("Bundle ID must not change after update", bundleId, b.getBundleId());
}
-
}
@Test
public void testUninstallWithBlacklistedVersions() throws Exception {
-
- // Reroute launchpad home containing empty blacklist for ramp up
- System.setProperty("sling.launchpad",new File("src/test/resources/blacklisttestempty").getAbsolutePath());
- updateInstallerBundle();
-
assertNull("Test bundle must not be present before test", findBundle(symbolicName));
- // Install first test bundle and check version
- long bundleId = 0;
+ // Install first test bundle - is blacklisted
{
- assertNull("Test bundle must be absent before installing", findBundle(symbolicName));
final Object listener = this.startObservingBundleEvents();
- installer.updateResources(URL_SCHEME, getInstallableResource(
- getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")), null);
- this.waitForBundleEvents(symbolicName + " must be installed", listener,
- new BundleEvent(symbolicName, "1.1", org.osgi.framework.BundleEvent.INSTALLED),
- new BundleEvent(symbolicName, "1.1", org.osgi.framework.BundleEvent.STARTED));
- final Bundle b = assertBundle("After installing", symbolicName, "1.1", Bundle.ACTIVE);
- bundleId = b.getBundleId();
+ installer.updateResources(URL_SCHEME,
+ getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")), null);
+ sleep(150);
+ this.assertNoBundleEvents("Bundle install of blacklisted version should not cause any change.", listener,
+ symbolicName);
}
- // Upgrade to later version, verify
+ // Upgrade to later version (not blacklisted)
{
final Object listener = this.startObservingBundleEvents();
- installer.updateResources(URL_SCHEME, getInstallableResource(
- getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar"), "digestA"), null);
+ installer.updateResources(URL_SCHEME,
+ getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar"), "digestA"), null);
this.waitForBundleEvents(symbolicName + " must be installed", listener,
- new BundleEvent(symbolicName, "1.1", org.osgi.framework.BundleEvent.STOPPED),
- new BundleEvent(symbolicName, "1.2", org.osgi.framework.BundleEvent.STARTED));
- final Bundle b = assertBundle("After updating to 1.2", symbolicName, "1.2", Bundle.ACTIVE);
- assertEquals("Bundle ID must not change after update", bundleId, b.getBundleId());
+ new BundleEvent(symbolicName, "1.2", org.osgi.framework.BundleEvent.INSTALLED),
+ new BundleEvent(symbolicName, "1.2", org.osgi.framework.BundleEvent.STARTED));
+ assertBundle("After updating to 1.2", symbolicName, "1.2", Bundle.ACTIVE);
}
- // configure blacklist bundle to ignore older version
- System.setProperty("sling.launchpad",new File("src/test/resources/blacklisttest").getAbsolutePath());
- updateInstallerBundle();
-
// Try to uninstall current version and verify uninstall instead of
// downgrade to blacklisted version
{
final Object listener = this.startObservingBundleEvents();
- installer.updateResources(URL_SCHEME, null, getNonInstallableResourceUrl(
- getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
+ installer.updateResources(URL_SCHEME, null,
+ getNonInstallableResourceUrl(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
this.waitForBundleEvents(symbolicName + " must be installed", listener,
- new BundleEvent(symbolicName, "1.2", org.osgi.framework.BundleEvent.STOPPED),
- new BundleEvent(symbolicName, "1.2", org.osgi.framework.BundleEvent.UNINSTALLED));
+ new BundleEvent(symbolicName, "1.2", org.osgi.framework.BundleEvent.STOPPED),
+ new BundleEvent(symbolicName, "1.2", org.osgi.framework.BundleEvent.UNINSTALLED));
final Bundle b = findBundle(symbolicName);
assertNull("Testbundle must be gone", b);
}
-
- }
-
- private void updateInstallerBundle() throws BundleException {
- // wait a little bit for updating bundle
- sleep(2000);
- bundleContext.getServiceReference(OsgiInstaller.class).getBundle().update();
- // wait a little bit after updating bundle
- sleep(2000);
- setupInstaller();
}
@Test
public void testUninstallWithBlacklistedIntermediateVersion() throws Exception {
+ assertNull("Test bundle must not be present before test", findBundle(symbolicName));
- // Reroute launchpad home containing empty blacklist for ramp up
- System.setProperty("sling.launchpad",new File("src/test/resources/blacklisttestempty").getAbsolutePath());
- updateInstallerBundle();
-
- assertNull("Test bundle must not be present before test",
- findBundle(symbolicName));
-
- // Install first test bundle and check version
+ // Install 1.0 (not blacklisted)
long bundleId = 0;
{
- assertNull("Test bundle must be absent before installing",
- findBundle(symbolicName));
final Object listener = this.startObservingBundleEvents();
- installer.updateResources(URL_SCHEME, getInstallableResource(
- getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar")), null);
+ installer.updateResources(URL_SCHEME,
+ getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar")), null);
this.waitForBundleEvents(symbolicName + " must be installed", listener,
- new BundleEvent(symbolicName, "1.0",
- org.osgi.framework.BundleEvent.INSTALLED),
- new BundleEvent(symbolicName, "1.0",
- org.osgi.framework.BundleEvent.STARTED));
- final Bundle b = assertBundle("After installing", symbolicName, "1.0",
- Bundle.ACTIVE);
+ new BundleEvent(symbolicName, "1.0", org.osgi.framework.BundleEvent.INSTALLED),
+ new BundleEvent(symbolicName, "1.0", org.osgi.framework.BundleEvent.STARTED));
+ final Bundle b = assertBundle("After installing", symbolicName, "1.0", Bundle.ACTIVE);
bundleId = b.getBundleId();
}
- // Upgrade to later version, verify
+ // Try update to 1.1 (blacklisted)
{
final Object listener = this.startObservingBundleEvents();
- installer.updateResources(URL_SCHEME, getInstallableResource(
- getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar"), "digestA"),
- null);
- this.waitForBundleEvents(symbolicName + " must be installed", listener,
- new BundleEvent(symbolicName, "1.0",
- org.osgi.framework.BundleEvent.STOPPED),
- new BundleEvent(symbolicName, "1.1",
- org.osgi.framework.BundleEvent.STARTED));
- final Bundle b = assertBundle("After updating to 1.1", symbolicName,
- "1.1", Bundle.ACTIVE);
- assertEquals("Bundle ID must not change after update", bundleId,
- b.getBundleId());
+ installer.updateResources(URL_SCHEME,
+ getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar"), "digestA"), null);
+ sleep(150);
+ this.assertNoBundleEvents("Bundle install of blacklisted version should not cause any change.", listener,
+ symbolicName);
+ final Bundle b = assertBundle("After updating to 1.1", symbolicName, "1.0", Bundle.ACTIVE);
+ assertEquals("Bundle ID must not change after update", bundleId, b.getBundleId());
}
- // upgrade to 3rd version
+ // update to 1.2 (not blacklisted)
{
final Object listener = this.startObservingBundleEvents();
- installer.updateResources(URL_SCHEME, getInstallableResource(
- getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar"), "digestA"),
- null);
+ installer.updateResources(URL_SCHEME,
+ getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar"), "digestA"), null);
this.waitForBundleEvents(symbolicName + " must be installed", listener,
- new BundleEvent(symbolicName, "1.1",
- org.osgi.framework.BundleEvent.STOPPED),
- new BundleEvent(symbolicName, "1.2",
- org.osgi.framework.BundleEvent.STARTED));
- final Bundle b = assertBundle("After updating to 1.2", symbolicName,
- "1.2", Bundle.ACTIVE);
- assertEquals("Bundle ID must not change after update", bundleId,
- b.getBundleId());
+ new BundleEvent(symbolicName, "1.0", org.osgi.framework.BundleEvent.STOPPED),
+ new BundleEvent(symbolicName, "1.2", org.osgi.framework.BundleEvent.STARTED));
+ final Bundle b = assertBundle("After updating to 1.2", symbolicName, "1.2", Bundle.ACTIVE);
+ assertEquals("Bundle ID must not change after update", bundleId, b.getBundleId());
}
- // configure blacklist bundle to ignore 1.1 version
- // configure blacklist bundle to ignore older version
- System.setProperty("sling.launchpad",new File("src/test/resources/blacklisttest").getAbsolutePath());
- updateInstallerBundle();
-
- // Try to uninstall current version and verify uninstall instead of
- // downgrade to blacklisted version
+ // uninstall 1.2 - as 1.1 is blacklisted, 1.0 should be active at the end
{
final Object listener = this.startObservingBundleEvents();
- installer.updateResources(URL_SCHEME, null, getNonInstallableResourceUrl(
- getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
+ installer.updateResources(URL_SCHEME, null,
+ getNonInstallableResourceUrl(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar")));
this.waitForBundleEvents(symbolicName + " must be installed", listener,
- new BundleEvent(symbolicName, "1.2",
- org.osgi.framework.BundleEvent.STOPPED),
- new BundleEvent(symbolicName, "1.0",
- org.osgi.framework.BundleEvent.STARTED));
-
- final Bundle b = assertBundle("After uninstalling 1.2", symbolicName,
- "1.0", Bundle.ACTIVE);
- assertEquals("Bundle ID must not change after update", bundleId,
- b.getBundleId());
+ new BundleEvent(symbolicName, "1.2", org.osgi.framework.BundleEvent.STOPPED),
+ new BundleEvent(symbolicName, "1.0", org.osgi.framework.BundleEvent.STARTED));
+
+ final Bundle b = assertBundle("After uninstalling 1.2", symbolicName, "1.0", Bundle.ACTIVE);
+ assertEquals("Bundle ID must not change after update", bundleId, b.getBundleId());
}
}
-
}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java b/src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java
index eea82a0..cf98ee7 100644
--- a/src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java
+++ b/src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java
@@ -495,19 +495,27 @@ public class OsgiInstallerTestBase implements FrameworkListener {
systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepo)
),
systemProperty( "org.ops4j.pax.logging.DefaultServiceLog.level" ).value(paxDebugLevel),
- frameworkProperty("sling.installer.requiredservices").value(requiredServices()),
+ when(!requiredServices().isEmpty())
+ .useOptions(frameworkProperty("sling.installer.requiredservices").value(requiredServices())
+ ),
provision(
mavenBundle("org.apache.sling", "org.apache.sling.commons.log", "4.0.6"),
mavenBundle("org.apache.sling", "org.apache.sling.commons.logservice", "1.0.6"),
- mavenBundle("org.slf4j", "slf4j-api", "1.7.5"),
- mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.5"),
- mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.5"),
+ // mavenBundle("org.slf4j", "slf4j-api", "1.7.5"),
+ // mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.5"),
+ // mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.5"),
+
+ mavenBundle("org.osgi", "org.osgi.util.function", "1.0.0"),
+ mavenBundle("org.osgi", "org.osgi.util.promise", "1.0.0"),
+
+ mavenBundle("org.apache.felix", "org.apache.felix.scr", "2.1.16"),
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.9.16"),
+ mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.2.2"),
+ mavenBundle("org.apache.felix", "org.apache.felix.converter", "1.0.10"),
+ mavenBundle("org.apache.sling", "org.apache.sling.commons.johnzon", "1.1.2"),
- mavenBundle("org.apache.felix", "org.apache.felix.scr", "2.1.0"),
- mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.9.4"),
- mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.2.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.installer.core", POM_VERSION).startLevel(5),
+ mavenBundle("org.apache.sling", "org.apache.sling.installer.core", POM_VERSION).startLevel(5),
mavenBundle("org.apache.sling", "org.apache.sling.installer.factory.configuration", CONFIG_VERSION).startLevel(5)
)
);
diff --git a/src/test/resources/blacklisttestempty/sling_bootstrap.txt b/src/test/resources/blacklisttestempty/sling_bootstrap.txt
deleted file mode 100644
index e69de29..0000000