Author: gnodet
Date: Thu Sep 23 09:18:07 2010
New Revision: 1000372

URL: http://svn.apache.org/viewvc?rev=1000372&view=rev
Log:
[KARAF-219] Fix integration tests

Added:
    
karaf/trunk/tooling/testing/src/main/java/org/apache/karaf/testing/HeaderParser.java
      - copied, changed from r1000371, 
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/HeaderParser.java
Removed:
    
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/HeaderParser.java
Modified:
    
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/CoreTest.java
    
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/FeaturesTest.java
    karaf/trunk/pom.xml
    karaf/trunk/tooling/testing/pom.xml
    
karaf/trunk/tooling/testing/src/main/java/org/apache/karaf/testing/Helper.java

Modified: 
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/CoreTest.java
URL: 
http://svn.apache.org/viewvc/karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/CoreTest.java?rev=1000372&r1=1000371&r2=1000372&view=diff
==============================================================================
--- 
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/CoreTest.java
 (original)
+++ 
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/CoreTest.java
 Thu Sep 23 09:18:07 2010
@@ -16,17 +16,25 @@
  */
 package org.apache.karaf.shell.itests;
 
+import java.io.InputStream;
+import java.util.List;
+import java.util.jar.Manifest;
+
 import org.apache.karaf.testing.AbstractIntegrationTest;
+import org.apache.karaf.testing.HeaderParser;
 import org.apache.karaf.testing.Helper;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Customizer;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.Configuration;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.Bundle;
 import org.apache.felix.service.command.CommandProcessor;
 import org.apache.felix.service.command.CommandSession;
+import org.osgi.framework.Constants;
 
+import static org.apache.karaf.testing.Helper.felixProvisionalApis;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.ops4j.pax.exam.CoreOptions.equinox;
@@ -36,6 +44,7 @@ import static org.ops4j.pax.exam.CoreOpt
 import static org.ops4j.pax.exam.OptionUtils.combine;
 
 import static 
org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.modifyBundle;
 
 @RunWith(JUnit4TestRunner.class)
 public class CoreTest extends AbstractIntegrationTest {
@@ -121,11 +130,14 @@ public class CoreTest extends AbstractIn
             waitForFrameworkStartup(),
 
             // Test on both equinox and felix
-            equinox(), felix()
+            equinox(), felix(),
+
+            felixProvisionalApis()
         );
         // Stop the shell log bundle 
         Helper.findMaven(options, "org.apache.karaf.shell", 
"org.apache.karaf.shell.log").noStart();
         return options;
     }
 
+
 }

Modified: 
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/FeaturesTest.java
URL: 
http://svn.apache.org/viewvc/karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/FeaturesTest.java?rev=1000372&r1=1000371&r2=1000372&view=diff
==============================================================================
--- 
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/FeaturesTest.java
 (original)
+++ 
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/FeaturesTest.java
 Thu Sep 23 09:18:07 2010
@@ -16,17 +16,24 @@
  */
 package org.apache.karaf.shell.itests;
 
+import java.io.InputStream;
+import java.util.List;
+import java.util.jar.Manifest;
+
 import org.apache.karaf.testing.AbstractIntegrationTest;
 import org.apache.karaf.testing.Helper;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Customizer;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.Configuration;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Constants;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.apache.felix.service.command.CommandProcessor;
 import org.apache.felix.service.command.CommandSession;
 
+import static org.apache.karaf.testing.Helper.felixProvisionalApis;
 import static org.junit.Assert.assertNotNull;
 import static org.ops4j.pax.exam.CoreOptions.equinox;
 import static org.ops4j.pax.exam.CoreOptions.felix;
@@ -37,6 +44,7 @@ import static org.ops4j.pax.exam.OptionU
 import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
 
 import static 
org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.modifyBundle;
 
 @RunWith(JUnit4TestRunner.class)
 public class FeaturesTest extends AbstractIntegrationTest {
@@ -73,7 +81,9 @@ public class FeaturesTest extends Abstra
             waitForFrameworkStartup(),
             
             // Test on both equinox and felix
-            equinox(), felix()
+            equinox(), felix(),
+
+            felixProvisionalApis()
         );
     }
 

Modified: karaf/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/karaf/trunk/pom.xml?rev=1000372&r1=1000371&r2=1000372&view=diff
==============================================================================
--- karaf/trunk/pom.xml (original)
+++ karaf/trunk/pom.xml Thu Sep 23 09:18:07 2010
@@ -139,6 +139,7 @@
         <pax.runner.version>1.5.0</pax.runner.version>
         <pax.url.version>1.1.3</pax.url.version>
         <pax.web.version>0.7.3</pax.web.version>
+        <pax.tinybundles.version>1.3.0</pax.tinybundles.version>
         <servlet.api.version>2.5</servlet.api.version>
         <spring.osgi.version>1.2.0</spring.osgi.version>
         <spring2.version>2.5.6.SEC01</spring2.version>
@@ -716,6 +717,11 @@
                 <version>${pax.exam.version}</version>
             </dependency>
             <dependency>
+                <groupId>org.ops4j.pax.swissbox</groupId>
+                <artifactId>pax-swissbox-tinybundles</artifactId>
+                <version>${pax.tinybundles.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>org.eclipse</groupId>
                 <artifactId>osgi</artifactId>
                 <version>${equinox.version}</version>

Modified: karaf/trunk/tooling/testing/pom.xml
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/testing/pom.xml?rev=1000372&r1=1000371&r2=1000372&view=diff
==============================================================================
--- karaf/trunk/tooling/testing/pom.xml (original)
+++ karaf/trunk/tooling/testing/pom.xml Thu Sep 23 09:18:07 2010
@@ -64,6 +64,10 @@
             <artifactId>pax-exam-junit-extender-impl</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.ops4j.pax.swissbox</groupId>
+            <artifactId>pax-swissbox-tinybundles</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.apache.servicemix.bundles</groupId>
             <artifactId>org.apache.servicemix.bundles.junit</artifactId>
         </dependency>
@@ -132,6 +136,7 @@
                         <Import-Package>
                             !org.apache.karaf.testing*,
                             !org.ops4j.pax.exam.junit.options,
+                            
org.ops4j.pax.swissbox.tinybundles*;resolution:=optional,
                             *
                         </Import-Package>
                         <Include-Resource>

Copied: 
karaf/trunk/tooling/testing/src/main/java/org/apache/karaf/testing/HeaderParser.java
 (from r1000371, 
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/HeaderParser.java)
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/testing/src/main/java/org/apache/karaf/testing/HeaderParser.java?p2=karaf/trunk/tooling/testing/src/main/java/org/apache/karaf/testing/HeaderParser.java&p1=karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/HeaderParser.java&r1=1000371&r2=1000372&rev=1000372&view=diff
==============================================================================
--- 
karaf/trunk/itests/tests/src/test/java/org/apache/karaf/shell/itests/HeaderParser.java
 (original)
+++ 
karaf/trunk/tooling/testing/src/main/java/org/apache/karaf/testing/HeaderParser.java
 Thu Sep 23 09:18:07 2010
@@ -16,12 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.karaf.shell.itests;
+package org.apache.karaf.testing;
 
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
 
 /**
  * Utility class to parse a standard OSGi header with paths.
@@ -35,6 +40,16 @@ public final class HeaderParser  {
     private HeaderParser() {
     }
 
+    public static InputStream wireTapManifest( InputStream is, Manifest mf ) 
throws IOException {
+        BufferedInputStream bis = new BufferedInputStream( is, 64 * 1024 );
+        bis.mark( 64 * 1024 );
+        JarInputStream jis = new JarInputStream( bis );
+        mf.getMainAttributes().putAll( jis.getManifest().getMainAttributes() );
+        mf.getEntries().putAll( jis.getManifest().getEntries() );
+        bis.reset();
+        return bis;
+    }
+
     /**
      * Parse a given OSGi header into a list of paths
      *

Modified: 
karaf/trunk/tooling/testing/src/main/java/org/apache/karaf/testing/Helper.java
URL: 
http://svn.apache.org/viewvc/karaf/trunk/tooling/testing/src/main/java/org/apache/karaf/testing/Helper.java?rev=1000372&r1=1000371&r2=1000372&view=diff
==============================================================================
--- 
karaf/trunk/tooling/testing/src/main/java/org/apache/karaf/testing/Helper.java 
(original)
+++ 
karaf/trunk/tooling/testing/src/main/java/org/apache/karaf/testing/Helper.java 
Thu Sep 23 09:18:07 2010
@@ -28,12 +28,15 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
+import java.util.jar.Manifest;
 
 import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Customizer;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.options.JUnitBundlesOption;
 import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
 import org.ops4j.pax.exam.options.SystemPropertyOption;
+import org.osgi.framework.Constants;
 
 import static org.ops4j.pax.exam.CoreOptions.bootClasspathLibrary;
 import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages;
@@ -42,6 +45,7 @@ import static org.ops4j.pax.exam.CoreOpt
 import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
 import static org.ops4j.pax.exam.OptionUtils.combine;
 import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.modifyBundle;
 
 /**
  * Helper class for setting up a pax-exam test environment for karaf.
@@ -68,6 +72,41 @@ public final class Helper {
     private Helper() {
     }
 
+    public static Customizer felixProvisionalApis() {
+        return new Customizer() {
+            @Override
+            public InputStream customizeTestProbe(InputStream testProbe) 
throws Exception {
+                Manifest mf = new Manifest();
+                testProbe = HeaderParser.wireTapManifest( testProbe, mf );
+                List<HeaderParser.PathElement> elems = 
HeaderParser.parseHeader( mf.getMainAttributes().getValue( 
Constants.IMPORT_PACKAGE ));
+                StringBuilder sb = new StringBuilder();
+                for (HeaderParser.PathElement elem : elems) {
+                    if 
(elem.getName().startsWith("org.apache.felix.service.")) {
+                        elem.getAttributes().put("status", "provisional");
+                    }
+                    if (sb.length() > 0) {
+                        sb.append(",");
+                    }
+                    sb.append(elem.toString());
+                }
+
+                System.out.println("==============================");
+                System.out.println("");
+                System.out.println("Old: " + mf.getMainAttributes().getValue( 
Constants.IMPORT_PACKAGE ));
+                System.out.println("");
+                System.out.println("==============================");
+                System.out.println("");
+                System.out.println("New: " + sb.toString());
+                System.out.println("");
+                System.out.println("==============================");
+
+                return modifyBundle( testProbe )
+                            .set( Constants.IMPORT_PACKAGE, sb.toString() )
+                            .build();
+            }
+        };
+    }
+
     /**
      *  Create an provisioning option for the specified maven artifact
      * (groupId and artifactId), using the version found in the list


Reply via email to