[FELIX-3808] Upgrade ConfigAdmin to pax-exam 2

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1421970 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/pom.xml b/configadmin/pom.xml
index 8655a75..7acb84a 100644
--- a/configadmin/pom.xml
+++ b/configadmin/pom.xml
@@ -121,28 +121,52 @@
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam</artifactId>
-            <version>0.6.0</version>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>2.6.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-junit</artifactId>
-            <version>0.6.0</version>
+            <artifactId>pax-exam-container-native</artifactId>
+            <version>2.6.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-container-default</artifactId>
-            <version>0.6.0</version>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>2.6.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.ops4j.pax.swissbox</groupId>
-            <artifactId>pax-swissbox-tinybundles</artifactId>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <version>1.5.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.tinybundles</groupId>
+            <artifactId>tinybundles</artifactId>
             <version>1.0.0</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+            <version>1.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>1.7.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.framework</artifactId>
+            <version>4.0.3</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationAdminUpdateStressTest.java b/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationAdminUpdateStressTest.java
index 0f7b8f3..d89d889 100644
--- a/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationAdminUpdateStressTest.java
+++ b/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationAdminUpdateStressTest.java
@@ -70,10 +70,10 @@
     // ----------------------- Initialization -------------------------------------------
 
     @Before
-    public void startup( BundleContext context )
+    public void startup()
     {
-        context.registerService( LogService.class.getName(), this, null );
-        _tracker = new ServiceTracker( context, ConfigurationAdmin.class.getName(), null );
+        bundleContext.registerService( LogService.class.getName(), this, null );
+        _tracker = new ServiceTracker( bundleContext, ConfigurationAdmin.class.getName(), null );
         _tracker.open();
     }
 
@@ -84,7 +84,7 @@
      */
 
     @After
-    public void tearDown( BundleContext context )
+    public void tearDown()
     {
         _tracker.close();
     }
@@ -143,12 +143,12 @@
     // --------------------------- CM Update stress test -------------------------------------
 
     @Test
-    public void testCMUpdateStress( BundleContext context )
+    public void testCMUpdateStress()
     {
         _testLatch = new CountDownLatch( 1 );
         try
         {
-            CreateUpdateStress stress = new CreateUpdateStress( context );
+            CreateUpdateStress stress = new CreateUpdateStress( bundleContext );
             stress.start();
 
             if ( !_testLatch.await( 15, TimeUnit.SECONDS ) )
@@ -312,4 +312,4 @@
             _testLatch.countDown(); // Notify that our test is done
         }
     }
-}
\ No newline at end of file
+}
diff --git a/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTestBase.java b/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTestBase.java
index f76e9af..8ae646a 100644
--- a/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTestBase.java
+++ b/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTestBase.java
@@ -19,10 +19,6 @@
 package org.apache.felix.cm.integration;
 
 
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -38,16 +34,18 @@
 
 import org.apache.felix.cm.integration.helper.BaseTestActivator;
 import org.apache.felix.cm.integration.helper.ManagedServiceTestActivator;
-import org.apache.felix.cm.integration.helper.MyTinyBundle;
 import org.apache.felix.cm.integration.helper.UpdateThreadSignalTask;
 import org.junit.After;
 import org.junit.Before;
+
+import javax.inject.Inject;
+
 import org.ops4j.pax.exam.CoreOptions;
-import org.ops4j.pax.exam.Inject;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.OptionUtils;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
+import org.ops4j.pax.exam.TestProbeBuilder;
+import org.ops4j.pax.exam.junit.ProbeBuilder;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -58,6 +56,8 @@
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.util.tracker.ServiceTracker;
 
+import static org.ops4j.pax.exam.CoreOptions.*;
+
 
 public abstract class ConfigurationTestBase
 {
@@ -107,15 +107,14 @@
         }
 
         final Option[] base = options(
-            /* CoreOptions.allFrameworks(), */
-            provision(
-                CoreOptions.bundle( bundleFile.toURI().toString() ),
-                mavenBundle( "org.ops4j.pax.swissbox", "pax-swissbox-tinybundles", "1.0.0" )
-             ),
-             waitForFrameworkStartup()
+                workingDirectory("target/paxexam/"),
+                cleanCaches(true),
+                junitBundles(),
+                mavenBundle("org.ops4j.pax.tinybundles", "tinybundles", "1.0.0"),
+                bundle(bundleFile.toURI().toString())
         );
-        final Option vmOption = ( paxRunnerVmOption != null ) ? PaxRunnerOptions.vmOption( paxRunnerVmOption ) : null;
-        return OptionUtils.combine( base, vmOption );
+        final Option option = ( paxRunnerVmOption != null ) ? vmOption( paxRunnerVmOption ) : null;
+        return OptionUtils.combine( base, option );
     }
 
 
@@ -157,19 +156,22 @@
     }
 
 
+    @ProbeBuilder
+    public TestProbeBuilder buildProbe( TestProbeBuilder builder ) {
+        return builder.setHeader(Constants.EXPORT_PACKAGE, "org.apache.felix.cm.integration.helper");
+    }
+
     protected Bundle installBundle( final String pid, final Class<?> activatorClass, final String location )
         throws BundleException
     {
         final String activatorClassName = activatorClass.getName();
-        final InputStream bundleStream = new MyTinyBundle()
-            .prepare(
-                TinyBundles.withBnd()
-                .set( Constants.BUNDLE_SYMBOLICNAME, activatorClassName )
+        final InputStream bundleStream = TinyBundles.bundle()
+                .set(Constants.BUNDLE_SYMBOLICNAME, activatorClassName)
                 .set( Constants.BUNDLE_VERSION, "0.0.11" )
                 .set( Constants.IMPORT_PACKAGE, "org.apache.felix.cm.integration.helper" )
                 .set( Constants.BUNDLE_ACTIVATOR, activatorClassName )
                 .set( BaseTestActivator.HEADER_PID, pid )
-            ).build( TinyBundles.asStream() );
+                .build( TinyBundles.withBnd() );
 
         try
         {
diff --git a/configadmin/src/test/java/org/apache/felix/cm/integration/helper/ManagedServiceFactoryTestActivator.java b/configadmin/src/test/java/org/apache/felix/cm/integration/helper/ManagedServiceFactoryTestActivator.java
index 691ec44..719281c 100644
--- a/configadmin/src/test/java/org/apache/felix/cm/integration/helper/ManagedServiceFactoryTestActivator.java
+++ b/configadmin/src/test/java/org/apache/felix/cm/integration/helper/ManagedServiceFactoryTestActivator.java
@@ -21,8 +21,8 @@
 
 import java.util.Dictionary;
 
-import org.ops4j.pax.swissbox.tinybundles.dp.Constants;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cm.ManagedServiceFactory;
 
diff --git a/configadmin/src/test/java/org/apache/felix/cm/integration/helper/ManagedServiceTestActivator.java b/configadmin/src/test/java/org/apache/felix/cm/integration/helper/ManagedServiceTestActivator.java
index db46b39..f6d6675 100644
--- a/configadmin/src/test/java/org/apache/felix/cm/integration/helper/ManagedServiceTestActivator.java
+++ b/configadmin/src/test/java/org/apache/felix/cm/integration/helper/ManagedServiceTestActivator.java
@@ -21,8 +21,8 @@
 
 import java.util.Dictionary;
 
-import org.ops4j.pax.swissbox.tinybundles.dp.Constants;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cm.ManagedService;
 
diff --git a/configadmin/src/test/java/org/apache/felix/cm/integration/helper/MyTinyBundle.java b/configadmin/src/test/java/org/apache/felix/cm/integration/helper/MyTinyBundle.java
deleted file mode 100644
index 238cd5d..0000000
--- a/configadmin/src/test/java/org/apache/felix/cm/integration/helper/MyTinyBundle.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.felix.cm.integration.helper;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.ops4j.pax.swissbox.tinybundles.core.BuildableBundle;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundle;
-import org.ops4j.pax.swissbox.tinybundles.core.metadata.RawBuilder;
-
-public class MyTinyBundle implements TinyBundle {
-
-    private Map<String, URL> m_resources = new HashMap<String, URL>();
-
-    @SuppressWarnings("unchecked")
-    public TinyBundle addClass( Class clazz )
-    {
-        String name = clazz.getName().replaceAll( "\\.", "/" ) + ".class";
-        addResource( name, clazz.getResource( "/" + name ) );
-        return this;
-    }
-
-    public TinyBundle addResource( String name, URL url )
-    {
-        m_resources.put( name, url );
-        return this;
-    }
-
-    public BuildableBundle prepare( BuildableBundle builder )
-    {
-        return builder.setResources( m_resources );
-    }
-
-    public BuildableBundle prepare()
-    {
-        return new RawBuilder().setResources( m_resources );
-    }
-
-}
\ No newline at end of file