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 ec6dff8  SLING-7786 : Use R7 configuration admin supporting named 
factory configurations
ec6dff8 is described below

commit ec6dff87c6bba954546d1076f59ed06b5a7d6397
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Wed Aug 1 10:58:55 2018 +0200

    SLING-7786 : Use R7 configuration admin supporting named factory 
configurations
---
 .../it/BundleInstallUpgradeDowngradeTest.java      |  8 ++++----
 .../it/BundleInstallUpgradeExceptionRetryTest.java | 12 +++++------
 .../sling/installer/it/ConfigUpdateTest.java       | 24 ++++++++++++++++++++++
 3 files changed, 34 insertions(+), 10 deletions(-)

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.assertEquals;
 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 class BundleInstallUpgradeDowngradeTest extends 
OsgiInstallerTestBase {
     public Option[] config() {
         return defaultConfiguration();
     }
-    
+
     @Before
     public void setUp() {
         setupInstaller();
     }
 
+    @Override
     @After
     public void tearDown() {
         super.tearDown();
@@ -211,7 +211,7 @@ public class BundleInstallUpgradeDowngradeTest extends 
OsgiInstallerTestBase {
     }
 
     /**
-     * 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 @@ public class BundleInstallUpgradeDowngradeTest extends 
OsgiInstallerTestBase {
         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 @@ public class BundleInstallUpgradeExceptionRetryTest extends 
OsgiInstallerTestBas
        @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 @@ public class BundleInstallUpgradeExceptionRetryTest extends 
OsgiInstallerTestBas
        @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 @@ public class BundleInstallUpgradeExceptionRetryTest 
extends OsgiInstallerTestBas
                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 @@ public class ConfigUpdateTest extends 
OsgiInstallerTestBase {
             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

Reply via email to