ACE-535 - cleanup the o.a.a.deployment project:

- applied patch from @brampouwelse;
- this closes #10.



git-svn-id: https://svn.apache.org/repos/asf/ace/trunk@1732288 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.ace.client.repository.itest/bnd.bnd b/org.apache.ace.client.repository.itest/bnd.bnd
index 340aabf..bd09959 100644
--- a/org.apache.ace.client.repository.itest/bnd.bnd
+++ b/org.apache.ace.client.repository.itest/bnd.bnd
@@ -44,11 +44,7 @@
 	org.apache.ace.discovery.property;version=latest,\
 	org.apache.ace.identification.api;version=latest,\
 	org.apache.ace.identification.property;version=latest,\
-	org.apache.ace.deployment.api;version=latest,\
-	org.apache.ace.deployment.deploymentadmin;version=latest,\
 	org.apache.ace.deployment.servlet;version=latest,\
-	org.apache.ace.deployment.task;version=latest,\
-	org.apache.ace.deployment.task.base;version=latest,\
 	org.apache.ace.deployment.streamgenerator;version=latest,\
 	org.apache.ace.deployment.provider.base;version=latest,\
 	org.apache.ace.range.api;version=latest,\
diff --git a/org.apache.ace.client.rest.itest/bnd.bnd b/org.apache.ace.client.rest.itest/bnd.bnd
index e0022ae..abc7b9c 100644
--- a/org.apache.ace.client.rest.itest/bnd.bnd
+++ b/org.apache.ace.client.rest.itest/bnd.bnd
@@ -48,8 +48,6 @@
 	org.apache.ace.discovery.property;version=latest,\
 	org.apache.ace.identification.api;version=latest,\
 	org.apache.ace.identification.property;version=latest,\
-	org.apache.ace.deployment.api;version=latest,\
-	org.apache.ace.deployment.deploymentadmin;version=latest,\
 	org.apache.ace.deployment.servlet;version=latest,\
 	org.apache.ace.deployment.streamgenerator;version=latest,\
 	org.apache.ace.deployment.provider.base;version=latest,\
diff --git a/org.apache.ace.deployment.itest/bnd.bnd b/org.apache.ace.deployment.itest/bnd.bnd
index a19e84c..d844fd4 100644
--- a/org.apache.ace.deployment.itest/bnd.bnd
+++ b/org.apache.ace.deployment.itest/bnd.bnd
@@ -21,8 +21,7 @@
 	org.apache.ace.deployment.provider.api;version=latest,\
 	org.apache.ace.deployment.util.test;version=latest,\
 	org.apache.ace.feedback.common;version=latest,\
-	org.apache.ace.deployment.provider.base;version=latest,\
-	org.apache.ace.deployment.task;version=latest
+	org.apache.ace.deployment.provider.base;version=latest
 -runfw: org.apache.felix.framework;version='[5.2.0,6)'
 -runvm: -ea
 -runbundles: osgi.cmpn,\
@@ -36,15 +35,11 @@
 	org.apache.felix.prefs,\
 	org.apache.ace.authentication.api;version=latest,\
 	org.apache.ace.connectionfactory;version=latest,\
-	org.apache.ace.deployment.api;version=latest,\
-	org.apache.ace.deployment.deploymentadmin;version=latest,\
 	org.apache.ace.deployment.provider.api;version=latest,\
 	org.apache.ace.deployment.provider.base;version=latest,\
 	org.apache.ace.deployment.provider.repositorybased;version=latest,\
 	org.apache.ace.deployment.servlet;version=latest,\
 	org.apache.ace.deployment.streamgenerator;version=latest,\
-	org.apache.ace.deployment.task;version=latest,\
-	org.apache.ace.deployment.task.base;version=latest,\
 	org.apache.ace.discovery.api;version=latest,\
 	org.apache.ace.discovery.property;version=latest,\
 	org.apache.ace.feedback.common;version=latest,\
diff --git a/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/DeploymentIntegrationTest.java b/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/DeploymentIntegrationTest.java
deleted file mode 100644
index 04a1510..0000000
--- a/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/DeploymentIntegrationTest.java
+++ /dev/null
@@ -1,410 +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.ace.it.deployment;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.ace.deployment.provider.ArtifactData;
-import org.apache.ace.deployment.provider.impl.ArtifactDataImpl;
-import org.apache.ace.deployment.util.test.BundleStreamGenerator;
-import org.apache.ace.discovery.DiscoveryConstants;
-import org.apache.ace.identification.IdentificationConstants;
-import org.apache.ace.it.IntegrationTestBase;
-import org.apache.ace.scheduler.constants.SchedulerConstants;
-import org.apache.ace.test.constants.TestConstants;
-import org.apache.felix.dm.Component;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.deploymentadmin.DeploymentAdmin;
-import org.osgi.service.deploymentadmin.DeploymentException;
-import org.osgi.service.deploymentadmin.DeploymentPackage;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventConstants;
-import org.osgi.service.event.EventHandler;
-import org.osgi.service.http.HttpService;
-
-public class DeploymentIntegrationTest extends IntegrationTestBase implements BundleListener, EventHandler {
-
-    /**
-     * Input stream wrapper that creates an input stream that breaks after N bytes. When it breaks, it will throw an IO
-     * exception and sends a notification to the semaphore that allows the overall test to continue.
-     */
-    private class BrokenInputStream extends InputStream {
-        private final InputStream m_normalStream;
-        private int m_bytesUntilBreakdown;
-        private boolean m_isBroken;
-
-        public BrokenInputStream(InputStream normalStream, int bytesUntilBreakdown) {
-            m_normalStream = normalStream;
-            m_bytesUntilBreakdown = bytesUntilBreakdown;
-        }
-
-        @Override
-        public void close() throws IOException {
-            m_normalStream.close();
-            breakStream();
-        }
-
-        @Override
-        public int read() throws IOException {
-            if (m_bytesUntilBreakdown-- < 1) {
-                breakStream();
-            }
-            return m_normalStream.read();
-        }
-
-        private synchronized void breakStream() throws IOException {
-            if (!m_isBroken) {
-                m_isBroken = true;
-
-                // release the semaphore to continue the test
-                m_semaphore.release();
-            }
-            throw new IOException("Stream broken.");
-        }
-
-    }
-
-    /**
-     * Wrapper around the deployment admin that will fail once, after N bytes.
-     */
-    private class FailingDeploymentAdmin implements DeploymentAdmin {
-        private final DeploymentAdmin m_deploymentAdmin;
-        private boolean m_wasBroken;
-        private final int m_failAfterBytes;
-
-        public FailingDeploymentAdmin(DeploymentAdmin deploymentAdmin, int failAfterBytes) {
-            m_deploymentAdmin = deploymentAdmin;
-            m_failAfterBytes = failAfterBytes;
-        }
-
-        public boolean cancel() {
-            return m_deploymentAdmin.cancel();
-        }
-
-        public DeploymentPackage getDeploymentPackage(Bundle bundle) {
-            return m_deploymentAdmin.getDeploymentPackage(bundle);
-        }
-
-        public DeploymentPackage getDeploymentPackage(String symbName) {
-            return m_deploymentAdmin.getDeploymentPackage(symbName);
-        }
-
-        public DeploymentPackage installDeploymentPackage(InputStream in) throws DeploymentException {
-            synchronized (this) {
-                if (!m_wasBroken) {
-                    m_wasBroken = true;
-                    in = new BrokenInputStream(in, m_failAfterBytes);
-                }
-            }
-            return m_deploymentAdmin.installDeploymentPackage(in);
-        }
-
-        public DeploymentPackage[] listDeploymentPackages() {
-            return m_deploymentAdmin.listDeploymentPackages();
-        }
-    }
-
-    public static final String HOST = "localhost";
-    public static final String TARGET_ID = "test-target";
-    public static final String POLL_INTERVAL = "1000";
-    public static final String STOP_UNAFFECTED_BUNDLES = "org.apache.felix.deploymentadmin.stopUnaffectedBundles";
-
-    private final Semaphore m_semaphore = new Semaphore(0);
-    private final ConcurrentMap<Integer, CopyOnWriteArrayList<Bundle>> m_events = new ConcurrentHashMap<>();
-
-    private volatile ConfigurationAdmin m_config;
-    private volatile DeploymentAdmin m_deployment;
-    private volatile File m_tempDir;
-    private volatile ServiceRegistration<DeploymentAdmin> m_deploymentAdminProxyReg;
-
-    @Override
-    public void bundleChanged(BundleEvent event) {
-        System.out.println("Bundle Event: " + event);
-        Integer eventType = Integer.valueOf(event.getType());
-        CopyOnWriteArrayList<Bundle> bundles = new CopyOnWriteArrayList<>();
-        CopyOnWriteArrayList<Bundle> oldBundles = m_events.putIfAbsent(eventType, bundles);
-        if (oldBundles != null) {
-            bundles = oldBundles;
-        }
-        bundles.addIfAbsent(event.getBundle());
-    }
-
-    @Override
-    public void handleEvent(Event event) {
-        System.out.println("Event: " + event);
-        m_semaphore.release();
-    }
-
-    /**
-     * Tests that we can deploy various versions of bundles stopping only affected bundles, which is a custom exension
-     * in Felix DeploymentAdmin.
-     */
-    public void testDeployVersionSeriesStopAffectedBundlesOnlyOk() throws Exception {
-        System.setProperty(STOP_UNAFFECTED_BUNDLES, "false");
-        try {
-            doTestDeployVersionSeriesOk();
-        }
-        finally {
-            System.clearProperty(STOP_UNAFFECTED_BUNDLES);
-        }
-    }
-
-    /**
-     * Tests that we can deploy various versions of bundles using a "stop the world" scenario, which is the default
-     * behavior in DeploymentAdmin.
-     */
-    public void testDeployVersionSeriesStopTheWorldOk() throws Exception {
-        doTestDeployVersionSeriesOk();
-    }
-
-    @Override
-    protected void configureAdditionalServices() throws Exception {
-        deleteDirOrFile(m_tempDir);
-    }
-    
-    @Override
-    protected void configureProvisionedServices() throws IOException {
-        m_tempDir = File.createTempFile("test", "");
-        m_tempDir.delete();
-        m_tempDir.mkdir();
-    }
-
-    @Override
-    protected void doTearDown() throws Exception {
-        for (DeploymentPackage dp : m_deployment.listDeploymentPackages()) {
-            dp.uninstallForced();
-        }
-    }
-
-    protected void doTestDeployVersionSeriesOk() throws Exception {
-        Bundle[] start = m_bundleContext.getBundles();
-
-        // Test deploy initial version 1.0.0 with 3 bundles in version 1.0.0
-        String[] versions = new String[] { "bundle1", "bundle2", "bundle3" };
-        generateBundles(createVersion("1.0.0"), versions, 0, versions.length, "1.0.0");
-        executeTest();
-        // start + versions bundles may be present
-        assertState(start, m_bundleContext.getBundles(), versions);
-
-        assertEquals("Received unexpected amount of starting events.", versions.length, m_events.get(BundleEvent.STARTED).size());
-        assertNull("Received unexpected amount of stopping events", m_events.get(BundleEvent.STOPPED));
-
-        m_events.clear();
-
-        // Test correct presence of deployment packages in deployment admin
-        assertEquals("Deployment admin reports unexpected number of deployment packages", 1, m_deployment.listDeploymentPackages().length);
-        assertNotNull("Deployment admin did not return the expected deployment package", m_deployment.getDeploymentPackage(TARGET_ID));
-
-        Bundle[] bundles = m_bundleContext.getBundles();
-        Bundle bundle = null;
-        for (int i = 0; i < bundles.length; i++) {
-            if ("bundle1".equals(bundles[i].getSymbolicName())) {
-                bundle = bundles[i];
-                break;
-            }
-        }
-        assertNotNull("Deployment admin did not return the expected deployment package", m_deployment.getDeploymentPackage(bundle));
-
-        // Test deploy a version 1.1.0 on top of the previous 1.0.0 with one new bundle and one updated to version 1.1.0
-        // (i.e., two fix-package bundles)
-        versions = new String[] { "bundle1", "bundle2", "bundle3", "bundle4" };
-        File version = createVersion("1.1.0");
-        generateBundle(new File(version, "0.jar"), versions[0], "1.1.0");
-        generateBundles(version, versions, 1, versions.length, "1.0.0");
-        executeTest();
-
-        int expectedStopEvents = versions.length - 1;
-        int expectedStartedEvents = versions.length;
-        if ("false".equals(System.getProperty(STOP_UNAFFECTED_BUNDLES))) {
-            expectedStopEvents = 1;
-            expectedStartedEvents = 2;
-        }
-
-        // start + versions bundles may be present
-        assertState(start, m_bundleContext.getBundles(), versions);
-        assertEquals("Received unexpected amount of updated events.", 1, m_events.get(BundleEvent.UPDATED).size());
-        assertEquals("Received unexpected update event.", versions[0], m_events.get(BundleEvent.UPDATED).get(0).getSymbolicName());
-        assertEquals("Received unexpected amount of stopped events.", expectedStopEvents, m_events.get(BundleEvent.STOPPED).size());
-        assertEquals("Received unexpected amount of started events.", expectedStartedEvents, m_events.get(BundleEvent.STARTED).size());
-        m_events.clear();
-
-        // Test to deploy an empty version 2.0.0, but break the stream which should cancel the deployment
-        createVersion("2.0.0");
-        executeTestWithFailingStream();
-        m_events.clear();
-
-        // Test to deploy an empty version 2.0.0 which should remove all the previously installed bundles
-        executeTest();
-
-        // only start bundles may be present
-        assertState(start, m_bundleContext.getBundles(), new String[0]);
-        assertNull("Received unexpected amount of installed events.", m_events.get(BundleEvent.INSTALLED));
-        assertNull("Received unexpected amount of starting events.", m_events.get(BundleEvent.STARTED));
-        assertEquals("Received unexpected amount of uninstalled events.", versions.length, m_events.get(BundleEvent.UNINSTALLED).size());
-        assertEquals("Received unexpected amount of stopped events.", versions.length, m_events.get(BundleEvent.STOPPED).size());
-        m_events.clear();
-    }
-
-    @Override
-    protected Component[] getDependencies() {
-        return new Component[] {
-            createComponent()
-                .setImplementation(this)
-                .add(createServiceDependency().setService(HttpService.class).setRequired(true))
-                .add(createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true))
-                .add(createServiceDependency().setService(DeploymentAdmin.class).setRequired(true)),
-        };
-    }
-
-    private void assertState(Bundle[] start, Bundle[] current, String[] versions) {
-        assert (start.length + versions.length) == current.length : "System has " + (((start.length + versions.length) < current.length) ? "more" : "less") + " bundes then expected: expected " + (start.length + versions.length) + ", found "
-            + current.length;
-        for (int i = 0; i < start.length; i++) {
-            assert current[i].getSymbolicName().equals(start[i].getSymbolicName()) : "Bundle names do not match: " + current[i].getSymbolicName() + " v.s. " + start[i];
-        }
-        List<String> index = Arrays.asList(versions);
-        for (int i = start.length; i < current.length; i++) {
-            assert index.contains(current[i].getSymbolicName()) : "Bundle names do not match: " + current[i].getSymbolicName();
-        }
-    }
-
-    private void configureServer() throws IOException {
-        // configure file based backend
-        configure("org.apache.ace.deployment.provider.filebased", 
-            "BaseDirectoryName", m_tempDir.getAbsolutePath());
-
-        configure("org.apache.ace.http.context", "authentication.enabled", "false");
-    }
-
-    private void configureTarget() throws IOException {
-        // configure discovery bundle
-        configure(DiscoveryConstants.DISCOVERY_PID, DiscoveryConstants.DISCOVERY_URL_KEY, "http://" + HOST + ":" + TestConstants.PORT);
-        // configure identification bundle
-        configure(IdentificationConstants.IDENTIFICATION_PID, IdentificationConstants.IDENTIFICATION_TARGETID_KEY, TARGET_ID);
-        // configure scheduler
-        configure(SchedulerConstants.SCHEDULER_PID,
-            "org.apache.ace.target.auditlog.task.AuditLogSyncTask", POLL_INTERVAL,
-            "org.apache.ace.deployment.task.DeploymentUpdateTask", POLL_INTERVAL);
-    }
-
-    private File createVersion(String version) {
-        File versionFile = new File(new File(m_tempDir, TARGET_ID), version);
-        versionFile.mkdirs();
-        return versionFile;
-    }
-
-    private void deleteDirOrFile(File root) {
-        if (root.isDirectory()) {
-            for (File file : root.listFiles()) {
-                deleteDirOrFile(file);
-            }
-        }
-        root.delete();
-    }
-
-    private void executeTest() throws IOException, InterruptedException {
-        Dictionary<String, Object> props = new Hashtable<>();
-        props.put(EventConstants.EVENT_TOPIC, "org/osgi/service/deployment/COMPLETE");
-        props.put(EventConstants.EVENT_FILTER, "(successful=true)");
-
-        m_bundleContext.addBundleListener(this);
-        ServiceRegistration<EventHandler> reg = m_bundleContext.registerService(EventHandler.class, this, props);
-
-        try {
-            configureTarget();
-            configureServer();
-
-            assertTrue("Timed out while waiting for deployment to complete.", m_semaphore.tryAcquire(8, TimeUnit.SECONDS));
-
-            unconfigureServer();
-            unconfigureTarget();
-        }
-        finally {
-            reg.unregister();
-            m_bundleContext.removeBundleListener(this);
-        }
-    }
-
-    private void executeTestWithFailingStream() throws IOException, InterruptedException {
-        m_bundleContext.addBundleListener(this);
-        registerDeploymentAdminProxy(new FailingDeploymentAdmin(m_deployment, 50));
-
-        try {
-            configureTarget();
-            configureServer();
-
-            assertTrue("Timed out while waiting for deployment to abort.", m_semaphore.tryAcquire(8, TimeUnit.SECONDS));
-
-            unconfigureServer();
-            unconfigureTarget();
-        }
-        finally {
-            unregisterDeploymentAdminProxy();
-            m_bundleContext.removeBundleListener(this);
-        }
-    }
-
-    private ArtifactData generateBundle(File file, String symbolicName, String version) throws Exception {
-        ArtifactData bundle = new ArtifactDataImpl(file.getName(), symbolicName, file.length(), version, file.toURI().toURL(), false);
-        BundleStreamGenerator.generateBundle(bundle);
-        return bundle;
-    }
-
-    private void generateBundles(File dir, String[] versions, int off, int len, String version) throws Exception {
-        for (int i = off; i < len; i++) {
-            generateBundle(new File(dir, i + ".jar"), versions[i], version);
-        }
-    }
-
-    private void registerDeploymentAdminProxy(DeploymentAdmin proxy) {
-        Dictionary<String, Object> props = new Hashtable<>();
-        props.put(org.osgi.framework.Constants.SERVICE_RANKING, 1);
-        m_deploymentAdminProxyReg = m_bundleContext.registerService(DeploymentAdmin.class, proxy, props);
-    }
-
-    private void unconfigureServer() throws IOException {
-        m_config.getConfiguration("org.apache.ace.deployment.servlet", null).delete();
-        m_config.getConfiguration("org.apache.ace.deployment.provider.filebased", null).delete();
-    }
-
-    private void unconfigureTarget() throws IOException {
-        m_config.getConfiguration(DiscoveryConstants.DISCOVERY_PID, null).delete();
-        m_config.getConfiguration(IdentificationConstants.IDENTIFICATION_PID, null).delete();
-        m_config.getConfiguration(SchedulerConstants.SCHEDULER_PID, null).delete();
-    }
-
-    private void unregisterDeploymentAdminProxy() {
-        m_deploymentAdminProxyReg.unregister();
-    }
-}
diff --git a/org.apache.ace.deployment/api.bnd b/org.apache.ace.deployment/api.bnd
deleted file mode 100644
index 5cd5cf8..0000000
--- a/org.apache.ace.deployment/api.bnd
+++ /dev/null
@@ -1,6 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under the terms of ASLv2 (http://www.apache.org/licenses/LICENSE-2.0).
-
-Export-Package: org.apache.ace.deployment
-Bundle-Version: 1.0.1
-Bundle-Name: Apache ACE Deployment API
-Bundle-Description: Provides the Apache ACE deployment API
\ No newline at end of file
diff --git a/org.apache.ace.deployment/deploymentadmin.bnd b/org.apache.ace.deployment/deploymentadmin.bnd
deleted file mode 100644
index b3804cf..0000000
--- a/org.apache.ace.deployment/deploymentadmin.bnd
+++ /dev/null
@@ -1,7 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under the terms of ASLv2 (http://www.apache.org/licenses/LICENSE-2.0).
-
-Private-Package: org.apache.ace.deployment.deploymentadmin
-Bundle-Activator: org.apache.ace.deployment.deploymentadmin.Activator
-Bundle-Version: 1.0.1
-Bundle-Name: Apache ACE Deployment DeploymentAdmin
-Bundle-Description: Registers the DeplouymentAdmin service
\ No newline at end of file
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/Deployment.java b/org.apache.ace.deployment/src/org/apache/ace/deployment/Deployment.java
deleted file mode 100644
index 766af8f..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/Deployment.java
+++ /dev/null
@@ -1,71 +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.ace.deployment;
-
-import java.io.InputStream;
-import org.osgi.framework.Version;
-
-import aQute.bnd.annotation.ProviderType;
-
-/**
- * Service that abstracts the actual implementation that manages components that are to be deployed.
- * Implementations of this interface could for example make use of the <code>DeploymentAdmin</code>
- * from the OSGi spec to actually deploy packages. The objects used as arguments and return values
- * must all be of the same type, which type depends on the implementation.
- */
-@ProviderType
-public interface Deployment {
-
-    /**
-     * Deploys the contents of the stream onto the system.
-     *
-     * @param inputStream Stream containing new components.
-     * @return The update package that was installed, may be null if the implementation does not support this.
-     * @throws Exception If the specified stream could not be deployed.
-     */
-    public Object install(InputStream inputStream) throws Exception;
-
-    /**
-     * Gets the name of the specified update package. Guaranteed to work with <code>Object</code>s returned
-     * by the same implementation of this interface.
-     *
-     * @param object The update package
-     * @return the name
-     * @throws IllegalArgumentException when the specified object is an invalid update package, only Objects returned by the same implementation of this interface should be used.
-     */
-    public String getName(Object object) throws IllegalArgumentException;
-
-    /**
-     * Gets the version of the specified update package. Guaranteed to work with <code>Object</code>s returned
-     * by the same implementation of this interface.
-     *
-     * @param object The update package
-     * @return the version
-     * @throws IllegalArgumentException when the specified object is an invalid update package, only Objects returned by the same implementation of this interface should be used.
-     */
-    public Version getVersion(Object object) throws IllegalArgumentException;
-
-    /**
-     * Retrieve a list of installed update packages.
-     *
-     * @return list of installed update packages or an empty array if none are available.
-     */
-    public Object[] list();
-
-}
\ No newline at end of file
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/deploymentadmin/Activator.java b/org.apache.ace.deployment/src/org/apache/ace/deployment/deploymentadmin/Activator.java
deleted file mode 100644
index 2007592..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/deploymentadmin/Activator.java
+++ /dev/null
@@ -1,40 +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.ace.deployment.deploymentadmin;

-

-import org.apache.ace.deployment.Deployment;

-import org.apache.felix.dm.DependencyActivatorBase;

-import org.apache.felix.dm.DependencyManager;

-import org.osgi.framework.BundleContext;

-import org.osgi.service.deploymentadmin.DeploymentAdmin;

-import org.osgi.service.log.LogService;

-

-public class Activator extends DependencyActivatorBase {

-    public void init(BundleContext context, DependencyManager manager) throws Exception {

-        manager.add(createComponent()

-            .setInterface(Deployment.class.getName(), null)

-            .setImplementation(DeploymentAdminDeployer.class)

-            .add(createServiceDependency().setService(DeploymentAdmin.class).setRequired(true))

-            .add(createServiceDependency().setService(LogService.class).setRequired(false)));

-    }

-

-    public void destroy(BundleContext context, DependencyManager manager) throws Exception {

-        // do nothing

-    }

-}
\ No newline at end of file
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/deploymentadmin/DeploymentAdminDeployer.java b/org.apache.ace.deployment/src/org/apache/ace/deployment/deploymentadmin/DeploymentAdminDeployer.java
deleted file mode 100644
index a0f19df..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/deploymentadmin/DeploymentAdminDeployer.java
+++ /dev/null
@@ -1,60 +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.ace.deployment.deploymentadmin;
-
-import java.io.InputStream;
-import org.apache.ace.deployment.Deployment;
-import org.osgi.framework.Version;
-import org.osgi.service.deploymentadmin.DeploymentAdmin;
-import org.osgi.service.deploymentadmin.DeploymentPackage;
-import org.osgi.service.log.LogService;
-
-/**
- * Implementation of the <code>DeploymentService</code> interface that uses the <code>DeploymentAdmin</code>
- * to deploy components.
- */
-public class DeploymentAdminDeployer implements Deployment {
-    private volatile LogService m_log; /* will be injected by dependencymanager */
-    private volatile DeploymentAdmin m_admin; /* will be injected by dependencymanager */
-
-    public String getName(Object object) throws IllegalArgumentException {
-        if (!(object instanceof DeploymentPackage)) {
-            throw new IllegalArgumentException("Argument is not a DeploymentPackage");
-        }
-        return ((DeploymentPackage) object).getName();
-    }
-
-    public Version getVersion(Object object) throws IllegalArgumentException {
-        if (!(object instanceof DeploymentPackage)) {
-            throw new IllegalArgumentException("Argument is not a DeploymentPackage");
-        }
-        return ((DeploymentPackage) object).getVersion();
-    }
-
-    public Object install(InputStream inputStream) throws Exception {
-        DeploymentPackage deploymentPackage = m_admin.installDeploymentPackage(inputStream);
-        m_log.log(LogService.LOG_INFO, "Deployment Package installed: name=" + deploymentPackage.getName() + " version=" + deploymentPackage.getVersion());
-        return deploymentPackage;
-    }
-
-    public Object[] list() {
-        // DeploymentAdmin spec says this call should never return null
-        return m_admin.listDeploymentPackages();
-    }
-}
\ No newline at end of file
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/packageinfo b/org.apache.ace.deployment/src/org/apache/ace/deployment/packageinfo
deleted file mode 100644
index a4f1546..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/packageinfo
+++ /dev/null
@@ -1 +0,0 @@
-version 1.0
\ No newline at end of file
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/service/DeploymentService.java b/org.apache.ace.deployment/src/org/apache/ace/deployment/service/DeploymentService.java
deleted file mode 100644
index b70dd67..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/service/DeploymentService.java
+++ /dev/null
@@ -1,85 +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.ace.deployment.service;
-
-import java.io.IOException;
-import java.util.SortedSet;
-
-import org.osgi.framework.Version;
-
-import aQute.bnd.annotation.ProviderType;
-
-/**
- * Deployment service can be used to talk to the management agent about deployment packages,
- * versions and updates, and to actually perform them. This interface coexists with the
- * tasks that are also published by the management agent and that are probably more convenient
- * if you just want to schedule (checks for) updates.
- */
-@ProviderType
-public interface DeploymentService {
-
-    /**
-     * Returns the highest version that is available locally (already installed).
-     * 
-     * @return The highest installed version, can be <code>null</code> if no version is locally available.
-     */
-    Version getHighestLocalVersion();
-
-    /**
-     * Returns the highest version that is available remotely.
-     * 
-     * @param url The URL to be used to retrieve the versions available on the remote.
-     * @return The highest version available on the remote or <code>null</code> if no versions were available or the remote could not be reached.
-     * @throws IOException in case of I/O problems obtaining the remote version.
-     */
-    Version getHighestRemoteVersion() throws IOException;
-
-    /**
-     * Returns all versions that are available remotely.
-     * 
-     * @return the remote versions, sorted, can be <code>null</code>.
-     * @throws IOException in case of I/O problems obtaining the remote versions.
-     */
-    SortedSet<Version> getRemoteVersions() throws IOException;
-
-    /**
-     * Installs the version specified by the highestRemoteVersion.
-     * 
-     * @param remoteVersion the version to retrieve and install;
-     * @param localVersion the current (local) version, can be <code>null</code> in case of no version is yet installed.
-     * @throws IOException in case of I/O problems installing the version;
-     * @throws Exception in case of other problems installing the version.
-     */
-    void installVersion(Version remoteVersion, Version localVersion) throws IOException, Exception;
-
-    /**
-     * Updates from the current local version to the given remote version.
-     * <p>
-     * This method is the same as calling:
-     * <pre>
-     * installVersion(toVersion, getHighestLocalVersion());
-     * </pre>
-     * </p>
-     * 
-     * @param toVersion the (remote) version to update to, cannot be <code>null</code>.
-     * @throws Exception in case of other problems updating to the requested version.
-     */
-    void update(Version toVersion) throws Exception;
-
-}
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/service/impl/Activator.java b/org.apache.ace.deployment/src/org/apache/ace/deployment/service/impl/Activator.java
deleted file mode 100644
index 4ec4165..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/service/impl/Activator.java
+++ /dev/null
@@ -1,155 +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.ace.deployment.service.impl;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.ace.connectionfactory.ConnectionFactory;
-import org.apache.ace.deployment.Deployment;
-import org.apache.ace.deployment.service.DeploymentService;
-import org.apache.ace.discovery.Discovery;
-import org.apache.ace.identification.Identification;
-import org.apache.felix.dm.Component;
-import org.apache.felix.dm.DependencyActivatorBase;
-import org.apache.felix.dm.DependencyManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.log.LogService;
-
-/**
- * Provides an activator for the deployment service.
- */
-public class Activator extends DependencyActivatorBase implements ManagedServiceFactory {
-
-    private static final String PID_NAME = "org.apache.ace.deployment.task.base.factory";
-
-    private static final String MA_NAME = "ma";
-    private static final String DEFAULT_MA_NAME = null;
-
-    private final Map<String, Component> m_instances = new ConcurrentHashMap<>();
-
-    private volatile DependencyManager m_manager;
-
-    /**
-     * @see org.osgi.service.cm.ManagedServiceFactory#deleted(java.lang.String)
-     */
-    public void deleted(String pid) {
-        Component component;
-        synchronized (m_instances) {
-            component = m_instances.remove(pid);
-        }
-        
-        if (component != null) {
-            m_manager.remove(component);
-        }
-    }
-
-    /**
-     * @see org.apache.felix.dm.DependencyActivatorBase#destroy(org.osgi.framework.BundleContext, org.apache.felix.dm.DependencyManager)
-     */
-    public void destroy(BundleContext context, DependencyManager manager) throws Exception {
-        // do nothing
-    }
-
-    /**
-     * @see org.osgi.service.cm.ManagedServiceFactory#getName()
-     */
-    public String getName() {
-        return "Deployment Service - base";
-    }
-
-    /**
-     * @see org.apache.felix.dm.DependencyActivatorBase#init(org.osgi.framework.BundleContext, org.apache.felix.dm.DependencyManager)
-     */
-    public void init(BundleContext context, DependencyManager manager) throws Exception {
-        m_manager = manager;
-
-        // Create a default deployment service instance...
-        m_manager.add(createService(DEFAULT_MA_NAME));
-
-        Properties props = new Properties();
-        props.put(Constants.SERVICE_PID, PID_NAME);
-
-        m_manager.add(createComponent()
-            .setInterface(ManagedServiceFactory.class.getName(), props)
-            .setImplementation(this)
-            );
-    }
-
-    /**
-     * @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String, java.util.Dictionary)
-     */
-    public void updated(String pid, Dictionary<String, ?> dict) throws ConfigurationException {
-        final String ma = (String) dict.get(MA_NAME);
-        
-        Component component = m_instances.get(pid);
-        if (component == null) {
-            component = createService(ma);
-            synchronized (m_instances) {
-                m_instances.put(pid, component);
-            }
-            m_manager.add(component);
-        }
-        else {
-            // TODO do we want to deal with changes here?
-        }
-    }
-
-    /**
-     * Creates the {@link DeploymentService} component for the given management agent name.
-     * 
-     * @param ma the name of the management agent to create the service for, can be <code>null</code>.
-     * @return a {@link Component} instance for the {@link DeploymentService}, never <code>null</code>.
-     */
-    private Component createService(String ma) {
-        Dictionary<String, Object> deploymentProperties = new Hashtable<>();
-
-        String identificationFilter = "(" + Constants.OBJECTCLASS + "=" + Identification.class.getName() + ")";
-        String discoveryFilter = "(" + Constants.OBJECTCLASS + "=" + Discovery.class.getName() + ")";
-
-        if (ma == null || "".equals(ma.trim())) {
-            identificationFilter = String.format("(&%s(!(%s=*)))", identificationFilter, MA_NAME);
-            discoveryFilter = String.format("(&%s(!(%s=*)))", discoveryFilter, MA_NAME); ;
-        }
-        else {
-            identificationFilter = String.format("(&%s(%s=%s))", identificationFilter, MA_NAME, ma);
-            discoveryFilter = String.format("(&%s(%s=%s))", discoveryFilter, MA_NAME, ma);
-            deploymentProperties.put(MA_NAME, ma);
-        }
-
-        DeploymentServiceImpl deploymentService = new DeploymentServiceImpl();
-
-        return createComponent()
-            .setInterface(DeploymentService.class.getName(), deploymentProperties)
-            .setImplementation(deploymentService)
-            .add(createServiceDependency().setService(Deployment.class).setRequired(true))
-            .add(createServiceDependency().setService(ConnectionFactory.class).setRequired(true))
-            .add(createServiceDependency().setService(Identification.class, identificationFilter).setRequired(true))
-            .add(createServiceDependency().setService(Discovery.class, discoveryFilter).setRequired(true))
-            .add(createServiceDependency().setService(EventAdmin.class).setRequired(false))
-            .add(createServiceDependency().setService(LogService.class).setRequired(false));
-    }
-}
\ No newline at end of file
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/service/impl/DeploymentServiceImpl.java b/org.apache.ace.deployment/src/org/apache/ace/deployment/service/impl/DeploymentServiceImpl.java
deleted file mode 100644
index d00e33b..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/service/impl/DeploymentServiceImpl.java
+++ /dev/null
@@ -1,298 +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.ace.deployment.service.impl;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.apache.ace.connectionfactory.ConnectionFactory;
-import org.apache.ace.deployment.Deployment;
-import org.apache.ace.deployment.service.DeploymentService;
-import org.apache.ace.discovery.Discovery;
-import org.apache.ace.identification.Identification;
-import org.osgi.framework.Version;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.log.LogService;
-
-/**
- * Provides an implementation for {@link DeploymentService}.
- */
-public class DeploymentServiceImpl implements DeploymentService {
-    
-    private final String TOPIC_DEPLOYMENTPACKAGE_INSTALL = "org/apache/ace/deployment/INSTALL";
-
-    // injected by dependencymanager
-    protected volatile Deployment m_deployer;
-    protected volatile Identification m_identification;
-    protected volatile Discovery m_discovery;
-    protected volatile LogService m_log;
-    protected volatile EventAdmin m_eventAdmin;
-    protected volatile ConnectionFactory m_connectionFactory;
-
-    /**
-     * @see org.apache.ace.deployment.service.DeploymentService#getHighestLocalVersion()
-     */
-    public Version getHighestLocalVersion() {
-        Object[] installedPackages = m_deployer.list();
-        List<Version> versions = new ArrayList<>();
-        for (int i = 0; i < installedPackages.length; i++) {
-            if (m_deployer.getName(installedPackages[i]).equals(m_identification.getID())) {
-                versions.add(m_deployer.getVersion(installedPackages[i]));
-            }
-        }
-        return getHighestVersion(versions);
-    }
-
-    /**
-     * @see org.apache.ace.deployment.service.DeploymentService#getHighestRemoteVersion()
-     */
-    public Version getHighestRemoteVersion() throws IOException {
-        SortedSet<Version> versions = getRemoteVersions(getURL());
-        return ((versions == null) || versions.isEmpty()) ? null : versions.last();
-    }
-
-    /**
-     * @see org.apache.ace.deployment.service.DeploymentService#getRemoteVersions()
-     */
-    public SortedSet<Version> getRemoteVersions() throws IOException {
-        return getRemoteVersions(getURL());
-    }
-
-    /**
-     * @see org.apache.ace.deployment.service.DeploymentService#installVersion(org.osgi.framework.Version, org.osgi.framework.Version)
-     */
-    public void installVersion(Version highestRemoteVersion, Version highestLocalVersion) throws IOException, Exception {
-        InputStream inputStream = null;
-        
-        m_log.log(LogService.LOG_INFO, "Installing version: " + highestRemoteVersion);
-        
-        try {
-            String version = highestRemoteVersion.toString();
-            URL baseURL = getURL();
-            boolean isFileBasedProtocol = "file".equals(baseURL.getProtocol());
-            if (highestLocalVersion != null && !isFileBasedProtocol) {
-                version += "?current=" + highestLocalVersion.toString();
-            }
-			URL dataURL = new URL(baseURL, version);
-			if (isFileBasedProtocol) {
-                File file = urlToFile(dataURL);
-                inputStream = new FileInputStream(file);
-            }
-            else {
-                inputStream = getContents(dataURL);
-            }
-
-            // Post event for auditlog
-            m_eventAdmin.postEvent(createEvent(version, dataURL));
-
-            m_deployer.install(inputStream);
-        }
-        finally {
-            if (inputStream != null) {
-                try {
-                    inputStream.close();
-                }
-                catch (Exception ex) {
-                    // Not much we can do.
-                }
-            }
-        }
-    }
-
-    /**
-     * @see org.apache.ace.deployment.service.DeploymentService#update(org.osgi.framework.Version)
-     */
-    public void update(Version toVersion) throws Exception {
-        installVersion(toVersion, getHighestLocalVersion());
-    }
-
-    /**
-     * @param url
-     * @return
-     * @throws IOException
-     */
-    final SortedSet<Version> getRemoteVersions(URL url) throws IOException {
-        if (url == null) {
-            return null;
-        }
-        
-        if ("file".equals(url.getProtocol())) {
-            return getVersionsFromDirectory(url);
-        }
-        else {
-            return getVersionsFromServer(url);
-        }
-    }
-
-    /**
-     * @param version
-     * @param dataURL
-     * @return
-     */
-    private Event createEvent(String version, URL dataURL) {
-        Dictionary<String, Object> properties = new Hashtable<>();
-        properties.put("deploymentpackage.url", dataURL.toString());
-        properties.put("deploymentpackage.version", version);
-        Event event = new Event(TOPIC_DEPLOYMENTPACKAGE_INSTALL, properties);
-        return event;
-    }
-
-    /**
-     * @param versions
-     * @return
-     */
-    private Version getHighestVersion(List<Version> versions) {
-        Version highestVersion = null;
-        for (Version version : versions) {
-            if (highestVersion == null) {
-                highestVersion = version;
-            }
-            else if (version.compareTo(highestVersion) > 0) {
-                highestVersion = version;
-            }
-        }
-        return highestVersion;
-    }
-
-    /**
-     * @return
-     */
-    private URL getURL() {
-        URL host = m_discovery.discover();
-        if (host == null) {
-            return null;
-        }
-        try {
-            return new URL(host, "deployment/" + m_identification.getID() + "/versions/");
-        }
-        catch (MalformedURLException e) {
-            m_log.log(LogService.LOG_WARNING, "Malformed URL", e);
-            return null;
-        }
-    }
-
-    /**
-     * @param url
-     * @return
-     */
-    private SortedSet<Version> getVersionsFromDirectory(URL url) {
-        File file = urlToFile(url);
-        if (!file.isDirectory()) {
-            return null;
-        }
-            
-        final File[] files = file.listFiles();
-        SortedSet<Version> versions = new TreeSet<>();
-        for (File f : files) {
-            try {
-                Version version = Version.parseVersion(f.getName());
-                if (version != Version.emptyVersion) {
-                    versions.add(version);
-                }
-            }
-            catch (IllegalArgumentException e) {
-                // if the file is not a valid version, we skip it
-            }
-        }
-        return versions;
-    }
-
-    /**
-     * @param url
-     * @return
-     */
-    private SortedSet<Version> getVersionsFromServer(URL url) {
-        BufferedReader bufReader = null;
-        try {
-            bufReader = new BufferedReader(new InputStreamReader(getContents(url)));
-            SortedSet<Version> versions = new TreeSet<>();
-            
-            String versionString;
-            while ((versionString = bufReader.readLine()) != null) {
-                try {
-                    Version version = Version.parseVersion(versionString);
-                    if (version != Version.emptyVersion) {
-                        versions.add(version);
-                    }
-                }
-                catch (IllegalArgumentException iae) {
-                    m_log.log(LogService.LOG_WARNING, "Received malformed version, ignoring: " + versionString);
-                }
-            }
-            
-            return versions;
-        }
-        catch (IOException ioe) {
-            m_log.log(LogService.LOG_DEBUG, "I/O error accessing server!", ioe);
-            return null;
-        }
-        finally {
-            if (bufReader != null) {
-                try {
-                    bufReader.close();
-                }
-                catch (Exception ex) {
-                    // not much we can do
-                }
-            }
-        }
-    }
-
-    /**
-     * @param url
-     * @return
-     */
-    private File urlToFile(URL url) {
-        File file;
-        // See: http://weblogs.java.net/blog/kohsuke/archive/2007/04/how_to_convert.html
-        // makes a best effort to convert a file URL to a File
-        try {
-            file = new File(url.toURI());
-        }
-        catch (URISyntaxException e) {
-            file = new File(url.getPath());
-        }
-        return file;
-    }
-
-    /**
-     * @param url the remote URL to connect to, cannot be <code>null</code>.
-     * @return an {@link InputStream} to the remote URL, never <code>null</code>.
-     * @throws IOException in case of I/O problems opening the remote connection.
-     */
-    private InputStream getContents(URL url) throws IOException {
-        URLConnection conn = m_connectionFactory.createConnection(url);
-        return conn.getInputStream();
-    }
-}
\ No newline at end of file
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/service/packageinfo b/org.apache.ace.deployment/src/org/apache/ace/deployment/service/packageinfo
deleted file mode 100644
index a4f1546..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/service/packageinfo
+++ /dev/null
@@ -1 +0,0 @@
-version 1.0
\ No newline at end of file
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/task/Activator.java b/org.apache.ace.deployment/src/org/apache/ace/deployment/task/Activator.java
deleted file mode 100644
index 5a410ad..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/task/Activator.java
+++ /dev/null
@@ -1,193 +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.ace.deployment.task;

-

-import java.util.ArrayList;

-import java.util.Dictionary;

-import java.util.HashMap;

-import java.util.Hashtable;

-import java.util.List;

-import java.util.Map;

-import java.util.Properties;

-

-import org.apache.ace.deployment.service.DeploymentService;

-import org.apache.ace.scheduler.constants.SchedulerConstants;

-import org.apache.felix.dm.Component;

-import org.apache.felix.dm.DependencyActivatorBase;

-import org.apache.felix.dm.DependencyManager;

-import org.osgi.framework.BundleContext;

-import org.osgi.framework.Constants;

-import org.osgi.service.cm.ConfigurationException;

-import org.osgi.service.cm.ManagedServiceFactory;

-import org.osgi.service.event.EventAdmin;

-import org.osgi.service.log.LogService;

-

-public class Activator extends DependencyActivatorBase implements ManagedServiceFactory {

-

-    private static final String PID_NAME = "org.apache.ace.deployment.task.default.factory";

-

-    private static final String MA_NAME = "ma";

-    private static final String DEFAULT_INTERVAL = "5000";

-

-    private final Map<String, List<Component>> m_instances = new HashMap<>();

-

-    private volatile DependencyManager m_manager;

-

-    /**

-     * @see org.osgi.service.cm.ManagedServiceFactory#deleted(java.lang.String)

-     */

-    public void deleted(String pid) {

-        List<Component> components;

-        synchronized (m_instances) {

-            components = m_instances.remove(pid);

-        }

-        if (components != null) {

-            for (Component component : components) {

-                m_manager.remove(component);

-            }

-        }

-    }

-

-    /**

-     * @see org.apache.felix.dm.DependencyActivatorBase#destroy(org.osgi.framework.BundleContext, org.apache.felix.dm.DependencyManager)

-     */

-    public void destroy(BundleContext context, DependencyManager manager) throws Exception {

-        // do nothing

-    }

-

-    /**

-     * @see org.osgi.service.cm.ManagedServiceFactory#getName()

-     */

-    public String getName() {

-        return "Deployment Service - default check/update tasks";

-    }

-

-    /**

-     * @see org.apache.felix.dm.DependencyActivatorBase#init(org.osgi.framework.BundleContext, org.apache.felix.dm.DependencyManager)

-     */

-    public void init(BundleContext context, DependencyManager manager) throws Exception {

-        m_manager = manager;

-

-        List<Component> components = createServices(null);

-        for (Component component : components) {

-            m_manager.add(component);

-        }

-

-        Properties props = new Properties();

-        props.put(Constants.SERVICE_PID, PID_NAME);

-

-        manager.add(createComponent()

-            .setInterface(ManagedServiceFactory.class.getName(), props)

-            .setImplementation(this)

-            );

-    }

-

-    /**

-     * @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String, java.util.Dictionary)

-     */

-    public void updated(String pid, Dictionary<String, ?> dict) throws ConfigurationException {

-        String ma = (String) dict.get(MA_NAME);

-

-        List<Component> components = m_instances.get(pid);

-        if (components == null) {

-            components = createServices(ma);

-            synchronized (m_instances) {

-                m_instances.put(pid, components);

-            }

-            for (Component component : components) {

-                m_manager.add(component);

-            }

-        }

-        else {

-            // TODO do we want to deal with changes here?

-        }

-    }

-

-    /**

-     * Creates the check/update task components for the given management agent name.

-     * 

-     * @param ma the name of the management agent to create the service for, can be <code>null</code>.

-     * @return an array with {@link Component} instances for the different tasks, never <code>null</code>.

-     */

-    private List<Component> createServices(String ma) {

-        Dictionary<String, Object> updateProperties = new Hashtable<>();

-        Dictionary<String, Object> checkProperties = new Hashtable<>();

-        Dictionary<String, Object> deploymentProperties = new Hashtable<>();

-        

-        String updateSchedulerName = DeploymentUpdateTask.class.getName();

-        String updateDescription = "Task that synchronizes the artifacts (bundles, resources) installed on this target with the server.";

-        

-        String checkSchedulerName = DeploymentCheckTask.class.getName();

-        String checkDescription = "Task that checks for updates of artifacts installed on this target with the server.";

-        

-        String deploymentFilter = "(" + Constants.OBJECTCLASS + "=" + DeploymentService.class.getName() + ")";

-

-        if (ma == null || "".equals(ma)) {

-            deploymentFilter = String.format("(&%s(!(%s=*)))", deploymentFilter, MA_NAME);

-        }

-        else {

-            updateSchedulerName = "ma=" + ma + ";name=" + updateSchedulerName;

-            updateDescription = "Task that synchronizes the artifacts (bundles, resources) installed on this target with the server with ma=" + ma + ".";

-            

-            checkSchedulerName = "ma=" + ma + ";name=" + checkSchedulerName;

-            checkDescription = "Task that checks for updates of artifacts installed on this target with the server with ma=" + ma + ".";

-            

-            deploymentFilter = String.format("(&%s(%s=%s))", deploymentFilter, MA_NAME, ma);

-            

-            updateProperties.put(MA_NAME, ma);

-            checkProperties.put(MA_NAME, ma);

-            deploymentProperties.put(MA_NAME, ma);

-        }

-

-        List<Component> result = new ArrayList<>();

-

-        updateProperties.put(SchedulerConstants.SCHEDULER_NAME_KEY, updateSchedulerName);

-        updateProperties.put(SchedulerConstants.SCHEDULER_DESCRIPTION_KEY, updateDescription);

-        updateProperties.put(SchedulerConstants.SCHEDULER_RECIPE, DEFAULT_INTERVAL);

-

-        DeploymentUpdateTask updateTask = new DeploymentUpdateTask();

-

-        Component updateTaskComponent =

-            createComponent()

-                .setInterface(Runnable.class.getName(), updateProperties)

-                .setImplementation(updateTask)

-                .add(createServiceDependency().setService(DeploymentService.class, deploymentFilter).setRequired(true))

-                .add(createServiceDependency().setService(LogService.class).setRequired(false));

-

-        checkProperties.put(SchedulerConstants.SCHEDULER_NAME_KEY, checkSchedulerName);

-        checkProperties.put(SchedulerConstants.SCHEDULER_DESCRIPTION_KEY, checkDescription);

-        checkProperties.put(SchedulerConstants.SCHEDULER_RECIPE, DEFAULT_INTERVAL);

-

-        result.add(updateTaskComponent);

-

-        DeploymentCheckTask checkTask = new DeploymentCheckTask();

-

-        Component checkTaskComponent =

-            createComponent()

-                .setInterface(Runnable.class.getName(), checkProperties)

-                .setImplementation(checkTask)

-                .add(createServiceDependency().setService(DeploymentService.class, deploymentFilter).setRequired(true))

-                .add(createServiceDependency().setService(EventAdmin.class).setRequired(false))

-                .add(createServiceDependency().setService(LogService.class).setRequired(false));

-

-        result.add(checkTaskComponent);

-

-        return result;

-    }

-}
\ No newline at end of file
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/task/DeploymentCheckTask.java b/org.apache.ace.deployment/src/org/apache/ace/deployment/task/DeploymentCheckTask.java
deleted file mode 100644
index 5876a7d..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/task/DeploymentCheckTask.java
+++ /dev/null
@@ -1,86 +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.ace.deployment.task;
-
-import java.net.MalformedURLException;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.apache.ace.deployment.service.DeploymentService;
-import org.osgi.framework.Version;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.log.LogService;
-
-/**
- * Task that checks for a new version and sends out an event if there is a new version. It does not actually
- * download or install it.
- */
-public class DeploymentCheckTask implements Runnable {
-
-    private static final String TOPIC_UPDATE_AVAILABLE = "org/apache/ace/deployment/UPDATEAVAILABLE";
-
-    private volatile LogService m_log;
-    private volatile EventAdmin m_eventAdmin;
-    private volatile DeploymentService m_service;
-
-    /**
-     * When run a check is made if a higher version is available on the remote. If so, send out an event.
-     */
-    public void run() {
-        try {
-            Version localVersion = m_service.getHighestLocalVersion();
-            Version remoteVersion = m_service.getHighestRemoteVersion();
-
-            if (remoteVersion == null) {
-                // expected if there's no discovered ps or relay server
-                // ACE-220: lower log level; not of real interest...
-                m_log.log(LogService.LOG_DEBUG, "Highest remote: unknown / Highest local: " + localVersion);
-                return;
-            }
-
-            // ACE-220: lower log level; not of real interest...
-            m_log.log(LogService.LOG_DEBUG, "Highest remote: " + remoteVersion + " / Highest local: " + localVersion);
-
-            if ((remoteVersion != null) && ((localVersion == null) || (remoteVersion.compareTo(localVersion) > 0))) {
-                m_eventAdmin.postEvent(createEvent(localVersion, remoteVersion));
-            }
-        }
-        catch (MalformedURLException e) {
-            m_log.log(LogService.LOG_ERROR, "Error creating endpoint url", e);
-        }
-        catch (Exception e) {
-            m_log.log(LogService.LOG_ERROR, "Error checking for update", e);
-        }
-    }
-
-    /**
-     * Creates an event for notifying listeners that a new version can be installed.
-     * 
-     * @param localVersion the highest local version;
-     * @param remoteVersion the higest remote version.
-     * @return a new {@link Event} instance, never <code>null</code>.
-     */
-    private Event createEvent(Version localVersion, Version remoteVersion) {
-        Dictionary<String, Object> properties = new Hashtable<>();
-        properties.put("deploymentpackage.localversion", ((localVersion == null) ? Version.emptyVersion : localVersion));
-        properties.put("deploymentpackage.remoteversion", remoteVersion);
-        return new Event(TOPIC_UPDATE_AVAILABLE, properties);
-    }
-}
\ No newline at end of file
diff --git a/org.apache.ace.deployment/src/org/apache/ace/deployment/task/DeploymentUpdateTask.java b/org.apache.ace.deployment/src/org/apache/ace/deployment/task/DeploymentUpdateTask.java
deleted file mode 100644
index 09ed5e2..0000000
--- a/org.apache.ace.deployment/src/org/apache/ace/deployment/task/DeploymentUpdateTask.java
+++ /dev/null
@@ -1,70 +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.ace.deployment.task;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import org.apache.ace.deployment.service.DeploymentService;
-import org.osgi.framework.Version;
-import org.osgi.service.log.LogService;
-
-/**
- * Implementation of the <code>Runnable</code> interface that updates software configurations by using the
- * <code>DeploymentService</code> to determine the current local version and to actually install new versions.
- */
-public class DeploymentUpdateTask implements Runnable {
-
-    private volatile DeploymentService m_service;
-    private volatile LogService m_log;
-
-    /**
-     * When run a check is made if a higher version is available on the remote. If so, an attempt is made to install
-     * this new version.
-     */
-    public void run() {
-        try {
-            Version highestLocalVersion = m_service.getHighestLocalVersion();
-            Version highestRemoteVersion = m_service.getHighestRemoteVersion();
-
-            if (highestRemoteVersion == null) {
-                // expected if there's no discovered ps or relay server
-                // ACE-220: lower log level; not of real interest...
-                m_log.log(LogService.LOG_DEBUG, "Highest remote: unknown / Highest local: " + highestLocalVersion);
-                return;
-            }
-            // ACE-220: lower log level; not of real interest...
-            m_log.log(LogService.LOG_DEBUG, "Highest remote: " + highestRemoteVersion + " / Highest local: " + highestLocalVersion);
-
-            if ((highestRemoteVersion != null) && ((highestLocalVersion == null) || (highestRemoteVersion.compareTo(highestLocalVersion) > 0))) {
-                // no local version or local version lower than remote, install the update
-                m_service.installVersion(highestRemoteVersion, highestLocalVersion);
-            }
-        }
-        catch (MalformedURLException e) {
-            m_log.log(LogService.LOG_ERROR, "Error creating endpoint url", e);
-        }
-        catch (IOException e) {
-            m_log.log(LogService.LOG_ERROR, "Error accessing resources", e);
-        }
-        catch (Exception e) {
-            m_log.log(LogService.LOG_ERROR, "Error installing update", e);
-        }
-    }
-}
\ No newline at end of file
diff --git a/org.apache.ace.deployment/task.base.bnd b/org.apache.ace.deployment/task.base.bnd
deleted file mode 100644
index c1513ee..0000000
--- a/org.apache.ace.deployment/task.base.bnd
+++ /dev/null
@@ -1,8 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under the terms of ASLv2 (http://www.apache.org/licenses/LICENSE-2.0).
-
-Private-Package: org.apache.ace.deployment.service.impl
-Bundle-Activator: org.apache.ace.deployment.service.impl.Activator
-Export-Package: org.apache.ace.deployment.service
-Bundle-Version: 1.0.2
-Bundle-Name: Apache ACE Deployment Task base
-Bundle-Description: Provides the Deployment task base packages
diff --git a/org.apache.ace.deployment/task.bnd b/org.apache.ace.deployment/task.bnd
deleted file mode 100644
index baeb00c..0000000
--- a/org.apache.ace.deployment/task.bnd
+++ /dev/null
@@ -1,7 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under the terms of ASLv2 (http://www.apache.org/licenses/LICENSE-2.0).
-
-Private-Package: org.apache.ace.deployment.task
-Bundle-Activator: org.apache.ace.deployment.task.Activator
-Bundle-Version: 1.0.1
-Bundle-Name: Apache ACE Deployment Tasks
-Bundle-Description: Registers a service factory for deployment check and update tasks
\ No newline at end of file
diff --git a/org.apache.ace.deployment/test/org/apache/ace/deployment/DeploymentTest.java b/org.apache.ace.deployment/test/org/apache/ace/deployment/DeploymentTest.java
deleted file mode 100644
index b55c4f4..0000000
--- a/org.apache.ace.deployment/test/org/apache/ace/deployment/DeploymentTest.java
+++ /dev/null
@@ -1,94 +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.ace.deployment;
-
-import static org.apache.ace.test.utils.TestUtils.UNIT;
-
-import java.io.InputStream;
-
-import org.apache.ace.deployment.deploymentadmin.DeploymentAdminDeployer;
-import org.apache.ace.test.utils.TestUtils;
-import org.osgi.framework.Version;
-import org.osgi.service.deploymentadmin.DeploymentAdmin;
-import org.osgi.service.deploymentadmin.DeploymentPackage;
-import org.osgi.service.log.LogService;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-public class DeploymentTest {
-
-    private DeploymentAdminDeployer m_deploymentAdminDeployer;
-    private DeploymentPackage m_mockDeploymentPackage;
-
-    private static final String MOCK_NAME = "MockName";
-    private static final Version MOCK_VERSION = new Version("0.1");
-
-    @BeforeTest(alwaysRun = true)
-    protected void setUp() throws Exception {
-        m_deploymentAdminDeployer = new DeploymentAdminDeployer();
-        TestUtils.configureObject(m_deploymentAdminDeployer, LogService.class);
-        Object mockDeploymentAdmin = TestUtils.createMockObjectAdapter(DeploymentAdmin.class, new MockDeploymentAdmin());
-        TestUtils.configureObject(m_deploymentAdminDeployer, DeploymentAdmin.class, mockDeploymentAdmin);
-        m_mockDeploymentPackage = TestUtils.createMockObjectAdapter(DeploymentPackage.class, new MockDeploymentPackage());
-    }
-
-    @Test(groups = { UNIT })
-    public void testDeployment() throws Exception {
-        Object deploymentPackage = m_deploymentAdminDeployer.install(null);
-        assert m_deploymentAdminDeployer.getName(deploymentPackage).equals(MOCK_NAME) : "Installation of mock deployment package failed";
-        assert m_deploymentAdminDeployer.getVersion(deploymentPackage).equals(MOCK_VERSION) : "Installation of mock deployment package failed";
-        assert ((DeploymentPackage) m_deploymentAdminDeployer.list()[0]).getName().equals(MOCK_NAME) : "List result does not match expected result";
-        boolean exceptionthrown = false;
-        try {
-            m_deploymentAdminDeployer.getName(new String("illegalargument"));
-        } catch (IllegalArgumentException iae) {
-            exceptionthrown = true;
-        }
-        assert exceptionthrown : "Illegal argument for getName() did not throw exception";
-        exceptionthrown = false;
-        try {
-            m_deploymentAdminDeployer.getVersion(new String("illegalargument"));
-        } catch (IllegalArgumentException iae) {
-            exceptionthrown = true;
-        }
-        assert exceptionthrown : "Illegal argument for getVersion() did not throw exception";
-    }
-
-    @SuppressWarnings("unused")
-    private class MockDeploymentAdmin {
-        public DeploymentPackage installDeploymentPackage(InputStream is) {
-            return m_mockDeploymentPackage;
-        }
-
-        public DeploymentPackage[] listDeploymentPackages() {
-            return new DeploymentPackage[] {m_mockDeploymentPackage};
-        }
-    }
-
-    @SuppressWarnings("unused")
-    private class MockDeploymentPackage {
-        public String getName() {
-            return MOCK_NAME;
-        }
-
-        public Version getVersion() {
-            return MOCK_VERSION;
-        }
-    }
-}
diff --git a/org.apache.ace.deployment/test/org/apache/ace/deployment/service/impl/DeploymentServiceImplTest.java b/org.apache.ace.deployment/test/org/apache/ace/deployment/service/impl/DeploymentServiceImplTest.java
deleted file mode 100644
index cb8907b..0000000
--- a/org.apache.ace.deployment/test/org/apache/ace/deployment/service/impl/DeploymentServiceImplTest.java
+++ /dev/null
@@ -1,286 +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.ace.deployment.service.impl;
-
-import static org.apache.ace.test.utils.TestUtils.UNIT;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-import java.util.SortedSet;
-
-import org.apache.ace.connectionfactory.ConnectionFactory;
-import org.apache.ace.deployment.Deployment;
-import org.apache.ace.discovery.Discovery;
-import org.apache.ace.identification.Identification;
-import org.apache.ace.test.utils.TestUtils;
-import org.osgi.framework.Version;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.log.LogService;
-import org.osgi.service.useradmin.User;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-public class DeploymentServiceImplTest {
-    
-    private static final Version VERSION1 = new Version("1.0.0");
-    private static final Version VERSION2 = new Version("2.0.0");
-    private static final Version VERSION3 = new Version("3.0.0");
-    
-    private DeploymentServiceImpl m_service;
-    private MockDeployerService m_mockDeployerService;
-    private boolean m_correctVersionInstalled;
-    private boolean m_installCalled;
-
-    @BeforeMethod(alwaysRun = true)
-    protected void setUp() throws Exception {
-        m_mockDeployerService = new MockDeployerService();
-        
-        m_correctVersionInstalled = false;
-        m_installCalled = false;
-        m_service = new DeploymentServiceImpl();
-        
-        TestUtils.configureObject(m_service, LogService.class);
-        TestUtils.configureObject(m_service, EventAdmin.class);
-        TestUtils.configureObject(m_service, ConnectionFactory.class, new MockConnectionFactory());
-        TestUtils.configureObject(m_service, Identification.class, new Identification() {
-            public String getID() {
-                return "test";
-            }
-        });
-        TestUtils.configureObject(m_service, Discovery.class, new Discovery() {
-            public URL discover() {
-                try {
-                    return new URL("http://localhost/");
-                }
-                catch (MalformedURLException e) {
-                    throw new RuntimeException(e);
-                }
-            }
-        });
-        TestUtils.configureObject(m_service, Deployment.class, m_mockDeployerService);
-    }
-
-    @Test(groups = { UNIT })
-    public void testGetHighestLocalVersion() {
-        prepareMockEnvironment(new Version[] {VERSION1, VERSION2, VERSION3}, null, null);
-        Version highestVersion = m_service.getHighestLocalVersion();
-        assert highestVersion.equals(VERSION3) : "Highest local version is incorrect, expected " + VERSION3.toString() + " but got " + highestVersion.toString();
-    }
-
-    @Test(groups = { UNIT })
-    public void testGetRemoteVersionsWithURL() throws MalformedURLException, IOException {
-        URL[] urls =  prepareMockEnvironment(null, new Version[] {VERSION1, VERSION2, VERSION3}, null);
-        SortedSet<Version> highestVersion = m_service.getRemoteVersions(urls[0]);
-        assert !highestVersion.isEmpty() : "Expected versions to return!";
-        assert highestVersion.last().equals(VERSION3) : "Highest remote version is incorrect, expected " + VERSION3.toString() + " but got " + highestVersion.toString();
-    }
-
-    @Test(groups = { UNIT })
-    public void testUpdateWithLatestVersion() throws Exception {
-        final URL[] urls=  prepareMockEnvironment(null, new Version[] {VERSION1, VERSION2, VERSION3}, VERSION3);
-
-        TestUtils.configureObject(m_service, Discovery.class, new Discovery() {
-            public URL discover() {
-                return urls[1];
-            }
-        });
-
-        m_service.update(VERSION3);
-        
-        assert m_installCalled : "Install not called?!";
-        assert m_correctVersionInstalled : "Wrong version installed?!";
-    }
-
-    @Test(groups = { UNIT })
-    public void testUpdateWithNonLatestVersion() throws Exception {
-        final URL[] urls=  prepareMockEnvironment(null, new Version[] {VERSION1, VERSION2, VERSION3}, VERSION2);
-
-        TestUtils.configureObject(m_service, Discovery.class, new Discovery() {
-            public URL discover() {
-                return urls[1];
-            }
-        });
-
-        m_service.update(VERSION2);
-        
-        assert m_installCalled : "Install not called?!";
-        assert m_correctVersionInstalled : "Wrong version installed?!";
-    }
-
-    /**
-     * Helper method to setup the correct endpoints and deploymentservice based on the appropriate mock classes.
-     *
-     * @param localVersions The versions that should appear to be installed.
-     * @param remoteVersions The versions that should appear to be available remotely.
-     * @param expectedInstallVersion The version that is expected to be installed.
-     * @return Array of two urls, element [0] is the controlEndpoint, element [1] is the dataEndpoint
-     */
-    private URL[] prepareMockEnvironment(Version[] localVersions, Version[] remoteVersions, Version expectedInstallVersion) {
-        if (localVersions == null) {
-            localVersions = new Version[0];
-        }
-        if (remoteVersions == null) {
-            remoteVersions = new Version[0];
-        }
-        if (expectedInstallVersion == null) {
-            expectedInstallVersion = Version.emptyVersion;
-        }
-        // mock installed versions
-        m_mockDeployerService.setList(localVersions);
-
-        // mock versions available remotely through the control channel
-        MockURLConnection controlURLConnection = new MockURLConnection();
-        controlURLConnection.setVersions(remoteVersions, null);
-
-        // mock version available remotely through the data channel
-        MockURLConnection dataURLConnection = new MockURLConnection();
-        dataURLConnection.setVersions(new Version[] {expectedInstallVersion}, null);
-
-        m_mockDeployerService.setExpectedInstallVersion(expectedInstallVersion);
-
-        final URL controlEndpoint;
-        URL dataEndpoint = null;
-        try {
-            // create endpoints based on mock classes
-            controlEndpoint = new URL(new URL("http://notmalformed"), "", new MockURLStreamHandler(controlURLConnection));
-            dataEndpoint = new URL(new URL("http://notmalformed"), "", new MockURLStreamHandler(dataURLConnection));
-        }
-        catch (MalformedURLException e) {
-            throw new RuntimeException(e);
-        }
-
-        return new URL[] {controlEndpoint, dataEndpoint};
-    }
-
-    /**
-     * Mock implementation of {@link ConnectionFactory}.
-     */
-    static final class MockConnectionFactory implements ConnectionFactory {
-        public URLConnection createConnection(URL url) throws IOException {
-            return url.openConnection();
-        }
-        
-        public URLConnection createConnection(URL url, User user) throws IOException {
-            return createConnection(url);
-        }
-    }
-
-    /**
-     * Mock implementation of <code>DeploymentService</code> that expects Version objects.
-     * The Version objects that are 'installed' can be mocked with the new <code>setList(Version[] objects)</code>
-     * method. The <code>install(Inputstream is)</code> method only checks if the call was expected by verifying the
-     * version matches the version set by the <code>setExpectedInstallVersion(Version v)</code> method. If so a boolean
-     * in the outer class is set to true.
-     */
-    private class MockDeployerService implements Deployment {
-        Object[] m_objects = new Object[]{};
-        Version m_expectedInstallVersion = Version.emptyVersion;
-
-        public String getName(Object object) throws IllegalArgumentException {
-            return "test";
-        }
-
-        public void setExpectedInstallVersion(Version version) {
-            m_expectedInstallVersion = version;
-        }
-
-        public Version getVersion(Object object) throws IllegalArgumentException {
-            return (Version) object;
-        }
-
-        public Object install(InputStream inputStream) throws Exception {
-            m_installCalled = true;
-            BufferedReader bufReader = new BufferedReader(new InputStreamReader(inputStream));
-            String versionString = bufReader.readLine();
-            if (m_expectedInstallVersion.equals(new Version(versionString))) {
-                m_correctVersionInstalled = true;
-            }
-            return new Version(versionString);
-        }
-
-        public Object[] list() {
-            return m_objects;
-        }
-
-        public void setList(Version[] objects) {
-            m_objects = objects;
-        }
-
-    }
-
-    /**
-     * Mock implementation of <code>URLStreamHandler</code>. Will return the <code>URLConnection</code>
-     * supplied in the constructor instead when <code>openConnection(URL url)</code> is called.
-     */
-    private static class MockURLStreamHandler extends URLStreamHandler {
-        private final URLConnection urlConn;
-
-        public MockURLStreamHandler(URLConnection urlConnection) {
-            this.urlConn = urlConnection;
-        }
-
-        @Override
-        protected URLConnection openConnection(URL url) throws IOException {
-            return urlConn;
-        }
-    }
-
-    /**
-     * Mock implementation of <code>URLConnection</code>. Instead of returning an inputstream
-     * based on the URL it will return an inputstream based on the versions specified by the
-     * new <code>setVersions(Version[] versions)</code> method.
-     */
-    private static class MockURLConnection extends URLConnection {
-        private ByteArrayInputStream m_inputStream = new ByteArrayInputStream(new byte[]{});
-
-        protected MockURLConnection() {
-            super(null);
-        }
-
-        @Override
-        public void connect() throws IOException {
-            // do nothing
-        }
-
-        @Override
-        public InputStream getInputStream() {
-            return m_inputStream;
-        }
-
-        public void setVersions(Version[] versions, String malformedVersion) {
-            String versionsString = "";
-            for(int i = 0; i < versions.length; i++) {
-                versionsString += versions[i] + "\n";
-            }
-            if (malformedVersion != null) {
-                versionsString += malformedVersion + "\n";
-            }
-            byte[] bytes = versionsString.getBytes();
-            m_inputStream = new ByteArrayInputStream(bytes);
-        }
-
-    }
-}