ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1539034 - in /ace/trunk: org.apache.ace.builder/ org.apache.ace.builder/src/org/apache/ace/builder/ org.apache.ace.builder/test/org/apache/ace/builder/ org.apache.ace.client.repository.itest/ org.apache.ace.client.repository.itest/src/org/...
Date Tue, 05 Nov 2013 15:35:31 GMT
Author: jawi
Date: Tue Nov  5 15:35:30 2013
New Revision: 1539034

URL: http://svn.apache.org/r1539034
Log:
ACE-412 (& ACE-292) - allow parameters in symbolic names:

- BSNs can have optional parameters in their name. These should be 
  stripped from the BSN to let ACE handle it correctly;
- adapted all places where something was done with BSNs to strip
  such parameters.


Added:
    ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/ArtifactDataTest.java   (with props)
Modified:
    ace/trunk/org.apache.ace.builder/   (props changed)
    ace/trunk/org.apache.ace.builder/src/org/apache/ace/builder/ArtifactData.java
    ace/trunk/org.apache.ace.builder/src/org/apache/ace/builder/DeploymentPackageBuilder.java
    ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/DeploymentPackageBuilderTest.java
    ace/trunk/org.apache.ace.client.repository.itest/   (props changed)
    ace/trunk/org.apache.ace.client.repository.itest/src/org/apache/ace/it/repositoryadmin/BaseRepositoryAdminTest.java
    ace/trunk/org.apache.ace.client.repository.itest/src/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperImpl.java
    ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperTest.java
    ace/trunk/org.apache.ace.deployment/   (props changed)
    ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java

Propchange: ace/trunk/org.apache.ace.builder/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Nov  5 15:35:30 2013
@@ -4,3 +4,4 @@ generated
 store
 bundle-cache
 felix-cache
+test-output

Modified: ace/trunk/org.apache.ace.builder/src/org/apache/ace/builder/ArtifactData.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.builder/src/org/apache/ace/builder/ArtifactData.java?rev=1539034&r1=1539033&r2=1539034&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.builder/src/org/apache/ace/builder/ArtifactData.java (original)
+++ ace/trunk/org.apache.ace.builder/src/org/apache/ace/builder/ArtifactData.java Tue Nov  5 15:35:30 2013
@@ -21,78 +21,97 @@ package org.apache.ace.builder;
 import java.net.URL;
 
 public class ArtifactData {
-	private final URL m_url;
-	private boolean m_isBundle;
-	private String m_filename;
-	private String m_bundleSymbolicName;
-	private String m_bundleVersion;
-	private boolean m_isCustomizer;
-	private String m_processorPID;
-	
-	private ArtifactData(URL url, String filename) {
-		m_url = url;
-		m_filename = filename;
-	}
-	
-	public static ArtifactData createBundle(URL url, String filename, String bundleSymbolicName, String bundleVersion) {
-		ArtifactData data = new ArtifactData(url, filename);
-		data.setBundleMetadata(bundleSymbolicName, bundleVersion);
-		return data;
-	}
-	
-	public static ArtifactData createResourceProcessor(URL url, String filename, String bundleSymbolicName, String bundleVersion, String processorPID) {
-		ArtifactData data = new ArtifactData(url, filename);
-		data.setBundleMetadata(bundleSymbolicName, bundleVersion);
-		data.setResourceProcessor(processorPID);
-		return data;
-	}
-	
-	public static ArtifactData createArtifact(URL url, String filename, String processorPID) {
-		ArtifactData data = new ArtifactData(url, filename);
-		data.setArtifactResourceProcessor(processorPID);
-		return data;
-	}
-	
-	public URL getURL() {
-		return m_url;
-	}
-
-	public boolean isBundle() {
-		return m_isBundle;
-	}
-	
-	public String getFilename() {
-		return m_filename;
-	}
-
-	public String getSymbolicName() {
-		return m_bundleSymbolicName;
-	}
-	
-	public String getVersion() {
-		return m_bundleVersion;
-	}
-	
-	public boolean isCustomizer() {
-		return m_isCustomizer;
-	}
-	
-	public String getProcessorPid() {
-		return m_processorPID;
-	}
-
-	private void setBundleMetadata(String bundleSymbolicName, String bundleVersion) {
-		m_isBundle = true;
-		m_bundleSymbolicName = bundleSymbolicName;
-		m_bundleVersion = bundleVersion;
-	}
-	
-	private void setResourceProcessor(String processorPID) {
-		m_isCustomizer = true;
-		m_processorPID = processorPID;
-	}
-	
-	private void setArtifactResourceProcessor(String processorPID) {
-		m_processorPID = processorPID;
-	}
+    private final URL m_url;
+    private final String m_filename;
+    private boolean m_isBundle;
+    private String m_bundleSymbolicName;
+    private String m_bundleVersion;
+    private boolean m_isCustomizer;
+    private String m_processorPID;
+
+    private ArtifactData(URL url, String filename) {
+        m_url = url;
+        m_filename = filename;
+    }
+
+    public static ArtifactData createBundle(URL url, String filename, String bundleSymbolicName, String bundleVersion) {
+        ArtifactData data = new ArtifactData(url, filename);
+        data.setBundleMetadata(bundleSymbolicName, bundleVersion);
+        return data;
+    }
+
+    public static ArtifactData createResourceProcessor(URL url, String filename, String bundleSymbolicName, String bundleVersion, String processorPID) {
+        ArtifactData data = new ArtifactData(url, filename);
+        data.setBundleMetadata(bundleSymbolicName, bundleVersion);
+        data.setResourceProcessor(processorPID);
+        return data;
+    }
+
+    public static ArtifactData createArtifact(URL url, String filename, String processorPID) {
+        ArtifactData data = new ArtifactData(url, filename);
+        data.setArtifactResourceProcessor(processorPID);
+        return data;
+    }
+
+    /**
+     * Some headers in OSGi allow for optional parameters, that are appended after the main value and always start with
+     * a semicolon.
+     * 
+     * @param name
+     *            the name to remove the (optional) parameters from, cannot be <code>null</code>.
+     * @return the cleaned name, never <code>null</code>.
+     */
+    private static String removeParameters(String name) {
+        int idx = name.indexOf(';');
+        if (idx > 0) {
+            return name.substring(0, idx);
+        }
+        return name;
+    }
+
+    public URL getURL() {
+        return m_url;
+    }
+
+    public boolean isBundle() {
+        return m_isBundle;
+    }
+
+    public String getFilename() {
+        return m_filename;
+    }
+
+    public String getSymbolicName() {
+        return m_bundleSymbolicName;
+    }
+
+    public String getVersion() {
+        return m_bundleVersion;
+    }
+
+    public boolean isCustomizer() {
+        return m_isCustomizer;
+    }
+
+    public String getProcessorPid() {
+        return m_processorPID;
+    }
+
+    private void setBundleMetadata(String bundleSymbolicName, String bundleVersion) {
+        m_isBundle = true;
+        // See OSGi spec, section 3.5.2 (v4.2)...
+        m_bundleSymbolicName = removeParameters(bundleSymbolicName);
+        m_bundleVersion = bundleVersion;
+    }
+
+    private void setResourceProcessor(String processorPID) {
+        m_isCustomizer = true;
+        // Not explicitly mentioned in the spec, but just to be sure...
+        m_processorPID = removeParameters(processorPID);
+    }
+
+    private void setArtifactResourceProcessor(String processorPID) {
+        // Not explicitly mentioned in the spec, but just to be sure...
+        m_processorPID = removeParameters(processorPID);
+    }
 }

Modified: ace/trunk/org.apache.ace.builder/src/org/apache/ace/builder/DeploymentPackageBuilder.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.builder/src/org/apache/ace/builder/DeploymentPackageBuilder.java?rev=1539034&r1=1539033&r2=1539034&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.builder/src/org/apache/ace/builder/DeploymentPackageBuilder.java (original)
+++ ace/trunk/org.apache.ace.builder/src/org/apache/ace/builder/DeploymentPackageBuilder.java Tue Nov  5 15:35:30 2013
@@ -31,189 +31,179 @@ import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
 
 /**
- * Builder for deployment packages. Can handle bundles, resource processors and artifacts. Uses
- * the builder pattern:
+ * Builder for deployment packages. Can handle bundles, resource processors and artifacts. Uses the builder pattern:
+ * 
  * <pre>
- * OutputStream out = new FileOutputStream("first.dp");
- * DeploymentPackageBuilder.createDeploymentPackage("mydp", "1.0")
- *     .addBundle(new URL("http://repository/api-1.1.0.jar"))
- *     .addBundle(new URL("http://repository/impl-1.1.3.jar"))
- *     .addResourceProcessor(new URL("http://repository/rp-1.0.2.jar"))
- *     .addArtifact(new URL("http://artifacts/config/v1.jar"), "rp.pid")
- *     .addArtifact(new URL("http://artifacts/data/v3.jar"), "rp.pid")
+ * OutputStream out = new FileOutputStream(&quot;first.dp&quot;);
+ * DeploymentPackageBuilder.createDeploymentPackage(&quot;mydp&quot;, &quot;1.0&quot;)
+ *     .addBundle(new URL(&quot;http://repository/api-1.1.0.jar&quot;))
+ *     .addBundle(new URL(&quot;http://repository/impl-1.1.3.jar&quot;))
+ *     .addResourceProcessor(new URL(&quot;http://repository/rp-1.0.2.jar&quot;))
+ *     .addArtifact(new URL(&quot;http://artifacts/config/v1.jar&quot;), &quot;rp.pid&quot;)
+ *     .addArtifact(new URL(&quot;http://artifacts/data/v3.jar&quot;), &quot;rp.pid&quot;)
  *     .generate(out);
  * </pre>
- * For bundles and resource processors, you can simply point to a valid URL and it will
- * be queried for all required metadata. For artifacts, you need to specify both the URL
- * and the PID of the resource processor. The builder will use the order you specify for
- * bundles, resource processors and artifacts, but you don't have to specify all bundles
- * and resource processors first and then all artifacts.
+ * 
+ * For bundles and resource processors, you can simply point to a valid URL and it will be queried for all required
+ * metadata. For artifacts, you need to specify both the URL and the PID of the resource processor. The builder will use
+ * the order you specify for bundles, resource processors and artifacts, but you don't have to specify all bundles and
+ * resource processors first and then all artifacts.
  */
 public class DeploymentPackageBuilder {
-	private static final String PREFIX_BUNDLE = "bundle-";
-	private static final String PREFIX_ARTIFACT = "artifact-";
-	private static final int BUFFER_SIZE = 32 * 1024;
-	private final String m_symbolicName;
-	private final String m_version;
-	private final List<ArtifactData> m_bundles = new ArrayList<ArtifactData>();
-	private final List<ArtifactData> m_processors = new ArrayList<ArtifactData>();
-	private final List<ArtifactData> m_artifacts = new ArrayList<ArtifactData>();
-	private int m_id = 1;
-	
-	private DeploymentPackageBuilder(String symbolicName, String version) {
-		m_symbolicName = symbolicName;
-		m_version = version;
-	}
-	
-	/**
-	 * Creates a new deployment package.
-	 * 
-	 * @param name the name of the deployment package
-	 * @param version the version of the deployment package
-	 * @return a builder to further add data to the deployment package
-	 */
-	public static DeploymentPackageBuilder createDeploymentPackage(String name, String version) {
-		return new DeploymentPackageBuilder(name, version);
-	}
-	
-	/**
-	 * Adds a bundle to the deployment package.
-	 * 
-	 * @param url a url that refers to the bundle
-	 * @return a builder to further add data to the deployment package
-	 * @throws Exception if something goes wrong while building
-	 */
-	public DeploymentPackageBuilder addBundle(URL url) throws Exception {
-		return addBundleArtifact(url, false);
-	}
-	
-	/**
-	 * Adds a resource processor to the deployment package. A resource processor is a special
-	 * type of bundle.
-	 * 
-	 * @param url a url that refers to the resource processor
-	 * @return a builder to further add data to the deployment package
-	 * @throws Exception if something goes wrong while building
-	 */
-	public DeploymentPackageBuilder addResourceProcessor(URL url) throws Exception {
-		return addBundleArtifact(url, true);
-	}
-	
-	/**
-	 * Adds an artifact to the deployment package.
-	 * 
-	 * @param url a url that refers to the artifact
-	 * @param processorPID the PID of the processor for this artifact
-	 * @return a builder to further add data to the deployment package
-	 * @throws Exception if something goes wrong while building
-	 */
-	public DeploymentPackageBuilder addArtifact(URL url, String processorPID) throws Exception {
-		String path = url.getPath();
-		int i = path.lastIndexOf('/');
-		if (i > 0 && i < (path.length() - 1)) {
-			path = path.substring(i + 1);
-		}
-		String name = PREFIX_ARTIFACT + getUniqueID() + "-" + path;
-    	m_artifacts.add(ArtifactData.createArtifact(url, name, processorPID));
-		return this;
-	}
-
-	/**
-	 * Generates a deployment package and streams it to the output stream you provide. Before
-	 * it starts generating, it will first validate that you have actually specified a
-	 * resource processor for each type of artifact you provided.
-	 * 
-	 * @param output the output stream to write to
-	 * @throws Exception if something goes wrong while validating or generating
-	 */
-	public void generate(OutputStream output) throws Exception {
-		validateArtifacts();
-		List<ArtifactData> artifacts = new ArrayList<ArtifactData>();
-		artifacts.addAll(m_bundles);
-		artifacts.addAll(m_processors);
-		artifacts.addAll(m_artifacts);
-		Manifest m = createManifest(artifacts);
-		writeStream(artifacts, m, output);
-	}
-	
-	/** Returns the symbolic name of the deployment package. */
-	public String getSymbolicName() {
-		return m_symbolicName;
-	}
-
-	/** Returns the version of the deployment package. */
-	public String getVersion() {
-		return m_version;
-	}
-	
-	private DeploymentPackageBuilder addBundleArtifact(URL url, boolean isResourceProcessor) throws Exception {
-		JarInputStream jis = null;
-		try {
-			jis = new JarInputStream(url.openStream());
-	        Manifest bundleManifest = jis.getManifest();
-	        if (bundleManifest == null) {
-	        	throw new Exception("Not a valid manifest in: " + url);
-	        }
-	        Attributes attributes = bundleManifest.getMainAttributes();
-			String bundleSymbolicName = getRequiredHeader(attributes, "Bundle-SymbolicName");
-	        String bundleVersion = getRequiredHeader(attributes, "Bundle-Version");
-	        String name = PREFIX_BUNDLE + bundleSymbolicName + "-" + bundleVersion;
-	        int i = name.lastIndexOf('/');
-	        if (i > 0 && i < (name.length() - 1)) {
-	        	name = name.substring(i + 1);
-	        }
-			if (isResourceProcessor) {
-	        	if (!"true".equals(getRequiredHeader(attributes, "DeploymentPackage-Customizer"))) {
-	        		throw new IOException("Invalid DeploymentPackage-Customizer header in: " + url);
-	        	}
-	        	String processorPID = getRequiredHeader(attributes, "Deployment-ProvidesResourceProcessor");
-	        	m_processors.add(ArtifactData.createResourceProcessor(url, name, bundleSymbolicName, bundleVersion, processorPID));
-	        }
-	        else {
-	        	m_bundles.add(ArtifactData.createBundle(url, name, bundleSymbolicName, bundleVersion));
-	        }
-		}
-		finally {
-			if (jis != null) {
-				jis.close();
-			}
-		}
-		return this;
-	}
-
-	private void validateArtifacts() throws Exception {
-		for (ArtifactData data : m_artifacts) {
-			String pid = data.getProcessorPid();
-			boolean found = false;
-			for (ArtifactData processor : m_processors) {
-				if (pid.equals(processor.getProcessorPid())) {
-					found = true;
-					break;
-				}
-			}
-			if (!found) {
-				throw new Exception("No resource processor found for artifact " + data.getURL() + " with processor PID " + pid);
-			}
-		}
-	}
-	
-	private String getRequiredHeader(Attributes mainAttributes, String headerName) throws Exception {
-		String value = mainAttributes.getValue(headerName);
-		if (value == null || value.equals("")) {
-			throw new Exception("Missing or invalid " + headerName + " header.");
-		}
-		return value;
-	}
-	
-	private Manifest createManifest(List<ArtifactData> files) throws Exception {
-		Manifest manifest = new Manifest();
+    private static final String PREFIX_BUNDLE = "bundle-";
+    private static final String PREFIX_ARTIFACT = "artifact-";
+    private static final int BUFFER_SIZE = 32 * 1024;
+
+    private final String m_symbolicName;
+    private final String m_version;
+    private final List<ArtifactData> m_bundles = new ArrayList<ArtifactData>();
+    private final List<ArtifactData> m_processors = new ArrayList<ArtifactData>();
+    private final List<ArtifactData> m_artifacts = new ArrayList<ArtifactData>();
+
+    private int m_id = 1;
+
+    private DeploymentPackageBuilder(String symbolicName, String version) {
+        m_symbolicName = symbolicName;
+        m_version = version;
+    }
+
+    /**
+     * Creates a new deployment package.
+     * 
+     * @param name
+     *            the name of the deployment package
+     * @param version
+     *            the version of the deployment package
+     * @return a builder to further add data to the deployment package
+     */
+    public static DeploymentPackageBuilder createDeploymentPackage(String name, String version) {
+        return new DeploymentPackageBuilder(name, version);
+    }
+
+    /**
+     * Adds an artifact to the deployment package.
+     * 
+     * @param url
+     *            a url that refers to the artifact
+     * @param processorPID
+     *            the PID of the processor for this artifact
+     * @return a builder to further add data to the deployment package
+     * @throws Exception
+     *             if something goes wrong while building
+     */
+    public DeploymentPackageBuilder addArtifact(URL url, String processorPID) throws Exception {
+        String path = url.getPath();
+        int i = path.lastIndexOf('/');
+        if (i > 0 && i < (path.length() - 1)) {
+            path = path.substring(i + 1);
+        }
+        String name = PREFIX_ARTIFACT + getUniqueID() + "-" + path;
+        m_artifacts.add(ArtifactData.createArtifact(url, name, processorPID));
+        return this;
+    }
+
+    /**
+     * Adds a bundle to the deployment package.
+     * 
+     * @param url
+     *            a url that refers to the bundle
+     * @return a builder to further add data to the deployment package
+     * @throws Exception
+     *             if something goes wrong while building
+     */
+    public DeploymentPackageBuilder addBundle(URL url) throws Exception {
+        return addBundleArtifact(url, false);
+    }
+
+    /**
+     * Adds a resource processor to the deployment package. A resource processor is a special type of bundle.
+     * 
+     * @param url
+     *            a url that refers to the resource processor
+     * @return a builder to further add data to the deployment package
+     * @throws Exception
+     *             if something goes wrong while building
+     */
+    public DeploymentPackageBuilder addResourceProcessor(URL url) throws Exception {
+        return addBundleArtifact(url, true);
+    }
+
+    /**
+     * Generates a deployment package and streams it to the output stream you provide. Before it starts generating, it
+     * will first validate that you have actually specified a resource processor for each type of artifact you provided.
+     * 
+     * @param output
+     *            the output stream to write to
+     * @throws Exception
+     *             if something goes wrong while validating or generating
+     */
+    public void generate(OutputStream output) throws Exception {
+        validateArtifacts();
+        List<ArtifactData> artifacts = new ArrayList<ArtifactData>();
+        artifacts.addAll(m_bundles);
+        artifacts.addAll(m_processors);
+        artifacts.addAll(m_artifacts);
+        Manifest m = createManifest(artifacts);
+        writeStream(artifacts, m, output);
+    }
+
+    /** Returns the symbolic name of the deployment package. */
+    public String getSymbolicName() {
+        return m_symbolicName;
+    }
+
+    /** Returns the version of the deployment package. */
+    public String getVersion() {
+        return m_version;
+    }
+
+    private DeploymentPackageBuilder addBundleArtifact(URL url, boolean isResourceProcessor) throws Exception {
+        JarInputStream jis = null;
+        try {
+            jis = new JarInputStream(url.openStream());
+
+            Manifest bundleManifest = jis.getManifest();
+            if (bundleManifest == null) {
+                throw new Exception("Not a valid manifest in: " + url);
+            }
+
+            Attributes attributes = bundleManifest.getMainAttributes();
+            String bundleSymbolicName = getRequiredHeader(attributes, "Bundle-SymbolicName");
+            String bundleVersion = getRequiredHeader(attributes, "Bundle-Version");
+
+            String name = PREFIX_BUNDLE + bundleSymbolicName + "-" + bundleVersion;
+            int i = name.lastIndexOf('/');
+            if (i > 0 && i < (name.length() - 1)) {
+                name = name.substring(i + 1);
+            }
+            if (isResourceProcessor) {
+                if (!"true".equals(getRequiredHeader(attributes, "DeploymentPackage-Customizer"))) {
+                    throw new IOException("Invalid DeploymentPackage-Customizer header in: " + url);
+                }
+                String processorPID = getRequiredHeader(attributes, "Deployment-ProvidesResourceProcessor");
+                m_processors.add(ArtifactData.createResourceProcessor(url, name, bundleSymbolicName, bundleVersion, processorPID));
+            }
+            else {
+                m_bundles.add(ArtifactData.createBundle(url, name, bundleSymbolicName, bundleVersion));
+            }
+        }
+        finally {
+            if (jis != null) {
+                jis.close();
+            }
+        }
+        return this;
+    }
+
+    private Manifest createManifest(List<ArtifactData> files) throws Exception {
+        Manifest manifest = new Manifest();
         Attributes main = manifest.getMainAttributes();
         main.putValue("Manifest-Version", "1.0");
         main.putValue("DeploymentPackage-SymbolicName", m_symbolicName);
         main.putValue("DeploymentPackage-Version", m_version);
 
         for (ArtifactData file : files) {
-        	if (file.isBundle()) {
+            if (file.isBundle()) {
                 Attributes a = new Attributes();
                 a.putValue("Bundle-SymbolicName", file.getSymbolicName());
                 a.putValue("Bundle-Version", file.getVersion());
@@ -222,21 +212,49 @@ public class DeploymentPackageBuilder {
                     a.putValue("Deployment-ProvidesResourceProcessor", file.getProcessorPid());
                 }
                 manifest.getEntries().put(file.getFilename(), a);
-        	}
-        	else {
+            }
+            else {
                 Attributes a = new Attributes();
                 a.putValue("Resource-Processor", file.getProcessorPid());
                 manifest.getEntries().put(file.getFilename(), a);
-        	}
+            }
+        }
+        return manifest;
+    }
+
+    private String getRequiredHeader(Attributes mainAttributes, String headerName) throws Exception {
+        String value = mainAttributes.getValue(headerName);
+        if (value == null || value.equals("")) {
+            throw new Exception("Missing or invalid " + headerName + " header.");
         }
-		return manifest;
-	}
-	
-	private void writeStream(List<ArtifactData> files, Manifest manifest, OutputStream outputStream) throws Exception {
+        return value;
+    }
+
+    private synchronized int getUniqueID() {
+        return m_id++;
+    }
+
+    private void validateArtifacts() throws Exception {
+        for (ArtifactData data : m_artifacts) {
+            String pid = data.getProcessorPid();
+            boolean found = false;
+            for (ArtifactData processor : m_processors) {
+                if (pid.equals(processor.getProcessorPid())) {
+                    found = true;
+                    break;
+                }
+            }
+            if (!found) {
+                throw new Exception("No resource processor found for artifact " + data.getURL() + " with processor PID " + pid);
+            }
+        }
+    }
+
+    private void writeStream(List<ArtifactData> files, Manifest manifest, OutputStream outputStream) throws Exception {
         JarOutputStream output = null;
         InputStream fis = null;
         try {
-			output = new JarOutputStream(outputStream, manifest);
+            output = new JarOutputStream(outputStream, manifest);
             byte[] buffer = new byte[BUFFER_SIZE];
             for (ArtifactData file : files) {
                 output.putNextEntry(new ZipEntry(file.getFilename()));
@@ -252,15 +270,12 @@ public class DeploymentPackageBuilder {
             }
         }
         finally {
-        	if (fis != null) {
-        		fis.close();
-        	}
+            if (fis != null) {
+                fis.close();
+            }
             if (output != null) {
-            	output.close();
+                output.close();
             }
         }
     }
-	private synchronized int getUniqueID() {
-		return m_id++;
-	}
 }

Added: ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/ArtifactDataTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/ArtifactDataTest.java?rev=1539034&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/ArtifactDataTest.java (added)
+++ ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/ArtifactDataTest.java Tue Nov  5 15:35:30 2013
@@ -0,0 +1,107 @@
+/*
+ * 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.builder;
+
+import static org.apache.ace.test.utils.TestUtils.UNIT;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test cases for {@link ArtifactData}.
+ */
+public class ArtifactDataTest {
+    private URL m_fakeURL;
+    private String m_filename;
+
+    @BeforeMethod(alwaysRun = true)
+    public void setUp() throws IOException {
+        File tmpFile = File.createTempFile("artifactData", ".tmp");
+        tmpFile.deleteOnExit();
+
+        m_filename = tmpFile.getAbsolutePath();
+        m_fakeURL = tmpFile.toURI().toURL();
+    }
+
+    @Test(groups = { UNIT })
+    public void testCreateArtifactWithoutParametersOk() throws Exception {
+        ArtifactData artifact = ArtifactData.createArtifact(m_fakeURL, m_filename, "rp");
+
+        assertNotNull(artifact);
+        assertNull(artifact.getSymbolicName());
+        assertNull(artifact.getVersion());
+        assertEquals(artifact.getProcessorPid(), "rp");
+        assertFalse(artifact.isCustomizer());
+        assertFalse(artifact.isBundle());
+    }
+
+    @Test(groups = { UNIT })
+    public void testCreateBundleWithoutParametersOk() throws Exception {
+        ArtifactData artifact = ArtifactData.createBundle(m_fakeURL, m_filename, "my.bundle.name", "1.0.0");
+
+        assertNotNull(artifact);
+        assertEquals(artifact.getSymbolicName(), "my.bundle.name");
+        assertEquals(artifact.getVersion(), "1.0.0");
+        assertNull(artifact.getProcessorPid());
+        assertFalse(artifact.isCustomizer());
+        assertTrue(artifact.isBundle());
+    }
+
+    @Test(groups = { UNIT })
+    public void testCreateBundleWithParametersOk() throws Exception {
+        ArtifactData artifact = ArtifactData.createBundle(m_fakeURL, m_filename, "my.bundle.name;singleton:=true, foo:=bar", "1.0.0");
+
+        assertNotNull(artifact);
+        assertEquals(artifact.getSymbolicName(), "my.bundle.name");
+        assertEquals(artifact.getVersion(), "1.0.0");
+        assertNull(artifact.getProcessorPid());
+        assertFalse(artifact.isCustomizer());
+        assertTrue(artifact.isBundle());
+    }
+
+    @Test(groups = { UNIT })
+    public void testCreateResourceProcessorWithoutParametersOk() throws Exception {
+        ArtifactData artifact = ArtifactData.createResourceProcessor(m_fakeURL, m_filename, "my.bundle.name", "1.0.0", "rp");
+
+        assertNotNull(artifact);
+        assertEquals(artifact.getSymbolicName(), "my.bundle.name");
+        assertEquals(artifact.getVersion(), "1.0.0");
+        assertEquals(artifact.getProcessorPid(), "rp");
+        assertTrue(artifact.isCustomizer());
+        assertTrue(artifact.isBundle());
+    }
+
+    @Test(groups = { UNIT })
+    public void testCreateResourceProcessorWithParametersOk() throws Exception {
+        ArtifactData artifact = ArtifactData.createResourceProcessor(m_fakeURL, m_filename, "my.bundle.name;singleton:=true, foo:=bar", "1.0.0", "rp;qux:=quu");
+
+        assertNotNull(artifact);
+        assertEquals(artifact.getSymbolicName(), "my.bundle.name");
+        assertEquals(artifact.getVersion(), "1.0.0");
+        assertEquals(artifact.getProcessorPid(), "rp");
+        assertTrue(artifact.isCustomizer());
+        assertTrue(artifact.isBundle());
+    }
+}

Propchange: ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/ArtifactDataTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/DeploymentPackageBuilderTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/DeploymentPackageBuilderTest.java?rev=1539034&r1=1539033&r2=1539034&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/DeploymentPackageBuilderTest.java (original)
+++ ace/trunk/org.apache.ace.builder/test/org/apache/ace/builder/DeploymentPackageBuilderTest.java Tue Nov  5 15:35:30 2013
@@ -36,218 +36,212 @@ import org.testng.annotations.Test;
 
 public class DeploymentPackageBuilderTest {
     @Test(groups = { UNIT })
-	public void testEmptyDeploymentPackage() throws Exception {
-		File tempFile = File.createTempFile("output-", ".jar");
-		System.out.println("File: " + tempFile);
-		FileOutputStream output = new FileOutputStream(tempFile);
-		String name = "test";
-		String version = "1.0.0";
-		DeploymentPackageBuilder.createDeploymentPackage(name, version).generate(output);
-		Manifest m = getManifest(tempFile);
-
-		// the deployment package should have just a name and a version, but no entries
-		Assert.assertEquals(name, m.getMainAttributes().getValue("DeploymentPackage-SymbolicName"));
-		Assert.assertEquals(version, m.getMainAttributes().getValue("DeploymentPackage-Version"));
-		Assert.assertTrue(m.getEntries().isEmpty());
-	}
+    public void testEmptyDeploymentPackage() throws Exception {
+        File tempFile = File.createTempFile("output-", ".jar");
+        System.out.println("File: " + tempFile);
+        FileOutputStream output = new FileOutputStream(tempFile);
+        String name = "test";
+        String version = "1.0.0";
+        DeploymentPackageBuilder.createDeploymentPackage(name, version).generate(output);
+        Manifest m = getManifest(tempFile);
+
+        // the deployment package should have just a name and a version, but no entries
+        Assert.assertEquals(name, m.getMainAttributes().getValue("DeploymentPackage-SymbolicName"));
+        Assert.assertEquals(version, m.getMainAttributes().getValue("DeploymentPackage-Version"));
+        Assert.assertTrue(m.getEntries().isEmpty());
+    }
 
     @Test(groups = { UNIT })
-	public void testSingleBundleDeploymentPackage() throws Exception {
-		File tempFile = File.createTempFile("output-", ".jar");
-		FileOutputStream output = new FileOutputStream(tempFile);
-		String name = "test";
-		String version = "1.0.0";
-		
-		String bundleSymbolicName = "bundle";
-		String bundleVersion = "1.0.0";
-		File tempBundleFile = File.createTempFile(bundleSymbolicName + "-" + bundleVersion + "-", ".jar");
-		
-		DeploymentPackageBuilder.createDeploymentPackage(name, version)
-			.addBundle(createBundle(bundleSymbolicName, bundleVersion, tempBundleFile))
-			.generate(output);
-
-		// the deployment package should have a name and a version, and a single entry (our bundle)
-		Manifest m = getManifest(tempFile);
-		Assert.assertEquals(name, m.getMainAttributes().getValue("DeploymentPackage-SymbolicName"));
-		Assert.assertEquals(version, m.getMainAttributes().getValue("DeploymentPackage-Version"));
-		Assert.assertEquals(1, m.getEntries().size());
-		contains(m.getEntries().values(),
-			"Bundle-SymbolicName", bundleSymbolicName,
-			"Bundle-Version", bundleVersion
-		);
-	}
+    public void testProcessorAndResourceDeploymentPackage() throws Exception {
+        File tempFile = File.createTempFile("output-", ".jar");
+        FileOutputStream output = new FileOutputStream(tempFile);
+        String name = "test";
+        String version = "1.0.0";
+
+        String bundleSymbolicName = "bundle";
+        String bundleVersion = "1.0.0";
+        File tempBundleFile = File.createTempFile(bundleSymbolicName + "-" + bundleVersion + "-", ".jar");
+
+        String pid = "my.processor";
+
+        File tempArtifactFile = File.createTempFile("artifact-", ".jar");
+
+        DeploymentPackageBuilder.createDeploymentPackage(name, version)
+            .addResourceProcessor(createResourceProcessor(bundleSymbolicName, bundleVersion, pid, tempBundleFile))
+            .addArtifact(createArtifact(pid, tempArtifactFile), pid)
+            .generate(output);
+
+        // the deployment package should have a name and a version, and a single entry (our bundle)
+        Manifest m = getManifest(tempFile);
+        Assert.assertEquals(name, m.getMainAttributes().getValue("DeploymentPackage-SymbolicName"));
+        Assert.assertEquals(version, m.getMainAttributes().getValue("DeploymentPackage-Version"));
+        Map<String, Attributes> entries = m.getEntries();
+        Assert.assertEquals(2, entries.size());
+        contains(entries.values(),
+            "Bundle-SymbolicName", bundleSymbolicName,
+            "Bundle-Version", bundleVersion,
+            "DeploymentPackage-Customizer", "true",
+            "Deployment-ProvidesResourceProcessor", pid);
+        contains(entries.values(),
+            "Resource-Processor", pid);
+    }
+
+    @Test(groups = { UNIT }, expectedExceptions = { Exception.class })
+    public void testResourceWithoutProcessorDeploymentPackage() throws Exception {
+        File tempFile = File.createTempFile("output-", ".jar");
+        FileOutputStream output = new FileOutputStream(tempFile);
+        String name = "test";
+        String version = "1.0.0";
+
+        String pid = "my.processor";
+
+        File tempArtifactFile = File.createTempFile("artifact-", ".jar");
+
+        DeploymentPackageBuilder.createDeploymentPackage(name, version)
+            .addArtifact(createArtifact(pid, tempArtifactFile), pid)
+            .generate(output);
+    }
 
     @Test(groups = { UNIT })
-	public void testTwoBundleDeploymentPackage() throws Exception {
-		File tempFile = File.createTempFile("output-", ".jar");
-		FileOutputStream output = new FileOutputStream(tempFile);
-		String name = "test";
-		String version = "1.0.0";
-		
-		String bundleSymbolicName = "bundle";
-		String bundleVersion = "1.0.0";
-		File tempBundleFile = File.createTempFile(bundleSymbolicName + "-" + bundleVersion + "-", ".jar");
-		
-		String bundleSymbolicName2 = "bundle-two";
-		String bundleVersion2 = "1.2.0";
-		File tempBundleFile2 = File.createTempFile(bundleSymbolicName2 + "-" + bundleVersion2 + "-", ".jar");
-
-		DeploymentPackageBuilder.createDeploymentPackage(name, version)
-			.addBundle(createBundle(bundleSymbolicName, bundleVersion, tempBundleFile))
-			.addBundle(createBundle(bundleSymbolicName2, bundleVersion2, tempBundleFile2))
-			.generate(output);
-
-		// the deployment package should have a name and a version, and a single entry (our bundle)
-		Manifest m = getManifest(tempFile);
-		Assert.assertEquals(name, m.getMainAttributes().getValue("DeploymentPackage-SymbolicName"));
-		Assert.assertEquals(version, m.getMainAttributes().getValue("DeploymentPackage-Version"));
-		Assert.assertEquals(2, m.getEntries().size());
-		contains(m.getEntries().values(),
-			"Bundle-SymbolicName", bundleSymbolicName,
-			"Bundle-Version", bundleVersion
-		);
-		contains(m.getEntries().values(),
-			"Bundle-SymbolicName", bundleSymbolicName2,
-			"Bundle-Version", bundleVersion2
-		);
-	}
-	
+    public void testSingleBundleDeploymentPackage() throws Exception {
+        File tempFile = File.createTempFile("output-", ".jar");
+        FileOutputStream output = new FileOutputStream(tempFile);
+        String name = "test";
+        String version = "1.0.0";
+
+        String bundleSymbolicName = "bundle";
+        String bundleVersion = "1.0.0";
+        File tempBundleFile = File.createTempFile(bundleSymbolicName + "-" + bundleVersion + "-", ".jar");
+
+        DeploymentPackageBuilder.createDeploymentPackage(name, version)
+            .addBundle(createBundle(bundleSymbolicName, bundleVersion, tempBundleFile))
+            .generate(output);
+
+        // the deployment package should have a name and a version, and a single entry (our bundle)
+        Manifest m = getManifest(tempFile);
+        Assert.assertEquals(name, m.getMainAttributes().getValue("DeploymentPackage-SymbolicName"));
+        Assert.assertEquals(version, m.getMainAttributes().getValue("DeploymentPackage-Version"));
+        Assert.assertEquals(1, m.getEntries().size());
+        contains(m.getEntries().values(),
+            "Bundle-SymbolicName", bundleSymbolicName,
+            "Bundle-Version", bundleVersion);
+    }
+
     @Test(groups = { UNIT })
-	public void testProcessorAndResourceDeploymentPackage() throws Exception {
-		File tempFile = File.createTempFile("output-", ".jar");
-		FileOutputStream output = new FileOutputStream(tempFile);
-		String name = "test";
-		String version = "1.0.0";
-		
-		String bundleSymbolicName = "bundle";
-		String bundleVersion = "1.0.0";
-		File tempBundleFile = File.createTempFile(bundleSymbolicName + "-" + bundleVersion + "-", ".jar");
-		
-		String pid = "my.processor";
-
-		File tempArtifactFile = File.createTempFile("artifact-", ".jar");
-
-		DeploymentPackageBuilder.createDeploymentPackage(name, version)
-			.addResourceProcessor(createResourceProcessor(bundleSymbolicName, bundleVersion, pid, tempBundleFile))
-			.addArtifact(createArtifact(pid, tempArtifactFile), pid)
-			.generate(output);
-
-		// the deployment package should have a name and a version, and a single entry (our bundle)
-		Manifest m = getManifest(tempFile);
-		Assert.assertEquals(name, m.getMainAttributes().getValue("DeploymentPackage-SymbolicName"));
-		Assert.assertEquals(version, m.getMainAttributes().getValue("DeploymentPackage-Version"));
-		Map<String, Attributes> entries = m.getEntries();
-		Assert.assertEquals(2, entries.size());
-		contains(entries.values(),
-			"Bundle-SymbolicName", bundleSymbolicName,
-			"Bundle-Version", bundleVersion,
-			"DeploymentPackage-Customizer", "true",
-			"Deployment-ProvidesResourceProcessor", pid
-		);
-		contains(entries.values(),
-			"Resource-Processor", pid
-		);
-	}
-    
-    @Test(groups = { UNIT }, expectedExceptions = { Exception.class })
-	public void testResourceWithoutProcessorDeploymentPackage() throws Exception {
-		File tempFile = File.createTempFile("output-", ".jar");
-		FileOutputStream output = new FileOutputStream(tempFile);
-		String name = "test";
-		String version = "1.0.0";
-		
-		String pid = "my.processor";
-
-		File tempArtifactFile = File.createTempFile("artifact-", ".jar");
-
-		DeploymentPackageBuilder.createDeploymentPackage(name, version)
-			.addArtifact(createArtifact(pid, tempArtifactFile), pid)
-			.generate(output);
-	}
-	
-	
-	private Manifest getManifest(File file) throws Exception {
-        JarInputStream jis = new JarInputStream(file.toURI().toURL().openStream());
-        Manifest bundleManifest = jis.getManifest();
-        jis.close();
-        return bundleManifest;
-	}
-	
-	private URL createBundle(String symbolicName, String version, File file) throws Exception {
-		Manifest manifest = new Manifest();
+    public void testTwoBundleDeploymentPackage() throws Exception {
+        File tempFile = File.createTempFile("output-", ".jar");
+        FileOutputStream output = new FileOutputStream(tempFile);
+        String name = "test";
+        String version = "1.0.0";
+
+        String bundleSymbolicName = "bundle";
+        String bundleVersion = "1.0.0";
+        File tempBundleFile = File.createTempFile(bundleSymbolicName + "-" + bundleVersion + "-", ".jar");
+
+        String bundleSymbolicName2 = "bundle-two";
+        String bundleVersion2 = "1.2.0";
+        File tempBundleFile2 = File.createTempFile(bundleSymbolicName2 + "-" + bundleVersion2 + "-", ".jar");
+
+        DeploymentPackageBuilder.createDeploymentPackage(name, version)
+            .addBundle(createBundle(bundleSymbolicName, bundleVersion, tempBundleFile))
+            .addBundle(createBundle(bundleSymbolicName2, bundleVersion2, tempBundleFile2))
+            .generate(output);
+
+        // the deployment package should have a name and a version, and a single entry (our bundle)
+        Manifest m = getManifest(tempFile);
+        Assert.assertEquals(name, m.getMainAttributes().getValue("DeploymentPackage-SymbolicName"));
+        Assert.assertEquals(version, m.getMainAttributes().getValue("DeploymentPackage-Version"));
+        Assert.assertEquals(2, m.getEntries().size());
+        contains(m.getEntries().values(),
+            "Bundle-SymbolicName", bundleSymbolicName,
+            "Bundle-Version", bundleVersion);
+        contains(m.getEntries().values(),
+            "Bundle-SymbolicName", bundleSymbolicName2,
+            "Bundle-Version", bundleVersion2);
+    }
+
+    private void contains(Collection<Attributes> list, String... keysAndValues) {
+        for (Attributes attributes : list) {
+            boolean found = true;
+            for (int i = 0; i < keysAndValues.length; i += 2) {
+                if (!keysAndValues[i + 1].equals(attributes.getValue(keysAndValues[i]))) {
+                    found = false;
+                    break;
+                }
+            }
+            if (found) {
+                return;
+            }
+        }
+        throw new IllegalStateException("Could not find entry in list.");
+    }
+
+    private URL createArtifact(String processorPID, File file) throws Exception {
+        FileOutputStream output = null;
+        try {
+            output = new FileOutputStream(file);
+            output.write(0);
+            return file.toURI().toURL();
+        }
+        finally {
+            if (output != null) {
+                output.close();
+            }
+        }
+    }
+
+    private URL createBundle(String symbolicName, String version, File file) throws Exception {
+        Manifest manifest = new Manifest();
         Attributes main = manifest.getMainAttributes();
         main.putValue("Manifest-Version", "1.0");
         main.putValue("Bundle-SymbolicName", symbolicName);
         main.putValue("Bundle-Version", version);
-        
+
         JarOutputStream output = null;
         InputStream fis = null;
         try {
-			output = new JarOutputStream(new FileOutputStream(file), manifest);
-			return file.toURI().toURL();
+            output = new JarOutputStream(new FileOutputStream(file), manifest);
+            return file.toURI().toURL();
         }
         finally {
             if (output != null) {
-            	output.close();
+                output.close();
             }
             if (fis != null) {
                 fis.close();
             }
         }
-	}
-	
-	private URL createResourceProcessor(String symbolicName, String version, String processorPID, File file) throws Exception {
-		Manifest manifest = new Manifest();
+    }
+
+    private URL createResourceProcessor(String symbolicName, String version, String processorPID, File file) throws Exception {
+        Manifest manifest = new Manifest();
         Attributes main = manifest.getMainAttributes();
         main.putValue("Manifest-Version", "1.0");
         main.putValue("Bundle-SymbolicName", symbolicName);
         main.putValue("Bundle-Version", version);
         main.putValue("DeploymentPackage-Customizer", "true");
         main.putValue("Deployment-ProvidesResourceProcessor", processorPID);
-        
+
         JarOutputStream output = null;
         InputStream fis = null;
         try {
-			output = new JarOutputStream(new FileOutputStream(file), manifest);
-			return file.toURI().toURL();
+            output = new JarOutputStream(new FileOutputStream(file), manifest);
+            return file.toURI().toURL();
         }
         finally {
             if (output != null) {
-            	output.close();
+                output.close();
             }
             if (fis != null) {
                 fis.close();
             }
         }
-	}
+    }
 
-	private URL createArtifact(String processorPID, File file) throws Exception {
-        FileOutputStream output = null;
-        try {
-			output = new FileOutputStream(file);
-			output.write(0);
-			return file.toURI().toURL();
-        }
-        finally {
-            if (output != null) {
-            	output.close();
-            }
-        }
-	}
-
-	private void contains(Collection<Attributes> list, String... keysAndValues) {
-		for (Attributes attributes : list) {
-			boolean found = true;
-			for (int i = 0; i < keysAndValues.length; i += 2) {
-				if (!keysAndValues[i + 1].equals(attributes.getValue(keysAndValues[i]))) {
-					found = false;
-					break;
-				}
-			}
-			if (found) {
-				return;
-			}
-		}
-		throw new IllegalStateException("Could not find entry in list.");
-	}
+    private Manifest getManifest(File file) throws Exception {
+        JarInputStream jis = new JarInputStream(file.toURI().toURL().openStream());
+        Manifest bundleManifest = jis.getManifest();
+        jis.close();
+        return bundleManifest;
+    }
 }

Propchange: ace/trunk/org.apache.ace.client.repository.itest/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Nov  5 15:35:30 2013
@@ -4,3 +4,4 @@ generated
 store
 bundle-cache
 felix-cache
+test-output

Modified: ace/trunk/org.apache.ace.client.repository.itest/src/org/apache/ace/it/repositoryadmin/BaseRepositoryAdminTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository.itest/src/org/apache/ace/it/repositoryadmin/BaseRepositoryAdminTest.java?rev=1539034&r1=1539033&r2=1539034&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository.itest/src/org/apache/ace/it/repositoryadmin/BaseRepositoryAdminTest.java (original)
+++ ace/trunk/org.apache.ace.client.repository.itest/src/org/apache/ace/it/repositoryadmin/BaseRepositoryAdminTest.java Tue Nov  5 15:35:30 2013
@@ -363,9 +363,10 @@ public abstract class BaseRepositoryAdmi
         try {
             assertTrue(startLatch.await(1500, TimeUnit.MILLISECONDS));
 
-            T result;
+            T result = null;
             // XXX this is dodgy, I know, but currently a workaround for some spurious failing itests...
-            while (true) {
+            int tries = 10;
+            while (tries-- > 0) {
                 try {
                     result = callable.call();
                     break;
@@ -373,6 +374,9 @@ public abstract class BaseRepositoryAdmi
                 catch (Exception exception) {
                     if (exception instanceof ConnectException) {
                         // Restart it...
+                        if (tries == 0) {
+                            throw exception;
+                        }
                     }
                     else {
                         // Rethrow it...

Modified: ace/trunk/org.apache.ace.client.repository.itest/src/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository.itest/src/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java?rev=1539034&r1=1539033&r2=1539034&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository.itest/src/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java (original)
+++ ace/trunk/org.apache.ace.client.repository.itest/src/org/apache/ace/it/repositoryadmin/RepositoryAdminTest.java Tue Nov  5 15:35:30 2013
@@ -253,7 +253,7 @@ public class RepositoryAdminTest extends
         }
 
         // Use a valid JAR file, with a Bundle-SymbolicName header, but do not supply an OBR.
-        attributes.putValue(BundleHelper.KEY_SYMBOLICNAME, "org.apache.ace.test" + System.currentTimeMillis());
+        attributes.putValue(BundleHelper.KEY_SYMBOLICNAME, String.format("org.apache.ace.test-%d; singleton:=true", System.currentTimeMillis()));
 
         temp = File.createTempFile("org.apache.ace.test2", ".jar");
         temp.deleteOnExit();

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperImpl.java?rev=1539034&r1=1539033&r2=1539034&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperImpl.java (original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperImpl.java Tue Nov  5 15:35:30 2013
@@ -72,7 +72,7 @@ public class BundleHelperImpl implements
         if (object == null) {
             return false;
         }
-        return (object.getMimetype().equals(MIMETYPE));
+        return (MIMETYPE.equals(object.getMimetype()));
     }
 
     public <TYPE extends ArtifactObject> String getAssociationFilter(TYPE obj, Map<String, String> properties) {
@@ -80,6 +80,8 @@ public class BundleHelperImpl implements
          * Creates an endpoint filter for an association. If there is a KEY_ASSOCIATION_VERSIONSTATEMENT, a filter will
          * be created that matches exactly the given range.
          */
+
+        String symbolicName = RepositoryUtil.escapeFilterValue(removeParameters(obj.getAttribute(KEY_SYMBOLICNAME)));
         if ((properties != null) && properties.containsKey(KEY_ASSOCIATION_VERSIONSTATEMENT)) {
             String versions = properties.get(KEY_ASSOCIATION_VERSIONSTATEMENT);
             VersionRange versionRange = null;
@@ -90,7 +92,7 @@ public class BundleHelperImpl implements
                 throw new IllegalArgumentException("version " + ((versions != null) ? versions + " " : "(null) ") + "cannot be parsed into a valid version range statement.");
             }
 
-            StringBuilder bundleStatement = new StringBuilder("(&(" + KEY_SYMBOLICNAME + "=" + RepositoryUtil.escapeFilterValue(obj.getAttribute(KEY_SYMBOLICNAME)) + ")");
+            StringBuilder bundleStatement = new StringBuilder("(&(" + KEY_SYMBOLICNAME + "=" + symbolicName + ")");
 
             bundleStatement.append("(" + KEY_VERSION + ">=" + versionRange.getLow() + ")");
             if (!versionRange.isLowInclusive()) {
@@ -110,11 +112,12 @@ public class BundleHelperImpl implements
         }
         else
         {
-            if (obj.getAttribute(KEY_VERSION) != null) {
-                return "(&(" + KEY_SYMBOLICNAME + "=" + RepositoryUtil.escapeFilterValue(obj.getAttribute(KEY_SYMBOLICNAME)) + ")(" + KEY_VERSION + "=" + RepositoryUtil.escapeFilterValue(obj.getAttribute(KEY_VERSION)) + "))";
+            String version = obj.getAttribute(KEY_VERSION);
+            if (version != null) {
+                return "(&(" + KEY_SYMBOLICNAME + "=" + symbolicName + ")(" + KEY_VERSION + "=" + RepositoryUtil.escapeFilterValue(version) + "))";
             }
             else {
-                return "(&(" + KEY_SYMBOLICNAME + "=" + RepositoryUtil.escapeFilterValue(obj.getAttribute(KEY_SYMBOLICNAME)) + ")(!(" + KEY_VERSION + "=*)))";
+                return "(&(" + KEY_SYMBOLICNAME + "=" + symbolicName + ")(!(" + KEY_VERSION + "=*)))";
             }
         }
     }
@@ -158,6 +161,22 @@ public class BundleHelperImpl implements
         return input;
     }
 
+    /**
+     * Some headers in OSGi allow for optional parameters, that are appended after the main value and always start with
+     * a semicolon.
+     * 
+     * @param name
+     *            the name to remove the (optional) parameters from, cannot be <code>null</code>.
+     * @return the cleaned name, never <code>null</code>.
+     */
+    private static String removeParameters(String name) {
+        int idx = name.indexOf(';');
+        if (idx > 0) {
+            return name.substring(0, idx);
+        }
+        return name;
+    }
+
     /*
      * From BundleHelper
      */
@@ -176,7 +195,7 @@ public class BundleHelperImpl implements
 
     public String getSymbolicName(ArtifactObject object) {
         ensureBundle(object);
-        return object.getAttribute(KEY_SYMBOLICNAME);
+        return removeParameters(object.getAttribute(KEY_SYMBOLICNAME));
     }
 
     public String getName(ArtifactObject object) {
@@ -213,7 +232,6 @@ public class BundleHelperImpl implements
     }
 
     public Map<String, String> extractMetaData(ArtifactResource artifact) throws IllegalArgumentException {
-
         try {
             Map<String, String> metadata = extractLocalizedHeaders(artifact);
 
@@ -225,7 +243,7 @@ public class BundleHelperImpl implements
             String name = metadata.get(KEY_NAME);
             String version = metadata.get(KEY_VERSION);
             if (name == null) {
-                name = metadata.get(KEY_SYMBOLICNAME);
+                name = removeParameters(metadata.get(KEY_SYMBOLICNAME));
             }
             metadata.put(ArtifactObject.KEY_ARTIFACT_NAME, name + "-" + version);
             return metadata;
@@ -310,6 +328,9 @@ public class BundleHelperImpl implements
                     }
                     value = localizationProperties.getProperty(value.substring(1), value);
                 }
+                if (KEY_SYMBOLICNAME.equals(key)) {
+                    value = removeParameters(value);
+                }
                 localizedHeaders.put(key, value);
             }
             return localizedHeaders;

Modified: ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperTest.java?rev=1539034&r1=1539033&r2=1539034&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperTest.java (original)
+++ ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/helper/bundle/impl/BundleHelperTest.java Tue Nov  5 15:35:30 2013
@@ -19,6 +19,7 @@
 package org.apache.ace.client.repository.helper.bundle.impl;
 
 import static org.apache.ace.test.utils.TestUtils.UNIT;
+import static org.testng.Assert.*;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -48,8 +49,8 @@ public class BundleHelperTest {
 
     @Test(groups = { UNIT })
     public void testMimetype() {
-        assert m_helper.canHandle("application/vnd.osgi.bundle") : "Should be able to handle bundle mimetype.";
-        assert !m_helper.canHandle("somecrazy/mimetype") : "Should not be able to handle crazy mimetype.";
+        assertTrue(m_helper.canHandle("application/vnd.osgi.bundle"), "Should be able to handle bundle mimetype.");
+        assertFalse(m_helper.canHandle("somecrazy/mimetype"), "Should not be able to handle crazy mimetype.");
     }
 
     @Test(groups = { UNIT })
@@ -61,7 +62,7 @@ public class BundleHelperTest {
                 Manifest manifest = new Manifest();
                 Attributes attrs = manifest.getMainAttributes();
                 attrs.putValue("Manifest-Version", "1");
-                attrs.putValue("Bundle-SymbolicName", "mybundle");
+                attrs.putValue("Bundle-SymbolicName", "mybundle;singleton:=true");
                 attrs.putValue("Bundle-Version", "1.0.0");
                 attrs.putValue("Bundle-Name", "My Cool Bundle");
                 JarOutputStream jos = new JarOutputStream(baos, manifest);
@@ -80,9 +81,9 @@ public class BundleHelperTest {
             }
         };
         Map<String, String> map = m_helper.extractMetaData(artifact);
-        assert "mybundle".equals(map.get("Bundle-SymbolicName")) : "Symbolic name should have been 'mybundle', was " + map.get("Bundle-SymbolicName");
-        assert "1.0.0".equals(map.get("Bundle-Version")) : "Version should have been '1.0.0', was " + map.get("Bundle-Version");
-        assert "My Cool Bundle-1.0.0".equals(map.get(ArtifactObject.KEY_ARTIFACT_NAME)) : "Artifact name should have been 'My Cool Bundle-1.0.0', was " + map.get(ArtifactObject.KEY_ARTIFACT_NAME);
+        assertEquals(map.get("Bundle-SymbolicName"), "mybundle");
+        assertEquals(map.get("Bundle-Version"), "1.0.0");
+        assertEquals(map.get(ArtifactObject.KEY_ARTIFACT_NAME), "My Cool Bundle-1.0.0");
     }
 
     @Test(groups = { UNIT })
@@ -94,7 +95,7 @@ public class BundleHelperTest {
                 Manifest manifest = new Manifest();
                 Attributes attrs = manifest.getMainAttributes();
                 attrs.putValue("Manifest-Version", "1");
-                attrs.putValue("Bundle-SymbolicName", "mybundle");
+                attrs.putValue("Bundle-SymbolicName", "mybundle;qux:=quu");
                 attrs.putValue("Bundle-Version", "1.0.0");
                 attrs.putValue("Bundle-Name", "%bundleName");
                 attrs.putValue("Bundle-Localization", "locale");
@@ -124,16 +125,14 @@ public class BundleHelperTest {
             }
         };
         Map<String, String> map = m_helper.extractMetaData(artifact);
-        assert "mybundle".equals(map.get("Bundle-SymbolicName")) : "Symbolic name should have been 'mybundle', was " + map.get("Bundle-SymbolicName");
-        assert "1.0.0".equals(map.get("Bundle-Version")) : "Version should have been '1.0.0', was " + map.get("Bundle-Version");
-        assert "The Coolest Bundle-1.0.0".equals(map.get(ArtifactObject.KEY_ARTIFACT_NAME)) : "Artifact name should have been 'The Coolest Bundle-1.0.0', was " + map.get(ArtifactObject.KEY_ARTIFACT_NAME);
+        assertEquals(map.get("Bundle-SymbolicName"), "mybundle");
+        assertEquals(map.get("Bundle-Version"), "1.0.0");
+        assertEquals(map.get(ArtifactObject.KEY_ARTIFACT_NAME), "The Coolest Bundle-1.0.0");
     }
 
     @Test(groups = { UNIT })
     public void testLocalizedManifestExtractionWithDefaultBase() {
-
         // note that we do not set the Bundle-Localization header
-
         ArtifactResource artifact = new ArtifactResource() {
             @Override
             public InputStream openStream() throws IOException {
@@ -164,9 +163,9 @@ public class BundleHelperTest {
             }
         };
         Map<String, String> map = m_helper.extractMetaData(artifact);
-        assert "mybundle".equals(map.get("Bundle-SymbolicName")) : "Symbolic name should have been 'mybundle', was " + map.get("Bundle-SymbolicName");
-        assert "1.0.0".equals(map.get("Bundle-Version")) : "Version should have been '1.0.0', was " + map.get("Bundle-Version");
-        assert "The Coolest Bundle-1.0.0".equals(map.get(ArtifactObject.KEY_ARTIFACT_NAME)) : "Artifact name should have been 'The Coolest Bundle-1.0.0', was " + map.get(ArtifactObject.KEY_ARTIFACT_NAME);
+        assertEquals(map.get("Bundle-SymbolicName"), "mybundle");
+        assertEquals(map.get("Bundle-Version"), "1.0.0");
+        assertEquals(map.get(ArtifactObject.KEY_ARTIFACT_NAME), "The Coolest Bundle-1.0.0");
     }
 
     @Test(groups = { UNIT })
@@ -202,9 +201,10 @@ public class BundleHelperTest {
             }
         };
         Map<String, String> map = m_helper.extractMetaData(artifact);
-        assert "mybundle".equals(map.get("Bundle-SymbolicName")) : "Symbolic name should have been 'mybundle', was " + map.get("Bundle-SymbolicName");
-        assert "1.0.0".equals(map.get("Bundle-Version")) : "Version should have been '1.0.0', was " + map.get("Bundle-Version");
-        assert "De koelste Bundle-1.0.0".equals(map.get(ArtifactObject.KEY_ARTIFACT_NAME)) : "Artifact name should have been 'The Coolest Bundle-1.0.0', was " + map.get(ArtifactObject.KEY_ARTIFACT_NAME);
+        assertEquals(map.get("Bundle-SymbolicName"), "mybundle");
+        assertEquals(map.get("Bundle-Name"), "De koelste Bundle");
+        assertEquals(map.get("Bundle-Version"), "1.0.0");
+        assertEquals(map.get(ArtifactObject.KEY_ARTIFACT_NAME), "De koelste Bundle-1.0.0");
     }
 
     @Test(groups = { UNIT })
@@ -249,8 +249,8 @@ public class BundleHelperTest {
             }
         };
         Map<String, String> map = m_helper.extractMetaData(artifact);
-        assert "mybundle".equals(map.get("Bundle-SymbolicName")) : "Symbolic name should have been 'mybundle', was " + map.get("Bundle-SymbolicName");
-        assert "1.0.0".equals(map.get("Bundle-Version")) : "Version should have been '1.0.0', was " + map.get("Bundle-Version");
-        assert "The Coolest Bundle-1.0.0".equals(map.get(ArtifactObject.KEY_ARTIFACT_NAME)) : "Artifact name should have been 'The Coolest Bundle-1.0.0', was " + map.get(ArtifactObject.KEY_ARTIFACT_NAME);
+        assertEquals(map.get("Bundle-SymbolicName"), "mybundle");
+        assertEquals(map.get("Bundle-Version"), "1.0.0");
+        assertEquals(map.get(ArtifactObject.KEY_ARTIFACT_NAME), "The Coolest Bundle-1.0.0");
     }
 }

Propchange: ace/trunk/org.apache.ace.deployment/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Nov  5 15:35:30 2013
@@ -4,3 +4,4 @@ generated
 store
 bundle-cache
 felix-cache
+test-output

Modified: ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java?rev=1539034&r1=1539033&r2=1539034&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java (original)
+++ ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java Tue Nov  5 15:35:30 2013
@@ -175,7 +175,7 @@ public class RepositoryBasedProviderTest
         BUNDLE3 = generateBundle(FileUtils.createTempFile(m_tempDirectory), null, "Bundle3", "3.0.0", null);
         BUNDLE4 = generateBundle(FileUtils.createTempFile(m_tempDirectory), null, "Bundle4", "4.0.0", null);
         BUNDLE4_1 = generateBundle(FileUtils.createTempFile(m_tempDirectory), null, "Bundle4", "4.1.0", null);
-        BUNDLE5 = generateBundle(FileUtils.createTempFile(m_tempDirectory), null, "Bundle5", "5.0.0", null);
+        BUNDLE5 = generateBundle(FileUtils.createTempFile(m_tempDirectory), null, "Bundle5;singleton:=true", "5.0.0", null);
         BUNDLE3_2 = generateBundle(FileUtils.createTempFile(m_tempDirectory), null, "Bundle3", "3.0.0", null);
         BUNDLE4_2 = generateBundle(FileUtils.createTempFile(m_tempDirectory), null, "Bundle4", "5.0.0", null);
 



Mime
View raw message