incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r805872 - in /sling/trunk/installer/osgi: installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java it/pom.xml it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java
Date Wed, 19 Aug 2009 16:38:00 GMT
Author: bdelacretaz
Date: Wed Aug 19 16:38:00 2009
New Revision: 805872

URL: http://svn.apache.org/viewvc?rev=805872&view=rev
Log:
SLING-1078 - BundleSnapshotUpdateTest added

Added:
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java
  (with props)
Modified:
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java
    sling/trunk/installer/osgi/it/pom.xml

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java?rev=805872&r1=805871&r2=805872&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java
Wed Aug 19 16:38:00 2009
@@ -125,7 +125,9 @@
     
     @Test 
     public void testBundleUpgradeSnapshot() {
-        final String v = "2.0.7.-SNAPSHOT";
+        // Need to use OSGi-compliant version number, in bundles
+        // bnd and other tools generate correct numbers.
+        final String v = "2.0.7.SNAPSHOT";
         final RegisteredResource [] r = {
                 new MockBundleResource(SN, v)
         };

Modified: sling/trunk/installer/osgi/it/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/pom.xml?rev=805872&r1=805871&r2=805872&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/pom.xml (original)
+++ sling/trunk/installer/osgi/it/pom.xml Wed Aug 19 16:38:00 2009
@@ -235,6 +235,32 @@
                             </archive>
                         </configuration>
                     </execution>
+                    <execution>
+                        <id>snapshot-1.0</id>
+                        <phase>compile</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>snap</classifier>
+                            <includes>
+                                <include>**/b/**</include>
+                                <include>META-INF/**</include>
+                            </includes>
+                            <archive>
+                                <manifestEntries>
+                                    <Manifest-Version>2</Manifest-Version>
+                                    <Bundle-Name>OSGi controller test bundle</Bundle-Name>
+                                    <Bundle-SymbolicName>osgi-installer-snapshot-test</Bundle-SymbolicName>
+                                    <!-- 
+                                        Need to use OSGi-compliant version, so .SNAPSHOT
not -SNAPSHOT.
+                                        In real bundles, bnd and similar tools to the conversion.
+                                     -->
+                                    <Bundle-Version>1.0.0.SNAPSHOT</Bundle-Version>
+                                </manifestEntries>
+                            </archive>
+                        </configuration>
+                    </execution>
                 </executions>
             </plugin>
           </plugins>

Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java?rev=805872&view=auto
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java
(added)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java
Wed Aug 19 16:38:00 2009
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+package org.apache.sling.osgi.installer.it;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+
+/** Verify that snapshot bundles are updated even if
+ *  their version number does not change.
+ *  TODO: digests should be taken into account, i.e. no action
+ *  if digest does not change
+ */
+@RunWith(JUnit4TestRunner.class)
+public class BundleSnapshotUpdateTest extends OsgiInstallerTestBase {
+    
+    @org.ops4j.pax.exam.junit.Configuration
+    public static Option[] configuration() {
+        return defaultConfiguration();
+    }
+    
+    @Before
+    public void setUp() {
+        setupInstaller();
+    }
+    
+    @After
+    public void tearDown() {
+        super.tearDown();
+    }
+ 
+    @Test
+    public void testNonSnapshot() throws IOException {
+        final String symbolicName = "osgi-installer-testbundle";
+        assertNull("Test bundle must be absent before installing", findBundle(symbolicName));
+        resetCounters();
+        installer.addResource(getInstallableResource(
+                getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
+        // wait for two tasks: install and start
+        waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+        final Bundle b = findBundle(symbolicName);
+        assertNotNull("Test bundle 1.1 must be found after waitForInstallerAction", b);
+        
+        final long nOps = installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER];
+        installer.addResource(getInstallableResource(
+                getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar")));
+        waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 1);
+        assertEquals("Updating non-snapshot bundle must not generate any OSGi tasks",
+                nOps, installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER]);
+    }
+    
+    @Test
+    public void testSnapshot() throws IOException {
+        final String symbolicName = "osgi-installer-snapshot-test";
+        assertNull("Snapshot test bundle must be absent before installing", findBundle(symbolicName));
+        resetCounters();
+        installer.addResource(getInstallableResource(
+                getTestBundle(BUNDLE_BASE_NAME + "-snap.jar")));
+        // wait for two tasks: install and start
+        waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+        final Bundle b = findBundle(symbolicName);
+        assertNotNull("Snapshot bundle must be found after waitForInstallerAction", b);
+
+        resetCounters();
+        installer.addResource(getInstallableResource(
+                getTestBundle(BUNDLE_BASE_NAME + "-snap.jar")));
+        waitForInstallerAction(OsgiInstaller.INSTALLER_CYCLES_COUNTER, 1);
+        // If this fails it means bundle has not been updated
+        waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 1);
+    }
+}

Propchange: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message