SLING-7786 : Use R7 configuration admin supporting named factory configurations
diff --git a/src/test/java/org/apache/sling/installer/it/BundleInstallUpgradeDowngradeTest.java b/src/test/java/org/apache/sling/installer/it/BundleInstallUpgradeDowngradeTest.java
index 70d93c9..f95caf0 100644
--- a/src/test/java/org/apache/sling/installer/it/BundleInstallUpgradeDowngradeTest.java
+++ b/src/test/java/org/apache/sling/installer/it/BundleInstallUpgradeDowngradeTest.java
@@ -20,7 +20,6 @@
import static org.junit.Assert.assertNull;
import org.apache.sling.installer.api.InstallableResource;
-import org.apache.sling.installer.it.OsgiInstallerTestBase.BundleEvent;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -36,12 +35,13 @@
public Option[] config() {
return defaultConfiguration();
}
-
+
@Before
public void setUp() {
setupInstaller();
}
+ @Override
@After
public void tearDown() {
super.tearDown();
@@ -211,7 +211,7 @@
}
/**
- * This test class assures that whenever a new bundle is
+ * This test class assures that whenever a new bundle is
* provided with the same url as an already installed bundle,
* the already installed bundle is uninstalled and the new one installed.
* @see <a href="https://issues.apache.org/jira/browse/SLING-6392">SLING-6392</a>
@@ -221,7 +221,7 @@
final String symbolicName = "osgi-installer-testbundle";
final String symbolicName2 = "osgi-installer-testA";
final String installableResourceId = "stable-id";
-
+
assertNull("Test bundle must not be present before test", findBundle(symbolicName));
assertNull("Test A bundle must not be present before test", findBundle(symbolicName2));
{
diff --git a/src/test/java/org/apache/sling/installer/it/BundleInstallUpgradeExceptionRetryTest.java b/src/test/java/org/apache/sling/installer/it/BundleInstallUpgradeExceptionRetryTest.java
index d5aaf35..0fbb122 100644
--- a/src/test/java/org/apache/sling/installer/it/BundleInstallUpgradeExceptionRetryTest.java
+++ b/src/test/java/org/apache/sling/installer/it/BundleInstallUpgradeExceptionRetryTest.java
@@ -73,8 +73,8 @@
@Test
public void testUpdateFailsWithMoreThanMaxRetrys() throws Exception {
// install version 1.1 and fail activation with exception all attempts
- final Object listener = this.startObservingBundleEvents();
- final AtomicReference<ServiceRegistration<AtomicInteger>> ref = new AtomicReference<ServiceRegistration<AtomicInteger>>(
+ this.startObservingBundleEvents();
+ final AtomicReference<ServiceRegistration<AtomicInteger>> ref = new AtomicReference<>(
null);
final AtomicInteger counter = new AtomicInteger(5);
bundleContext.addBundleListener(new SynchronousBundleListener() {
@@ -124,8 +124,8 @@
@Test
public void testUpdateSuccedsWithLessThanMaxRetrys() throws Exception {
// install version 1.1 and fail activation with exception all attempts
- final Object listener = this.startObservingBundleEvents();
- final AtomicReference<ServiceRegistration<AtomicInteger>> ref = new AtomicReference<ServiceRegistration<AtomicInteger>>(
+ this.startObservingBundleEvents();
+ final AtomicReference<ServiceRegistration<AtomicInteger>> ref = new AtomicReference<>(
null);
final AtomicInteger counter = new AtomicInteger(3);
bundleContext.addBundleListener(new SynchronousBundleListener() {
@@ -175,14 +175,14 @@
return createBundle("testbundle", manifest, ThrowingActivator.class);
}
- private static File createBundle(String name, String manifest, Class... classes) throws IOException {
+ private static File createBundle(String name, String manifest, Class<?>... classes) throws IOException {
File f = File.createTempFile(name, ".jar");
f.deleteOnExit();
Manifest mf = new Manifest(new ByteArrayInputStream(manifest.getBytes("utf-8")));
JarOutputStream os = new JarOutputStream(new FileOutputStream(f), mf);
- for (Class clazz : classes) {
+ for (Class<?> clazz : classes) {
String path = clazz.getName().replace('.', '/') + ".class";
os.putNextEntry(new ZipEntry(path));
diff --git a/src/test/java/org/apache/sling/installer/it/ConfigUpdateTest.java b/src/test/java/org/apache/sling/installer/it/ConfigUpdateTest.java
index 6074c0e..60452a3 100644
--- a/src/test/java/org/apache/sling/installer/it/ConfigUpdateTest.java
+++ b/src/test/java/org/apache/sling/installer/it/ConfigUpdateTest.java
@@ -141,6 +141,30 @@
assertEquals(FACTORY_PID, c1.getFactoryPid());
assertEquals(Boolean.TRUE, c.getProperties().get("modified"));
}
+
+ // make sure there is only one state in the OSGi installer
+ final InfoProvider infoProvider = getService(InfoProvider.class);
+ ResourceGroup found = null;
+ final InstallationState state = infoProvider.getInstallationState();
+ for(final ResourceGroup group : state.getInstalledResources()) {
+ for(final Resource rsrc : group.getResources()) {
+ if ( rsrc.getScheme().equals(SCHEME) && rsrc.getURL().equals(SCHEME + ":" + "configs/" + FACTORY_PID + "-" + name + ".cfg")) {
+ found = group;
+ break;
+ }
+ }
+ if ( found != null ) {
+ break;
+ }
+ }
+ assertNotNull(found);
+ assertEquals(1, found.getResources().size());
+ final Resource r = found.getResources().get(0);
+ if ( checkNew ) {
+ assertEquals("config:" + FACTORY_PID + "~" + name, r.getEntityId());
+ } else {
+ assertEquals("config:" + FACTORY_PID + "." + name, r.getEntityId());
+ }
}
@Override