Author: [email protected]
Date: Fri Jan 27 13:31:52 2012
New Revision: 2015

Log:
Work in progress for AMDATU-408 & AMDATU-508.

Refactored CoreFixture into a more generic reusable Fixture, and split out its 
functionality to separate classes for core & web. This makes it easier to mix 
and match bundles from core & web + allows room for extensions later on.
Tests of core + web all run successfully again.

Added:
   
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/CoreBundles.java
   (contents, props changed)
   
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/CoreConfigs.java
   (contents, props changed)
   
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/Fixture.java
      - copied, changed from r2012, 
/trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/CoreFixture.java
   
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/ProvisionedBundle.java
   (contents, props changed)
   
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/ProvisionedConfig.java
   (contents, props changed)
   
trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/WebBundles.java
   (contents, props changed)
   
trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/WebConfigs.java
   (contents, props changed)
Modified:
   
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/CoreFixture.java
   
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/TestContext.java
   
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/DefaultCoreServicesTest.java
   
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/IntegrationFrameworkTest.java
   
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/tenant/MultiTenantTest.java
   
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/tenant/mock/MyDependencyServiceImpl.java
   
trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/WebFixture.java
   
trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/BenchmarkTest.java
   
trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/WebTest.java

Added: 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/CoreBundles.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/CoreBundles.java
      Fri Jan 27 13:31:52 2012
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2010-2012 The Amdatu Foundation
+ * 
+ * Licensed 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.amdatu.core.itest.base;
+
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.options.ProvisionOption;
+
+/**
+ * Provides a mean to include/exclude platform bundles from an integration 
test.
+ */
+public enum CoreBundles implements ProvisionedBundle {
+
+    DEPENDENCYMANAGER("org.apache.felix", 
"org.apache.felix.dependencymanager"),
+        LOG("org.apache.felix", "org.apache.felix.log"),
+        CONFIGADMIN("org.amdatu.core", "org.amdatu.core.configadmin"),
+        EVENTADMIN("org.amdatu.core", "org.amdatu.core.eventadmin"),
+        PREFS("org.amdatu.core", "org.amdatu.core.preferences"),
+        USERADMIN("org.amdatu.core", "org.amdatu.core.useradmin"),
+        USERADMINSTORE_PREFS("org.amdatu.core", 
"org.amdatu.core.useradminstore.prefs"),
+        ITEST_BASE("org.amdatu.core", "org.amdatu.core.itest.base"),
+        LOG_CONSOLE("org.amdatu.core", "org.amdatu.core.log.console"),
+        LOG_FORWARDER_JDK("org.amdatu.core", 
"org.amdatu.core.log.forwarder.jdk"),
+        TENANT("org.amdatu.core", "org.amdatu.core.tenant"),
+        TENANT_ADAPTOR("org.amdatu.core", "org.amdatu.core.tenant.adaptor"),
+        TENANT_FACTORY("org.amdatu.core", "org.amdatu.core.tenant.factory");
+
+    private final String m_groupId;
+    private final String m_artifactId;
+
+    /**
+     * Creates a new {@link CoreBundles} instance with a given group and 
artifact-ID.
+     * 
+     * @param groupId the Maven group ID of the bundle;
+     * @param artifactId the Maven artifact ID of the bundle.
+     */
+    private CoreBundles(String groupId, String artifactId) {
+        m_groupId = groupId;
+        m_artifactId = artifactId;
+    }
+
+    /**
+     * Convenience method to provision all of the core bundles.
+     * 
+     * @return a PAX-exam provisioning option with all core bundles.
+     */
+    public static Option provisionAll() {
+        return provisionAllExcluding();
+    }
+
+    /**
+     * Convenience method to provision a subset of the core bundles.
+     * 
+     * @param excludes the optional core bundles to exclude from provisioning.
+     * @return a PAX-exam provisioning option with the requested subset of 
core bundles.
+     */
+    public static Option provisionAllExcluding(CoreBundles... excludes) {
+        List<CoreBundles> values = new 
ArrayList<CoreBundles>(Arrays.asList(values()));
+        values.removeAll(Arrays.asList(excludes));
+        return Fixture.provision(values.toArray(new 
CoreBundles[values.size()]));
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.amdatu.core.itest.base.ProvisionedBundle#getProvisionOption()
+     */
+    public ProvisionOption<?> getProvisionOption() {
+        return 
mavenBundle().groupId(m_groupId).artifactId(m_artifactId).versionAsInProject();
+    }
+}
\ No newline at end of file

Added: 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/CoreConfigs.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/CoreConfigs.java
      Fri Jan 27 13:31:52 2012
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2010-2012 The Amdatu Foundation
+ * 
+ * Licensed 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.amdatu.core.itest.base;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Provides a mean to provide default configurations for certain core platform 
services.
+ */
+public enum CoreConfigs implements ProvisionedConfig {
+    LOGHANDLER("org.amdatu.core.loghandler", logHandlerCnf(), false),
+        TENANT("org.amdatu.core.tenant.factory", tenantCnf(), true);
+
+    private final String m_pid;
+    private final Properties m_properties;
+    private final boolean m_factory;
+
+    private CoreConfigs(String pid, Properties properties, boolean factory) {
+        m_pid = pid;
+        m_properties = properties;
+        m_factory = factory;
+    }
+
+    /**
+     * Convenience method to provision a subset of the core configurations.
+     * 
+     * @param testContext the {@link TestContext} to use for provisioning the 
configurations;
+     * @param excludes the optional core configurations to exclude from 
provisioning.
+     * @return the given test context, never <code>null</code>.
+     * @throws IOException in case on of the core configurations failed.
+     */
+    public static TestContext provisionAllExcluding(TestContext testContext, 
CoreConfigs... excludes)
+        throws IOException {
+        List<CoreConfigs> values = new 
ArrayList<CoreConfigs>(Arrays.asList(values()));
+        values.removeAll(Arrays.asList(excludes));
+
+        Fixture.configure(testContext, values.toArray(new 
CoreConfigs[values.size()]));
+        return testContext;
+    }
+
+    /**
+     * Convenience method to provision all of the core configurations.
+     * 
+     * @param testContext the {@link TestContext} to use for provisioning the 
configurations.
+     * @return the given test context, never <code>null</code>.
+     * @throws IOException in case on of the core configurations failed.
+     */
+    public static TestContext provisionAll(TestContext testContext) throws 
IOException {
+        return provisionAllExcluding(testContext);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.amdatu.core.itest.base.ProvisionedConfig#getPid()
+     */
+    public String getPid() {
+        return m_pid;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.amdatu.core.itest.base.ProvisionedConfig#getProperties()
+     */
+    public Properties getProperties() {
+        return m_properties;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.amdatu.core.itest.base.ProvisionedConfig#isFactory()
+     */
+    public boolean isFactory() {
+        return m_factory;
+    }
+
+    /**
+     * Provides a default log handler configuration.
+     * 
+     * @return a log handler configuration, never <code>null</code>.
+     */
+    private static Properties logHandlerCnf() {
+        Properties properties = new Properties();
+        properties.put("console.mininum.loglevel", "INFO");
+        return properties;
+    }
+
+    /**
+     * Provides a default tenant configuration to provide a default tenant.
+     * 
+     * @return a tenant configuration, never <code>null</code>.
+     */
+    private static Properties tenantCnf() {
+        Properties properties = new Properties();
+        properties.put("id", "Default");
+        properties.put("name", "Default Tenant");
+        properties.put("host", "localhost");
+        return properties;
+    }
+}
\ No newline at end of file

Copied: 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/Fixture.java
 (from r2012, 
/trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/CoreFixture.java)
==============================================================================
--- 
/trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/CoreFixture.java
     (original)
+++ 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/Fixture.java
  Fri Jan 27 13:31:52 2012
@@ -15,11 +15,9 @@
  */
 package org.amdatu.core.itest.base;
 
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-
-import java.util.LinkedList;
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Properties;
 
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.options.ProvisionOption;
@@ -28,110 +26,27 @@
  * Amdatu Core integration test fixture providing provisioning and 
configuration
  * for tests.
  */
-public final class CoreFixture {
-
-    public enum Bundles {
-        DEPENDENCYMANAGER("org.apache.felix", 
"org.apache.felix.dependencymanager"),
-            LOG("org.apache.felix", "org.apache.felix.log"),
-            CONFIGADMIN("org.amdatu.core", "org.amdatu.core.configadmin"),
-            EVENTADMIN("org.amdatu.core", "org.amdatu.core.eventadmin"),
-            PREFS("org.amdatu.core", "org.amdatu.core.preferences"),
-            USERADMIN("org.amdatu.core", "org.amdatu.core.useradmin"),
-            USERADMINSTORE_PREFS("org.amdatu.core", 
"org.amdatu.core.useradminstore.prefs"),
-            ITEST_BASE("org.amdatu.core", "org.amdatu.core.itest.base"),
-            LOG_CONSOLE("org.amdatu.core", "org.amdatu.core.log.console"),
-            LOG_FORWARDER_JDK("org.amdatu.core", 
"org.amdatu.core.log.forwarder.jdk"),
-            TENANT("org.amdatu.core", "org.amdatu.core.tenant"),
-            TENANT_ADAPTOR("org.amdatu.core", 
"org.amdatu.core.tenant.adaptor"),
-            TENANT_FACTORY("org.amdatu.core", 
"org.amdatu.core.tenant.factory");
-
-        private final String m_groupId;
-        private final String m_artifactId;
-
-        private Bundles(String groupId, String artifactId) {
-            m_groupId = groupId;
-            m_artifactId = artifactId;
-        }
-
-        public String getGroupId() {
-            return m_groupId;
-        }
-
-        public String getArtifactId() {
-            return m_artifactId;
-        }
-
-        public ProvisionOption<?> getProvisionOption() {
-            return 
mavenBundle().groupId(m_groupId).artifactId(m_artifactId).versionAsInProject();
-        }
-    }
-
-    public enum Configs {
-        LOGHANDLER("org.amdatu.core.loghandler", logHandlerCnf(), false),
-            TENANT("org.amdatu.core.tenant.factory", tenantCnf(), true);
-
-        private final String m_pid;
-        private final Properties m_properties;
-        private final boolean m_factory;
-
-        private Configs(String pid, Properties properties, boolean factory) {
-            m_pid = pid;
-            m_properties = properties;
-            m_factory = factory;
-        }
-
-        public String getPid() {
-            return m_pid;
-        }
-
-        public Properties getProperties() {
-            return m_properties;
-        }
-
-        public boolean isFactory() {
-            return m_factory;
-        }
+public final class Fixture {
 
-        private static Properties logHandlerCnf() {
-            Properties properties = new Properties();
-            properties.put("console.mininum.loglevel", "INFO");
-            return properties;
-        }
-
-        private static Properties tenantCnf() {
-            Properties properties = new Properties();
-            properties.put("id", "Default");
-            properties.put("name", "Default Tenant");
-            properties.put("host", "localhost");
-            return properties;
-        }
-    }
-
-    private CoreFixture() {
+    /**
+     * Utility class, not meant to instantiate.
+     */
+    private Fixture() {
+        // NO-op
     }
 
     /**
-     * Gets a Pax Exam composite provisioning option for all core bundles not 
listed as exclude.
+     * Returns a Pax Exam composite provisioning option for all requested 
bundles.
      * 
-     * @param excludes bundles to exclude from the option.
-     * @return the option
+     * @param includes the included bundles, can be none if no bundles are to 
be provisioned.
+     * @return the provisioning option, never <code>null</code>.
      */
-    public static Option provision(Bundles... excludes) {
-        List<ProvisionOption<?>> provisionOptions = new 
LinkedList<ProvisionOption<?>>();
-        for (Bundles b : Bundles.values()) {
-            boolean exclude = false;
-            if (excludes != null && excludes.length > 0) {
-                for (Bundles e : excludes) {
-                    if (b == e) {
-                        exclude = true;
-                        break;
-                    }
-                }
-            }
-            if (!exclude) {
-                provisionOptions.add(b.getProvisionOption());
-            }
+    public static Option provision(ProvisionedBundle... includes) {
+        List<ProvisionOption<?>> provisionOptions = new 
ArrayList<ProvisionOption<?>>();
+        for (ProvisionedBundle b : includes) {
+            provisionOptions.add(b.getProvisionOption());
         }
+
         return org.ops4j.pax.exam.CoreOptions.provision(provisionOptions
             .toArray(new ProvisionOption<?>[provisionOptions.size()]));
     }
@@ -140,35 +55,23 @@
      * Configures a <code>TestContext</code> with the default configuration 
for configurations that
      * are not listed as an exclude.
      * 
-     * @param testContext the testContext to configure
-     * @param excludes Configs to exclude from the configuration
+     * @param testContext the testContext to configure;
+     * @param includes the included configurations, can be none if no 
configurations are to be provisioned.
      * @throws Exception if (partial) configuration fails
      */
-    public static void configure(TestContext testContext, Configs... excludes) 
throws Exception {
-        for (Configs b : Configs.values()) {
-            boolean exclude = false;
-            if (excludes != null && excludes.length > 0) {
-                for (Configs e : excludes) {
-                    if (b == e) {
-                        exclude = true;
-                        break;
-                    }
-                }
-            }
-            if (!exclude) {
-                testContext.updateConfig(b.getPid(), b.getProperties(), 
b.isFactory());
+    public static void configure(TestContext testContext, ProvisionedConfig... 
includes) throws IOException {
+        if (includes == null || includes.length == 0) {
+            // Nothing to do...
+            return;
+        }
+        try {
+            for (ProvisionedConfig c : includes) {
+                testContext.updateConfig(c.getPid(), c.getProperties(), 
c.isFactory());
             }
         }
-        testContext.waitForSystemToSettle();
-    }
-
-    /**
-     * Configures a <code>TestContext</code> with the default configuration.
-     * 
-     * @param testContext the testeContext to configure
-     * @throws Exception if (partial) configuration fails
-     */
-    public static void configure(TestContext testContext) throws Exception {
-        configure(testContext, (Configs) null);
+        finally {
+            // In any case, wait a little while, even if the configuration was 
rejected...
+            testContext.waitForSystemToSettle();
+        }
     }
 }

Added: 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/ProvisionedBundle.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/ProvisionedBundle.java
        Fri Jan 27 13:31:52 2012
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010-2012 The Amdatu Foundation
+ * 
+ * Licensed 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.amdatu.core.itest.base;
+
+import org.ops4j.pax.exam.options.ProvisionOption;
+
+/**
+ * Denotes an interface for all provisioned bundles.
+ */
+public interface ProvisionedBundle {
+    /**
+     * Returns the provision option used by PAX-exam to provision a bundle.
+     * 
+     * @return the PAX-exam provision option, never <code>null</code>.
+     */
+    ProvisionOption<?> getProvisionOption();
+}
\ No newline at end of file

Added: 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/ProvisionedConfig.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/ProvisionedConfig.java
        Fri Jan 27 13:31:52 2012
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2010-2012 The Amdatu Foundation
+ * 
+ * Licensed 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.amdatu.core.itest.base;
+
+import java.util.Properties;
+
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.cm.ManagedServiceFactory;
+
+/**
+ * Denotes a provisioned configuration.
+ */
+public interface ProvisionedConfig {
+    /**
+     * Returns the PID of the {@link ManagedService} or {@link 
ManagedServiceFactory}.
+     * 
+     * @return a PID, never <code>null</code>.
+     */
+    String getPid();
+
+    /**
+     * Returns the configuration properties.
+     * 
+     * @return a configuration properties, can be <code>null</code> if the 
configuration is to be deleted.
+     */
+    Properties getProperties();
+
+    /**
+     * Returns whether or not the PID denotes a {@link ManagedServiceFactory}.
+     * 
+     * @return <code>true</code> if this configuration is for a {@link 
ManagedServiceFactory}, <code>false</code> if it is for a {@link 
ManagedService}.
+     */
+    boolean isFactory();
+}

Modified: 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/TestContext.java
==============================================================================
--- 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/TestContext.java
      (original)
+++ 
trunk/amdatu-core/itest/base/src/main/java/org/amdatu/core/itest/base/TestContext.java
      Fri Jan 27 13:31:52 2012
@@ -19,7 +19,6 @@
 import static org.hamcrest.core.IsNull.notNullValue;
 import static org.junit.Assert.assertThat;
 
-import java.io.File;
 import java.io.IOException;
 import java.util.Dictionary;
 import java.util.Hashtable;
@@ -28,13 +27,18 @@
 import java.util.Properties;
 import java.util.UUID;
 
+import junit.framework.AssertionFailedError;
+
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.cm.ManagedServiceFactory;
 import org.osgi.util.tracker.ServiceTracker;
 
 /**
@@ -43,6 +47,7 @@
  */
 public class TestContext {
 
+    /** The number of milliseconds to wait until a service lookup should fail. 
*/
     private static final int SERVICE_LOOKUP_TIMEOUT = 10000;
 
     private final List<ServiceTracker> m_serviceTrackers = new 
LinkedList<ServiceTracker>();
@@ -50,49 +55,106 @@
     private BundleContext m_bundleContext;
     private DependencyManager m_dependencyManager;
 
+    /**
+     * Creates a new {@link TestContext} instance, ensuring a new dependency 
manager is created.
+     * 
+     * @param bundleContext the bundle context of this test context, cannot be 
<code>null</code>.
+     */
     public TestContext(BundleContext bundleContext) {
         m_bundleContext = bundleContext;
         m_dependencyManager = new DependencyManager(m_bundleContext);
-        createContextWorkDir();
-    }
-
-    public void tearDown() {
-        for (ServiceTracker serviceTracker : m_serviceTrackers) {
-            serviceTracker.close();
-        }
     }
 
+    /**
+     * Returns the current test's bundle context.
+     * 
+     * @return this test context's bundle context, never <code>null</code>.
+     */
     public BundleContext getBundleContext() {
         return m_bundleContext;
     }
 
+    /**
+     * Convenience method to return the {@link ConfigurationAdmin} service.
+     * 
+     * @return the {@link ConfigurationAdmin} service, can be 
<code>null</code> if it is not available.
+     */
+    public ConfigurationAdmin getConfigurationAdmin() {
+        return getService(ConfigurationAdmin.class);
+    }
+
+    /**
+     * Returns the Felix dependency manager.
+     * 
+     * @return a dependency manager instance, never <code>null</code>.
+     */
     public DependencyManager getDependencyManager() {
         return m_dependencyManager;
     }
 
-    public <T> T getService(Class<T> serviceClass) throws Exception {
+    /**
+     * Tries to acquire a service with the default timeout ({@value 
#SERVICE_LOOKUP_TIMEOUT} ms).
+     * <p>NOTE: this method blocks until the requested service becomes 
available, or until the timeout has expired!</p>
+     * 
+     * @param serviceClass the service class to obtain a service for, cannot 
be <code>null</code>.
+     * @return the service instance, can be <code>null</code> if no matching 
service is found.
+     */
+    public <T> T getService(Class<T> serviceClass) {
         return getService(serviceClass, SERVICE_LOOKUP_TIMEOUT);
     }
 
-    public <T> T getService(Class<T> serviceClass, long timeout) throws 
Exception {
-        return getService(serviceClass, null, timeout);
+    /**
+     * Tries to acquire a service with a given timeout.
+     * <p>NOTE: this method blocks until the requested service becomes 
available, or until the given timeout has expired!</p>
+     * 
+     * @param serviceClass the service class to obtain a service for, cannot 
be <code>null</code>;
+     * @param timeout the timeout (in milliseconds) to wait for the service to 
become available, >= 0.
+     * @return the service instance, can be <code>null</code> if no matching 
service is found.
+     */
+    public <T> T getService(Class<T> serviceClass, long timeout) {
+        try {
+            return getService(serviceClass, null, timeout);
+        }
+        catch (InvalidSyntaxException exception) {
+            throw new RuntimeException("null-filter invalid?!");
+        }
     }
 
+    /**
+     * Tries to acquire a service additionally specified by the given filter 
expression.
+     * <p>NOTE: this method blocks until the requested service becomes 
available, or until the timeout has expired!</p>
+     * 
+     * @param serviceClass the service class to obtain a service for, cannot 
be <code>null</code>;
+     * @param extraFilterExpression the additional filter clause to narrow 
down the requested service.
+     * @return the service instance, can be <code>null</code> if no matching 
service is found.
+     * @throws InvalidSyntaxException in case the given filter expression was 
invalid.
+     */
     public <T> T getService(Class<T> serviceClass, String 
extraFilterExpression)
-        throws Exception {
+        throws InvalidSyntaxException {
         return getService(serviceClass, extraFilterExpression, 
SERVICE_LOOKUP_TIMEOUT);
     }
 
+    /**
+     * Tries to acquire a service additionally specified by the given filter 
expression.
+     * <p>NOTE: this method blocks until the requested service becomes 
available, or until the given timeout has expired!</p>
+     * 
+     * @param serviceClass the service class to obtain a service for, cannot 
be <code>null</code>;
+     * @param extraFilterExpression the additional filter clause to narrow 
down the requested service;
+     * @param timeout the timeout (in milliseconds) to wait for the service to 
become available, >= 0.
+     * @return the service instance, can be <code>null</code> if no matching 
service is found.
+     * @throws InvalidSyntaxException in case the given filter expression was 
invalid.
+     */
     public <T> T getService(Class<T> serviceClass, String 
extraFilterExpression, long timeout)
-        throws Exception {
-        String filterExpression = "(" + Constants.OBJECTCLASS + "=" + 
serviceClass.getName() + ")";
+        throws InvalidSyntaxException {
+        String filterExpression = String.format("(%s=%s)", 
Constants.OBJECTCLASS, serviceClass.getName());
         if (extraFilterExpression != null) {
-            filterExpression =
-                "(&" + filterExpression + extraFilterExpression + ")";
+            filterExpression = String.format("(&%s%s)", filterExpression, 
extraFilterExpression);
         }
+
         ServiceTracker serviceTracker =
             new ServiceTracker(m_bundleContext, 
m_bundleContext.createFilter(filterExpression), null);
         serviceTracker.open();
+
         m_serviceTrackers.add(serviceTracker);
 
         try {
@@ -103,78 +165,128 @@
         }
     }
 
-    public void waitForSystemToSettle() throws Exception {
+    /**
+     * Should be called after each test to ensure all created service trackers 
are closed.
+     */
+    public void tearDown() {
+        for (ServiceTracker serviceTracker : m_serviceTrackers) {
+            serviceTracker.close();
+        }
+    }
+
+    /**
+     * Updates the configuration for the {@link ManagedService} identified by 
the given PID to the given properties.
+     * 
+     * @param pid the PID of the {@link ManagedService} to update, cannot be 
<code>null</code>;
+     * @param properties the new service properties, can be <code>null</code> 
to delete the existing service properties (if any).
+     * @return the updated configuration information, never <code>null</code>.
+     * @throws IOException if the configuration was rejected or otherwise 
caused an exception.
+     */
+    public Configuration updateConfig(String pid, Properties properties) 
throws IOException {
+        return updateConfig(pid, properties, false /* factory */);
+    }
+
+    /**
+     * Updates the configuration for the {@link ManagedServiceFactory} 
identified by the given PID to the given properties.
+     * 
+     * @param pid the PID of the {@link ManagedServiceFactory} to update, 
cannot be <code>null</code>;
+     * @param properties the new service properties, can be <code>null</code> 
to delete the existing service properties (if any).
+     * @return the updated configuration information, never <code>null</code>.
+     * @throws IOException if the configuration was rejected or otherwise 
caused an exception.
+     */
+    public Configuration updateFactoryConfig(String pid, Properties 
properties) throws IOException {
+        return updateConfig(pid, properties, true /* factory */);
+    }
+
+    /**
+     * Allows the system to settle after a configuration has been supplied to 
the {@link ConfigurationAdmin} service.
+     */
+    public void waitForSystemToSettle() {
         // Heuristic is that if we register a service, update the configuration
         // and receive that update from CM... all preceding CM/DM events have 
been
         // handled as well.
         String uid = UUID.randomUUID().toString();
+
         String pid = "org.amdatu.core.itest.base." + uid;
         Dictionary<String, Object> props = new Hashtable<String, Object>();
         props.put("org.amdatu.core.itest.base.sid", uid);
+
         Component com = m_dependencyManager.createComponent()
             .setInterface(Object.class.getName(), props)
             .setImplementation(uid)
-            .add(m_dependencyManager.createConfigurationDependency()
-                .setPid(pid));
+            .add(m_dependencyManager
+                .createConfigurationDependency().setPid(pid));
+
         m_dependencyManager.add(com);
-        updateConfig(pid, new Properties());
-        getService(Object.class, "(org.amdatu.core.itest.base.sid=" + uid + 
")");
-        m_dependencyManager.remove(com);
-    }
 
-    public Configuration updateConfig(String pid, Properties properties) 
throws Exception {
-        return updateConfig(pid, properties, false);
-    }
+        try {
+            updateConfig(pid, new Properties());
 
-    public Configuration updateFactoryConfig(String pid, Properties 
properties) throws Exception {
-        return updateConfig(pid, properties, true);
+            getService(Object.class, "(org.amdatu.core.itest.base.sid=" + uid 
+ ")");
+        }
+        catch (InvalidSyntaxException exception) {
+            throw new RuntimeException("Filter is incorrect?!");
+        }
+        catch (IOException exception) {
+            throw new RuntimeException("Empty configuration is incorrect?!");
+        }
+        finally {
+            m_dependencyManager.remove(com);
+        }
     }
 
-    public Configuration updateConfig(String pid, Properties properties, 
boolean factory) throws Exception {
+    /**
+     * Updates the configuration for the {@link ManagedService} identified by 
the given PID to the given properties.
+     * 
+     * @param pid the PID of the {@link ManagedService} to update, cannot be 
<code>null</code>;
+     * @param properties the new service properties, can be <code>null</code> 
to delete the existing service properties (if any);
+     * @param factory if <code>true</code> assume the given PID is a {@link 
ManagedServiceFactory} that creates the configuration for us, 
<code>false</code> if the given PID is a "normal" {@link ManagedService}.
+     * @return the updated configuration information, never <code>null</code>.
+     * @throws IOException if the configuration was rejected or otherwise 
caused an exception.
+     */
+    final Configuration updateConfig(String pid, Properties properties, 
boolean factory) throws IOException {
         ServiceReference sr = getConfigAdminServiceRef();
         try {
             ConfigurationAdmin configurationAdmin = getConfigAdminService(sr);
+
+            Configuration configuration;
             if (!factory) {
-                Configuration configuration = 
configurationAdmin.getConfiguration(pid, null);
-                configuration.update(properties);
-                return configuration;
+                configuration = configurationAdmin.getConfiguration(pid, null 
/* location */);
             }
             else {
-                Configuration config = 
configurationAdmin.createFactoryConfiguration(pid, null);
-                config.update(properties);
-                return config;
+                configuration = 
configurationAdmin.createFactoryConfiguration(pid, null /* location */);
             }
+            configuration.update(properties);
+
+            return configuration;
         }
         finally {
             m_bundleContext.ungetService(sr);
         }
     }
 
-    public ConfigurationAdmin getConfigurationAdmin() throws Exception {
-        return getService(ConfigurationAdmin.class);
-    }
-
+    /**
+     * Obtains the {@link ConfigurationAdmin} service through the given 
service reference.
+     * 
+     * @param sr the service reference of the {@link ConfigurationAdmin} 
service, cannot be <code>null</code>.
+     * @return the {@link ConfigurationAdmin} service, never <code>null</code>.
+     * @throws AssertionFailedError in case the requested service was not 
available.
+     */
     private ConfigurationAdmin getConfigAdminService(ServiceReference sr) {
         ConfigurationAdmin configurationAdmin = (ConfigurationAdmin) 
m_bundleContext.getService(sr);
         assertThat("ConfigurationAdmin service unavailable", 
configurationAdmin, is(notNullValue()));
         return configurationAdmin;
     }
 
+    /**
+     * Obtains the {@link ConfigurationAdmin} service reference.
+     * 
+     * @return the {@link ConfigurationAdmin} service reference, never 
<code>null</code>.
+     * @throws AssertionFailedError in case the requested service reference 
was not available.
+     */
     private ServiceReference getConfigAdminServiceRef() {
         ServiceReference sr = 
m_bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
         assertThat("ConfigurationAdmin serviceReference unavailable", sr, 
is(notNullValue()));
         return sr;
     }
-
-    private void createContextWorkDir() {
-        try {
-            File contextDir = File.createTempFile("testContext", 
Long.toString(System.nanoTime()));
-            contextDir.delete();
-            contextDir.mkdir();
-            System.setProperty("amdatu.dir", contextDir.getAbsolutePath());
-        }
-        catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
 }

Modified: 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/DefaultCoreServicesTest.java
==============================================================================
--- 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/DefaultCoreServicesTest.java
        (original)
+++ 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/DefaultCoreServicesTest.java
        Fri Jan 27 13:31:52 2012
@@ -26,7 +26,9 @@
 
 import javax.inject.Inject;
 
-import org.amdatu.core.itest.base.CoreFixture;
+import org.amdatu.core.itest.base.CoreConfigs;
+import org.amdatu.core.itest.base.CoreBundles;
+import org.amdatu.core.itest.base.Fixture;
 import org.amdatu.core.itest.base.TestContext;
 import org.amdatu.core.itest.tests.mock.TestService;
 import org.amdatu.core.itest.tests.mock.TestServiceImpl;
@@ -49,7 +51,7 @@
 
 /**
  * Integration test covering basic availability of core services in a default
- * configuration provided by {@link CoreFixture}.
+ * configuration provided by {@link Fixture}.
  * <p/>
  * Note: This class is also extended to run tests against different
  * configurations.
@@ -68,13 +70,13 @@
     public Option[] config() {
         return options(
             junitBundles(),
-            CoreFixture.provision());
+            CoreBundles.provisionAll());
     }
 
     @Before
     public void setUp() throws Exception {
         m_testContext = new TestContext(m_bundleContext);
-        CoreFixture.configure(m_testContext);
+        CoreConfigs.provisionAll(m_testContext);
     }
 
     @After
@@ -135,12 +137,12 @@
         properties.put("name", "Tenant localhost");
         properties.put("host", "localhost");
 
-        m_testContext.updateFactoryConfig(CoreFixture.Configs.TENANT.getPid(), 
properties);
+        m_testContext.updateFactoryConfig(CoreConfigs.TENANT.getPid(), 
properties);
 
         properties.put("id", "[email protected]");
         properties.put("name", "Tenant 127.0.0.1");
         properties.put("host", "127.0.0.1");
-        m_testContext.updateFactoryConfig(CoreFixture.Configs.TENANT.getPid(), 
properties);
+        m_testContext.updateFactoryConfig(CoreConfigs.TENANT.getPid(), 
properties);
 
         UserAdmin userAdmin1 = m_testContext.getService(UserAdmin.class, 
"(tenant_id=tenant@localhost)");
         assertThat("Expected a UserAdmin for tenant@localhost to be 
available", userAdmin1, is(notNullValue()));

Modified: 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/IntegrationFrameworkTest.java
==============================================================================
--- 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/IntegrationFrameworkTest.java
       (original)
+++ 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/IntegrationFrameworkTest.java
       Fri Jan 27 13:31:52 2012
@@ -7,7 +7,8 @@
 
 import javax.inject.Inject;
 
-import org.amdatu.core.itest.base.CoreFixture;
+import org.amdatu.core.itest.base.CoreBundles;
+import org.amdatu.core.itest.base.Fixture;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -75,7 +76,7 @@
     public Option[] configureOptions() {
         return options(CoreOptions.systemPackages("sun.misc", 
"com.sun.management", "org.w3c.dom.traversal"),
             CoreOptions.junitBundles(),
-            CoreFixture.provision());
+            CoreBundles.provisionAll());
     }
 
     /**

Modified: 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/tenant/MultiTenantTest.java
==============================================================================
--- 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/tenant/MultiTenantTest.java
 (original)
+++ 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/tenant/MultiTenantTest.java
 Fri Jan 27 13:31:52 2012
@@ -34,8 +34,8 @@
 
 import javax.inject.Inject;
 
-import org.amdatu.core.itest.base.CoreFixture;
-import org.amdatu.core.itest.base.CoreFixture.Configs;
+import org.amdatu.core.itest.base.CoreBundles;
+import org.amdatu.core.itest.base.CoreConfigs;
 import org.amdatu.core.itest.base.TestContext;
 import org.amdatu.core.itest.tests.tenant.mock.MyDependencyService;
 import org.amdatu.core.itest.tests.tenant.mock.MyDependencyServiceImpl;
@@ -146,25 +146,28 @@
      */
     @org.ops4j.pax.exam.junit.Configuration
     public Option[] config() {
-        InputStream mtBundle = bundle()
-            .add(MyTenancyActivator.class)
-            .add(MyDependentService.class)
-            .add(MyDependentServiceImpl.class)
-            .add(MyDependencyService.class)
-            .add(MyDependencyServiceImpl.class)
-            .set(TenantConstants.MULTITENANT_SCOPE_KEY, 
TenantConstants.MULTITENANT_SCOPE_VALUE_BOTH)
-            .set(TenantConstants.MULTITENANT_VERSION_KEY, 
TenantConstants.MULTITENANT_VERSION_VALUE)
-            .set(TenantConstants.MULTITENANT_BUNDLE_ACTIVATOR_KEY, 
MyTenancyActivator.class.getName())
-            .set(Constants.BUNDLE_ACTIVATOR, 
MultiTenantBundleActivator.class.getName())
-            .set(Constants.BUNDLE_SYMBOLICNAME, "My Tenancy Bundle")
-            .set(Constants.EXPORT_PACKAGE, 
"org.amdatu.core.itest.tests.tenant.mock")
-            .set(Constants.IMPORT_PACKAGE, 
"org.amdatu.core.itest.tests.tenant.mock,org.amdatu.core.tenant,org.amdatu.core.tenant.adaptor,org.osgi.service.log,org.osgi.framework,org.apache.felix.dm,junit.framework")
-            .build();
+        InputStream mtBundle =
+            bundle()
+                .add(MyTenancyActivator.class)
+                .add(MyDependentService.class)
+                .add(MyDependentServiceImpl.class)
+                .add(MyDependencyService.class)
+                .add(MyDependencyServiceImpl.class)
+                .set(TenantConstants.MULTITENANT_SCOPE_KEY, 
TenantConstants.MULTITENANT_SCOPE_VALUE_BOTH)
+                .set(TenantConstants.MULTITENANT_VERSION_KEY, 
TenantConstants.MULTITENANT_VERSION_VALUE)
+                .set(TenantConstants.MULTITENANT_BUNDLE_ACTIVATOR_KEY, 
MyTenancyActivator.class.getName())
+                .set(Constants.BUNDLE_ACTIVATOR, 
MultiTenantBundleActivator.class.getName())
+                .set(Constants.BUNDLE_SYMBOLICNAME, "My Tenancy Bundle")
+                .set(Constants.EXPORT_PACKAGE, 
"org.amdatu.core.itest.tests.tenant.mock")
+                .set(Constants.IMPORT_PACKAGE,
+                    
"org.amdatu.core.itest.tests.tenant.mock,org.amdatu.core.tenant,org.amdatu.core.tenant.adaptor,"
 +
+                        
"org.osgi.service.log,org.osgi.framework,org.apache.felix.dm,junit.framework")
+                .build();
 
         return options(
             cleanCaches(),
             junitBundles(),
-            CoreFixture.provision(),
+            CoreBundles.provisionAll(),
             provision(mtBundle),
             systemTimeout(30000));
     }
@@ -177,7 +180,7 @@
     @Before
     public void setUp() throws Exception {
         m_testContext = new TestContext(m_bundleContext);
-        CoreFixture.configure(m_testContext, Configs.TENANT);
+        CoreConfigs.provisionAllExcluding(m_testContext, CoreConfigs.TENANT);
 
         Properties properties = new Properties();
         properties.put(EventConstants.EVENT_TOPIC, new String[] { 
"org/osgi/service/log/LogEntry/LOG_INFO" });
@@ -363,7 +366,7 @@
      * @throws Exception
      */
     private Configuration updateTenantConfig(Properties properties) throws 
Exception {
-        Configuration config = 
m_testContext.updateFactoryConfig(CoreFixture.Configs.TENANT.getPid(), 
properties);
+        Configuration config = 
m_testContext.updateFactoryConfig(CoreConfigs.TENANT.getPid(), properties);
         m_configurations.add(config);
         m_testContext.waitForSystemToSettle();
         return config;

Modified: 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/tenant/mock/MyDependencyServiceImpl.java
==============================================================================
--- 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/tenant/mock/MyDependencyServiceImpl.java
    (original)
+++ 
trunk/amdatu-core/itest/tests/src/test/java/org/amdatu/core/itest/tests/tenant/mock/MyDependencyServiceImpl.java
    Fri Jan 27 13:31:52 2012
@@ -16,14 +16,14 @@
 
 package org.amdatu.core.itest.tests.tenant.mock;
 
-import org.apache.felix.dm.Component;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogService;
 
 /**
  * @author <a href="mailto:[email protected]";>Amdatu Project 
Team</a>
  */
 public class MyDependencyServiceImpl implements MyDependencyService {
-    private volatile Component m_component;
+    private volatile ServiceReference m_serviceReference;
     private volatile LogService m_logService;
 
     /**
@@ -31,7 +31,7 @@
      */
     protected void start() {
         m_logService.log(LogService.LOG_INFO, "Starting " + 
getClass().getSimpleName());
-        m_logService.log(LogService.LOG_INFO, 
MyDependentServiceImpl.getMTServiceTag(m_component.getServiceRegistration().getReference(),
 "START"));
+        m_logService.log(LogService.LOG_INFO, 
MyDependentServiceImpl.getMTServiceTag(m_serviceReference, "START"));
     }
 
     /**
@@ -39,6 +39,6 @@
      */
     protected void stop() {
         m_logService.log(LogService.LOG_INFO, "Stopping " + 
getClass().getSimpleName());
-        m_logService.log(LogService.LOG_INFO, 
MyDependentServiceImpl.getMTServiceTag(m_component.getServiceRegistration().getReference(),
 "STOP"));
+        m_logService.log(LogService.LOG_INFO, 
MyDependentServiceImpl.getMTServiceTag(m_serviceReference, "STOP"));
     }
 }

Added: 
trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/WebBundles.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/WebBundles.java
 Fri Jan 27 13:31:52 2012
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010-2012 The Amdatu Foundation
+ * 
+ * Licensed 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.amdatu.web.itest.base;
+
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.amdatu.core.itest.base.Fixture;
+import org.amdatu.core.itest.base.ProvisionedBundle;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.options.ProvisionOption;
+
+/**
+ * Provides a mean to provision all core web-bundles.
+ */
+public enum WebBundles implements ProvisionedBundle {
+
+    SERVLET("javax.servlet", "servlet-api"),
+        ITEST_BASE("org.amdatu.web", "org.amdatu.web.itest.base"),
+        JETTY("org.apache.felix", "org.apache.felix.http.jetty"),
+        DISPATCHER("org.amdatu.web", "org.amdatu.web.dispatcher"),
+        HTTPCONTEXT("org.amdatu.web", "org.amdatu.web.httpcontext"),
+        JSP("org.amdatu.web", "org.amdatu.web.jsp"),
+        RESOURCE("org.amdatu.web", "org.amdatu.web.resource"),
+        JAXRS("org.amdatu.web", "org.amdatu.web.jaxrs"),
+        WINK("org.amdatu.web", "org.amdatu.web.wink"),
+        TENANTRESOLVER_PARAMETER("org.amdatu.web", 
"org.amdatu.web.tenantresolver.parameter"),
+        TENANTRESOLVER_HOSTNAME("org.amdatu.web", 
"org.amdatu.web.tenantresolver.hostname");
+
+    private final String m_groupId;
+    private final String m_artifactId;
+
+    private WebBundles(String groupId, String artifactId) {
+        m_groupId = groupId;
+        m_artifactId = artifactId;
+    }
+
+    /**
+     * Convenience method to provision all of the core bundles.
+     * 
+     * @return a PAX-exam provisioning option with all core bundles.
+     */
+    public static Option provisionAll() {
+        return provisionAllExcluding();
+    }
+
+    /**
+     * Convenience method to provision a subset of the core bundles.
+     * 
+     * @param excludes the optional core bundles to exclude from provisioning.
+     * @return a PAX-exam provisioning option with the requested subset of 
core bundles.
+     */
+    public static Option provisionAllExcluding(WebBundles... excludes) {
+        List<WebBundles> values = new 
ArrayList<WebBundles>(Arrays.asList(values()));
+        values.removeAll(Arrays.asList(excludes));
+        return Fixture.provision(values.toArray(new 
WebBundles[values.size()]));
+    }
+
+    /* (non-Javadoc)
+     * @see org.amdatu.core.itest.base.ProvisionedBundle#getProvisionOption()
+     */
+    public ProvisionOption<?> getProvisionOption() {
+        return 
mavenBundle().groupId(m_groupId).artifactId(m_artifactId).versionAsInProject();
+    }
+}
\ No newline at end of file

Added: 
trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/WebConfigs.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-web/itest/base/src/main/java/org/amdatu/web/itest/base/WebConfigs.java
 Fri Jan 27 13:31:52 2012
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010-2012 The Amdatu Foundation
+ * 
+ * Licensed 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.amdatu.web.itest.base;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import org.amdatu.core.itest.base.Fixture;
+import org.amdatu.core.itest.base.ProvisionedConfig;
+import org.amdatu.core.itest.base.TestContext;
+
+/**
+ * Provides a mean to provision web-configurations.
+ */
+public enum WebConfigs implements ProvisionedConfig {
+    HTTPSERVICE("org.osgi.service.http", httpCnf(), false);
+
+    private final String m_pid;
+    private final Properties m_properties;
+    private final boolean m_factory;
+
+    private WebConfigs(String pid, Properties properties, boolean factory) {
+        m_pid = pid;
+        m_properties = properties;
+        m_factory = factory;
+    }
+
+    /**
+     * Convenience method to provision a subset of the core configurations.
+     * 
+     * @param testContext the {@link TestContext} to use for provisioning the 
configurations;
+     * @param excludes the optional core configurations to exclude from 
provisioning.
+     * @return the given test context, never <code>null</code>.
+     * @throws IOException in case on of the core configurations failed.
+     */
+    public static TestContext provisionAllExcluding(TestContext testContext, 
WebConfigs... excludes)
+        throws IOException {
+        List<WebConfigs> values = new 
ArrayList<WebConfigs>(Arrays.asList(values()));
+        values.removeAll(Arrays.asList(excludes));
+
+        Fixture.configure(testContext, values.toArray(new 
WebConfigs[values.size()]));
+        return testContext;
+    }
+
+    /**
+     * Convenience method to provision all of the core configurations.
+     * 
+     * @param testContext the {@link TestContext} to use for provisioning the 
configurations.
+     * @return the given test context, never <code>null</code>.
+     * @throws IOException in case on of the core configurations failed.
+     */
+    public static TestContext provisionAll(TestContext testContext) throws 
IOException {
+        return provisionAllExcluding(testContext);
+    }
+
+    /* (non-Javadoc)
+     * @see org.amdatu.core.itest.base.ProvisionedConfig#getPid()
+     */
+    public String getPid() {
+        return m_pid;
+    }
+
+    /* (non-Javadoc)
+     * @see org.amdatu.core.itest.base.ProvisionedConfig#getProperties()
+     */
+    public Properties getProperties() {
+        return m_properties;
+    }
+
+    /* (non-Javadoc)
+     * @see org.amdatu.core.itest.base.ProvisionedConfig#isFactory()
+     */
+    public boolean isFactory() {
+        return m_factory;
+    }
+
+    /**
+     * @return
+     */
+    private static Properties httpCnf() {
+        Properties properties = new Properties();
+        properties.put("org.osgi.service.http.port", "8080");
+        properties.put("org.apache.felix.http.debug", "true");
+        properties.put("org.apache.felix.log.storeDebug", "false");
+        return properties;
+    }
+}
\ No newline at end of file

Modified: 
trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/BenchmarkTest.java
==============================================================================
--- 
trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/BenchmarkTest.java
    (original)
+++ 
trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/BenchmarkTest.java
    Fri Jan 27 13:31:52 2012
@@ -29,11 +29,12 @@
 import javax.inject.Inject;
 import javax.servlet.Servlet;
 
-import org.amdatu.core.itest.base.CoreFixture;
+import org.amdatu.core.itest.base.CoreBundles;
+import org.amdatu.core.itest.base.CoreConfigs;
 import org.amdatu.core.itest.base.TestContext;
 import org.amdatu.web.dispatcher.DispatcherService;
-import org.amdatu.web.itest.base.WebFixture;
-import org.amdatu.web.itest.base.WebFixture.Bundles;
+import org.amdatu.web.itest.base.WebBundles;
+import org.amdatu.web.itest.base.WebConfigs;
 import org.amdatu.web.itest.tests.mock.BenchMarkServlet;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
@@ -73,15 +74,15 @@
     public Option[] config() {
         return options(
             CoreOptions.junitBundles(),
-            CoreFixture.provision(),
-            WebFixture.provision(Bundles.TENANTRESOLVER_PARAMETER));
+            CoreBundles.provisionAllExcluding(),
+            
WebBundles.provisionAllExcluding(WebBundles.TENANTRESOLVER_PARAMETER));
     }
 
     @Before
     public void setUp() throws Exception {
         m_testContext = new TestContext(m_bundleContext);
-        CoreFixture.configure(m_testContext);
-        WebFixture.configure(m_testContext);
+        CoreConfigs.provisionAll(m_testContext);
+        WebConfigs.provisionAll(m_testContext);
 
         m_port =
             (String) 
m_testContext.getConfigurationAdmin().getConfiguration("org.osgi.service.http").getProperties()

Modified: 
trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/WebTest.java
==============================================================================
--- 
trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/WebTest.java
  (original)
+++ 
trunk/amdatu-web/itest/tests/src/test/java/org/amdatu/web/itest/tests/WebTest.java
  Fri Jan 27 13:31:52 2012
@@ -22,9 +22,11 @@
 
 import javax.inject.Inject;
 
-import org.amdatu.core.itest.base.CoreFixture;
+import org.amdatu.core.itest.base.CoreBundles;
+import org.amdatu.core.itest.base.CoreConfigs;
 import org.amdatu.core.itest.base.TestContext;
-import org.amdatu.web.itest.base.WebFixture;
+import org.amdatu.web.itest.base.WebBundles;
+import org.amdatu.web.itest.base.WebConfigs;
 import org.amdatu.web.itest.tests.mock.TestService;
 import org.amdatu.web.itest.tests.mock.TestServiceImpl;
 import org.apache.felix.dm.Component;
@@ -54,15 +56,15 @@
     public Option[] config() {
         return options(
             CoreOptions.junitBundles(),
-            CoreFixture.provision(),
-            WebFixture.provision());
+            CoreBundles.provisionAll(),
+            WebBundles.provisionAll());
     }
 
     @Before
     public void setUp() throws Exception {
         m_testContext = new TestContext(m_bundleContext);
-        CoreFixture.configure(m_testContext);
-        WebFixture.configure(m_testContext);
+        CoreConfigs.provisionAll(m_testContext);
+        WebConfigs.provisionAll(m_testContext);
     }
 
     @After
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to