ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1727373 - in /ace/trunk: org.apache.ace.authentication.itest/ org.apache.ace.client.repository.itest/ org.apache.ace.client.rest.itest/ org.apache.ace.configurator.useradmin.itest/ org.apache.ace.deployment.itest/ org.apache.ace.deployment...
Date Thu, 28 Jan 2016 15:02:14 GMT
Author: jawi
Date: Thu Jan 28 15:02:14 2016
New Revision: 1727373

URL: http://svn.apache.org/viewvc?rev=1727373&view=rev
Log:
ACE-423 - Remove the file based provider:

- applied the patch from @brampouwelse;
- code is moved to the provider itest bundle.


Added:
    ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/
    ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/
    ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java   (with props)
    ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java   (with props)
    ace/trunk/org.apache.ace.deployment.itest/test/org/
    ace/trunk/org.apache.ace.deployment.itest/test/org/apache/
    ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/
    ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/
    ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/
    ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/
    ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/
    ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java   (with props)
Removed:
    ace/trunk/org.apache.ace.deployment/provider.filebased.bnd
    ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/filebased/
Modified:
    ace/trunk/org.apache.ace.authentication.itest/bnd.bnd
    ace/trunk/org.apache.ace.client.repository.itest/bnd.bnd
    ace/trunk/org.apache.ace.client.rest.itest/bnd.bnd
    ace/trunk/org.apache.ace.configurator.useradmin.itest/bnd.bnd
    ace/trunk/org.apache.ace.deployment.itest/.classpath
    ace/trunk/org.apache.ace.deployment.itest/bnd.bnd
    ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/filebased/FileBasedProviderTest.java
    ace/trunk/org.apache.ace.repository.itest/bnd.bnd

Modified: ace/trunk/org.apache.ace.authentication.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.authentication.itest/bnd.bnd?rev=1727373&r1=1727372&r2=1727373&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.authentication.itest/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.authentication.itest/bnd.bnd Thu Jan 28 15:02:14 2016
@@ -11,7 +11,6 @@ Test-Cases: ${classes;CONCRETE;NAMED;*Te
 	org.apache.ace.repository.api;version=latest,\
 	org.apache.ace.log.server.store.api;version=latest,\
 	org.apache.ace.client.repository.api;version=latest,\
-	org.apache.ace.repository.impl;version=latest,\
 	org.apache.ace.discovery.api;version=latest,\
 	org.apache.ace.identification.api;version=latest,\
 	org.apache.ace.discovery.property;version=latest,\

Modified: ace/trunk/org.apache.ace.client.repository.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository.itest/bnd.bnd?rev=1727373&r1=1727372&r2=1727373&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository.itest/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.client.repository.itest/bnd.bnd Thu Jan 28 15:02:14 2016
@@ -16,10 +16,8 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o
 	org.apache.ace.identification.property;version=latest,\
 	org.apache.ace.scheduler.api;version=latest,\
 	org.apache.ace.deployment.servlet;version=latest,\
-	org.apache.ace.deployment.provider.filebased;version=latest,\
 	org.apache.ace.obr.storage;version=latest,\
 	org.apache.ace.repository.api;version=latest,\
-	org.apache.ace.repository.impl;version=latest,\
 	org.apache.ace.client.repository.api;version=latest,\
 	org.apache.ace.client.repository.helper.bundle;version=latest,\
 	org.apache.ace.log.server.store.api;version=latest,\
@@ -44,7 +42,6 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o
 	org.apache.ace.scheduler.impl;version=latest,\
 	org.apache.ace.scheduler.api;version=latest,\
 	org.apache.ace.deployment.provider.api;version=latest,\
-	org.apache.ace.deployment.provider.filebased;version=latest,\
 	org.apache.ace.discovery.api;version=latest,\
 	org.apache.ace.discovery.property;version=latest,\
 	org.apache.ace.identification.api;version=latest,\

Modified: ace/trunk/org.apache.ace.client.rest.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.rest.itest/bnd.bnd?rev=1727373&r1=1727372&r2=1727373&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.rest.itest/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.client.rest.itest/bnd.bnd Thu Jan 28 15:02:14 2016
@@ -18,10 +18,8 @@
 	org.apache.ace.log.server.store.api;version=latest,\
 	org.apache.ace.scheduler.api;version=latest,\
 	org.apache.ace.deployment.servlet;version=latest,\
-	org.apache.ace.deployment.provider.filebased;version=latest,\
 	org.apache.ace.obr.storage;version=latest,\
 	org.apache.ace.repository.api;version=latest,\
-	org.apache.ace.repository.impl;version=latest,\
 	org.apache.ace.client.repository.api;version=latest,\
 	org.apache.ace.client.repository.helper.base;version=latest,\
 	org.apache.ace.client.repository.helper.bundle;version=latest,\

Modified: ace/trunk/org.apache.ace.configurator.useradmin.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.configurator.useradmin.itest/bnd.bnd?rev=1727373&r1=1727372&r2=1727373&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.configurator.useradmin.itest/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.configurator.useradmin.itest/bnd.bnd Thu Jan 28 15:02:14 2016
@@ -15,7 +15,6 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o
 	org.apache.ace.log.server.store.api;version=latest,\
 	org.apache.ace.range.api;version=latest,\
 	org.apache.ace.repository.api;version=latest,\
-	org.apache.ace.repository.impl;version=latest,\
 	org.apache.ace.feedback.common;version=latest
 -runfw: org.apache.felix.framework;version='[5.2.0,6)'
 -runvm: -ea

Modified: ace/trunk/org.apache.ace.deployment.itest/.classpath
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.itest/.classpath?rev=1727373&r1=1727372&r2=1727373&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment.itest/.classpath (original)
+++ ace/trunk/org.apache.ace.deployment.itest/.classpath Thu Jan 28 15:02:14 2016
@@ -2,7 +2,8 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="src" output="bin_test" path="test"/>
-    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
 	<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
+	<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: ace/trunk/org.apache.ace.deployment.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.itest/bnd.bnd?rev=1727373&r1=1727372&r2=1727373&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment.itest/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.deployment.itest/bnd.bnd Thu Jan 28 15:02:14 2016
@@ -17,7 +17,6 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o
 	org.apache.ace.scheduler.api;version=latest,\
 	org.apache.ace.deployment.servlet;version=latest,\
 	org.apache.ace.deployment.provider.api;version=latest,\
-	org.apache.ace.deployment.provider.filebased;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,\
@@ -40,7 +39,6 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o
 	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.filebased;version=latest,\
 	org.apache.ace.deployment.provider.repositorybased;version=latest,\
 	org.apache.ace.deployment.servlet;version=latest,\
 	org.apache.ace.deployment.streamgenerator;version=latest,\
@@ -63,7 +61,13 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o
 	org.apache.ace.scheduler.api;version=latest,\
 	org.apache.ace.test;version=latest,\
 	org.apache.ace.range.api;version=latest
-Private-Package: org.apache.ace.it.deployment, org.apache.ace.deployment.util.test
+Private-Package: \
+	org.apache.ace.it.deployment,\
+	org.apache.ace.deployment.util.test,\
+	org.apache.ace.deployment.provider.impl,\
+	org.apache.ace.it.deployment.provider.filebased
+	
+Bundle-Activator: org.apache.ace.it.deployment.provider.filebased.Activator
 Bundle-Version: 1.0.0
 Bundle-Name: Apache ACE Deployment itest
 Bundle-Description: Integration test bundle for Apache ACE Deployment

Added: ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java?rev=1727373&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java (added)
+++ ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java Thu Jan 28 15:02:14 2016
@@ -0,0 +1,47 @@
+/*
+ * 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.provider.filebased;
+
+import org.apache.ace.deployment.provider.DeploymentProvider;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+public class Activator extends DependencyActivatorBase {
+    public static final String PID = "org.apache.ace.deployment.provider.filebased";
+
+    @Override
+    public void init(BundleContext context, DependencyManager manager) throws Exception {
+        manager.add(createComponent()
+            .setInterface(DeploymentProvider.class.getName(), null)
+            .setImplementation(FileBasedProvider.class)
+            .add(createConfigurationDependency()
+                .setPid(PID)
+             )
+             .add(createServiceDependency()
+                 .setService(LogService.class)
+                 .setRequired(false)));
+    }
+
+    @Override
+    public void destroy(BundleContext arg0, DependencyManager arg1) throws Exception {
+        // TODO Auto-generated method stub
+    }
+}
\ No newline at end of file

Propchange: ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java?rev=1727373&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java (added)
+++ ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java Thu Jan 28 15:02:14 2016
@@ -0,0 +1,415 @@
+/*
+ * 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.provider.filebased;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.jar.Attributes;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.DeploymentProvider;
+import org.apache.ace.deployment.provider.OverloadedException;
+import org.apache.ace.deployment.provider.impl.ArtifactDataImpl;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.log.LogService;
+
+/**
+ * This class reads data from the filesystem. It contains deployment data in the following format: <storage dir>/<target-name>/<bundle-version>/<jars>
+ * example : storage-directory/ storage-directory/target-a storage-directory/target-a/1.0.0
+ * storage-directory/target-a/1.0.0/bundle1.jar storage-directory/target-a/1.0.0/bundle2.jar storage-directory/target-a/1.1.0
+ * storage-directory/target-a/1.1.0/bundle2.jar storage-directory/target-a/1.1.0/bundle3.jar The versions are in the
+ * org.osgi.framework.Version format.
+ */
+public class FileBasedProvider implements DeploymentProvider, ManagedService {
+    /** Directory where all the target ID folders are located. */
+    private static final String DIRECTORY_NAME = "BaseDirectoryName";
+    /** Fallback directory for all targets that have no specific versions. Defaults to BaseDirectoryName if not specified. */
+    private static final String DEFAULT_DIRECTORY_NAME = "DefaultDirectoryName";
+    /** Configuration key for the number of concurrent users */
+    private static final String MAXIMUM_NUMBER_OF_USERS = "MaximumNumberOfUsers";
+    private static final int OSGI_R4_MANIFEST_VERSION = 2;
+    private volatile File m_baseDirectory;
+    private volatile File m_defaultDirectory;
+    private volatile LogService m_log;
+    private final Semaphore m_disk = new Semaphore(1, true);
+    
+    private final AtomicInteger m_usageCounter = new AtomicInteger();
+    /** Maximum number of concurrent users. Value 0 is used for unlimited users. */
+    private int m_maximumNumberOfUsers = 0;
+    /** The default backoff time for each new user over the limit */
+    private static final int BACKOFF_TIME_PER_USER = 5; 
+
+    /**
+     * Get the bundle data from the bundles in the &lt;data dir&gt;/&lt;target&gt;/&lt;version&gt; directory It reads the manifest from all the
+     * .jar files in that directory. If the manifest cannot be found, This method can only parse OSGi R4 bundles
+     */
+    public List<ArtifactData> getBundleData(String targetId, String version) throws OverloadedException, IllegalArgumentException {
+        try {
+            int concurrentUsers = m_usageCounter.incrementAndGet();
+            if (m_maximumNumberOfUsers != 0  && m_maximumNumberOfUsers < concurrentUsers) {
+                throw new OverloadedException("Too many users, maximum allowed = " + m_maximumNumberOfUsers + ", current = " + concurrentUsers,  (concurrentUsers - m_maximumNumberOfUsers) * BACKOFF_TIME_PER_USER);
+            }
+            return internalGetBundleData(targetId, version);
+        } finally {
+            m_usageCounter.getAndDecrement();
+        }
+
+    }
+
+    /**
+     * Version folder and requested version do not always match (see implementation of getVersions, which uses Versions.parseVersion to allow different styles)
+     * like 1 instead of 1.0.0 and alike.
+     * So we need to do some crawling to map them.
+     *
+     * @param targetDirectory store directory
+     * @param version          that has been requested.
+     *
+     * @return the matching folder.
+     *
+     * @throws IllegalArgumentException if no matching folder has been found. If this happens something is weirdly wrong.
+     */
+    private File findMatchingVersionDirectory(File targetDirectory, String version) {
+        // first try the direct way:
+        File directTry = new File(targetDirectory, version);
+        if ((directTry != null) && directTry.isDirectory()) {
+            return directTry;
+        }
+        // otherwise try to find it:
+        Version requestedVersion;
+        try {
+            requestedVersion = Version.parseVersion(version);
+        }
+        catch (IllegalArgumentException iae) {
+            throw new IllegalArgumentException("Requested version " + version + " has no matching folder in store: " + targetDirectory.getAbsolutePath());
+        }
+
+        File[] files = targetDirectory.listFiles();
+        for (int i = 0; i < files.length; i++) {
+            File possibleVersionDirectory = files[i];
+            if (possibleVersionDirectory.isDirectory()) {
+                // ok, it is a directory. Now see if it is a version
+                try {
+                    Version foundVersion = Version.parseVersion(possibleVersionDirectory.getName());
+                    // no exception, but is could still be an empty version
+                    if ((requestedVersion != null) && requestedVersion.equals(foundVersion)) {
+                        return new File(targetDirectory, possibleVersionDirectory.getName());
+                    }
+                }
+                catch (IllegalArgumentException iae) {
+                    // dont' care at this point.
+                }
+            }
+        }
+        throw new IllegalArgumentException("Requested version " + version + " has no matching folder in store: " + targetDirectory.getAbsolutePath());
+    }
+
+    public List<ArtifactData> getBundleData(String targetId, String versionFrom, String versionTo) throws OverloadedException, IllegalArgumentException {
+        try {
+            int concurrentUsers = m_usageCounter.incrementAndGet();
+            if (m_maximumNumberOfUsers != 0  && m_maximumNumberOfUsers < concurrentUsers) {
+                throw new OverloadedException("Too many users, maximum allowed = " + m_maximumNumberOfUsers + ", current = " + concurrentUsers,  (concurrentUsers - m_maximumNumberOfUsers) * BACKOFF_TIME_PER_USER);
+            }
+            List<ArtifactData> dataVersionFrom = internalGetBundleData(targetId, versionFrom);
+            List<ArtifactData> dataVersionTo = internalGetBundleData(targetId, versionTo);
+    
+            Iterator<ArtifactData> it = dataVersionTo.iterator();
+            while (it.hasNext()) {
+                ArtifactDataImpl bundleDataVersionTo = (ArtifactDataImpl) it.next();
+                // see if there was previously a version of this bundle.
+                ArtifactData bundleDataVersionFrom = getBundleData(bundleDataVersionTo.getSymbolicName(), dataVersionFrom);
+                bundleDataVersionTo.setChanged(!bundleDataVersionTo.equals(bundleDataVersionFrom));
+            }
+            return dataVersionTo;
+        } finally {
+            m_usageCounter.getAndDecrement();
+        }
+    }
+
+    /**
+     * Check for the existence of bundledata in the collection for a bundle with the given symbolic name
+     *
+     * @param symbolicName
+     */
+    private ArtifactData getBundleData(String symbolicName, Collection<ArtifactData> data) {
+        Iterator<ArtifactData> it = data.iterator();
+        while (it.hasNext()) {
+            ArtifactData bundle = it.next();
+            if (bundle.getSymbolicName().equals(symbolicName)) {
+                return bundle;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Look in the baseDirectory for the specified target. If it exists, get the list of directories in there and check if they
+     * conform to the <code>org.osgi.framework.Version</code> format. If it does, it will be in the list of versions that are
+     * returned. If there are no valid versions, return an empty list. If the target cannot be found, an
+     * IllegalArgumentException is thrown. The list will be sorted on version.
+     */
+    public List<String> getVersions(String targetId) throws OverloadedException, IllegalArgumentException {
+        try {
+            int concurrentUsers = m_usageCounter.incrementAndGet();
+            if (m_maximumNumberOfUsers != 0  && m_maximumNumberOfUsers < concurrentUsers) {
+                throw new OverloadedException("Too many users, maximum allowed = " + m_maximumNumberOfUsers + ", current = " + concurrentUsers,  (concurrentUsers - m_maximumNumberOfUsers) * BACKOFF_TIME_PER_USER);
+            }
+            List<Version> versionList = new ArrayList<Version>();
+            File targetDirectory = new File(m_baseDirectory.getAbsolutePath(), targetId);
+            if (targetDirectory.isDirectory()) {
+                getVersions(targetId, versionList, targetDirectory);
+            }
+            else {
+                // try the default
+                getVersions(targetId, versionList, m_defaultDirectory);
+            }
+    
+            // now sort the list of versions and convert all values to strings.
+            Collections.sort(versionList);
+            List<String> stringVersionList = new ArrayList<String>();
+            Iterator<Version> it = versionList.iterator();
+            while (it.hasNext()) {
+                String version = (it.next()).toString();
+                stringVersionList.add(version);
+            }
+            return stringVersionList;
+        } finally {
+            m_usageCounter.getAndDecrement();
+        }
+    }
+
+    private List<ArtifactData> internalGetBundleData(String targetId, String version) throws OverloadedException, IllegalArgumentException {
+        List<String> versions = getVersions(targetId);
+        if (!versions.contains(version)) {
+            throw new IllegalArgumentException("Unknown version " + version + " requested");
+        }
+        File targetDirectory = new File(m_baseDirectory, targetId);
+        File versionDirectory;
+        if (targetDirectory.isDirectory()) {
+            // target has its own folder
+            versionDirectory = findMatchingVersionDirectory(targetDirectory, version);
+        }
+        else {
+            versionDirectory = findMatchingVersionDirectory(m_defaultDirectory, version);
+        }
+        List<ArtifactData> bundleData = new ArrayList<ArtifactData>();
+
+        JarInputStream jarInputStream = null;
+
+        File[] jarFiles = versionDirectory.listFiles();
+        for (int i = 0; i < jarFiles.length; i++) {
+            Manifest bundleManifest = null;
+            File jarFile = jarFiles[i];
+            try {
+                jarInputStream = new JarInputStream(new FileInputStream(jarFile));
+                bundleManifest = jarInputStream.getManifest();
+            }
+            catch (IOException ioe) {
+                m_log.log(LogService.LOG_WARNING, "Error making inputstream", ioe);
+                continue;
+            }
+            finally {
+                if (jarInputStream != null) {
+                    try {
+                        jarInputStream.close();
+                    }
+                    catch (Exception ioe) {
+                        m_log.log(LogService.LOG_ERROR, "Error closing the file input stream", ioe);
+                    }
+                }
+            }
+            Attributes mainAttributes = bundleManifest.getMainAttributes();
+            String manifestVersion = mainAttributes.getValue(Constants.BUNDLE_MANIFESTVERSION);
+            String symbolicName = mainAttributes.getValue(Constants.BUNDLE_SYMBOLICNAME);
+            String bundleVersion = mainAttributes.getValue(Constants.BUNDLE_VERSION);
+
+            if ((manifestVersion != null) && (symbolicName != null) && (bundleVersion != null)) {
+                // ok, now at least we have the required attributes
+                // now check if they have the expected values
+                if (OSGI_R4_MANIFEST_VERSION != new Integer(manifestVersion).intValue()) {
+                    m_log.log(LogService.LOG_WARNING, "Invalid bundle:" + jarFile.getAbsolutePath() + " has the wrong manifest version.");
+                }
+                else {
+                    // it is the right manifest version
+                    if (symbolicName.trim().equals("")) {
+                        m_log.log(LogService.LOG_WARNING, "Invalid bundle:" + jarFile.getAbsolutePath() + " the symbolic name is empty.");
+                    }
+                    else {
+                        // it also has the right symbolic name
+                        try {
+                            new Version(bundleVersion);
+                            // Do a file.toURI().toURL() to preserve special path characters
+                            // see http://www.javalobby.org/java/forums/t19698.html
+                            URL bundleUrl = new URL(null, jarFile.toURI().toURL().toString(), new URLStreamHandler() {
+                                @Override
+                                protected URLConnection openConnection(final URL u) throws IOException {
+                                    return new URLConnection(u) {
+                                        @Override
+                                        public void connect() throws IOException {
+                                            // TODO Auto-generated method stub
+                                        }
+                                        @Override
+                                        public InputStream getInputStream() throws IOException {
+                                            final InputStream parent;
+                                            try {
+                                                parent = new URL(u.toURI().toURL().toString()).openStream();
+                                            }
+                                            catch (URISyntaxException ex) {
+                                                throw new IOException(ex.getMessage());
+                                            }
+                                            return new InputStream() {
+                                                @Override
+                                                public int read() throws IOException {
+                                                    return parent.read();
+                                                }
+
+                                                @Override
+                                                public int read(byte[] buffer) throws IOException {
+                                                    return read(buffer, 0, buffer.length);
+                                                }
+
+                                                @Override
+                                                public int read(byte[] buffer, int off, int length) throws IOException {
+                                                    m_disk.acquireUninterruptibly();
+                                                    try {
+                                                        return parent.read(buffer, off, length);
+                                                    }
+                                                    finally {
+                                                        m_disk.release();
+                                                    }
+                                                }
+
+                                                @Override
+                                                public void close() throws IOException {
+                                                    parent.close();
+                                                }
+                                            };
+                                        }
+                                    };
+                                }
+                            });
+                            bundleData.add(new ArtifactDataImpl(jarFile.getName(), symbolicName, jarFile.length(), bundleVersion, bundleUrl, true));
+                        }
+                        catch (IllegalArgumentException iae) {
+                            m_log.log(LogService.LOG_WARNING, "Invalid bundle:" + jarFile.getAbsolutePath() + " has an illegal version", iae);
+                        }
+                        catch (MalformedURLException mue) {
+                            m_log.log(LogService.LOG_WARNING, "Invalid bundle:" + jarFile.getAbsolutePath() + " unable to convert path to URL", mue);
+                        }
+                    }
+                }
+            }
+            else {
+                m_log.log(LogService.LOG_WARNING, "Invalid bundle:" + jarFile.getAbsolutePath() + " is missing required attributes");
+            }
+        }
+
+        return bundleData;
+    }
+    
+    /**
+     *
+     * @param targetId ID that requested versions
+     * @param versionList where collected versions will be put into.
+     * @param base folder to be crawled.
+     */
+    private void getVersions(String targetId, List<Version> versionList, File base) {
+        // ok, it is a directory. Now treat all the subdirectories as seperate versions
+        File[] files = base.listFiles();
+        for (int i = 0; i < files.length; i++) {
+            File possibleVersionDirectory = files[i];
+            if (possibleVersionDirectory.isDirectory()) {
+                // ok, it is a directory. Now see if it is a version
+                try {
+                    Version version = Version.parseVersion(possibleVersionDirectory.getName());
+                    // no exception, but is could still be an empty version
+                    if (!version.equals(Version.emptyVersion)) {
+                        versionList.add(version);
+                    }
+                }
+                catch (IllegalArgumentException iae) {
+                    // do nothing. This version will be ignored.
+                }
+            }
+        }
+        if (files.length == 0) {
+            m_log.log(LogService.LOG_DEBUG, "No versions found for target: " + targetId);
+        }
+    }
+
+    /**
+     * Update the configuration for this bundle. It checks if the basedirectory exists and is a directory.
+     */
+    public void updated(Dictionary<String, ?> settings) throws ConfigurationException {
+        if (settings != null) {
+            String maximumNumberOfUsers = (String) settings.get(MAXIMUM_NUMBER_OF_USERS);
+            if (maximumNumberOfUsers != null) {
+                m_maximumNumberOfUsers = Integer.parseInt(maximumNumberOfUsers);
+            }
+            
+            String baseDirectoryName = getNotNull(settings, DIRECTORY_NAME, "The base directory cannot be null");
+            File baseDirectory = new File(baseDirectoryName);
+            if (!baseDirectory.exists() || !baseDirectory.isDirectory()) {
+                throw new ConfigurationException(DIRECTORY_NAME, "The directory called '" + baseDirectoryName + "' " + (baseDirectory.exists() ? "is no directory." : "doesn't exist."));
+            }
+            m_baseDirectory = baseDirectory;
+
+            String defaultDirectoryName = (String) settings.get(DEFAULT_DIRECTORY_NAME);
+            if (defaultDirectoryName != null) {
+                File defaultDirectory = new File(defaultDirectoryName);
+                if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
+                    m_defaultDirectory = defaultDirectory;
+                    return;
+                }
+            }
+            // fallback to using the base directory
+            m_defaultDirectory = baseDirectory;
+        }
+    }
+
+    /**
+     * Convenience method for getting settings from a configuration dictionary.
+     */
+    private String getNotNull(Dictionary<String, ?> settings, String id, String errorMessage) throws ConfigurationException {
+        String result = (String) settings.get(id);
+        if (result == null) {
+            throw new ConfigurationException(id, errorMessage);
+        }
+        return result;
+    }
+}
\ No newline at end of file

Propchange: ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java?rev=1727373&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java (added)
+++ ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java Thu Jan 28 15:02:14 2016
@@ -0,0 +1,293 @@
+/*
+ * 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.provider.filebased;
+
+import static org.apache.ace.test.utils.TestUtils.UNIT;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+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.test.utils.FileUtils;
+import org.apache.ace.test.utils.TestUtils;
+import org.osgi.service.log.LogService;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * This test class tests the FileBasedProvider class.
+ * This class implements 2 backend interfaces,
+ * and both are tested here.
+ */
+public class FileBasedProviderTest {
+
+    private FileBasedProvider m_backend;
+
+    private File m_tempDirectory;
+
+    private final String VERSION1 = "1.0.0";
+    private final String VERSION2 = "2.0.0";
+    private final String VERSION3 = "3.0.0";
+    private final String VERSION4 = "4.0.0";
+    private final String INVALIDVERSION = "Invalid.version.directory";
+
+    private final String TARGET = "target";
+    private final String MULTIPLEVERSIONTARGET = "multi-version-target";
+    private final String INVALIDVERSIONTARGET = "illegal-version-target";
+    private ArtifactData BUNDLE1;
+    private ArtifactData BUNDLE3;
+    private ArtifactData BUNDLE4;
+    private ArtifactData BUNDLE4_1;
+    private ArtifactData BUNDLE5;
+    private ArtifactData BUNDLE3_2;
+    private ArtifactData BUNDLE4_2;
+
+    @SuppressWarnings("serial")
+    @BeforeTest(alwaysRun = true)
+    protected void setUp() throws Exception {
+
+        // first create a file
+        m_tempDirectory = FileUtils.createTempFile(null);
+        // and make a directory with that name.
+        m_tempDirectory.mkdir();
+        setupSampleData();
+
+        m_backend = new FileBasedProvider();
+        TestUtils.configureObject(m_backend, LogService.class);
+        m_backend.updated(new Hashtable<String, String>() {{put("BaseDirectoryName", m_tempDirectory.getAbsolutePath());}});
+    }
+
+    /**
+     * make a bundle with the given symbolic name and version in the given file.
+     */
+    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;
+    }
+
+    /**
+     * Create the test targets, versions and testbundles..
+     */
+    private void setupSampleData() throws Exception {
+        File target = new File(m_tempDirectory, TARGET);
+        target.mkdirs();
+        File targetVersion1 = new File(target, VERSION1);
+        targetVersion1.mkdirs();
+        BUNDLE1 = generateBundle(FileUtils.createTempFile(targetVersion1), "Bundle1", "1.0.0");
+
+        File illegalVersionTarget = new File(m_tempDirectory, INVALIDVERSIONTARGET);
+        illegalVersionTarget.mkdirs();
+        File faultyVersion = new File(illegalVersionTarget, INVALIDVERSION);
+        faultyVersion.mkdirs();
+        // this bundle should never be accessed
+        generateBundle(FileUtils.createTempFile(faultyVersion), "Bundle2", "2.0.0");
+
+        File multipleVersionTarget = new File(m_tempDirectory, MULTIPLEVERSIONTARGET);
+        multipleVersionTarget.mkdir();
+        File multipleVersionTargetVersion1 = new File(multipleVersionTarget, VERSION1);
+        multipleVersionTargetVersion1.mkdir();
+        BUNDLE3 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion1), "Bundle3", "3.0.0");
+        BUNDLE4 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion1), "Bundle4", "4.0.0");
+        File multipleVersionTargetVersion2 = new File(multipleVersionTarget, VERSION2);
+        multipleVersionTargetVersion2.mkdir();
+        BUNDLE4_1 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion2), "Bundle4", "4.1.0");
+        BUNDLE5 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion2), "Bundle5", "5.0.0");
+        File multipleVersionTargetVersion3 = new File(multipleVersionTarget, VERSION3);
+        multipleVersionTargetVersion3.mkdir();
+        File multipleVersionTargetVersion4 = new File(multipleVersionTarget, VERSION4);
+        multipleVersionTargetVersion4.mkdir();
+        BUNDLE3_2 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion4), "Bundle3", "3.0.0");
+        BUNDLE4_2 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion4), "Bundle4", "5.0.0");
+    }
+
+    /**
+     * See if the getVersions() methods normal output works
+     */
+    @Test(groups = { UNIT })
+    public void testGetVersion() {
+        List<String> versions = m_backend.getVersions(TARGET);
+        assert versions.size() == 1 : "Expected one version to be found, but found " + versions.size();
+        assert versions.get(0).equals(VERSION1) : "Expected version " + VERSION1 + " but found " + versions.get(0);
+    }
+
+    /**
+     * Test the getVersions method with an illegal version (not in org.osgi.framework.Version format)
+     */
+    @Test(groups = { UNIT })
+    public void testIllegalVersion() {
+        // an illegal version should be silently ignored
+        List<String> versions = m_backend.getVersions(INVALIDVERSIONTARGET);
+        assert versions.isEmpty() : "Expected no versions to be found, but found " + versions.size();
+    }
+
+    /**
+     * Test with multiple versions. It expects all versions in an ascending order.
+     */
+    @Test(groups = { UNIT })
+    public void testMultipleVersions() {
+        List<String> versions = m_backend.getVersions(MULTIPLEVERSIONTARGET);
+        assert versions.size() == 4 : "Expected three version to be found, but found " + versions.size();
+        // all versions should be in ascending order
+        assert versions.get(0).equals(VERSION1) : "Expected version " + VERSION1 + " but found " + versions.get(0);
+        assert versions.get(1).equals(VERSION2) : "Expected version " + VERSION2 + " but found " + versions.get(1);
+        assert versions.get(2).equals(VERSION3) : "Expected version " + VERSION3 + " but found " + versions.get(2);
+        assert versions.get(3).equals(VERSION4) : "Expected version " + VERSION4 + " but found " + versions.get(3);
+    }
+
+    /**
+     * Test the getBundleData for a single version, returning a single bundle
+     */
+    @Test(groups = { UNIT })
+    public void testSingleBundleSingleVersionBundleData() {
+        Collection<ArtifactData> bundleData = m_backend.getBundleData(TARGET, VERSION1);
+        assert bundleData.size() == 1 : "Expected one bundle to be found, but found " + bundleData.size();
+        assert bundleData.contains(BUNDLE1) : "Expected to find bundle " + BUNDLE1.getSymbolicName();
+    }
+
+    /**
+     * Test the getBundleData for a single version, returning a multiple bundles
+     */
+    @Test(groups = { UNIT })
+    public void testMultipleBundleSingleVersionBundleData() {
+        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION1);
+        assert bundleData.size() == 2 : "Expected two bundle to be found, but found " + bundleData.size();
+        assert bundleData.contains(BUNDLE3) : "Expected to find bundle " + BUNDLE3.getSymbolicName();
+        assert bundleData.contains(BUNDLE4) : "Expected to find bundle " + BUNDLE4.getSymbolicName();
+    }
+
+    /**
+     * Test the getBundleData with an illegal version (i.e. a version that doesn't exist)
+     */
+    @Test(groups = { UNIT })
+    public void testInvalidVersionBundleData() {
+        try {
+            m_backend.getBundleData(INVALIDVERSIONTARGET, INVALIDVERSION);
+            assert false : "Expected an error because version " + INVALIDVERSION + " doesn't exist for target" + INVALIDVERSIONTARGET;
+        } catch (IllegalArgumentException iae) {
+            // expected, because the version doesn't exist
+        }
+    }
+
+    /**
+     * Test the getBundleData for a two versions, returning a single bundle that hasn't changed
+     */
+    @Test(groups = { UNIT })
+    public void testSingleUnchangedBundleMultipleVersions() {
+        Collection<ArtifactData> bundleData = m_backend.getBundleData(TARGET, VERSION1, VERSION1);
+        assert bundleData.size() == 1 : "Expect one bundle, got " + bundleData.size();
+        Iterator<ArtifactData> it = bundleData.iterator();
+        while(it.hasNext()) {
+            ArtifactData data = it.next();
+            assert data.getSize() > 200 : "Bundle has no sensible size?!";
+            assert !data.hasChanged() : "The data should not have been changed.";
+        }
+    }
+
+    /**
+     * Test the getBundleData for a two versions, returning multiple bundles that haven't changed
+     */
+    @Test(groups = { UNIT })
+    public void testMultipleBundlesMultipleVersions() {
+        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION1, VERSION1);
+        assert bundleData.size() == 2 : "Expected two bundle to be found, but found " + bundleData.size();
+        Iterator<ArtifactData> it = bundleData.iterator();
+        while(it.hasNext()) {
+            ArtifactData data = it.next();
+            assert !data.hasChanged() : "The data should not have been changed.";
+        }
+    }
+
+    /**
+     * Test the getBundleData for a two versions, where in the second version a bundle is removed
+     */
+    @Test(groups = { UNIT })
+    public void testRemovedBundleMultipleVersions() {
+        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION1, VERSION3);
+        assert bundleData.size() == 0 : "Expected zero bundle to be found, but found " + bundleData.size();
+    }
+
+    /**
+     * Test the getBundleData for a two versions, where in the second version a bundle is added
+     */
+    @Test(groups = { UNIT })
+    public void testAddedBundleMultipleVersions() {
+        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION3, VERSION1);
+        assert bundleData.size() == 2 : "Expected two bundle to be found, but found " + bundleData.size();
+        Iterator<ArtifactData> it = bundleData.iterator();
+        while(it.hasNext()) {
+            ArtifactData data = it.next();
+            assert data.hasChanged() : "The data should have been changed.";
+        }
+    }
+
+    /**
+     * Test the getBundleData for a two versions, where in the second version one bundle has changed and another hasn't
+     */
+    @Test(groups = { UNIT })
+    public void testSingleChangedBundleMultipleVersions() {
+        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION1, VERSION4);
+        assert bundleData.size() == 2 : "Expected one bundle to be found, but found " + bundleData.size();
+        Iterator<ArtifactData> it = bundleData.iterator();
+        while(it.hasNext()) {
+            ArtifactData data = it.next();
+            if (data.equals(BUNDLE3_2)) {
+                assert !data.hasChanged() : "The data should not have been changed.";
+            } else if (data.equals(BUNDLE4_2)) {
+                assert data.hasChanged() : "The data should have been changed.";
+            } else {
+                assert false : "Unknown bundle found";
+            }
+        }
+    }
+
+    /**
+     * Test the getBundleData for a two versions, where two bundles have changed
+     */
+    @Test(groups = { UNIT })
+    public void testMultipleChangedBundlesMultipleVersions() {
+        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION1, VERSION2);
+        assert bundleData.size() == 2 : "Expected one bundle to be found, but found " + bundleData.size();
+        Iterator<ArtifactData> it = bundleData.iterator();
+        while(it.hasNext()) {
+            ArtifactData data = it.next();
+            if (data.equals(BUNDLE4_1)) {
+                assert data.hasChanged() : "The data should have been changed.";
+            } else if (data.equals(BUNDLE5)) {
+                assert data.hasChanged() : "The data should have been changed.";
+            } else {
+                assert false : "Unknown bundle found";
+            }
+        }
+    }
+
+
+    @AfterTest(alwaysRun = true)
+    public void tearDown() throws Exception {
+        FileUtils.removeDirectoryWithContent(m_tempDirectory);
+    }
+
+
+}

Propchange: ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/filebased/FileBasedProviderTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/filebased/FileBasedProviderTest.java?rev=1727373&r1=1727372&r2=1727373&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/filebased/FileBasedProviderTest.java (original)
+++ ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/filebased/FileBasedProviderTest.java Thu Jan 28 15:02:14 2016
@@ -1,293 +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.provider.filebased;
-
-import static org.apache.ace.test.utils.TestUtils.UNIT;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-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.test.utils.FileUtils;
-import org.apache.ace.test.utils.TestUtils;
-import org.osgi.service.log.LogService;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-/**
- * This test class tests the FileBasedProvider class.
- * This class implements 2 backend interfaces,
- * and both are tested here.
- */
-public class FileBasedProviderTest {
-
-    private FileBasedProvider m_backend;
-
-    private File m_tempDirectory;
-
-    private final String VERSION1 = "1.0.0";
-    private final String VERSION2 = "2.0.0";
-    private final String VERSION3 = "3.0.0";
-    private final String VERSION4 = "4.0.0";
-    private final String INVALIDVERSION = "Invalid.version.directory";
-
-    private final String TARGET = "target";
-    private final String MULTIPLEVERSIONTARGET = "multi-version-target";
-    private final String INVALIDVERSIONTARGET = "illegal-version-target";
-    private ArtifactData BUNDLE1;
-    private ArtifactData BUNDLE3;
-    private ArtifactData BUNDLE4;
-    private ArtifactData BUNDLE4_1;
-    private ArtifactData BUNDLE5;
-    private ArtifactData BUNDLE3_2;
-    private ArtifactData BUNDLE4_2;
-
-    @SuppressWarnings("serial")
-    @BeforeTest(alwaysRun = true)
-    protected void setUp() throws Exception {
-
-        // first create a file
-        m_tempDirectory = FileUtils.createTempFile(null);
-        // and make a directory with that name.
-        m_tempDirectory.mkdir();
-        setupSampleData();
-
-        m_backend = new FileBasedProvider();
-        TestUtils.configureObject(m_backend, LogService.class);
-        m_backend.updated(new Properties() {{put("BaseDirectoryName", m_tempDirectory.getAbsolutePath());}});
-    }
-
-    /**
-     * make a bundle with the given symbolic name and version in the given file.
-     */
-    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;
-    }
-
-    /**
-     * Create the test targets, versions and testbundles..
-     */
-    private void setupSampleData() throws Exception {
-        File target = new File(m_tempDirectory, TARGET);
-        target.mkdirs();
-        File targetVersion1 = new File(target, VERSION1);
-        targetVersion1.mkdirs();
-        BUNDLE1 = generateBundle(FileUtils.createTempFile(targetVersion1), "Bundle1", "1.0.0");
-
-        File illegalVersionTarget = new File(m_tempDirectory, INVALIDVERSIONTARGET);
-        illegalVersionTarget.mkdirs();
-        File faultyVersion = new File(illegalVersionTarget, INVALIDVERSION);
-        faultyVersion.mkdirs();
-        // this bundle should never be accessed
-        generateBundle(FileUtils.createTempFile(faultyVersion), "Bundle2", "2.0.0");
-
-        File multipleVersionTarget = new File(m_tempDirectory, MULTIPLEVERSIONTARGET);
-        multipleVersionTarget.mkdir();
-        File multipleVersionTargetVersion1 = new File(multipleVersionTarget, VERSION1);
-        multipleVersionTargetVersion1.mkdir();
-        BUNDLE3 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion1), "Bundle3", "3.0.0");
-        BUNDLE4 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion1), "Bundle4", "4.0.0");
-        File multipleVersionTargetVersion2 = new File(multipleVersionTarget, VERSION2);
-        multipleVersionTargetVersion2.mkdir();
-        BUNDLE4_1 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion2), "Bundle4", "4.1.0");
-        BUNDLE5 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion2), "Bundle5", "5.0.0");
-        File multipleVersionTargetVersion3 = new File(multipleVersionTarget, VERSION3);
-        multipleVersionTargetVersion3.mkdir();
-        File multipleVersionTargetVersion4 = new File(multipleVersionTarget, VERSION4);
-        multipleVersionTargetVersion4.mkdir();
-        BUNDLE3_2 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion4), "Bundle3", "3.0.0");
-        BUNDLE4_2 = generateBundle(FileUtils.createTempFile(multipleVersionTargetVersion4), "Bundle4", "5.0.0");
-    }
-
-    /**
-     * See if the getVersions() methods normal output works
-     */
-    @Test(groups = { UNIT })
-    public void testGetVersion() {
-        List<String> versions = m_backend.getVersions(TARGET);
-        assert versions.size() == 1 : "Expected one version to be found, but found " + versions.size();
-        assert versions.get(0).equals(VERSION1) : "Expected version " + VERSION1 + " but found " + versions.get(0);
-    }
-
-    /**
-     * Test the getVersions method with an illegal version (not in org.osgi.framework.Version format)
-     */
-    @Test(groups = { UNIT })
-    public void testIllegalVersion() {
-        // an illegal version should be silently ignored
-        List<String> versions = m_backend.getVersions(INVALIDVERSIONTARGET);
-        assert versions.isEmpty() : "Expected no versions to be found, but found " + versions.size();
-    }
-
-    /**
-     * Test with multiple versions. It expects all versions in an ascending order.
-     */
-    @Test(groups = { UNIT })
-    public void testMultipleVersions() {
-        List<String> versions = m_backend.getVersions(MULTIPLEVERSIONTARGET);
-        assert versions.size() == 4 : "Expected three version to be found, but found " + versions.size();
-        // all versions should be in ascending order
-        assert versions.get(0).equals(VERSION1) : "Expected version " + VERSION1 + " but found " + versions.get(0);
-        assert versions.get(1).equals(VERSION2) : "Expected version " + VERSION2 + " but found " + versions.get(1);
-        assert versions.get(2).equals(VERSION3) : "Expected version " + VERSION3 + " but found " + versions.get(2);
-        assert versions.get(3).equals(VERSION4) : "Expected version " + VERSION4 + " but found " + versions.get(3);
-    }
-
-    /**
-     * Test the getBundleData for a single version, returning a single bundle
-     */
-    @Test(groups = { UNIT })
-    public void testSingleBundleSingleVersionBundleData() {
-        Collection<ArtifactData> bundleData = m_backend.getBundleData(TARGET, VERSION1);
-        assert bundleData.size() == 1 : "Expected one bundle to be found, but found " + bundleData.size();
-        assert bundleData.contains(BUNDLE1) : "Expected to find bundle " + BUNDLE1.getSymbolicName();
-    }
-
-    /**
-     * Test the getBundleData for a single version, returning a multiple bundles
-     */
-    @Test(groups = { UNIT })
-    public void testMultipleBundleSingleVersionBundleData() {
-        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION1);
-        assert bundleData.size() == 2 : "Expected two bundle to be found, but found " + bundleData.size();
-        assert bundleData.contains(BUNDLE3) : "Expected to find bundle " + BUNDLE3.getSymbolicName();
-        assert bundleData.contains(BUNDLE4) : "Expected to find bundle " + BUNDLE4.getSymbolicName();
-    }
-
-    /**
-     * Test the getBundleData with an illegal version (i.e. a version that doesn't exist)
-     */
-    @Test(groups = { UNIT })
-    public void testInvalidVersionBundleData() {
-        try {
-            m_backend.getBundleData(INVALIDVERSIONTARGET, INVALIDVERSION);
-            assert false : "Expected an error because version " + INVALIDVERSION + " doesn't exist for target" + INVALIDVERSIONTARGET;
-        } catch (IllegalArgumentException iae) {
-            // expected, because the version doesn't exist
-        }
-    }
-
-    /**
-     * Test the getBundleData for a two versions, returning a single bundle that hasn't changed
-     */
-    @Test(groups = { UNIT })
-    public void testSingleUnchangedBundleMultipleVersions() {
-        Collection<ArtifactData> bundleData = m_backend.getBundleData(TARGET, VERSION1, VERSION1);
-        assert bundleData.size() == 1 : "Expect one bundle, got " + bundleData.size();
-        Iterator<ArtifactData> it = bundleData.iterator();
-        while(it.hasNext()) {
-            ArtifactData data = it.next();
-            assert data.getSize() > 200 : "Bundle has no sensible size?!";
-            assert !data.hasChanged() : "The data should not have been changed.";
-        }
-    }
-
-    /**
-     * Test the getBundleData for a two versions, returning multiple bundles that haven't changed
-     */
-    @Test(groups = { UNIT })
-    public void testMultipleBundlesMultipleVersions() {
-        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION1, VERSION1);
-        assert bundleData.size() == 2 : "Expected two bundle to be found, but found " + bundleData.size();
-        Iterator<ArtifactData> it = bundleData.iterator();
-        while(it.hasNext()) {
-            ArtifactData data = it.next();
-            assert !data.hasChanged() : "The data should not have been changed.";
-        }
-    }
-
-    /**
-     * Test the getBundleData for a two versions, where in the second version a bundle is removed
-     */
-    @Test(groups = { UNIT })
-    public void testRemovedBundleMultipleVersions() {
-        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION1, VERSION3);
-        assert bundleData.size() == 0 : "Expected zero bundle to be found, but found " + bundleData.size();
-    }
-
-    /**
-     * Test the getBundleData for a two versions, where in the second version a bundle is added
-     */
-    @Test(groups = { UNIT })
-    public void testAddedBundleMultipleVersions() {
-        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION3, VERSION1);
-        assert bundleData.size() == 2 : "Expected two bundle to be found, but found " + bundleData.size();
-        Iterator<ArtifactData> it = bundleData.iterator();
-        while(it.hasNext()) {
-            ArtifactData data = it.next();
-            assert data.hasChanged() : "The data should have been changed.";
-        }
-    }
-
-    /**
-     * Test the getBundleData for a two versions, where in the second version one bundle has changed and another hasn't
-     */
-    @Test(groups = { UNIT })
-    public void testSingleChangedBundleMultipleVersions() {
-        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION1, VERSION4);
-        assert bundleData.size() == 2 : "Expected one bundle to be found, but found " + bundleData.size();
-        Iterator<ArtifactData> it = bundleData.iterator();
-        while(it.hasNext()) {
-            ArtifactData data = it.next();
-            if (data.equals(BUNDLE3_2)) {
-                assert !data.hasChanged() : "The data should not have been changed.";
-            } else if (data.equals(BUNDLE4_2)) {
-                assert data.hasChanged() : "The data should have been changed.";
-            } else {
-                assert false : "Unknown bundle found";
-            }
-        }
-    }
-
-    /**
-     * Test the getBundleData for a two versions, where two bundles have changed
-     */
-    @Test(groups = { UNIT })
-    public void testMultipleChangedBundlesMultipleVersions() {
-        Collection<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET, VERSION1, VERSION2);
-        assert bundleData.size() == 2 : "Expected one bundle to be found, but found " + bundleData.size();
-        Iterator<ArtifactData> it = bundleData.iterator();
-        while(it.hasNext()) {
-            ArtifactData data = it.next();
-            if (data.equals(BUNDLE4_1)) {
-                assert data.hasChanged() : "The data should have been changed.";
-            } else if (data.equals(BUNDLE5)) {
-                assert data.hasChanged() : "The data should have been changed.";
-            } else {
-                assert false : "Unknown bundle found";
-            }
-        }
-    }
-
-
-    @AfterTest(alwaysRun = true)
-    public void tearDown() throws Exception {
-        FileUtils.removeDirectoryWithContent(m_tempDirectory);
-    }
-
-
-}

Modified: ace/trunk/org.apache.ace.repository.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.repository.itest/bnd.bnd?rev=1727373&r1=1727372&r2=1727373&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.repository.itest/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.repository.itest/bnd.bnd Thu Jan 28 15:02:14 2016
@@ -9,7 +9,6 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o
 	org.apache.ace.test;version=latest,\
 	org.apache.ace.http.listener;version=latest,\
 	org.apache.ace.repository.api;version=latest,\
-	org.apache.ace.repository.impl;version=latest,\
 	org.apache.ace.repository.servlet;version=latest,\
 	org.apache.felix.dependencymanager
 -runfw: org.apache.felix.framework;version='[5.2.0,6)'



Mime
View raw message