Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff McAffer2007-11-13 01:42:18 +0000
committerJeff McAffer2007-11-13 01:42:18 +0000
commitd2010141492295ff80d70e0c904dacb67712c7a0 (patch)
tree55b494fe45064bc59120a8f34acdaf9e171d04e3
parent11621e9ef64b984cc4dc8fb2a3e0d7fb003e94c0 (diff)
downloadrt.equinox.p2-d2010141492295ff80d70e0c904dacb67712c7a0.tar.gz
rt.equinox.p2-d2010141492295ff80d70e0c904dacb67712c7a0.tar.xz
rt.equinox.p2-d2010141492295ff80d70e0c904dacb67712c7a0.zip
add JarDelta optimizer, some tests and refactor all of the above
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/plugin.xml8
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/AbstractBufferingStep.java96
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/AbstractDeltaStep.java (renamed from bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/AbstractDeltaDiffStep.java)53
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/Activator.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/VersionlessArtifactKey.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/Application.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/DeltaComputer.java68
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/JarDeltaOptimizerStep.java114
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/Optimizer.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Application.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/ArtifactKeyDeSerializer.java120
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffStep.java89
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffZipStep.java67
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Optimizer.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/VersionLessArtifactKey.java87
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Application.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Optimizer.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Pack200OptimizerStep.java70
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Pack200Step.java108
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/plugin.xml4
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java (renamed from bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/AbstractDeltaPatchStep.java)34
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/Activator.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jardelta/DeltaApplier.java61
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jardelta/JarDeltaProcessorStep.java110
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/ArtifactKeyDeSerializer.java120
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchStep.java64
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchZipStep.java42
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/pack200/Pack200ProcessorStep.java79
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/pack200/Unpack200Step.java110
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/verifier/MD5Verifier.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java55
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IArtifactKey.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/plugin.xml6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/AllTests.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/jbdiff/AllTests.java)7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JBDiffStepTest.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/jbdiff/JBDiffStepTest.java)16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JBDiffZipStepTest.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/jbdiff/JBDiffZipStepTest.java)19
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JarDeltaOptimizerTest.java132
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/Pack200OptimizerTest.java66
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/AllTests.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/JarDeltaRepositoryTest.java137
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/PackRepositoryTest.java136
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/TestArtifactKey.java47
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/AllTests.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/AllTests.java)7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/ArtifactRepositoryMock.java)2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/JBPatchStepTest.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/JBPatchStepTest.java)14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/JBPatchZipStepTest.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/JBPatchZipStepTest.java)17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/JarDeltaProcessorTest.java73
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/Pack200ProcessorTest.java52
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/MD5Verifier.java90
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/ArtifactkeyDeSerializerTest.java)34
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/enginerepo.zipbin50876 -> 0 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/artifacts.xml29
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/content.xml276
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/org.eclipse.equinox.prov.engine_0.1.0.200709241631.jarbin51366 -> 0 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/testdata_1.0.0.1.jarbin1958 -> 0 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/testdata_1.0.0.2.jarbin1939 -> 0 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/eclipse-3.2-3.3.jbdiff (renamed from bundles/org.eclipse.equinox.p2.tests/testData/delta/eclipse-3.2-3.3.jbdiff)bin8261 -> 8261 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/eclipse-3.2.exe (renamed from bundles/org.eclipse.equinox.p2.tests/testData/delta/eclipse-3.2.exe)bin180224 -> 180224 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/eclipse-3.3.exe (renamed from bundles/org.eclipse.equinox.p2.tests/testData/delta/eclipse-3.3.exe)bin53248 -> 53248 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jarbin0 -> 78074 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar.pack.gzbin0 -> 33474 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.jdt_3.2.0-3.3.0.jbdiff (renamed from bundles/org.eclipse.equinox.p2.tests/testData/delta/org.eclipse.jdt_3.2.0-3.3.0.jbdiff)bin25144 -> 25144 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.jdt_3.2.0.v20060605-1400.njar (renamed from bundles/org.eclipse.equinox.p2.tests/testData/delta/org.eclipse.jdt_3.2.0.v20060605-1400.njar)bin40662 -> 40662 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.jdt_3.3.0.v20070607-1300.njar (renamed from bundles/org.eclipse.equinox.p2.tests/testData/delta/org.eclipse.jdt_3.3.0.v20070607-1300.njar)bin42387 -> 42387 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/testdata_1.0.0.1-2.jarbin0 -> 1893 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/testdata_1.0.0.1.jar (renamed from bundles/org.eclipse.equinox.p2.tests/rawData/testdata_1.0.0.1.jar)bin1958 -> 1958 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/optimizers/testdata_1.0.0.2.jar (renamed from bundles/org.eclipse.equinox.p2.tests/rawData/testdata_1.0.0.2.jar)bin1939 -> 1939 bytes
74 files changed, 1108 insertions, 1819 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.optimizers/META-INF/MANIFEST.MF
index 132d2227f..c9930290e 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/META-INF/MANIFEST.MF
@@ -22,7 +22,7 @@ Eclipse-LazyStart: true
Require-Bundle: org.eclipse.equinox.common
Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,
J2SE-1.4
-Export-Package: org.eclipse.equinox.internal.p2.artifact.optimizers;x-internal:=true,
+Export-Package: org.eclipse.equinox.internal.p2.artifact.optimizers;x-friends:="org.eclipse.equinox.p2.artifact.processors",
org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta;x-internal:=true,
org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff;x-internal:=true,
org.eclipse.equinox.internal.p2.artifact.optimizers.pack200;x-internal:=true
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/plugin.xml b/bundles/org.eclipse.equinox.p2.artifact.optimizers/plugin.xml
index d384752c7..fb0e4f618 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/plugin.xml
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/plugin.xml
@@ -19,8 +19,12 @@
</application>
</extension>
- <extension id="Pack200Packer" point="org.eclipse.equinox.p2.artifact.repository.processingSteps">
- <step class="org.eclipse.equinox.internal.p2.artifact.optimizers.pack200.Pack200Step"/>
+ <extension id="Pack200Optimizer" point="org.eclipse.equinox.p2.artifact.repository.processingSteps">
+ <step class="org.eclipse.equinox.internal.p2.artifact.optimizers.pack200.Pack200OptimizerStep"/>
+ </extension>
+
+ <extension id="JarDeltaOptimizer" point="org.eclipse.equinox.p2.artifact.repository.processingSteps">
+ <step class="org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta.JarDeltaOptimizerStep"/>
</extension>
<extension id="JBDiffStep" point="org.eclipse.equinox.p2.artifact.repository.processingSteps">
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/AbstractBufferingStep.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/AbstractBufferingStep.java
new file mode 100644
index 000000000..c594065fa
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/AbstractBufferingStep.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.artifact.optimizers;
+
+import java.io.*;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
+
+public abstract class AbstractBufferingStep extends ProcessingStep {
+ protected static final String JAR_SUFFIX = ".jar"; //$NON-NLS-1$
+ protected static final String INCOMING_ROOT = "p2.optimizers.incoming"; //$NON-NLS-1$
+ protected static final String RESULT_ROOT = "p2.optimizers.result"; //$NON-NLS-1$
+ protected static final String PREDECESSOR_ROOT = "p2.optimizers.predecessor"; //$NON-NLS-1$
+
+ protected OutputStream incomingStream;
+ private File workDir;
+
+ protected AbstractBufferingStep() {
+ super();
+ }
+
+ public void write(int b) throws IOException {
+ OutputStream stream = getOutputStream();
+ stream.write(b);
+ }
+
+ protected OutputStream getOutputStream() throws IOException {
+ if (incomingStream != null)
+ return incomingStream;
+ // if buffering, store input stream in temporary file
+ incomingStream = createIncomingStream();
+ return incomingStream;
+ }
+
+ protected abstract OutputStream createIncomingStream() throws IOException;
+
+ public void close() throws IOException {
+ // When we go to close we must have seen all the content we are going to see.
+ // If no one wrote to the temp stream then there is nothing to do. If there is
+ // content then close the temporary stream and perform the optimization.
+ // Performing the optimization should result in the new content being written to
+ // the destination. Make sure we delete the temporary file if any.
+ try {
+ if (incomingStream != null) {
+ incomingStream.close();
+ performProcessing();
+ }
+ } finally {
+ incomingStream = null;
+ cleanupTempFiles();
+ cleanupWorkDir();
+ }
+
+ super.close();
+ // TODO need to get real status here. sometimes the optimizers do not give
+ // any reasonable return status
+ if (status == null)
+ status = Status.OK_STATUS;
+ }
+
+ protected abstract void performProcessing() throws IOException;
+
+ protected void cleanupTempFiles() {
+ }
+
+ private void cleanupWorkDir() throws IOException {
+ if (workDir != null) {
+ FileUtils.deleteAll(workDir);
+ // TODO try twice since there seems to be some cases where the dir is not
+ // deleted the first time. At least on Windows...
+ FileUtils.deleteAll(workDir);
+ }
+ }
+
+ protected File getWorkDir() throws IOException {
+ if (workDir != null)
+ return workDir;
+ workDir = File.createTempFile("work", "");
+ if (!workDir.delete())
+ throw new IOException("Could not delete file for creating temporary working dir.");
+ if (!workDir.mkdirs())
+ throw new IOException("Could not create temporary working dir.");
+ return workDir;
+ }
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/AbstractDeltaDiffStep.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/AbstractDeltaStep.java
index 0b53dfe8a..be9158772 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/AbstractDeltaDiffStep.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/AbstractDeltaStep.java
@@ -8,14 +8,13 @@
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff;
+package org.eclipse.equinox.internal.p2.artifact.optimizers;
+import java.io.*;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.equinox.internal.p2.artifact.optimizers.Activator;
-import org.eclipse.equinox.p2.artifact.repository.IArtifactDescriptor;
-import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
+import org.eclipse.equinox.p2.artifact.repository.*;
import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
@@ -25,34 +24,50 @@ import org.eclipse.equinox.p2.metadata.IArtifactKey;
* artifact key. It assumes that the artifact key is stored within the data property
* of the processing step descriptor and that is encoded with the <code>ArtifactKeySerializer</code>.
*/
-public abstract class AbstractDeltaDiffStep extends ProcessingStep {
+public abstract class AbstractDeltaStep extends AbstractBufferingStep {
protected IArtifactKey key;
protected IArtifactRepository repository;
- protected AbstractDeltaDiffStep(IArtifactRepository repository) {
+ public AbstractDeltaStep() {
+ this(null);
+ }
+
+ protected AbstractDeltaStep(IArtifactRepository repository) {
+ super();
this.repository = repository;
}
- /* (non-Javadoc)
- * @see org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep#initialize(org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor, org.eclipse.equinox.p2.artifact.repository.IArtifactDescriptor)
- */
public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
super.initialize(descriptor, context);
-
- fetchArtifactKey(descriptor);
+ readArtifactKey(descriptor);
}
- /**
- * Fetch the artifact key from the given processing step descriptor.
- * @param descriptor
- */
- private void fetchArtifactKey(ProcessingStepDescriptor descriptor) {
+ protected void readArtifactKey(ProcessingStepDescriptor descriptor) {
try {
- key = ArtifactKeyDeSerializer.deserialize(descriptor.getData());
+ key = ArtifactKey.parse(descriptor.getData());
} catch (IllegalArgumentException e) {
status = new Status(IStatus.ERROR, Activator.ID, "Predecessor artifact key for delta could not be deserialized. Serialized key is " + descriptor.getData(), e);
}
}
-}
+ protected File fetchPredecessor(ArtifactDescriptor descriptor) {
+ if (repository instanceof IFileArtifactRepository)
+ return ((IFileArtifactRepository) repository).getArtifactFile(descriptor);
+ File result = null;
+ OutputStream resultStream = null;
+ try {
+ try {
+ result = File.createTempFile(PREDECESSOR_ROOT, JAR_SUFFIX);
+ resultStream = new BufferedOutputStream(new FileOutputStream(result));
+ status = repository.getArtifact(descriptor, resultStream, monitor);
+ return result;
+ } finally {
+ if (resultStream != null)
+ resultStream.close();
+ }
+ } catch (IOException e) {
+ }
+ return null;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/Activator.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/Activator.java
index cfcd1e8d9..4d0ea17fd 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/Activator.java
@@ -4,7 +4,8 @@
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors: IBM Corporation - initial API and implementation
+ * Contributors:
+ * IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.optimizers;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/VersionlessArtifactKey.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/VersionlessArtifactKey.java
new file mode 100644
index 000000000..fcaf292f6
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/VersionlessArtifactKey.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.artifact.optimizers;
+
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.osgi.framework.Version;
+
+public class VersionlessArtifactKey extends ArtifactKey {
+
+ public VersionlessArtifactKey(String namespace, String classifier, String id) {
+ super(namespace, classifier, id, Version.emptyVersion);
+ }
+
+ public VersionlessArtifactKey(IArtifactKey base) {
+ super(base.getNamespace(), base.getClassifier(), base.getId(), Version.emptyVersion);
+ }
+
+ public int hashCode() {
+ int hash = getId().hashCode();
+ hash = 17 * hash + getNamespace().hashCode();
+ hash = 17 * hash + getClassifier().hashCode();
+ return hash;
+ }
+
+ public boolean equals(Object obj) {
+ if (!(obj instanceof IArtifactKey))
+ return false;
+ IArtifactKey ak = (IArtifactKey) obj;
+ return ak.getId().equals(getId()) && ak.getNamespace().equals(getNamespace()) && ak.getClassifier().equals(getClassifier());
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/Application.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/Application.java
index d16090f38..190ebccbc 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/Application.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/Application.java
@@ -4,7 +4,8 @@
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors: IBM Corporation - initial API and implementation
+ * Contributors:
+ * IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/DeltaComputer.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/DeltaComputer.java
index a176e939a..099283bd5 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/DeltaComputer.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/DeltaComputer.java
@@ -12,17 +12,18 @@ package org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta;
import java.io.*;
import java.util.*;
-import java.util.jar.*;
+import java.util.zip.*;
public class DeltaComputer {
private File target;
private File base;
private File destination;
- private JarFile baseJar;
- private JarFile targetJar;
+ private ZipFile baseJar;
+ private ZipFile targetJar;
private Set baseEntries;
private ArrayList additions;
private ArrayList changes;
+ private ZipFile manifestJar = null;
public DeltaComputer(File base, File target, File destination) {
this.base = base;
@@ -30,7 +31,7 @@ public class DeltaComputer {
this.destination = destination;
}
- public void run() {
+ public void run() throws IOException {
try {
if (!openJars())
return;
@@ -42,21 +43,24 @@ public class DeltaComputer {
}
private void writeDelta() {
- JarOutputStream result = null;
+ ZipOutputStream result = null;
try {
try {
- result = new JarOutputStream(new FileOutputStream(destination));
+ result = new ZipOutputStream(new FileOutputStream(destination));
+ // if the delta includes the manifest, be sure to write it first
+ if (manifestJar != null)
+ writeEntry(result, manifestJar.getEntry("META-INF/MANIFEST.MF"), manifestJar, true);
// write out the removals. These are all the entries left in the baseEntries
// since they were not seen in the targetJar. Here just write out an empty
// entry with a name that signals the delta processor to delete.
for (Iterator i = baseEntries.iterator(); i.hasNext();)
- writeEntry(result, new JarEntry(((String) i.next()) + ".delete"), null);
+ writeEntry(result, new ZipEntry(((String) i.next()) + ".delete"), null, false);
// write out the additions.
for (Iterator i = additions.iterator(); i.hasNext();)
- writeEntry(result, (JarEntry) i.next(), targetJar);
+ writeEntry(result, (ZipEntry) i.next(), targetJar, false);
// write out the changes.
for (Iterator i = changes.iterator(); i.hasNext();)
- writeEntry(result, (JarEntry) i.next(), targetJar);
+ writeEntry(result, (ZipEntry) i.next(), targetJar, false);
} finally {
if (result != null)
result.close();
@@ -67,7 +71,9 @@ public class DeltaComputer {
}
}
- private void writeEntry(JarOutputStream result, JarEntry entry, JarFile sourceJar) throws IOException {
+ private void writeEntry(ZipOutputStream result, ZipEntry entry, ZipFile sourceJar, boolean manifest) throws IOException {
+ if (!manifest && entry.getName().equalsIgnoreCase("META-INF/MANIFEST.MF"))
+ return;
// add the entry
result.putNextEntry(entry);
try {
@@ -109,21 +115,19 @@ public class DeltaComputer {
}
}
- private void computeDelta() {
+ private void computeDelta() throws IOException {
changes = new ArrayList();
additions = new ArrayList();
// start out assuming that all the base entries are being removed
baseEntries = getEntries(baseJar);
- for (Enumeration e = targetJar.entries(); e.hasMoreElements();) {
- JarEntry entry = (JarEntry) e.nextElement();
- check(entry);
- }
+ for (Enumeration e = targetJar.entries(); e.hasMoreElements();)
+ check((ZipEntry) e.nextElement(), targetJar);
}
private boolean openJars() {
try {
- baseJar = new JarFile(base);
- targetJar = new JarFile(target);
+ baseJar = new ZipFile(base);
+ targetJar = new ZipFile(target);
} catch (IOException e) {
return false;
}
@@ -151,9 +155,13 @@ public class DeltaComputer {
* Compare the given entry against the base JAR to see if/how it differs. Update the appropriate set
* based on the discovered difference.
* @param entry the entry to test
+ * @throws IOException
*/
- private void check(JarEntry entry) {
- JarEntry baseEntry = baseJar.getJarEntry(entry.getName());
+ private void check(ZipEntry entry, ZipFile file) throws IOException {
+ ZipEntry baseEntry = baseJar.getEntry(entry.getName());
+
+ // remember the manifest if we see it
+ checkForManifest(entry, file);
// if there is no entry then this is an addition. remember the addition and return;
if (baseEntry == null) {
additions.add(entry);
@@ -167,7 +175,7 @@ public class DeltaComputer {
}
// compare the two entries. We already know that they have the same name.
- private boolean equals(JarEntry entry, JarEntry baseEntry) {
+ private boolean equals(ZipEntry entry, ZipEntry baseEntry) {
if (entry.getSize() != baseEntry.getSize())
return false;
// make sure the entries are of the same type
@@ -180,10 +188,24 @@ public class DeltaComputer {
return true;
}
- private Set getEntries(JarFile jar) {
+ private Set getEntries(ZipFile jar) {
HashSet result = new HashSet(jar.size());
- for (Enumeration e = jar.entries(); e.hasMoreElements();)
- result.add(((JarEntry) e.nextElement()).getName());
+ for (Enumeration e = jar.entries(); e.hasMoreElements();) {
+ ZipEntry entry = (ZipEntry) e.nextElement();
+ checkForManifest(entry, jar);
+ result.add(entry.getName());
+ }
return result;
}
+
+ /**
+ * Check to see if the given entry is the manifest. If so, remember it for use when writing
+ * the resultant JAR.
+ * @param entry
+ * @param jar
+ */
+ private void checkForManifest(ZipEntry entry, ZipFile jar) {
+ if (entry.getName().equalsIgnoreCase("META-INF/MANIFEST.MF"))
+ manifestJar = jar;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/JarDeltaOptimizerStep.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/JarDeltaOptimizerStep.java
index 968bb77e9..ffb2e626a 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/JarDeltaOptimizerStep.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/JarDeltaOptimizerStep.java
@@ -1,122 +1,76 @@
/*******************************************************************************
-* Copyright (c) 2007 compeople AG and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* compeople AG (Stefan Liebig) - initial API and implementation
-* IBM - continuing development
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
*******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta;
import java.io.*;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.artifact.optimizers.AbstractDeltaStep;
import org.eclipse.equinox.internal.p2.artifact.optimizers.Activator;
-import org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff.AbstractDeltaDiffStep;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
-import org.eclipse.equinox.p2.artifact.repository.*;
+import org.eclipse.equinox.p2.artifact.repository.ArtifactDescriptor;
+import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
/**
- * The Pack200Packer expects an input containing normal ".jar" data.
+ * The JAR delta expects an input containing normal ".jar" data.
*/
-public class JarDeltaOptimizerStep extends AbstractDeltaDiffStep {
- private static final String JAR_SUFFIX = ".jar"; //$NON-NLS-1$
+public class JarDeltaOptimizerStep extends AbstractDeltaStep {
private File incoming;
- private OutputStream tempStream;
protected JarDeltaOptimizerStep(IArtifactRepository repository) {
super(repository);
}
- public void write(int b) throws IOException {
- OutputStream stream = getOutputStream();
- stream.write(b);
+ protected OutputStream createIncomingStream() throws IOException {
+ incoming = File.createTempFile(INCOMING_ROOT, JAR_SUFFIX);
+ return new BufferedOutputStream(new FileOutputStream(incoming));
}
- private OutputStream getOutputStream() throws IOException {
- if (tempStream != null)
- return tempStream;
- // store input stream in temporary file
- incoming = File.createTempFile("p2.jardelta.optimizer.incoming", JAR_SUFFIX);
- tempStream = new BufferedOutputStream(new FileOutputStream(incoming));
- return tempStream;
+ protected void cleanupTempFiles() {
+ super.cleanupTempFiles();
+ if (incoming != null)
+ incoming.delete();
}
- private void performOptimization() throws IOException {
- File predecessor = null;
+ protected void performProcessing() throws IOException {
File resultFile = null;
try {
- // get the predecessor and perform the optimization into a temp file
- predecessor = fetchPredecessor(new ArtifactDescriptor(key));
- resultFile = File.createTempFile("p2.jardelta.optimizer.result", JAR_SUFFIX);
- new DeltaComputer(predecessor, incoming, resultFile).run();
-
+ resultFile = optimize();
// now write the optimized content to the destination
if (resultFile.length() > 0) {
InputStream resultStream = new BufferedInputStream(new FileInputStream(resultFile));
FileUtils.copyStream(resultStream, true, destination, false);
} else {
- status = new Status(IStatus.ERROR, Activator.ID, "Empty optimized file: " + resultFile);
+ status = new Status(IStatus.ERROR, Activator.ID, "Empty optimized file: " + resultFile); //$NON-NLS-1$
}
} finally {
- // if we have a predecessor and it is our temp file then clean up the file
- if (predecessor != null && predecessor.getAbsolutePath().indexOf("p2.jardelta.predecessor") > -1)
- predecessor.delete();
if (resultFile != null)
resultFile.delete();
}
}
- private File fetchPredecessor(ArtifactDescriptor descriptor) {
- if (repository instanceof IFileArtifactRepository)
- return ((IFileArtifactRepository) repository).getArtifactFile(descriptor);
- File result = null;
- OutputStream resultStream = null;
- try {
- try {
- result = File.createTempFile("p2.jardelta.predecessor", JAR_SUFFIX);
- resultStream = new BufferedOutputStream(new FileOutputStream(result));
- status = repository.getArtifact(descriptor, resultStream, monitor);
- return result;
- } finally {
- if (resultStream != null)
- resultStream.close();
- }
- } catch (IOException e) {
- }
- return null;
- }
-
- public void close() throws IOException {
- // When we go to close we must have seen all the content we are going to see.
- // If no one wrote to the temp stream then there is nothing to do. Be sure to delete the
- // the temporary file if any.
- if (tempStream == null) {
- if (incoming != null)
- incoming.delete();
- return;
- }
-
- // So there is content. Close the temporary stream and perform the optimization.
- // Performing the optimization should result in the new content being written to
- // the destination. Make sure we delete the temporary file if any.
+ protected File optimize() throws IOException {
+ File predecessor = null;
try {
- tempStream.close();
- performOptimization();
+ File resultFile = File.createTempFile(RESULT_ROOT, JAR_SUFFIX);
+ // get the predecessor and perform the optimization into a temp file
+ predecessor = fetchPredecessor(new ArtifactDescriptor(key));
+ new DeltaComputer(predecessor, incoming, resultFile).run();
+ return resultFile;
} finally {
- if (incoming != null)
- incoming.delete();
+ // if we have a predecessor and it is our temp file then clean up the file
+ if (predecessor != null && predecessor.getAbsolutePath().indexOf(PREDECESSOR_ROOT) > -1)
+ predecessor.delete();
}
-
- super.close();
- // TODO need to get real status here. sometimes the optimizers do not give
- // any reasonable return status
- if (status == null)
- status = Status.OK_STATUS;
}
-
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/Optimizer.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/Optimizer.java
index a321cd804..6a89bec8a 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/Optimizer.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jardelta/Optimizer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
-* Copyright (c) 2007 compeople AG and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* compeople AG (Stefan Liebig) - initial API and implementation
-* IBM Corporation - adaptation to JAR deltas and on-going development
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - adaptation to JAR deltas and on-going development
*******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta;
@@ -15,7 +15,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff.ArtifactKeyDeSerializer;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.p2.artifact.repository.*;
import org.eclipse.equinox.p2.artifact.repository.processing.*;
@@ -163,7 +162,7 @@ public class Optimizer {
int minDepth = Math.min(depth, descriptors.length);
for (int i = 0; i < minDepth; i++) {
System.out.println("\t with jar delta against " + descriptors[i].getArtifactKey());
- String predecessorData = ArtifactKeyDeSerializer.serialize(descriptors[i].getArtifactKey());
+ String predecessorData = descriptors[i].getArtifactKey().toExternalForm();
ArtifactDescriptor newDescriptor = new ArtifactDescriptor(canonical);
ProcessingStepDescriptor patchStep = new ProcessingStepDescriptor(JAR_DELTA_PATCH_STEP, predecessorData, true);
ProcessingStepDescriptor[] steps = new ProcessingStepDescriptor[] {patchStep};
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Application.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Application.java
index 1e328d9a1..74955a1cb 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Application.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Application.java
@@ -4,7 +4,8 @@
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors: IBM Corporation - initial API and implementation
+ * Contributors:
+ * IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/ArtifactKeyDeSerializer.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/ArtifactKeyDeSerializer.java
deleted file mode 100644
index ef9f66673..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/ArtifactKeyDeSerializer.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 compeople AG and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * compeople AG (Stefan Liebig) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff;
-
-import java.util.StringTokenizer;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
-import org.osgi.framework.Version;
-
-/**
- * The <code>ArtifactKeyDeSerializer</code> encapsulates the serialization and de-serialization
- * of artifact keys into string representation and vice versa.
- * This encoding pattern is used within the processing step descriptor's data property.<p>
- * <b>Note: </b>This class is a duplicate of org.eclipse.equinox.internal.p2.artifact.processor.jbdiff.ArtifactKeyDeSerializer.
- * This has been done because this class is only relevant for the delta stuff.
- */
-public class ArtifactKeyDeSerializer {
-
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private static final String SEPARATOR = ","; //$NON-NLS-1$
-
- public static IArtifactKey deserialize(String data) {
-
- if (data == null || data.length() == 0)
- throw new IllegalArgumentException("Artifact key could not be deserialized. Null or empty. Serialized key is " + data); //$NON-NLS-1$
-
- String[] parts = new String[4];
- StringTokenizer tokenizer = new StringTokenizer(data, SEPARATOR, true);
- int i = 0;
- int sepCount = 0;
- boolean lastTokenWasSep = true;
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if (!token.equals(SEPARATOR)) {
- parts[i++] = token;
- lastTokenWasSep = false;
- continue;
- }
- sepCount++;
- if (lastTokenWasSep) {
- parts[i++] = EMPTY_STRING;
- continue;
- }
- lastTokenWasSep = true;
- }
-
- if (sepCount != 3)
- throw new IllegalArgumentException("Artifact key could not be deserialized. Unexpected number of parts. Serialized key is " + data); //$NON-NLS-1$
-
- if (i == 3)
- parts[i++] = EMPTY_STRING;
-
- try {
- return new ArtifactKey(parts[0], parts[1], parts[2], Version.parseVersion(parts[3]));
- } catch (IllegalArgumentException e) {
- throw (IllegalArgumentException) new IllegalArgumentException("Artifact key could not be deserialized. Wrong version syntay. Serialized key is " + data).initCause(e); //$NON-NLS-1$
- }
- }
-
- public static String serialize(IArtifactKey key) {
- StringBuffer data = new StringBuffer(key.getNamespace()).append(SEPARATOR);
- data.append(key.getClassifier()).append(SEPARATOR);
- data.append(key.getId()).append(SEPARATOR);
- data.append(key.getVersion().toString());
- return data.toString();
- }
-
- private static class ArtifactKey implements IArtifactKey {
-
- private final String namespace;
- private final String id;
- private final String classifier;
- private final Version version;
- private static final char SEP_CHAR = ',';
-
- protected ArtifactKey(String namespace, String classifier, String id, Version version) {
- super();
- Assert.isNotNull(namespace);
- Assert.isNotNull(classifier);
- Assert.isNotNull(id);
- Assert.isNotNull(version);
- if (namespace.indexOf(SEP_CHAR) != -1)
- throw new IllegalArgumentException("comma not allowed in namespace"); //$NON-NLS-1$
- if (classifier.indexOf(SEP_CHAR) != -1)
- throw new IllegalArgumentException("comma not allowed in classifier"); //$NON-NLS-1$
- if (id.indexOf(SEP_CHAR) != -1)
- throw new IllegalArgumentException("comma not allowed in id"); //$NON-NLS-1$
- this.namespace = namespace;
- this.classifier = classifier;
- this.id = id;
- this.version = version;
- }
-
- public String getClassifier() {
- return classifier;
- }
-
- public String getId() {
- return id;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- public Version getVersion() {
- return version;
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffStep.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffStep.java
index 05765cb05..5904b63be 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffStep.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffStep.java
@@ -1,18 +1,19 @@
/*******************************************************************************
-* Copyright (c) 2007 compeople AG and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* compeople AG (Stefan Liebig) - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
+ *******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff;
import ie.wombat.jbdiff.JBDiff;
import java.io.*;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.artifact.optimizers.AbstractDeltaStep;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.p2.artifact.repository.ArtifactDescriptor;
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
@@ -21,60 +22,40 @@ import org.eclipse.equinox.p2.sar.DirectByteArrayOutputStream;
/**
*
*/
-public class JBDiffStep extends AbstractDeltaDiffStep {
-
- protected DirectByteArrayOutputStream current;
- protected DirectByteArrayOutputStream predecessor;
-
- public JBDiffStep(IArtifactRepository repository) {
- super(repository);
- }
+public class JBDiffStep extends AbstractDeltaStep {
- public void write(int b) throws IOException {
- OutputStream stream = getOutputStream();
- stream.write(b);
+ public JBDiffStep() {
+ super();
}
- private OutputStream getOutputStream() {
- if (current != null)
- return current;
-
- current = new DirectByteArrayOutputStream();
- return current;
+ // TODO We need a different way of injecting the base artifacts. This approach forces
+ // the target and base to live in the same repo. Typical but not really required.
+ protected JBDiffStep(IArtifactRepository repository) {
+ super(repository);
}
- protected void performDiff() throws IOException {
- if (current == null)
- // hmmm, no one wrote to this stream so there is nothing to pass on
- return;
- // Ok, so there is content, close stream
- current.close();
-
- try {
- fetchPredecessor(new ArtifactDescriptor(key));
- byte[] diff = JBDiff.bsdiff(predecessor.getBuffer(), predecessor.getBufferLength(), current.getBuffer(), current.getBufferLength());
- predecessor = null;
- current = null;
- FileUtils.copyStream(new ByteArrayInputStream(diff), true, destination, false);
- } finally {
- predecessor = null;
- current = null;
- }
+ protected OutputStream createIncomingStream() throws IOException {
+ return new DirectByteArrayOutputStream();
}
- public void close() throws IOException {
- // When we go to close we must have seen all the content we are going to see
- // So before closing, run unpack and write the unpacked result to the destination
- performDiff();
- super.close();
- status = Status.OK_STATUS;
+ protected void performProcessing() throws IOException {
+ DirectByteArrayOutputStream predecessor = fetchPredecessorBytes(new ArtifactDescriptor(key));
+ DirectByteArrayOutputStream current = (DirectByteArrayOutputStream) incomingStream;
+ byte[] diff = JBDiff.bsdiff(predecessor.getBuffer(), predecessor.getBufferLength(), current.getBuffer(), current.getBufferLength());
+ // free up the memory as soon as possible.
+ predecessor = null;
+ current = null;
+ incomingStream = null;
+
+ // copy the result of the optimization to the destination.
+ FileUtils.copyStream(new ByteArrayInputStream(diff), true, destination, false);
}
- private void fetchPredecessor(ArtifactDescriptor artifactDescriptor) throws IOException {
- predecessor = new DirectByteArrayOutputStream();
- status = repository.getArtifact(artifactDescriptor, predecessor, monitor);
+ private DirectByteArrayOutputStream fetchPredecessorBytes(ArtifactDescriptor artifactDescriptor) throws IOException {
+ DirectByteArrayOutputStream result = new DirectByteArrayOutputStream();
+ status = repository.getArtifact(artifactDescriptor, result, monitor);
if (!status.isOK())
throw (IOException) new IOException(status.getMessage()).initCause(status.getException());
+ return result;
}
-
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffZipStep.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffZipStep.java
index e51c2bd65..c53339f09 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffZipStep.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffZipStep.java
@@ -1,13 +1,14 @@
/*******************************************************************************
-* Copyright (c) 2007 compeople AG and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* compeople AG (Stefan Liebig) - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
+ *******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff;
import ie.wombat.jbdiff.JBDiff;
@@ -21,41 +22,41 @@ import org.eclipse.equinox.p2.sar.SarUtil;
public class JBDiffZipStep extends JBDiffStep {
- public JBDiffZipStep(IArtifactRepository repository) {
+ public JBDiffZipStep() {
+ super();
+ }
+
+ // TODO We need a different way of injecting the base artifacts. This approach forces
+ // the target and base to live in the same repo. Typical but not really required.
+ protected JBDiffZipStep(IArtifactRepository repository) {
super(repository);
}
- protected void performDiff() throws IOException {
- if (current == null)
- // hmmm, no one wrote to this stream so there is nothing to pass on
- return;
- // Ok, so there is content, close stream
- current.close();
-
- try {
- DirectByteArrayOutputStream sarredCurrent = new DirectByteArrayOutputStream();
- SarUtil.zipToSar(current.getInputStream(), sarredCurrent);
- current = null;
- fetchPredecessor(new ArtifactDescriptor(key));
- byte[] diff = JBDiff.bsdiff(predecessor.getBuffer(), predecessor.getBufferLength(), sarredCurrent.getBuffer(), sarredCurrent.getBufferLength());
- predecessor = null;
- sarredCurrent = null;
- FileUtils.copyStream(new ByteArrayInputStream(diff), true, destination, false);
- } finally {
- predecessor = null;
- current = null;
- }
+ protected void performProcessing() throws IOException {
+ DirectByteArrayOutputStream sarredCurrent = new DirectByteArrayOutputStream();
+ SarUtil.zipToSar(((DirectByteArrayOutputStream) incomingStream).getInputStream(), sarredCurrent);
+ incomingStream = null;
+ DirectByteArrayOutputStream predecessor = fetchPredecessorBytes(new ArtifactDescriptor(key));
+ byte[] diff = JBDiff.bsdiff(predecessor.getBuffer(), predecessor.getBufferLength(), sarredCurrent.getBuffer(), sarredCurrent.getBufferLength());
+ // free up the memory as soon as possible.
+ predecessor = null;
+ incomingStream = null;
+ sarredCurrent = null;
+
+ // copy the result of the optimization to the destination.
+ FileUtils.copyStream(new ByteArrayInputStream(diff), true, destination, false);
}
- private void fetchPredecessor(ArtifactDescriptor artifactDescriptor) throws IOException {
+ private DirectByteArrayOutputStream fetchPredecessorBytes(ArtifactDescriptor artifactDescriptor) throws IOException {
DirectByteArrayOutputStream zippedPredecessor = new DirectByteArrayOutputStream();
status = repository.getArtifact(artifactDescriptor, zippedPredecessor, monitor);
if (!status.isOK())
throw (IOException) new IOException(status.getMessage()).initCause(status.getException());
- predecessor = new DirectByteArrayOutputStream();
- SarUtil.zipToSar(zippedPredecessor.getInputStream(), predecessor);
+ DirectByteArrayOutputStream result = new DirectByteArrayOutputStream();
+ SarUtil.zipToSar(zippedPredecessor.getInputStream(), result);
+ return result;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Optimizer.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Optimizer.java
index 224cc978c..eedd23545 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Optimizer.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Optimizer.java
@@ -1,19 +1,21 @@
/*******************************************************************************
-* Copyright (c) 2007 compeople AG and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* compeople AG (Stefan Liebig) - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
+ *******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.p2.artifact.optimizers.VersionlessArtifactKey;
import org.eclipse.equinox.p2.artifact.repository.*;
import org.eclipse.equinox.p2.artifact.repository.processing.*;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
@@ -135,7 +137,7 @@ public class Optimizer {
private IArtifactKey[][] getSortedRelatedArtifactKeys(IArtifactKey[] artifactKeys) {
Map map = new HashMap();
for (int i = 0; i < artifactKeys.length; i++) {
- IArtifactKey freeKey = new VersionLessArtifactKey(artifactKeys[i]);
+ IArtifactKey freeKey = new VersionlessArtifactKey(artifactKeys[i]);
List values = (List) map.get(freeKey);
if (values == null) {
values = new ArrayList();
@@ -173,7 +175,7 @@ public class Optimizer {
for (int i = 0; i < minDepth; i++) {
System.out.println("\t with " + strategy + " against " + descriptors[i].getArtifactKey());
- String predecessorData = ArtifactKeyDeSerializer.serialize(descriptors[i].getArtifactKey());
+ String predecessorData = descriptors[i].getArtifactKey().toExternalForm();
ArtifactDescriptor newDescriptor = new ArtifactDescriptor(complete);
ProcessingStepDescriptor patchStep = new ProcessingStepDescriptor(strategy, predecessorData, true);
ProcessingStepDescriptor[] steps = new ProcessingStepDescriptor[] {patchStep};
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/VersionLessArtifactKey.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/VersionLessArtifactKey.java
deleted file mode 100644
index d76e57f1e..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/VersionLessArtifactKey.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 compeople AG and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * compeople AG (Stefan Liebig) - initial API and implementation
- *******************************************************************************/
-/**
- *
- */
-package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff;
-
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
-import org.osgi.framework.Version;
-
-final class VersionLessArtifactKey implements IArtifactKey {
- private String classifier;
- private String id;
- private String namespace;
-
- public VersionLessArtifactKey(IArtifactKey copyFrom) {
- this.classifier = copyFrom.getClassifier();
- this.id = copyFrom.getId();
- this.namespace = copyFrom.getNamespace();
- }
-
- public String getClassifier() {
- return classifier;
- }
-
- public String getId() {
- return id;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- public Version getVersion() {
- return Version.emptyVersion;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((classifier == null) ? 0 : classifier.hashCode());
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof VersionLessArtifactKey))
- return false;
- final VersionLessArtifactKey other = (VersionLessArtifactKey) obj;
- if (classifier == null) {
- if (other.classifier != null)
- return false;
- } else if (!classifier.equals(other.classifier))
- return false;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (namespace == null) {
- if (other.namespace != null)
- return false;
- } else if (!namespace.equals(other.namespace))
- return false;
- return true;
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Application.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Application.java
index ed5194076..4d61b5f00 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Application.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Application.java
@@ -4,7 +4,8 @@
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors: IBM Corporation - initial API and implementation
+ * Contributors:
+ * IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.optimizers.pack200;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Optimizer.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Optimizer.java
index 15501dcc6..dfbeefb23 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Optimizer.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Optimizer.java
@@ -60,7 +60,7 @@ public class Optimizer {
// Add in all the processing steps needed to optimize (e.g., pack200, ...)
ProcessingStepHandler handler = new ProcessingStepHandler();
- OutputStream destination = handler.link(new ProcessingStep[] {new Pack200Step()}, repositoryStream, null);
+ OutputStream destination = handler.link(new ProcessingStep[] {new Pack200OptimizerStep()}, repositoryStream, null);
// Do the actual work by asking the repo to get the artifact and put it in the destination.
repository.getArtifact(descriptor, destination, new NullProgressMonitor());
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Pack200OptimizerStep.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Pack200OptimizerStep.java
new file mode 100644
index 000000000..a1a00e38b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Pack200OptimizerStep.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.artifact.optimizers.pack200;
+
+import java.io.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.artifact.optimizers.AbstractBufferingStep;
+import org.eclipse.equinox.internal.p2.artifact.optimizers.Activator;
+import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.p2.jarprocessor.JarProcessorExecutor;
+import org.eclipse.equinox.p2.jarprocessor.JarProcessorExecutor.Options;
+
+/**
+ * The Pack200Packer expects an input containing normal ".jar" data.
+ */
+public class Pack200OptimizerStep extends AbstractBufferingStep {
+ private static final String PACKED_SUFFIX = ".pack.gz"; //$NON-NLS-1$
+ private File incoming;
+
+ protected OutputStream createIncomingStream() throws IOException {
+ incoming = File.createTempFile(INCOMING_ROOT, JAR_SUFFIX);
+ return new BufferedOutputStream(new FileOutputStream(incoming));
+ }
+
+ protected void cleanupTempFiles() {
+ super.cleanupTempFiles();
+ if (incoming != null)
+ incoming.delete();
+ }
+
+ protected void performProcessing() throws IOException {
+ File resultFile = null;
+ try {
+ resultFile = process();
+ // now write the optimized content to the destination
+ if (resultFile.length() > 0) {
+ InputStream resultStream = new BufferedInputStream(new FileInputStream(resultFile));
+ FileUtils.copyStream(resultStream, true, destination, false);
+ } else {
+ status = new Status(IStatus.ERROR, Activator.ID, "Empty intermediate file: " + resultFile); //$NON-NLS-1$
+ }
+ } finally {
+ if (resultFile != null)
+ resultFile.delete();
+ }
+ }
+
+ protected File process() throws IOException {
+ // unpack
+ Options options = new Options();
+ options.pack = true;
+ // TODO use false here assuming that all content is conditioned. Need to revise this
+ options.processAll = false;
+ options.input = incoming;
+ options.outputDir = getWorkDir().getPath();
+ options.verbose = true;
+ new JarProcessorExecutor().runJarProcessor(options);
+ return new File(getWorkDir(), incoming.getName() + PACKED_SUFFIX);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Pack200Step.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Pack200Step.java
deleted file mode 100644
index cf11900c1..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/pack200/Pack200Step.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007 compeople AG and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* compeople AG (Stefan Liebig) - initial API and implementation
-* IBM - continuing development
-*******************************************************************************/
-package org.eclipse.equinox.internal.p2.artifact.optimizers.pack200;
-
-import java.io.*;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.equinox.internal.p2.artifact.optimizers.Activator;
-import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
-import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
-import org.eclipse.equinox.p2.jarprocessor.JarProcessorExecutor;
-import org.eclipse.equinox.p2.jarprocessor.JarProcessorExecutor.Options;
-
-/**
- * The Pack200Packer expects an input containing normal ".jar" data.
- */
-public class Pack200Step extends ProcessingStep {
- private static final String PACKED_SUFFIX = ".pack.gz"; //$NON-NLS-1$
- private static final String JAR_SUFFIX = ".jar"; //$NON-NLS-1$
-
- private File source;
- private OutputStream tempStream;
-
- public void write(int b) throws IOException {
- OutputStream stream = getOutputStream();
- stream.write(b);
- }
-
- private OutputStream getOutputStream() throws IOException {
- if (tempStream != null)
- return tempStream;
- // store input stream in temporary file
- source = File.createTempFile("p2.pack200", JAR_SUFFIX);
- tempStream = new BufferedOutputStream(new FileOutputStream(source));
- return tempStream;
- }
-
- private void performPack() throws IOException {
- BufferedInputStream resultStream = null;
- File resultFile = null;
- File workDir = null;
- try {
- if (tempStream == null)
- // hmmm, no one wrote to this stream so there is nothing to pass on
- return;
- // Ok, so there is content, close the tempStream
- tempStream.close();
- // now create a temporary directory for the JarProcessor to work in
- // TODO How to create a unique, temporary directory atomically?
- workDir = File.createTempFile("p2.pack200.", "");
- if (!workDir.delete())
- throw new IOException("Could not delete file for creating temporary working dir.");
- if (!workDir.mkdirs())
- throw new IOException("Could not create temporary working dir.");
-
- // unpack
- Options options = new Options();
- options.pack = true;
- // TODO use false here assuming that all content is conditioned. Need to revise this
- options.processAll = false;
- options.input = source;
- options.outputDir = workDir.getPath();
- options.verbose = true;
- new JarProcessorExecutor().runJarProcessor(options);
-
- // now write the packed content to our destination
- resultFile = new File(workDir, source.getName() + PACKED_SUFFIX);
- if (resultFile.length() > 0) {
- resultStream = new BufferedInputStream(new FileInputStream(resultFile));
- FileUtils.copyStream(resultStream, true, destination, false);
- } else {
- status = new Status(IStatus.ERROR, Activator.ID, "Empty file packed: " + resultFile);
- }
- } finally {
- if (source != null)
- source.delete();
- if (resultFile != null)
- resultFile.delete();
- if (workDir != null) {
- FileUtils.deleteAll(workDir);
- // TODO try twice since there seems to be some cases where the dir is not
- // deleted the first time. At least on Windows...
- FileUtils.deleteAll(workDir);
- }
- }
- }
-
- public void close() throws IOException {
- // When we go to close we must have seen all the content we are going to see
- // So before closing, run unpack and write the unpacked result to the destination
- performPack();
- super.close();
- // TODO need to get real status here but curently the JAR processor does not give
- // any reasonable return status
- if (status == null)
- status = Status.OK_STATUS;
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.processors/META-INF/MANIFEST.MF
index f7f3df000..b60a5af18 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/META-INF/MANIFEST.MF
@@ -10,8 +10,10 @@ Require-Bundle: org.eclipse.equinox.common,
org.eclipse.equinox.registry,
org.eclipse.osgi
Import-Package: ie.wombat.jbdiff,
+ org.eclipse.equinox.internal.p2.artifact.optimizers,
org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.internal.p2.jarprocessor,
+ org.eclipse.equinox.internal.p2.metadata,
org.eclipse.equinox.p2.artifact.repository,
org.eclipse.equinox.p2.artifact.repository.processing,
org.eclipse.equinox.p2.core.repository,
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/plugin.xml b/bundles/org.eclipse.equinox.p2.artifact.processors/plugin.xml
index 842276102..d80e2d3ad 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/plugin.xml
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/plugin.xml
@@ -4,7 +4,7 @@
<extension
point="org.eclipse.equinox.p2.artifact.repository.processingSteps"
id="org.eclipse.equinox.p2.processing.Pack200Unpacker">
- <step class="org.eclipse.equinox.internal.p2.artifact.processors.pack200.Unpack200Step"/>
+ <step class="org.eclipse.equinox.internal.p2.artifact.processors.pack200.Pack200ProcessorStep"/>
</extension>
<extension
point="org.eclipse.equinox.p2.artifact.repository.processingSteps"
@@ -23,7 +23,7 @@
</extension>
<extension
point="org.eclipse.equinox.p2.artifact.repository.processingSteps"
- id="MD5Verifier">
+ id="org.eclipse.equinox.p2.processing.MD5Verifier">
<step class="org.eclipse.equinox.internal.p2.artifact.processors.verifier.MD5Verifier"/>
</extension>
</plugin>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/AbstractDeltaPatchStep.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java
index 2cc3e3369..8f0087692 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/AbstractDeltaPatchStep.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java
@@ -7,58 +7,38 @@
*
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
*******************************************************************************/
-package org.eclipse.equinox.internal.p2.artifact.processors.jbdiff;
+package org.eclipse.equinox.internal.p2.artifact.processors;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.equinox.internal.p2.artifact.processors.Activator;
+import org.eclipse.equinox.internal.p2.artifact.optimizers.AbstractDeltaStep;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.p2.artifact.repository.*;
-import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor;
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
/**
* The <code>AbstractDeltaPatchStep</code> is an abstract processing step that
* retrieves a local artifact repository containing the serialized/encoded
* artifact key. It assumes that the artifact key is stored within the data property
- * of the processing step descriptor and that is encoded with the <code>ArtifactKeyDeserializerXXX</code>.
+ * of the processing step descriptor encoding the artifact key of the base artifact.
*/
-public abstract class AbstractDeltaPatchStep extends ProcessingStep {
+public abstract class AbstractDeltaProcessorStep extends AbstractDeltaStep {
- protected IArtifactKey key;
- protected IArtifactRepository repository;
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep#initialize(org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor, org.eclipse.equinox.p2.artifact.repository.IArtifactDescriptor)
- */
public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
super.initialize(descriptor, context);
-
- fetchArtifactKey(descriptor);
if (!status.isOK())
return;
-
fetchLocalArtifactRepository();
}
/**
- * Fetch the artifact key from the given processing step descriptor.
- * @param descriptor
- */
- private void fetchArtifactKey(ProcessingStepDescriptor descriptor) {
- try {
- key = ArtifactKeyDeSerializer.deserialize(descriptor.getData());
- } catch (IllegalArgumentException e) {
- status = new Status(IStatus.ERROR, Activator.ID, "Predecessor artifact key for delta could not be deserialized. Serialized key is " + descriptor.getData(), e);
- }
- }
-
- /**
* Fetch a local artifact repository containing the fetched artifact key.
*/
private void fetchLocalArtifactRepository() {
+ if (repository != null)
+ return;
IArtifactRepositoryManager repoMgr = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
if (repoMgr == null) {
status = new Status(IStatus.ERROR, Activator.ID, "Could not get artifact repository manager.");
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/Activator.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/Activator.java
index 1b5854b01..9de6886df 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/Activator.java
@@ -4,7 +4,8 @@
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors: IBM Corporation - initial API and implementation
+ * Contributors:
+ * IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.processors;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jardelta/DeltaApplier.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jardelta/DeltaApplier.java
index 5239807a1..d5f4d16f2 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jardelta/DeltaApplier.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jardelta/DeltaApplier.java
@@ -12,16 +12,18 @@ package org.eclipse.equinox.internal.p2.artifact.processors.jardelta;
import java.io.*;
import java.util.*;
-import java.util.jar.*;
+import java.util.zip.*;
public class DeltaApplier {
private static final String DELETE_SUFFIX = ".delete"; //$NON-NLS-1$
+ private static final String MANIFEST_ENTRY_NAME = "META-INF/MANIFEST.MF"; //$NON-NLS-1$
private File delta;
private File base;
private File destination;
- private JarFile baseJar;
- private JarFile deltaJar;
+ private ZipFile baseJar;
+ private ZipFile deltaJar;
private Set baseEntries;
+ private ZipFile manifestJar;
public DeltaApplier(File base, File delta, File destination) {
this.base = base;
@@ -45,29 +47,37 @@ public class DeltaApplier {
baseEntries = getEntries(baseJar);
// remove from the base all the entries that appear in the delta
for (Enumeration e = deltaJar.entries(); e.hasMoreElements();) {
- JarEntry entry = ((JarEntry) e.nextElement());
+ ZipEntry entry = ((ZipEntry) e.nextElement());
+ checkForManifest(entry, deltaJar);
String name = entry.getName();
- if (name.endsWith(DELETE_SUFFIX))
+ if (name.endsWith(DELETE_SUFFIX)) {
name = name.substring(0, name.length() - DELETE_SUFFIX.length());
+ // if the manifest is being deleted, forget anyone who might have a manifest
+ if (name.equalsIgnoreCase(MANIFEST_ENTRY_NAME))
+ manifestJar = null;
+ }
baseEntries.remove(name);
}
}
private void writeResult() {
- JarOutputStream result = null;
+ ZipOutputStream result = null;
try {
try {
- result = new JarOutputStream(new FileOutputStream(destination));
+ result = new ZipOutputStream(new FileOutputStream(destination));
+ // if the delta includes the manifest, be sure to write it first
+ if (manifestJar != null)
+ writeEntry(result, manifestJar.getEntry(MANIFEST_ENTRY_NAME), manifestJar, true);
// write out the things we know are staying from the base JAR
for (Iterator i = baseEntries.iterator(); i.hasNext();) {
- JarEntry entry = baseJar.getJarEntry((String) i.next());
- writeEntry(result, entry, baseJar);
+ ZipEntry entry = baseJar.getEntry((String) i.next());
+ writeEntry(result, entry, baseJar, false);
}
// write out the changes/additions from the delta.
for (Enumeration e = deltaJar.entries(); e.hasMoreElements();) {
- JarEntry entry = (JarEntry) e.nextElement();
+ ZipEntry entry = (ZipEntry) e.nextElement();
if (!entry.getName().endsWith(DELETE_SUFFIX))
- writeEntry(result, entry, deltaJar);
+ writeEntry(result, entry, deltaJar, false);
}
} finally {
if (result != null)
@@ -79,7 +89,9 @@ public class DeltaApplier {
}
}
- private void writeEntry(JarOutputStream result, JarEntry entry, JarFile sourceJar) throws IOException {
+ private void writeEntry(ZipOutputStream result, ZipEntry entry, ZipFile sourceJar, boolean manifest) throws IOException {
+ if (!manifest && entry.getName().equalsIgnoreCase(MANIFEST_ENTRY_NAME))
+ return;
// add the entry
result.putNextEntry(entry);
try {
@@ -123,8 +135,8 @@ public class DeltaApplier {
private boolean openJars() {
try {
- baseJar = new JarFile(base);
- deltaJar = new JarFile(delta);
+ baseJar = new ZipFile(base);
+ deltaJar = new ZipFile(delta);
} catch (IOException e) {
return false;
}
@@ -148,10 +160,25 @@ public class DeltaApplier {
}
}
- private Set getEntries(JarFile jar) {
+ private Set getEntries(ZipFile jar) {
HashSet result = new HashSet(jar.size());
- for (Enumeration e = jar.entries(); e.hasMoreElements();)
- result.add(((JarEntry) e.nextElement()).getName());
+ for (Enumeration e = jar.entries(); e.hasMoreElements();) {
+ ZipEntry entry = (ZipEntry) e.nextElement();
+ checkForManifest(entry, jar);
+ result.add(entry.getName());
+ }
return result;
}
+
+ /**
+ * Check to see if the given entry is the manifest. If so, remember it for use when writing
+ * the resultant JAR.
+ * @param entry
+ * @param jar
+ */
+ private void checkForManifest(ZipEntry entry, ZipFile jar) {
+ if (entry.getName().equalsIgnoreCase(MANIFEST_ENTRY_NAME))
+ manifestJar = jar;
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jardelta/JarDeltaProcessorStep.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jardelta/JarDeltaProcessorStep.java
index 8e97b668e..e9e6fed37 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jardelta/JarDeltaProcessorStep.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jardelta/JarDeltaProcessorStep.java
@@ -1,116 +1,74 @@
/*******************************************************************************
-* Copyright (c) 2007 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* IBM Corporation - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.processors.jardelta;
import java.io.*;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.artifact.processors.AbstractDeltaProcessorStep;
import org.eclipse.equinox.internal.p2.artifact.processors.Activator;
-import org.eclipse.equinox.internal.p2.artifact.processors.jbdiff.AbstractDeltaPatchStep;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.p2.artifact.repository.ArtifactDescriptor;
-import org.eclipse.equinox.p2.artifact.repository.IFileArtifactRepository;
/**
* Processor that takes a JAR delta and applies it.
*/
-public class JarDeltaProcessorStep extends AbstractDeltaPatchStep {
- private static final String JAR_SUFFIX = ".jar"; //$NON-NLS-1$
+public class JarDeltaProcessorStep extends AbstractDeltaProcessorStep {
private File incoming;
- private OutputStream tempStream;
- public void write(int b) throws IOException {
- OutputStream stream = getOutputStream();
- stream.write(b);
+ public JarDeltaProcessorStep() {
+ super();
}
- private OutputStream getOutputStream() throws IOException {
- if (tempStream != null)
- return tempStream;
- // store input stream in temporary file
- incoming = File.createTempFile("p2.jardelta.processor.incoming", JAR_SUFFIX);
- tempStream = new BufferedOutputStream(new FileOutputStream(incoming));
- return tempStream;
+ protected OutputStream createIncomingStream() throws IOException {
+ incoming = File.createTempFile(INCOMING_ROOT, JAR_SUFFIX);
+ return new BufferedOutputStream(new FileOutputStream(incoming));
}
- public void close() throws IOException {
- // When we go to close we must have seen all the content we are going to see.
- // If no one wrote to the temp stream then there is nothing to do. Be sure to delete the
- // the temporary file if any.
- if (tempStream == null) {
- if (incoming != null)
- incoming.delete();
- return;
- }
-
- // So there is content. Close the temporary stream and perform the optimization.
- // Performing the optimization should result in the new content being written to
- // the destination. Make sure we delete the temporary file if any.
- try {
- tempStream.close();
- performPatch();
- } finally {
- if (incoming != null)
- incoming.delete();
- }
-
- super.close();
- // TODO need to get real status here. sometimes the optimizers do not give
- // any reasonable return status
- if (status == null)
- status = Status.OK_STATUS;
+ protected void cleanupTempFiles() {
+ super.cleanupTempFiles();
+ if (incoming != null)
+ incoming.delete();
}
- private void performPatch() throws IOException {
- File predecessor = null;
+ protected void performProcessing() throws IOException {
File resultFile = null;
try {
- // get the predecessor and perform the optimization into a temp file
- predecessor = fetchPredecessor(new ArtifactDescriptor(key));
- resultFile = File.createTempFile("p2.jardelta.processor.result", JAR_SUFFIX);
- new DeltaApplier(predecessor, incoming, resultFile).run();
-
+ resultFile = process();
// now write the optimized content to the destination
if (resultFile.length() > 0) {
InputStream resultStream = new BufferedInputStream(new FileInputStream(resultFile));
FileUtils.copyStream(resultStream, true, destination, false);
} else {
- status = new Status(IStatus.ERROR, Activator.ID, "Empty optimized file: " + resultFile);
+ status = new Status(IStatus.ERROR, Activator.ID, "Empty optimized file: " + resultFile); //$NON-NLS-1$
}
} finally {
- if (predecessor != null)
- predecessor.delete();
if (resultFile != null)
resultFile.delete();
}
}
- private File fetchPredecessor(ArtifactDescriptor descriptor) {
- if (repository instanceof IFileArtifactRepository)
- return ((IFileArtifactRepository) repository).getArtifactFile(descriptor);
- File result = null;
- OutputStream resultStream = null;
+ protected File process() throws IOException {
+ File predecessor = null;
try {
- try {
- result = File.createTempFile("p2.jardelta.predecessor", JAR_SUFFIX);
- resultStream = new BufferedOutputStream(new FileOutputStream(result));
- status = repository.getArtifact(descriptor, resultStream, monitor);
- return result;
- } finally {
- if (resultStream != null)
- resultStream.close();
- }
- } catch (IOException e) {
+ File resultFile = File.createTempFile(RESULT_ROOT, JAR_SUFFIX);
+ // get the predecessor and perform the optimization into a temp file
+ predecessor = fetchPredecessor(new ArtifactDescriptor(key));
+ new DeltaApplier(predecessor, incoming, resultFile).run();
+ return resultFile;
+ } finally {
+ // if we have a predecessor and it is our temp file then clean up the file
+ if (predecessor != null && predecessor.getAbsolutePath().indexOf(PREDECESSOR_ROOT) > -1)
+ predecessor.delete();
}
- return null;
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/ArtifactKeyDeSerializer.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/ArtifactKeyDeSerializer.java
deleted file mode 100644
index 7aead57b2..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/ArtifactKeyDeSerializer.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 compeople AG and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * compeople AG (Stefan Liebig) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.artifact.processors.jbdiff;
-
-import java.util.StringTokenizer;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
-import org.osgi.framework.Version;
-
-/**
- * The <code>ArtifactKeyDeSerializer</code> encapsulates the serialization and de-serialization
- * of artifact keys into string representation and vice versa.
- * This encoding pattern is used within the processing step descriptor´s data property.<p>
- * <b>Note: </b>This class is a duplicate of org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff.ArtifactKeyDeSerializer.
- * This has been done because this class is only relevant for the delta stuff.
- */
-public class ArtifactKeyDeSerializer {
-
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private static final String SEPARATOR = ","; //$NON-NLS-1$
-
- public static IArtifactKey deserialize(String data) {
-
- if (data == null || data.length() == 0)
- throw new IllegalArgumentException("Artifact key could not be deserialized. Null or empty. Serialized key is " + data); //$NON-NLS-1$
-
- String[] parts = new String[4];
- StringTokenizer tokenizer = new StringTokenizer(data, SEPARATOR, true);
- int i = 0;
- int sepCount = 0;
- boolean lastTokenWasSep = true;
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if (!token.equals(SEPARATOR)) {
- parts[i++] = token;
- lastTokenWasSep = false;
- continue;
- }
- sepCount++;
- if (lastTokenWasSep) {
- parts[i++] = EMPTY_STRING;
- continue;
- }
- lastTokenWasSep = true;
- }
-
- if (sepCount != 3)
- throw new IllegalArgumentException("Artifact key could not be deserialized. Unexpected number of parts. Serialized key is " + data); //$NON-NLS-1$
-
- if (i == 3)
- parts[i++] = EMPTY_STRING;
-
- try {
- return new ArtifactKey(parts[0], parts[1], parts[2], Version.parseVersion(parts[3]));
- } catch (IllegalArgumentException e) {
- throw (IllegalArgumentException) new IllegalArgumentException("Artifact key could not be deserialized. Wrong version syntay. Serialized key is " + data).initCause(e); //$NON-NLS-1$
- }
- }
-
- public static String serialize(IArtifactKey key) {
- StringBuffer data = new StringBuffer(key.getNamespace()).append(SEPARATOR);
- data.append(key.getClassifier()).append(SEPARATOR);
- data.append(key.getId()).append(SEPARATOR);
- data.append(key.getVersion().toString());
- return data.toString();
- }
-
- private static class ArtifactKey implements IArtifactKey {
-
- private final String namespace;
- private final String id;
- private final String classifier;
- private final Version version;
- private static final char SEP_CHAR = ',';
-
- protected ArtifactKey(String namespace, String classifier, String id, Version version) {
- super();
- Assert.isNotNull(namespace);
- Assert.isNotNull(classifier);
- Assert.isNotNull(id);
- Assert.isNotNull(version);
- if (namespace.indexOf(SEP_CHAR) != -1)
- throw new IllegalArgumentException("comma not allowed in namespace"); //$NON-NLS-1$
- if (classifier.indexOf(SEP_CHAR) != -1)
- throw new IllegalArgumentException("comma not allowed in classifier"); //$NON-NLS-1$
- if (id.indexOf(SEP_CHAR) != -1)
- throw new IllegalArgumentException("comma not allowed in id"); //$NON-NLS-1$
- this.namespace = namespace;
- this.classifier = classifier;
- this.id = id;
- this.version = version;
- }
-
- public String getClassifier() {
- return classifier;
- }
-
- public String getId() {
- return id;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- public Version getVersion() {
- return version;
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchStep.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchStep.java
index 01423773b..c5d526217 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchStep.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchStep.java
@@ -7,12 +7,13 @@
*
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
*******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.processors.jbdiff;
import ie.wombat.jbdiff.JBPatch;
import java.io.*;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.artifact.processors.AbstractDeltaProcessorStep;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.p2.artifact.repository.ArtifactDescriptor;
import org.eclipse.equinox.p2.sar.DirectByteArrayOutputStream;
@@ -20,55 +21,34 @@ import org.eclipse.equinox.p2.sar.DirectByteArrayOutputStream;
/**
* The JBPatchStep patches a JBDiff based data.
*/
-public class JBPatchStep extends AbstractDeltaPatchStep {
+public class JBPatchStep extends AbstractDeltaProcessorStep {
- protected DirectByteArrayOutputStream diff;
- protected DirectByteArrayOutputStream predecessor;
-
- public void write(int b) throws IOException {
- OutputStream stream = getOutputStream();
- stream.write(b);
+ public JBPatchStep() {
+ super();
}
- private OutputStream getOutputStream() {
- if (diff != null)
- return diff;
- diff = new DirectByteArrayOutputStream();
- return diff;
+ protected OutputStream createIncomingStream() throws IOException {
+ return new DirectByteArrayOutputStream();
}
- public void close() throws IOException {
- // When we go to close we must have seen all the content we are going to see
- // So before closing, run patch and write the patched result to the destination
- performPatch();
- super.close();
- status = Status.OK_STATUS;
+ protected void performProcessing() throws IOException {
+ DirectByteArrayOutputStream predecessor = fetchPredecessorBytes(new ArtifactDescriptor(key));
+ DirectByteArrayOutputStream current = (DirectByteArrayOutputStream) incomingStream;
+ byte[] result = JBPatch.bspatch(predecessor.getBuffer(), predecessor.getBufferLength(), current.getBuffer(), current.getBufferLength());
+ // free up the memory as soon as possible.
+ predecessor = null;
+ current = null;
+ incomingStream = null;
+
+ // copy the result of the optimization to the destination.
+ FileUtils.copyStream(new ByteArrayInputStream(result), true, destination, false);
}
- protected void performPatch() throws IOException {
- if (diff == null)
- // hmmm, no one wrote to this stream so there is nothing to pass on
- return;
- // Ok, so there is content, close the diff
- diff.close();
-
- try {
- fetchPredecessor(new ArtifactDescriptor(key));
- byte[] result = JBPatch.bspatch(predecessor.getBuffer(), predecessor.getBufferLength(), diff.getBuffer(), diff.getBufferLength());
- diff = null;
- predecessor = null;
- FileUtils.copyStream(new ByteArrayInputStream(result), true, destination, false);
- } finally {
- diff = null;
- predecessor = null;
- }
- }
-
- private void fetchPredecessor(ArtifactDescriptor artifactDescriptor) throws IOException {
- predecessor = new DirectByteArrayOutputStream();
- status = repository.getArtifact(artifactDescriptor, predecessor, monitor);
+ private DirectByteArrayOutputStream fetchPredecessorBytes(ArtifactDescriptor artifactDescriptor) throws IOException {
+ DirectByteArrayOutputStream result = new DirectByteArrayOutputStream();
+ status = repository.getArtifact(artifactDescriptor, result, monitor);
if (!status.isOK())
throw (IOException) new IOException(status.getMessage()).initCause(status.getException());
+ return result;
}
-
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchZipStep.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchZipStep.java
index 7c5bc0cab..0f2865b6a 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchZipStep.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchZipStep.java
@@ -7,6 +7,7 @@
*
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
*******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.processors.jbdiff;
@@ -22,35 +23,32 @@ import org.eclipse.equinox.p2.sar.SarUtil;
*/
public class JBPatchZipStep extends JBPatchStep {
- protected void performPatch() throws IOException {
-
- if (diff == null)
- // hmmm, no one wrote to this stream so there is nothing to pass on
- return;
- // Ok, so there is content, close the diff
- diff.close();
-
- try {
- fetchPredecessor(new ArtifactDescriptor(key));
- byte[] result = JBPatch.bspatch(predecessor.getBuffer(), predecessor.getBufferLength(), diff.getBuffer(), diff.getBufferLength());
- diff = null;
- predecessor = null;
- SarUtil.sarToZip(new ByteArrayInputStream(result), true, destination, false);
- } finally {
- diff = null;
- predecessor = null;
- }
+ public JBPatchZipStep() {
+ super();
}
- private void fetchPredecessor(ArtifactDescriptor artifactDescriptor) throws IOException {
- DirectByteArrayOutputStream zippedPredecessor = new DirectByteArrayOutputStream();
+ protected void performProcessing() throws IOException {
+ DirectByteArrayOutputStream predecessor = fetchPredecessorBytes(new ArtifactDescriptor(key));
+ DirectByteArrayOutputStream current = (DirectByteArrayOutputStream) incomingStream;
+ byte[] result = JBPatch.bspatch(predecessor.getBuffer(), predecessor.getBufferLength(), current.getBuffer(), current.getBufferLength());
+ // free up the memory as soon as possible.
+ predecessor = null;
+ current = null;
+ incomingStream = null;
+
+ // copy the result of the optimization to the destination.
+ SarUtil.sarToZip(new ByteArrayInputStream(result), true, destination, false);
+ }
+ private DirectByteArrayOutputStream fetchPredecessorBytes(ArtifactDescriptor artifactDescriptor) throws IOException {
+ DirectByteArrayOutputStream zippedPredecessor = new DirectByteArrayOutputStream();
status = repository.getArtifact(artifactDescriptor, zippedPredecessor, monitor);
if (!status.isOK())
throw (IOException) new IOException(status.getMessage()).initCause(status.getException());
- predecessor = new DirectByteArrayOutputStream();
- SarUtil.zipToSar(zippedPredecessor.getInputStream(), predecessor);
+ DirectByteArrayOutputStream result = new DirectByteArrayOutputStream();
+ SarUtil.zipToSar(zippedPredecessor.getInputStream(), result);
+ return result;
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/pack200/Pack200ProcessorStep.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/pack200/Pack200ProcessorStep.java
new file mode 100644
index 000000000..3402cf240
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/pack200/Pack200ProcessorStep.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.artifact.processors.pack200;
+ import java.io.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.artifact.optimizers.AbstractBufferingStep;
+import org.eclipse.equinox.internal.p2.artifact.processors.Activator;
+import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.internal.p2.jarprocessor.UnpackStep;
+import org.eclipse.equinox.p2.artifact.repository.IArtifactDescriptor;
+import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor;
+import org.eclipse.equinox.p2.jarprocessor.JarProcessorExecutor;
+import org.eclipse.equinox.p2.jarprocessor.JarProcessorExecutor.Options;
+
+
+/**
+ * The Pack200Unpacker expects an input containing ".jar.pack.gz" data.
+ */
+public class Pack200ProcessorStep extends AbstractBufferingStep {
+ public static final String PACKED_SUFFIX = ".pack.gz"; //$NON-NLS-1$
+
+ private File incoming;
+
+ protected OutputStream createIncomingStream() throws IOException {
+ incoming = File.createTempFile(INCOMING_ROOT, JAR_SUFFIX + PACKED_SUFFIX);
+ return new BufferedOutputStream(new FileOutputStream(incoming));
+ }
+
+ public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
+ super.initialize(descriptor, context);
+ if (!UnpackStep.canUnpack())
+ status = new Status(IStatus.ERROR, Activator.ID, "Unpack facility not configured"); //$NON-NLS-1$
+ }
+
+ protected void cleanupTempFiles() {
+ super.cleanupTempFiles();
+ if (incoming != null)
+ incoming.delete();
+ }
+
+ protected void performProcessing() throws IOException {
+ File resultFile = null;
+ try {
+ resultFile = process();
+ // now write the processed content to the destination
+ if (resultFile.length() > 0) {
+ InputStream resultStream = new BufferedInputStream(new FileInputStream(resultFile));
+ FileUtils.copyStream(resultStream, true, destination, false);
+ } else {
+ status = new Status(IStatus.ERROR, Activator.ID, "Empty intermediate file: " + resultFile); //$NON-NLS-1$
+ }
+ } finally {
+ if (resultFile != null)
+ resultFile.delete();
+ }
+ }
+
+ protected File process() throws IOException {
+ Options options = new Options();
+ options.unpack = true;
+ // TODO use false here assuming that all content is conditioned. Need to revise this
+ options.processAll = false;
+ options.input = incoming;
+ options.outputDir = getWorkDir().getPath();
+ options.verbose = true;
+ new JarProcessorExecutor().runJarProcessor(options);
+ return new File(getWorkDir(), incoming.getName().substring(0, incoming.getName().length() - PACKED_SUFFIX.length()));
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/pack200/Unpack200Step.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/pack200/Unpack200Step.java
deleted file mode 100644
index c79d78d48..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/pack200/Unpack200Step.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007 compeople AG and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* compeople AG (Stefan Liebig) - initial API and implementation
-* IBM - continuing development
-*******************************************************************************/
-package org.eclipse.equinox.internal.p2.artifact.processors.pack200;
-
-import java.io.*;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
-import org.eclipse.equinox.internal.p2.jarprocessor.UnpackStep;
-import org.eclipse.equinox.p2.artifact.repository.IArtifactDescriptor;
-import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
-import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor;
-import org.eclipse.equinox.p2.jarprocessor.JarProcessorExecutor;
-import org.eclipse.equinox.p2.jarprocessor.JarProcessorExecutor.Options;
-
-/**
- * The Pack200Unpacker expects an input containing ".jar.pack.gz" data.
- */
-public class Unpack200Step extends ProcessingStep {
- public static final String ID = "org.eclipse.equinox.p2.artifact.processor.pack200"; //$NON-NLS-1$
- public static final String JAR_SUFFIX = ".jar"; //$NON-NLS-1$
- public static final String PACKED_SUFFIX = ".pack.gz"; //$NON-NLS-1$
- private final static String PACKED_EXT = JAR_SUFFIX + PACKED_SUFFIX;
-
- private File packed;
- private OutputStream tempStream;
-
- public void close() throws IOException {
- // When we go to close we must have seen all the content we are going to see
- // So before closing, run unpack and write the unpacked result to the destination
- performUnpack();
- super.close();
- if (status == null)
- status = Status.OK_STATUS;
- }
-
- private OutputStream getOutputStream() throws IOException {
- if (tempStream != null)
- return tempStream;
- // store input stream in temporary file
- packed = File.createTempFile("p2.pack200", PACKED_EXT);
- tempStream = new BufferedOutputStream(new FileOutputStream(packed));
- return tempStream;
- }
-
- public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
- super.initialize(descriptor, context);
- if (!UnpackStep.canUnpack())
- status = new Status(IStatus.ERROR, ID, "Unpack facility not configured");
- }
-
- private void performUnpack() throws IOException {
- BufferedInputStream unpackedStream = null;
- File unpacked = null;
- File workDir = null;
- try {
- if (tempStream == null)
- // hmmm, no one wrote to this stream so there is nothing to pass on
- return;
- // Ok, so there is content, close the tempStream
- tempStream.close();
- // now create a temporary directory for the JarProcessor to work in
- // TODO How to create a unique, temporary directory atomically?
- workDir = File.createTempFile("p2.unpack.", "");
- if (!workDir.delete())
- throw new IOException("Could not delete file for creating temporary working dir.");
- if (!workDir.mkdirs())
- throw new IOException("Could not create temporary working dir.");
-
- // unpack
- Options options = new Options();
- options.unpack = true;
- options.processAll = true;
- options.input = packed;
- options.outputDir = workDir.getPath();
- new JarProcessorExecutor().runJarProcessor(options);
-
- // now write the unpacked content to our destination
- String packedFileName = packed.getName();
- unpacked = new File(workDir, packedFileName.substring(0, packedFileName.length() - PACKED_SUFFIX.length()));
- if (unpacked.length() == 0)
- System.out.println("Empty file unpacked: " + unpacked);
- unpackedStream = new BufferedInputStream(new FileInputStream(unpacked));
- FileUtils.copyStream(unpackedStream, true, destination, false);
- } finally {
- // note that unpackedStream will be closed by copyStream()
- if (packed != null)
- packed.delete();
- if (unpacked != null)
- unpacked.delete();
- if (workDir != null)
- FileUtils.deleteAll(workDir);
- }
- }
-
- public void write(int b) throws IOException {
- OutputStream stream = getOutputStream();
- stream.write(b);
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/verifier/MD5Verifier.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/verifier/MD5Verifier.java
index f098c4bb0..4559d6d9b 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/verifier/MD5Verifier.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/verifier/MD5Verifier.java
@@ -1,14 +1,14 @@
/*******************************************************************************
-* Copyright (c) 2007 compeople AG and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* compeople AG (Stefan Liebig) - initial API and implementation
-* IBM - continuing development
-*******************************************************************************/
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
+ *******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.processors.verifier;
import java.io.IOException;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF
index 2f6c463b0..8675af3f1 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF
@@ -5,7 +5,7 @@ Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-Version: 0.1.0.qualifier
-Export-Package: org.eclipse.equinox.internal.p2.metadata;x-friends:="org.eclipse.equinox.p2.metadata.generator,org.eclipse.equinox.p2.metadata.repository,org.eclipse.equinox.p2.engine,org.eclipse.equinox.p2.artifact.repository,org.eclipse.equinox.p2.artifact.optimizers",
+Export-Package: org.eclipse.equinox.internal.p2.metadata;x-friends:="org.eclipse.equinox.p2.metadata.generator,org.eclipse.equinox.p2.metadata.repository,org.eclipse.equinox.p2.engine,org.eclipse.equinox.p2.artifact.repository,org.eclipse.equinox.p2.artifact.optimizers,org.eclipse.equinox.p2.artifact.processors",
org.eclipse.equinox.p2.metadata,
org.eclipse.equinox.p2.query,
org.eclipse.equinox.p2.resolution
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java
index f34182859..b88c4b41f 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ArtifactKey.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.osgi.framework.Version;
@@ -20,24 +22,61 @@ import org.osgi.framework.Version;
* See {link IArtifact for a description of the lifecycle of artifact keys)
*/
public class ArtifactKey implements IArtifactKey {
- private static final char SEP_CHAR = ',';
+ private static final String SEPARATOR = ","; //$NON-NLS-1$
private final String namespace;
private final String id;
private final String classifier;
private final Version version;
+ private static String[] getArrayFromList(String stringList, String separator) {
+ if (stringList == null || stringList.trim().length() == 0)
+ return new String[0];
+ ArrayList list = new ArrayList();
+ boolean separatorSeen = true;
+ StringTokenizer tokens = new StringTokenizer(stringList, separator, true);
+ while (tokens.hasMoreTokens()) {
+ String token = tokens.nextToken().trim();
+ if (token.equals(separator)) {
+ if (separatorSeen)
+ list.add("");
+ separatorSeen = true;
+ } else {
+ separatorSeen = false;
+ if (token.length() != 0)
+ list.add(token);
+ }
+ }
+ if (separatorSeen)
+ list.add(""); //$NON-NLS-1$
+ return (String[]) list.toArray(new String[list.size()]);
+ }
+
+ public static IArtifactKey parse(String specification) {
+ String[] parts = getArrayFromList(specification, SEPARATOR);
+ if (parts.length < 3 || parts.length > 4)
+ throw new IllegalArgumentException("Unexpected number of parts in artifact key: " + specification); //$NON-NLS-1$
+ Version version = Version.emptyVersion;
+ if (parts.length == 4 && parts[3].trim().length() > 0)
+ version = Version.parseVersion(parts[3]);
+ try {
+ return new ArtifactKey(parts[0], parts[1], parts[2], version);
+ } catch (IllegalArgumentException e) {
+ throw (IllegalArgumentException) new IllegalArgumentException("Wrong version syntax in artifact key: " + specification).initCause(e); //$NON-NLS-1$
+ }
+ }
+
public ArtifactKey(String namespace, String classifier, String id, Version version) {
super();
Assert.isNotNull(namespace);
Assert.isNotNull(classifier);
Assert.isNotNull(id);
Assert.isNotNull(version);
- if (namespace.indexOf(SEP_CHAR) != -1)
+ if (namespace.indexOf(SEPARATOR) != -1)
throw new IllegalArgumentException("comma not allowed in namespace"); //$NON-NLS-1$
- if (classifier.indexOf(SEP_CHAR) != -1)
+ if (classifier.indexOf(SEPARATOR) != -1)
throw new IllegalArgumentException("comma not allowed in classifier"); //$NON-NLS-1$
- if (id.indexOf(SEP_CHAR) != -1)
+ if (id.indexOf(SEPARATOR) != -1)
throw new IllegalArgumentException("comma not allowed in id"); //$NON-NLS-1$
this.namespace = namespace;
this.classifier = classifier;
@@ -80,4 +119,12 @@ public class ArtifactKey implements IArtifactKey {
return id;
}
+ public String toExternalForm() {
+ StringBuffer data = new StringBuffer(namespace).append(SEPARATOR);
+ data.append(classifier).append(SEPARATOR);
+ data.append(id).append(SEPARATOR);
+ data.append(version.toString());
+ return data.toString();
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IArtifactKey.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IArtifactKey.java
index cd0b248ce..5d1a4a1bf 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IArtifactKey.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IArtifactKey.java
@@ -23,32 +23,32 @@ import org.osgi.framework.Version;
public interface IArtifactKey {
/**
- * The namespace.
- * @return This returns the namespace segment of the artifact. Never
- * null or empty.
+ * Returns the namespace for this artifact key. The returned value can never be empty.
+ * @return the namespace segment of the key.
*/
- String getNamespace();
+ public String getNamespace();
/**
- * The classifier.
- * @return This returns the classifier segment of the key. Never
- * null. Can be empty.
+ * Returns the classifier for this artifact key. The returned value can be empty.
+ * @return the classifier segment of the key.
*/
- String getClassifier();
+ public String getClassifier();
/**
- * The identity of the artifact.
- * @return This returns the id segment of the artifact. Can
- * be empty.
- *
- * TODO: consider renaming this to getIdentity.
+ * Returns the id for this artifact key. The returned value can be empty.
+ * @return the classifier segment of the key.
*/
- String getId();
+ public String getId();
/**
- * The version of the artifact.
- * @return This returns the version of the artifact. Never null. Can
- * be empty (Version.emptyVersion).
+ * Returns the version for this artifact key.
+ * @return the version segment of the key.
*/
- Version getVersion();
+ public Version getVersion();
+
+ /**
+ * Returns the canonical string form of this artifact key.
+ * @return the canonical string representing this key
+ */
+ public String toExternalForm();
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF
index 36d1a10bf..47fd1248d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF
@@ -7,12 +7,14 @@ Bundle-Localization: plugin
Bundle-Version: 0.1.0.qualifier
Import-Package: ie.wombat.jbdiff,
junit.framework;version="3.8.2",
+ org.eclipse.equinox.internal.p2.artifact.optimizers,
org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta,
org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff,
org.eclipse.equinox.internal.p2.artifact.optimizers.pack200,
org.eclipse.equinox.internal.p2.artifact.processors.jardelta,
org.eclipse.equinox.internal.p2.artifact.processors.jbdiff,
org.eclipse.equinox.internal.p2.artifact.processors.pack200,
+ org.eclipse.equinox.internal.p2.artifact.processors.verifier,
org.eclipse.equinox.internal.p2.artifact.repository,
org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.internal.p2.director,
@@ -54,9 +56,8 @@ Eclipse-LazyStart: true
Eclipse-RegisterBuddy: org.eclipse.equinox.p2.artifact.repository
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Export-Package: org.eclipse.equinox.p2.tests,
- org.eclipse.equinox.p2.tests.artifact.optimizers.jbdiff,
- org.eclipse.equinox.p2.tests.artifact.optimizers.pack200,
- org.eclipse.equinox.p2.tests.artifact.processor.jbdiff,
+ org.eclipse.equinox.p2.tests.artifact.optimizers,
+ org.eclipse.equinox.p2.tests.artifact.processors,
org.eclipse.equinox.p2.tests.artifact.repository,
org.eclipse.equinox.p2.tests.artifact.repository.processing,
org.eclipse.equinox.p2.tests.director,
diff --git a/bundles/org.eclipse.equinox.p2.tests/plugin.xml b/bundles/org.eclipse.equinox.p2.tests/plugin.xml
index 875d57916..bed49ce7d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/plugin.xml
+++ b/bundles/org.eclipse.equinox.p2.tests/plugin.xml
@@ -9,12 +9,6 @@
<extension
point="org.eclipse.equinox.p2.artifact.repository.processingSteps"
- id="org.eclipse.equinox.p2.processing.MD5Verifier">
- <step class="org.eclipse.equinox.p2.tests.artifact.repository.processing.MD5Verifier"/>
- </extension>
-
- <extension
- point="org.eclipse.equinox.p2.artifact.repository.processingSteps"
id="org.eclipse.equinox.p2.processing.Adder">
<step class="org.eclipse.equinox.p2.tests.artifact.repository.processing.Adder"/>
</extension>
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java
index 2ff421202..582fb8566 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java
@@ -20,8 +20,8 @@ import junit.framework.*;
public class AutomatedTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AutomatedTests.class.getName());
- suite.addTest(org.eclipse.equinox.p2.tests.artifact.optimizers.jbdiff.AllTests.suite());
- suite.addTest(org.eclipse.equinox.p2.tests.artifact.processor.jbdiff.AllTests.suite());
+ suite.addTest(org.eclipse.equinox.p2.tests.artifact.optimizers.AllTests.suite());
+ suite.addTest(org.eclipse.equinox.p2.tests.artifact.processors.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.artifact.repository.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.artifact.repository.processing.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.director.AllTests.suite());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/jbdiff/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/AllTests.java
index d1200a7d5..7f14f4988 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/jbdiff/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/AllTests.java
@@ -7,8 +7,9 @@
*
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
*******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.optimizers.jbdiff;
+package org.eclipse.equinox.p2.tests.artifact.optimizers;
import junit.framework.*;
@@ -20,7 +21,9 @@ public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AllTests.class.getName());
suite.addTestSuite(JBDiffStepTest.class);
- suite.addTestSuite(JBDiffZipStepTest.class);
+ // suite.addTestSuite(JBDiffZipStepTest.class);
+ suite.addTestSuite(Pack200OptimizerTest.class);
+ suite.addTestSuite(JarDeltaOptimizerTest.class);
return suite;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/jbdiff/JBDiffStepTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JBDiffStepTest.java
index 1ab968b90..663110e9a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/jbdiff/JBDiffStepTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JBDiffStepTest.java
@@ -8,7 +8,7 @@
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.optimizers.jbdiff;
+package org.eclipse.equinox.p2.tests.artifact.optimizers;
import java.io.*;
import java.util.Arrays;
@@ -16,13 +16,13 @@ import junit.framework.TestCase;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff.JBDiffStep;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.p2.artifact.repository.ArtifactDescriptor;
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.tests.TestActivator;
-import org.eclipse.equinox.p2.tests.artifact.processor.jbdiff.ArtifactRepositoryMock;
-import org.eclipse.equinox.p2.tests.artifact.processor.jbdiff.TestArtifactKey;
+import org.eclipse.equinox.p2.tests.artifact.processors.ArtifactRepositoryMock;
import org.osgi.framework.Version;
/**
@@ -37,20 +37,20 @@ public class JBDiffStepTest extends TestCase {
*/
public void testDiffEclipseExe32to33() throws IOException {
- IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/delta/eclipse-3.2.exe");
+ IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/optimizers/eclipse-3.2.exe");
MockableJBDiffStep differ = new MockableJBDiffStep(repoMock);
ProcessingStepDescriptor stepDescriptor = new ProcessingStepDescriptor("id", "ns,cl,id1,1.0", true);
- IArtifactKey key = new TestArtifactKey("ns", "cl", "id1", new Version("1.1"));
+ IArtifactKey key = new ArtifactKey("ns", "cl", "id1", new Version("1.1"));
ArtifactDescriptor descriptor = new ArtifactDescriptor(key);
differ.initialize(stepDescriptor, descriptor);
ByteArrayOutputStream destination = new ByteArrayOutputStream();
differ.link(destination, new NullProgressMonitor());
- InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/delta/eclipse-3.3.exe").openStream();
+ InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/eclipse-3.3.exe").openStream();
FileUtils.copyStream(inputStream, true, differ, true);
- inputStream = TestActivator.getContext().getBundle().getEntry("testData/delta/eclipse-3.2-3.3.jbdiff").openStream();
+ inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/eclipse-3.2-3.3.jbdiff").openStream();
ByteArrayOutputStream expected = new ByteArrayOutputStream();
FileUtils.copyStream(inputStream, true, expected, true);
assertTrue(Arrays.equals(expected.toByteArray(), destination.toByteArray()));
@@ -60,11 +60,9 @@ public class JBDiffStepTest extends TestCase {
* Need to inject a repository!
*/
private static class MockableJBDiffStep extends JBDiffStep {
-
public MockableJBDiffStep(IArtifactRepository repository) {
super(repository);
}
-
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/jbdiff/JBDiffZipStepTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JBDiffZipStepTest.java
index df55e3cfe..c2d3b8f0b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/jbdiff/JBDiffZipStepTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JBDiffZipStepTest.java
@@ -8,20 +8,20 @@
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.optimizers.jbdiff;
+package org.eclipse.equinox.p2.tests.artifact.optimizers;
import java.io.*;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff.JBDiffZipStep;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.p2.artifact.repository.ArtifactDescriptor;
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
-import org.eclipse.equinox.p2.tests.artifact.processor.jbdiff.ArtifactRepositoryMock;
-import org.eclipse.equinox.p2.tests.artifact.processor.jbdiff.TestArtifactKey;
+import org.eclipse.equinox.p2.tests.artifact.processors.ArtifactRepositoryMock;
import org.osgi.framework.Version;
/**
@@ -35,23 +35,23 @@ public class JBDiffZipStepTest extends AbstractProvisioningTest {
* @throws IOException
*/
public void testDiffJdt32to33() throws IOException {
-
- IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/delta/org.eclipse.jdt_3.2.0.v20060605-1400.njar");
+ IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/optimizers/org.eclipse.jdt_3.2.0.v20060605-1400.njar");
MockableJBDiffZipStep differ = new MockableJBDiffZipStep(repoMock);
ProcessingStepDescriptor stepDescriptor = new ProcessingStepDescriptor("id", "ns,cl,id1,1.0", true);
- IArtifactKey key = new TestArtifactKey("ns", "cl", "id1", new Version("1.1"));
+ IArtifactKey key = new ArtifactKey("ns", "cl", "id1", new Version("1.1"));
ArtifactDescriptor descriptor = new ArtifactDescriptor(key);
differ.initialize(stepDescriptor, descriptor);
ByteArrayOutputStream destination = new ByteArrayOutputStream();
differ.link(destination, new NullProgressMonitor());
- InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/delta/org.eclipse.jdt_3.3.0.v20070607-1300.njar").openStream();
+ InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/org.eclipse.jdt_3.3.0.v20070607-1300.njar").openStream();
FileUtils.copyStream(inputStream, true, differ, true);
- inputStream = TestActivator.getContext().getBundle().getEntry("testData/delta/org.eclipse.jdt_3.2.0-3.3.0.jbdiff").openStream();
+ inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/org.eclipse.jdt_3.2.0-3.3.0.jbdiff").openStream();
ByteArrayOutputStream expected = new ByteArrayOutputStream();
FileUtils.copyStream(inputStream, true, expected, true);
+
assertEquals("", expected.toByteArray(), destination.toByteArray());
}
@@ -59,11 +59,8 @@ public class JBDiffZipStepTest extends AbstractProvisioningTest {
* Need to inject a repository!
*/
private static class MockableJBDiffZipStep extends JBDiffZipStep {
-
public MockableJBDiffZipStep(IArtifactRepository repository) {
super(repository);
}
-
}
-
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JarDeltaOptimizerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JarDeltaOptimizerTest.java
new file mode 100644
index 000000000..54f47a272
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JarDeltaOptimizerTest.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2007 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - ongoing development
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.artifact.optimizers;
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta.JarDeltaOptimizerStep;
+import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
+import org.eclipse.equinox.p2.artifact.repository.ArtifactDescriptor;
+import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
+import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.tests.TestActivator;
+import org.eclipse.equinox.p2.tests.artifact.processors.ArtifactRepositoryMock;
+import org.osgi.framework.Version;
+
+/**
+ * Test the <code>JarDelta</code> processing step.
+ */
+public class JarDeltaOptimizerTest extends TestCase {
+
+ private static Map getEntries(ZipInputStream input) throws IOException {
+ Map result = new HashMap();
+ while (true) {
+ ZipEntry entry = input.getNextEntry();
+ if (entry == null)
+ return result;
+
+ ByteArrayOutputStream content = new ByteArrayOutputStream();
+ FileUtils.copyStream(input, false, content, true);
+ input.closeEntry();
+ result.put(entry.getName(), new Object[] {entry, content.toByteArray()});
+ }
+ }
+
+ public static void compare(ZipInputStream input1, ZipInputStream input2) throws IOException {
+ Map jar1 = getEntries(input1);
+ Map jar2 = getEntries(input2);
+ for (Iterator i = jar1.keySet().iterator(); i.hasNext();) {
+ String name = (String) i.next();
+ Object[] file1 = (Object[]) jar1.get(name);
+ Object[] file2 = (Object[]) jar2.remove(name);
+ Assert.assertNotNull(file2);
+
+ ZipEntry entry1 = (ZipEntry) file1[0];
+ ZipEntry entry2 = (ZipEntry) file2[0];
+ // compare the entries
+ Assert.assertTrue(entry1.getName().equals(entry2.getName()));
+ Assert.assertTrue(entry1.getSize() == entry2.getSize());
+ // TODO for now skip over the timestamp as they seem to be different
+ // assertTrue(entry1.getTime() == entry2.getTime());
+ Assert.assertTrue(entry1.isDirectory() == entry2.isDirectory());
+ Assert.assertTrue(entry1.getCrc() == entry2.getCrc());
+ Assert.assertTrue(entry1.getMethod() == entry2.getMethod());
+
+ // check the content of the entries
+ Assert.assertTrue(Arrays.equals((byte[]) file1[1], (byte[]) file2[1]));
+ }
+
+ // ensure that we have consumed all of the entries in the second JAR
+ Assert.assertTrue(jar2.size() == 0);
+ }
+
+ // public void testPrepare() throws IOException {
+ // IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/optimizers/testdata_1.0.0.1.jar");
+ // ProcessingStep step = new MockableJarDeltaOptimizerStep(repoMock);
+ // ProcessingStepDescriptor stepDescriptor = new ProcessingStepDescriptor("id", "ns,cl,id1,1.0.0.1", true);
+ // IArtifactKey key = new ArtifactKey("ns", "cl", "id1", new Version("1.0.0.2"));
+ // ArtifactDescriptor descriptor = new ArtifactDescriptor(key);
+ // step.initialize(stepDescriptor, descriptor);
+ // ByteArrayOutputStream destination = new ByteArrayOutputStream();
+ // step.link(destination, new NullProgressMonitor());
+ //
+ // InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/testdata_1.0.0.2.jar").openStream();
+ // FileUtils.copyStream(inputStream, true, step, true);
+ // destination.close();
+ //
+ // inputStream = new ByteArrayInputStream(destination.toByteArray());
+ // FileOutputStream file = new FileOutputStream("d:/jardelta.jar");
+ // FileUtils.copyStream(inputStream, true, file, true);
+ // }
+
+ public void testOptimization() throws IOException {
+ IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/optimizers/testdata_1.0.0.1.jar");
+ ProcessingStep step = new MockableJarDeltaOptimizerStep(repoMock);
+ ProcessingStepDescriptor stepDescriptor = new ProcessingStepDescriptor("id", "ns,cl,id1,1.0.0.1", true);
+ IArtifactKey key = new ArtifactKey("ns", "cl", "id1", new Version("1.0.0.2"));
+ ArtifactDescriptor descriptor = new ArtifactDescriptor(key);
+ step.initialize(stepDescriptor, descriptor);
+ ByteArrayOutputStream destination = new ByteArrayOutputStream();
+ step.link(destination, new NullProgressMonitor());
+
+ InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/testdata_1.0.0.2.jar").openStream();
+ FileUtils.copyStream(inputStream, true, step, true);
+ destination.close();
+
+ inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/testdata_1.0.0.1-2.jar").openStream();
+ ByteArrayOutputStream expected = new ByteArrayOutputStream();
+ FileUtils.copyStream(inputStream, true, expected, true);
+
+ ZipInputStream expectedJar = new ZipInputStream(new ByteArrayInputStream(expected.toByteArray()));
+ ZipInputStream testJar = new ZipInputStream(new ByteArrayInputStream(destination.toByteArray()));
+ compare(expectedJar, testJar);
+ expectedJar.close();
+ testJar.close();
+ }
+
+ /**
+ * Need to inject a repository!
+ */
+ private static class MockableJarDeltaOptimizerStep extends JarDeltaOptimizerStep {
+ public MockableJarDeltaOptimizerStep(IArtifactRepository repository) {
+ super(repository);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/Pack200OptimizerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/Pack200OptimizerTest.java
new file mode 100644
index 000000000..fec18954c
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/Pack200OptimizerTest.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.artifact.optimizers;
+
+import java.io.*;
+import java.util.Arrays;
+import junit.framework.TestCase;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.p2.artifact.optimizers.pack200.Pack200OptimizerStep;
+import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.p2.tests.TestActivator;
+import org.osgi.framework.Bundle;
+
+public class Pack200OptimizerTest extends TestCase {
+
+ public Pack200OptimizerTest(String name) {
+ super(name);
+ }
+
+ public Pack200OptimizerTest() {
+ super("");
+ }
+
+ public void testPrepare() throws IOException {
+ // Setup the step
+ ProcessingStep step = new Pack200OptimizerStep();
+ FileOutputStream destination = new FileOutputStream("d:/packed.pack.gz");
+ step.link(destination, new NullProgressMonitor());
+
+ // drive the source data through the step
+ Bundle bundle = TestActivator.getContext().getBundle();
+ InputStream inputStream = bundle.getEntry("testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar").openStream();
+ FileUtils.copyStream(inputStream, true, step, true);
+
+ destination.close();
+ }
+
+ public void testPack() throws IOException {
+ // Setup the step
+ ProcessingStep step = new Pack200OptimizerStep();
+ ByteArrayOutputStream destination = new ByteArrayOutputStream();
+ step.link(destination, new NullProgressMonitor());
+
+ // drive the source data through the step
+ Bundle bundle = TestActivator.getContext().getBundle();
+ InputStream inputStream = bundle.getEntry("testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar").openStream();
+ FileUtils.copyStream(inputStream, true, step, true);
+
+ // Get the test data
+ inputStream = bundle.getEntry("testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar.pack.gz").openStream();
+ ByteArrayOutputStream expected = new ByteArrayOutputStream();
+ FileUtils.copyStream(inputStream, true, expected, true);
+
+ // Compare
+ assertTrue(Arrays.equals(expected.toByteArray(), destination.toByteArray()));
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/AllTests.java
deleted file mode 100644
index f0624bed3..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/AllTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.optimizers.pack200;
-
-import junit.framework.*;
-
-/**
- * Performs all automated director tests.
- */
-public class AllTests extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AllTests.class.getName());
- // suite.addTestSuite(PackRepositoryTest.class);
- suite.addTestSuite(JarDeltaRepositoryTest.class);
- return suite;
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/JarDeltaRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/JarDeltaRepositoryTest.java
deleted file mode 100644
index d8e49c0e0..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/JarDeltaRepositoryTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.optimizers.pack200;
-
-import java.io.*;
-import java.net.URL;
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta.Optimizer;
-import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.p2.artifact.repository.*;
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.p2.tests.TestActivator;
-import org.eclipse.osgi.service.urlconversion.URLConverter;
-import org.osgi.framework.Version;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class JarDeltaRepositoryTest extends TestCase {
- private ServiceTracker managerTracker;
- private File workDir;
-
- public JarDeltaRepositoryTest(String name) {
- super(name);
- }
-
- public JarDeltaRepositoryTest() {
- super("");
- }
-
- protected void setUp() throws Exception {
- managerTracker = new ServiceTracker(TestActivator.getContext(), IArtifactRepositoryManager.class.getName(), null);
- managerTracker.open();
- }
-
- protected void tearDown() throws Exception {
- managerTracker.close();
- if (workDir != null)
- FileUtils.deleteAll(workDir);
- }
-
- public void testJarURLRepository() {
- URL repositoryJar = TestActivator.getContext().getBundle().getEntry("/testData/enginerepo.zip");
- URL repositoryURL = extractRepositoryJAR(repositoryJar);
- assertNotNull("Could not extract repository", repositoryURL);
- IArtifactRepository repository = ((IArtifactRepositoryManager) managerTracker.getService()).loadRepository(repositoryURL, null);
- IArtifactKey key = new ArtifactKey("eclipse", "plugin", "testdata", new Version("1.0.0.2"));
- IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(key);
- assertTrue("Artifact Descriptor for engine missing", descriptors.length == 1);
-
- new Optimizer(repository, 1, 1).run();
- descriptors = repository.getArtifactDescriptors(key);
- assertTrue("Optimization was a no-op", descriptors.length == 2);
-
- IArtifactDescriptor canonical = null;
- IArtifactDescriptor optimized = null;
- for (int i = 0; i < descriptors.length; i++) {
- if (descriptors[i].getProcessingSteps().length == 0)
- canonical = descriptors[i];
- else
- optimized = descriptors[i];
- }
-
- assertTrue("Optmized descriptor not found", optimized != null);
- assertTrue("Canonical descriptor not found", canonical != null);
- long optimizedSize = Long.parseLong(optimized.getProperty(IArtifactDescriptor.DOWNLOAD_SIZE));
- long canonicalSize = Long.parseLong(canonical.getProperty(IArtifactDescriptor.DOWNLOAD_SIZE));
- assertTrue("Optimzed not smaller than canonical", optimizedSize < canonicalSize);
-
- File canonicalFile = fetchArtifact("canonical", canonical);
- File optimizedFile = fetchArtifact("optimized", optimized);
- compareFiles(canonicalFile, optimizedFile);
- }
-
- private URL extractRepositoryJAR(URL source) {
- String filter = "(protocol=" + source.getProtocol() + ")";
- URLConverter converter = (URLConverter) ServiceHelper.getService(TestActivator.getContext(), URLConverter.class.getName(), filter);
- try {
- if (converter == null)
- return null;
- URL repoURL = converter.toFileURL(source);
- if (!repoURL.toExternalForm().endsWith(".jar") && !repoURL.toExternalForm().endsWith(".zip"))
- return repoURL;
- // else the repo is a JAR or zip and we should extract the contents to a work dir.
- File repoLocation = getWorkDir();
- FileUtils.unzipFile(new File(repoURL.getPath()), repoLocation);
- return repoLocation.toURL();
- } catch (IOException e) {
- return null;
- }
- }
-
- private void compareFiles(File canonicalFile, File optimizedFile) {
- assertTrue("Canonical file does not exist", canonicalFile.exists());
- assertTrue("Optimized file does not exist", optimizedFile.exists());
- assertEquals(canonicalFile.length(), optimizedFile.length());
- // TODO compare the actual content
- }
-
- private File fetchArtifact(String name, IArtifactDescriptor descriptor) {
- try {
- File result = new File(getWorkDir(), name);
- OutputStream destination = new BufferedOutputStream(new FileOutputStream(result));
- try {
- descriptor.getRepository().getArtifact(descriptor, destination, new NullProgressMonitor());
- return result;
- } finally {
- if (destination != null)
- destination.close();
- }
- } catch (IOException e) {
- fail("Could not fetch artifact " + descriptor);
- }
- return null;
- }
-
- private File getWorkDir() throws IOException {
- if (workDir != null)
- return workDir;
- workDir = File.createTempFile("work", "");
- if (!workDir.delete())
- throw new IOException("Could not delete file for creating temporary working dir.");
- if (!workDir.mkdirs())
- throw new IOException("Could not create temporary working dir.");
- return workDir;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/PackRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/PackRepositoryTest.java
deleted file mode 100644
index 7c90e31bd..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/optimizers/pack200/PackRepositoryTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.optimizers.pack200;
-
-import java.io.*;
-import java.net.URL;
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.artifact.optimizers.pack200.Optimizer;
-import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.p2.artifact.repository.*;
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.p2.tests.TestActivator;
-import org.eclipse.osgi.service.urlconversion.URLConverter;
-import org.osgi.framework.Version;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class PackRepositoryTest extends TestCase {
- private ServiceTracker managerTracker;
- private File workDir;
-
- public PackRepositoryTest(String name) {
- super(name);
- }
-
- public PackRepositoryTest() {
- super("");
- }
-
- protected void setUp() throws Exception {
- managerTracker = new ServiceTracker(TestActivator.getContext(), IArtifactRepositoryManager.class.getName(), null);
- managerTracker.open();
- }
-
- protected void tearDown() throws Exception {
- managerTracker.close();
- if (workDir != null)
- FileUtils.deleteAll(workDir);
- }
-
- public void testJarURLRepository() {
- URL repositoryJar = TestActivator.getContext().getBundle().getEntry("/testData/enginerepo.zip");
- URL repositoryURL = extractRepositoryJAR(repositoryJar);
- assertNotNull("Could not extract repository", repositoryURL);
- IArtifactRepository repository = ((IArtifactRepositoryManager) managerTracker.getService()).loadRepository(repositoryURL, null);
- IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.equinox.prov.engine", new Version("0.1.0.200709241631"));
- IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(key);
- assertTrue("Artifact Descriptor for engine missing", descriptors.length == 1);
-
- new Optimizer(repository).run();
- descriptors = repository.getArtifactDescriptors(key);
- assertTrue("Optimization was a no-op", descriptors.length == 2);
-
- IArtifactDescriptor canonical = null;
- IArtifactDescriptor optimized = null;
- for (int i = 0; i < descriptors.length; i++) {
- if (descriptors[i].getProcessingSteps().length == 0)
- canonical = descriptors[i];
- else
- optimized = descriptors[i];
- }
-
- assertTrue("Optmized descriptor not found", optimized != null);
- assertTrue("Canonical descriptor not found", canonical != null);
- long optimizedSize = Long.parseLong(optimized.getProperty(IArtifactDescriptor.DOWNLOAD_SIZE));
- long canonicalSize = Long.parseLong(canonical.getProperty(IArtifactDescriptor.DOWNLOAD_SIZE));
- assertTrue("Optimzed not smaller than canonical", optimizedSize < canonicalSize);
-
- File canonicalFile = fetchArtifact("canonical", canonical);
- File optimizedFile = fetchArtifact("optimized", optimized);
- compareFiles(canonicalFile, optimizedFile);
- }
-
- private URL extractRepositoryJAR(URL source) {
- String filter = "(protocol=" + source.getProtocol() + ")";
- URLConverter converter = (URLConverter) ServiceHelper.getService(TestActivator.getContext(), URLConverter.class.getName(), filter);
- try {
- if (converter == null)
- return null;
- URL repoURL = converter.toFileURL(source);
- if (!repoURL.toExternalForm().endsWith(".jar") && !repoURL.toExternalForm().endsWith(".zip"))
- return repoURL;
- // else the repo is a JAR or zip and we should extract the contents to a work dir.
- File repoLocation = getWorkDir();
- FileUtils.unzipFile(new File(repoURL.getPath()), repoLocation);
- return repoLocation.toURL();
- } catch (IOException e) {
- return null;
- }
- }
-
- private void compareFiles(File canonicalFile, File optimizedFile) {
- assertTrue("Canonical file does not exist", canonicalFile.exists());
- assertTrue("Optimized file does not exist", optimizedFile.exists());
- assertEquals(canonicalFile.length(), optimizedFile.length());
- // TODO compare the actual content
- }
-
- private File fetchArtifact(String name, IArtifactDescriptor descriptor) {
- try {
- File result = new File(getWorkDir(), name);
- OutputStream destination = new BufferedOutputStream(new FileOutputStream(result));
- try {
- descriptor.getRepository().getArtifact(descriptor, destination, new NullProgressMonitor());
- return result;
- } finally {
- if (destination != null)
- destination.close();
- }
- } catch (IOException e) {
- fail("Could not fetch artifact " + descriptor);
- }
- return null;
- }
-
- private File getWorkDir() throws IOException {
- if (workDir != null)
- return workDir;
- workDir = File.createTempFile("work", "");
- if (!workDir.delete())
- throw new IOException("Could not delete file for creating temporary working dir.");
- if (!workDir.mkdirs())
- throw new IOException("Could not create temporary working dir.");
- return workDir;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/TestArtifactKey.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/TestArtifactKey.java
deleted file mode 100644
index df4733088..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/TestArtifactKey.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 compeople AG and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * compeople AG (Stefan Liebig) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.processor.jbdiff;
-
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
-import org.osgi.framework.Version;
-
-public class TestArtifactKey implements IArtifactKey {
-
- private String namespace;
- private String classifier;
- private String id;
- private Version version;
-
- public TestArtifactKey(String namespace, String classifier, String id, Version version) {
- super();
- this.namespace = namespace;
- this.classifier = classifier;
- this.id = id;
- this.version = version;
- }
-
- public String getClassifier() {
- return classifier;
- }
-
- public String getId() {
- return id;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- public Version getVersion() {
- return version;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/AllTests.java
index ef623dfb7..89f3685bb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/AllTests.java
@@ -8,7 +8,7 @@
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.processor.jbdiff;
+package org.eclipse.equinox.p2.tests.artifact.processors;
import junit.framework.*;
@@ -19,9 +19,10 @@ public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AllTests.class.getName());
- suite.addTestSuite(ArtifactkeyDeSerializerTest.class);
suite.addTestSuite(JBPatchStepTest.class);
- suite.addTestSuite(JBPatchZipStepTest.class);
+ // suite.addTestSuite(JBPatchZipStepTest.class);
+ suite.addTestSuite(JarDeltaProcessorTest.class);
+ suite.addTestSuite(Pack200ProcessorTest.class);
return suite;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/ArtifactRepositoryMock.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java
index 2d9bdf63c..462bff2dd 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/ArtifactRepositoryMock.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java
@@ -8,7 +8,7 @@
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.processor.jbdiff;
+package org.eclipse.equinox.p2.tests.artifact.processors;
import java.io.*;
import java.lang.reflect.*;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/JBPatchStepTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/JBPatchStepTest.java
index bc40cec90..a60f8d51d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/JBPatchStepTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/JBPatchStepTest.java
@@ -8,7 +8,7 @@
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.processor.jbdiff;
+package org.eclipse.equinox.p2.tests.artifact.processors;
import java.io.*;
import java.util.Arrays;
@@ -16,6 +16,7 @@ import junit.framework.TestCase;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.artifact.processors.jbdiff.JBPatchStep;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.p2.artifact.repository.ArtifactDescriptor;
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
@@ -31,21 +32,20 @@ import org.osgi.framework.Version;
public class JBPatchStepTest extends TestCase {
public void testPatchEclipseExe32to33() throws IOException {
-
- IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/delta/eclipse-3.2.exe");
+ IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/optimizers/eclipse-3.2.exe");
ProcessingStep patcher = new MockableJBPatchStep(repoMock);
ProcessingStepDescriptor descriptor = new ProcessingStepDescriptor("id", "ns,cl,id1,1.0", true);
- IArtifactKey key = new TestArtifactKey("ns", "cl", "id1", new Version("1.1"));
+ IArtifactKey key = new ArtifactKey("ns", "cl", "id1", new Version("1.1"));
ArtifactDescriptor context = new ArtifactDescriptor(key);
patcher.initialize(descriptor, context);
ByteArrayOutputStream destination = new ByteArrayOutputStream();
patcher.link(destination, new NullProgressMonitor());
- InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/delta/eclipse-3.2-3.3.jbdiff").openStream();
+ InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/eclipse-3.2-3.3.jbdiff").openStream();
FileUtils.copyStream(inputStream, true, patcher, true);
- inputStream = TestActivator.getContext().getBundle().getEntry("testData/delta/eclipse-3.3.exe").openStream();
+ inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/eclipse-3.3.exe").openStream();
ByteArrayOutputStream expected = new ByteArrayOutputStream();
FileUtils.copyStream(inputStream, true, expected, true);
assertTrue(Arrays.equals(expected.toByteArray(), destination.toByteArray()));
@@ -55,11 +55,9 @@ public class JBPatchStepTest extends TestCase {
* Need to inject a repository!
*/
private static class MockableJBPatchStep extends JBPatchStep {
-
public MockableJBPatchStep(IArtifactRepository repository) {
super.repository = repository;
}
-
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/JBPatchZipStepTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/JBPatchZipStepTest.java
index 85e683b31..8c8a0fc1f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/JBPatchZipStepTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/JBPatchZipStepTest.java
@@ -8,12 +8,13 @@
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.processor.jbdiff;
+package org.eclipse.equinox.p2.tests.artifact.processors;
import java.io.*;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.artifact.processors.jbdiff.JBPatchZipStep;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.p2.artifact.repository.ArtifactDescriptor;
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
@@ -34,13 +35,13 @@ public class JBPatchZipStepTest extends AbstractProvisioningTest {
// */
// public void testPrepare() throws IOException {
// String base = "C:/projekte/rcp/org.eclipse.equinox.p2.tests";
- // File tonormalize32 = new File(base, TestActivator.getContext().getBundle().getEntry("testData/delta/org.eclipse.jdt_3.2.0.v20060605-1400.jar").getFile());
+ // File tonormalize32 = new File(base, TestActivator.getContext().getBundle().getEntry("testData/optimizers/org.eclipse.jdt_3.2.0.v20060605-1400.jar").getFile());
// File normalized32 = File.createTempFile("3.2", ".njar");
// SarUtil.normalize(tonormalize32, normalized32);
// File sar32 = File.createTempFile("3.2", ".sar");
// SarUtil.zipToSar(normalized32, sar32);
//
- // File tonormalize33 = new File(base, TestActivator.getContext().getBundle().getEntry("testData/delta/org.eclipse.jdt_3.3.0.v20070607-1300.jar").getFile());
+ // File tonormalize33 = new File(base, TestActivator.getContext().getBundle().getEntry("testData/optimizers/org.eclipse.jdt_3.3.0.v20070607-1300.jar").getFile());
// File normalized33 = File.createTempFile("3.3", ".njar");
// SarUtil.normalize(tonormalize33, normalized33);
// File sar33 = File.createTempFile("3.3", ".sar");
@@ -57,20 +58,20 @@ public class JBPatchZipStepTest extends AbstractProvisioningTest {
*/
public void testPatchOrgEclipseJdt32to33() throws IOException {
- IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/delta/org.eclipse.jdt_3.2.0.v20060605-1400.njar");
+ IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/optimizers/org.eclipse.jdt_3.2.0.v20060605-1400.njar");
ProcessingStep patcher = new MockableJBPatchZipStep(repoMock);
ProcessingStepDescriptor descriptor = new ProcessingStepDescriptor("id", "ns,cl,id1,1.0", true);
- IArtifactKey key = new TestArtifactKey("ns", "cl", "id1", new Version("1.1"));
+ IArtifactKey key = new ArtifactKey("ns", "cl", "id1", new Version("1.1"));
ArtifactDescriptor context = new ArtifactDescriptor(key);
patcher.initialize(descriptor, context);
ByteArrayOutputStream destination = new ByteArrayOutputStream();
patcher.link(destination, new NullProgressMonitor());
- InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/delta/org.eclipse.jdt_3.2.0-3.3.0.jbdiff").openStream();
+ InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/org.eclipse.jdt_3.2.0-3.3.0.jbdiff").openStream();
FileUtils.copyStream(inputStream, true, patcher, true);
- inputStream = TestActivator.getContext().getBundle().getEntry("testData/delta/org.eclipse.jdt_3.3.0.v20070607-1300.njar").openStream();
+ inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/org.eclipse.jdt_3.3.0.v20070607-1300.njar").openStream();
ByteArrayOutputStream expected = new ByteArrayOutputStream();
FileUtils.copyStream(inputStream, true, expected, true);
assertEquals("", expected.toByteArray(), destination.toByteArray());
@@ -80,11 +81,9 @@ public class JBPatchZipStepTest extends AbstractProvisioningTest {
* Need to inject a repository!
*/
private static class MockableJBPatchZipStep extends JBPatchZipStep {
-
public MockableJBPatchZipStep(IArtifactRepository repository) {
super.repository = repository;
}
-
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/JarDeltaProcessorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/JarDeltaProcessorTest.java
new file mode 100644
index 000000000..35ef39c06
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/JarDeltaProcessorTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.artifact.processors;
+
+import java.io.*;
+import java.util.zip.ZipInputStream;
+import junit.framework.TestCase;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.p2.artifact.processors.jardelta.JarDeltaProcessorStep;
+import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
+import org.eclipse.equinox.p2.artifact.repository.ArtifactDescriptor;
+import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
+import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.tests.TestActivator;
+import org.eclipse.equinox.p2.tests.artifact.optimizers.JarDeltaOptimizerTest;
+import org.osgi.framework.Version;
+
+public class JarDeltaProcessorTest extends TestCase {
+
+ public JarDeltaProcessorTest(String name) {
+ super(name);
+ }
+
+ public JarDeltaProcessorTest() {
+ super("");
+ }
+
+ public void testProcessing() throws IOException {
+ IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/optimizers/testdata_1.0.0.1.jar");
+ ProcessingStep step = new MockableJarDeltaProcessorStep(repoMock);
+ ProcessingStepDescriptor stepDescriptor = new ProcessingStepDescriptor("id", "ns,cl,id1,1.0.0.1", true);
+ IArtifactKey key = new ArtifactKey("ns", "cl", "id1", new Version("1.0.0.2"));
+ ArtifactDescriptor descriptor = new ArtifactDescriptor(key);
+ step.initialize(stepDescriptor, descriptor);
+ ByteArrayOutputStream destination = new ByteArrayOutputStream();
+ step.link(destination, new NullProgressMonitor());
+
+ InputStream inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/testdata_1.0.0.1-2.jar").openStream();
+ FileUtils.copyStream(inputStream, true, step, true);
+ destination.close();
+
+ inputStream = TestActivator.getContext().getBundle().getEntry("testData/optimizers/testdata_1.0.0.2.jar").openStream();
+ ByteArrayOutputStream expected = new ByteArrayOutputStream();
+ FileUtils.copyStream(inputStream, true, expected, true);
+
+ ZipInputStream expectedJar = new ZipInputStream(new ByteArrayInputStream(expected.toByteArray()));
+ ZipInputStream testJar = new ZipInputStream(new ByteArrayInputStream(destination.toByteArray()));
+ JarDeltaOptimizerTest.compare(expectedJar, testJar);
+ expectedJar.close();
+ testJar.close();
+ }
+
+ /**
+ * Need to inject a repository!
+ */
+ private static class MockableJarDeltaProcessorStep extends JarDeltaProcessorStep {
+ public MockableJarDeltaProcessorStep(IArtifactRepository repository) {
+ super();
+ this.repository = repository;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/Pack200ProcessorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/Pack200ProcessorTest.java
new file mode 100644
index 000000000..4349159bb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/Pack200ProcessorTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.artifact.processors;
+
+import java.io.*;
+import java.util.Arrays;
+import junit.framework.TestCase;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.p2.artifact.processors.pack200.Pack200ProcessorStep;
+import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.p2.tests.TestActivator;
+import org.osgi.framework.Bundle;
+
+public class Pack200ProcessorTest extends TestCase {
+
+ public Pack200ProcessorTest(String name) {
+ super(name);
+ }
+
+ public Pack200ProcessorTest() {
+ super("");
+ }
+
+ public void testUnpack() throws IOException {
+ // Setup the processor
+ ProcessingStep step = new Pack200ProcessorStep();
+ ByteArrayOutputStream destination = new ByteArrayOutputStream();
+ step.link(destination, new NullProgressMonitor());
+
+ // drive the source data through the step
+ Bundle bundle = TestActivator.getContext().getBundle();
+ InputStream inputStream = bundle.getEntry("testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar.pack.gz").openStream();
+ FileUtils.copyStream(inputStream, true, step, true);
+
+ // Get the test data
+ inputStream = bundle.getEntry("testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar").openStream();
+ ByteArrayOutputStream expected = new ByteArrayOutputStream();
+ FileUtils.copyStream(inputStream, true, expected, true);
+
+ // Compare
+ assertTrue(Arrays.equals(expected.toByteArray(), destination.toByteArray()));
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/MD5Verifier.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/MD5Verifier.java
deleted file mode 100644
index 56758cc6b..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/MD5Verifier.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2007 compeople AG and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* compeople AG (Stefan Liebig) - initial API and implementation
-* IBM - continuing development
-*******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.repository.processing;
-
-import java.io.IOException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
-import org.eclipse.equinox.p2.artifact.repository.IArtifactDescriptor;
-import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStep;
-import org.eclipse.equinox.p2.artifact.repository.processing.ProcessingStepDescriptor;
-
-public class MD5Verifier extends ProcessingStep {
-
- protected String md5Test;
- private MessageDigest md5;
-
- public MD5Verifier() {
- super();
- }
-
- public MD5Verifier(String md5Test) {
- super();
- this.md5Test = md5Test;
- basicInitialize(null);
- }
-
- public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
- super.initialize(descriptor, context);
- String data = descriptor.getData();
- if (data.equals("download"))
- md5Test = context.getProperty(IArtifactDescriptor.DOWNLOAD_MD5);
- else if (data.equals("artifact"))
- md5Test = context.getProperty(IArtifactDescriptor.ARTIFACT_MD5);
- else
- md5Test = data;
- basicInitialize(descriptor);
- }
-
- private void basicInitialize(ProcessingStepDescriptor descriptor) {
- int code;
- if (descriptor == null)
- code = IStatus.ERROR;
- else
- code = descriptor.isRequired() ? IStatus.ERROR : IStatus.INFO;
- if (md5Test == null || md5Test.length() != 32)
- status = new Status(code, Activator.ID, "MD5 value not available or incorrect size");
- try {
- md5 = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- status = new Status(code, Activator.ID, "Could not create MD5 algorithm", e);
- }
- }
-
- public void write(int b) throws IOException {
- if (b != -1)
- md5.update((byte) b);
- destination.write(b);
- }
-
- public void close() throws IOException {
- super.close();
-
- byte[] digest = md5.digest();
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < digest.length; i++) {
- if ((digest[i] & 0xFF) < 0x10)
- buf.append('0');
- buf.append(Integer.toHexString(digest[i] & 0xFF));
- }
-
- // if the hashes don't line up set the status to error.
- if (!buf.toString().equals(md5Test)) {
- String message = "Error processing stream. MD5 hash is not as expected.";
- status = new Status(IStatus.ERROR, "plugin id", message);
- } else
- status = Status.OK_STATUS;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java
index 246b796a9..d99dcc69f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java
@@ -15,7 +15,8 @@ import java.io.*;
import java.util.Arrays;
import junit.framework.TestCase;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.artifact.processors.pack200.Unpack200Step;
+import org.eclipse.equinox.internal.p2.artifact.processors.pack200.Pack200ProcessorStep;
+import org.eclipse.equinox.internal.p2.artifact.processors.verifier.MD5Verifier;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.p2.artifact.repository.processing.*;
import org.eclipse.equinox.p2.tests.TestActivator;
@@ -169,7 +170,7 @@ public class ProcessingStepHandlerTest extends TestCase {
ProcessingStep[] steps = handler.create(descriptors, null);
assertNotNull(steps);
assertEquals(1, steps.length);
- assertEquals(Unpack200Step.class, steps[0].getClass());
+ assertEquals(Pack200ProcessorStep.class, steps[0].getClass());
}
public void testCreatePSsAndAssureOrderingOfPSs1() throws IOException {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java
index 7c37d1269..e90afea72 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/AllTests.java
@@ -19,6 +19,7 @@ public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AllTests.class.getName());
+ suite.addTestSuite(ArtifactKeyParsingTest.class);
suite.addTestSuite(FragmentMethodTest.class);
suite.addTestSuite(FragmentTest.class);
suite.addTestSuite(MultipleIUAndFragmentTest.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/ArtifactkeyDeSerializerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java
index a0ee996b1..18b4acd7b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processor/jbdiff/ArtifactkeyDeSerializerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java
@@ -8,30 +8,30 @@
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.processor.jbdiff;
+package org.eclipse.equinox.p2.tests.metadata;
import junit.framework.TestCase;
-import org.eclipse.equinox.internal.p2.artifact.processors.jbdiff.ArtifactKeyDeSerializer;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.osgi.framework.Version;
/**
* Test <code>ArtifactkeyDeSerializer</code>
*/
-public class ArtifactkeyDeSerializerTest extends TestCase {
+public class ArtifactKeyParsingTest extends TestCase {
public void testSerialize() {
- IArtifactKey key = new TestArtifactKey("namespace", "classifier", "identifier", new Version("1.0"));
- assertEquals("namespace,classifier,identifier,1.0.0", ArtifactKeyDeSerializer.serialize(key));
+ IArtifactKey key = new ArtifactKey("namespace", "classifier", "identifier", new Version("1.0"));
+ assertEquals("namespace,classifier,identifier,1.0.0", key.toExternalForm());
}
public void testSerializeEmptyNamespace() {
- IArtifactKey key = new TestArtifactKey("", "classifier", "identifier", new Version("1.0"));
- assertEquals(",classifier,identifier,1.0.0", ArtifactKeyDeSerializer.serialize(key));
+ IArtifactKey key = new ArtifactKey("", "classifier", "identifier", new Version("1.0"));
+ assertEquals(",classifier,identifier,1.0.0", key.toExternalForm());
}
public void testDeserialize() {
- IArtifactKey key = ArtifactKeyDeSerializer.deserialize("namespace,classifier,identifier,1.0.0");
+ IArtifactKey key = ArtifactKey.parse("namespace,classifier,identifier,1.0.0");
assertNotNull(key);
assertEquals("namespace", key.getNamespace());
assertEquals("classifier", key.getClassifier());
@@ -40,7 +40,7 @@ public class ArtifactkeyDeSerializerTest extends TestCase {
}
public void testDeserializeEmptyNamespace() {
- IArtifactKey key = ArtifactKeyDeSerializer.deserialize(",classifier,identifier,1.0.0");
+ IArtifactKey key = ArtifactKey.parse(",classifier,identifier,1.0.0");
assertNotNull(key);
assertEquals("", key.getNamespace());
assertEquals("classifier", key.getClassifier());
@@ -49,7 +49,7 @@ public class ArtifactkeyDeSerializerTest extends TestCase {
}
public void testDeserializeEmptyClassifier() {
- IArtifactKey key = ArtifactKeyDeSerializer.deserialize("namespace,,identifier,1.0.0");
+ IArtifactKey key = ArtifactKey.parse("namespace,,identifier,1.0.0");
assertNotNull(key);
assertEquals("namespace", key.getNamespace());
assertEquals("", key.getClassifier());
@@ -58,7 +58,7 @@ public class ArtifactkeyDeSerializerTest extends TestCase {
}
public void testDeserializeEmptyIdentifier() {
- IArtifactKey key = ArtifactKeyDeSerializer.deserialize("namespace,classifier,,1.0.0");
+ IArtifactKey key = ArtifactKey.parse("namespace,classifier,,1.0.0");
assertNotNull(key);
assertEquals("namespace", key.getNamespace());
assertEquals("classifier", key.getClassifier());
@@ -67,7 +67,7 @@ public class ArtifactkeyDeSerializerTest extends TestCase {
}
public void testDeserializeEmptyVersion() {
- IArtifactKey key = ArtifactKeyDeSerializer.deserialize("namespace,classifier,identifier,");
+ IArtifactKey key = ArtifactKey.parse("namespace,classifier,identifier,");
assertNotNull(key);
assertEquals("namespace", key.getNamespace());
assertEquals("classifier", key.getClassifier());
@@ -76,7 +76,7 @@ public class ArtifactkeyDeSerializerTest extends TestCase {
}
public void testDeserializeEmptyEverything() {
- IArtifactKey key = ArtifactKeyDeSerializer.deserialize(",,,");
+ IArtifactKey key = ArtifactKey.parse(",,,");
assertNotNull(key);
assertEquals("", key.getNamespace());
assertEquals("", key.getClassifier());
@@ -86,16 +86,16 @@ public class ArtifactkeyDeSerializerTest extends TestCase {
public void testDeserializeTooFewPartsI() {
try {
- ArtifactKeyDeSerializer.deserialize(",,");
+ ArtifactKey.parse(",");
fail();
} catch (IllegalArgumentException e) {
assertTrue(true);
}
}
- public void testDeserializeTooMuchPartsI() {
+ public void testDeserializeTooManyPartsI() {
try {
- ArtifactKeyDeSerializer.deserialize(",,,,");
+ ArtifactKey.parse(",,,,");
fail();
} catch (IllegalArgumentException e) {
assertTrue(true);
@@ -104,7 +104,7 @@ public class ArtifactkeyDeSerializerTest extends TestCase {
public void testDeserializeTooFewPartsII() {
try {
- ArtifactKeyDeSerializer.deserialize("namespace,classifier,1.0.0");
+ ArtifactKey.parse("namespace,classifier");
fail();
} catch (IllegalArgumentException e) {
assertTrue(true);
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo.zip b/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo.zip
deleted file mode 100644
index afbb1afeb..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo.zip
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/artifacts.xml b/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/artifacts.xml
deleted file mode 100644
index f52003e6a..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/artifacts.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<?artifactRepository class='org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository' version='0.0.1'?>
-<repository name='file:D:\workspaces\prov.selfhost\org.eclipse.equinox.p2.tests\testData\enginerepo - artifacts' type='org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository' version='1.0.0'>
- <mappings size='3'>
- <rule filter='(&amp; (namespace=eclipse) (classifier=plugin))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
- <rule filter='(&amp; (namespace=eclipse) (classifier=native))' output='${repoUrl}/native/${id}_${version}'/>
- <rule filter='(&amp; (namespace=eclipse) (classifier=feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
- </mappings>
- <artifacts size='3'>
- <artifact namespace='eclipse' classifier='plugin' id='testdata' version='1.0.0.2'>
- <properties size='2'>
- <property name='artifact.size' value='1939'/>
- <property name='download.size' value='1939'/>
- </properties>
- </artifact>
- <artifact namespace='eclipse' classifier='plugin' id='org.eclipse.equinox.prov.engine' version='0.1.0.200709241631'>
- <properties size='2'>
- <property name='artifact.size' value='51366'/>
- <property name='download.size' value='51366'/>
- </properties>
- </artifact>
- <artifact namespace='eclipse' classifier='plugin' id='testdata' version='1.0.0.1'>
- <properties size='2'>
- <property name='artifact.size' value='1958'/>
- <property name='download.size' value='1958'/>
- </properties>
- </artifact>
- </artifacts>
-</repository>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/content.xml b/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/content.xml
deleted file mode 100644
index e60920027..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/content.xml
+++ /dev/null
@@ -1,276 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<?metadataRepository class='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='0.0.1'?>
-<repository name='file:D:\workspaces\prov.selfhost\org.eclipse.equinox.p2.tests\testData\enginerepo - metadata' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1.0.0'>
- <units size='5'>
- <unit id='a.jre' version='1.5.0' singleton='false'>
- <provides size='119'>
- <provided namespace='org.eclipse.equinox.p2.iunamespace' name='a.jre' version='1.5.0'/>
- <provided namespace='osgi.packages' name='javax.accessibility' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.activity' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.crypto' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.crypto.interfaces' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.crypto.spec' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.imageio' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.imageio.event' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.imageio.metadata' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.imageio.plugins.bmp' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.imageio.plugins.jpeg' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.imageio.spi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.imageio.stream' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.management' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.management.loading' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.management.modelmbean' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.management.monitor' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.management.openmbean' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.management.relation' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.management.remote' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.management.remote.rmi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.management.timer' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.naming' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.naming.directory' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.naming.event' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.naming.ldap' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.naming.spi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.net' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.net.ssl' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.print' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.print.attribute' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.print.attribute.standard' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.print.event' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.rmi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.rmi.CORBA' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.rmi.ssl' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.security.auth' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.security.auth.callback' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.security.auth.kerberos' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.security.auth.login' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.security.auth.spi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.security.auth.x500' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.security.cert' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.security.sasl' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.servlet' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.servlet.http' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.sound.midi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.sound.midi.spi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.sound.sampled' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.sound.sampled.spi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.sql' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.sql.rowset' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.sql.rowset.serial' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.sql.rowset.spi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.border' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.colorchooser' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.event' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.filechooser' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.plaf' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.plaf.basic' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.plaf.metal' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.plaf.multi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.plaf.synth' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.table' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.text' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.text.html' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.text.html.parser' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.text.rtf' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.tree' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.swing.undo' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.transaction' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.transaction.xa' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.xml' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.xml.datatype' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.xml.namespace' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.xml.parsers' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.xml.transform' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.xml.transform.dom' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.xml.transform.sax' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.xml.transform.stream' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.xml.validation' version='0.0.0'/>
- <provided namespace='osgi.packages' name='javax.xml.xpath' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.ietf.jgss' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.CORBA' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.CORBA_2_3' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.CORBA_2_3.portable' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.CORBA.DynAnyPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.CORBA.ORBPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.CORBA.portable' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.CORBA.TypeCodePackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.CosNaming' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.CosNaming.NamingContextExtPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.CosNaming.NamingContextPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.Dynamic' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.DynamicAny' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.DynamicAny.DynAnyFactoryPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.DynamicAny.DynAnyPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.IOP' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.IOP.CodecFactoryPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.IOP.CodecPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.Messaging' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.PortableInterceptor' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.PortableInterceptor.ORBInitInfoPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.PortableServer' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.PortableServer.CurrentPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.PortableServer.POAManagerPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.PortableServer.POAPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.PortableServer.portable' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.PortableServer.ServantLocatorPackage' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.SendingContext' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.omg.stub.java.rmi' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.w3c.dom' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.w3c.dom.bootstrap' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.w3c.dom.events' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.w3c.dom.ls' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.xml.sax' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.xml.sax.ext' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.xml.sax.helpers' version='0.0.0'/>
- </provides>
- <touchpoint id='native' version='1.0.0'/>
- </unit>
- <unit id='org.eclipse.equinox.prov.engine' version='0.1.0.200709241631'>
- <properties size='3'>
- <property name='equinox.p2.update.from' value='org.eclipse.equinox.prov.engine'/>
- <property name='equinox.p2.update.range' value='0.0.0'/>
- <property name='equinox.p2.name' value='Engine Plug-in (Incubation)'/>
- </properties>
- <provides size='6'>
- <provided namespace='org.eclipse.equinox.p2.iunamespace' name='org.eclipse.equinox.prov.engine' version='0.1.0.200709241631'/>
- <provided namespace='osgi.packages' name='org.eclipse.equinox.internal.prov.engine' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.eclipse.equinox.prov.engine' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.eclipse.equinox.prov.engine.phases' version='0.0.0'/>
- <provided namespace='osgi.packages' name='org.eclipse.equinox.prov.installregistry' version='0.0.0'/>
- <provided namespace='org.eclipse.equinox.p2.eclipsetouchpoint.types' name='bundle' version='1.0.0'/>
- </provides>
- <requires size='15'>
- <required namespace='org.eclipse.equinox.p2.iunamespace' name='org.eclipse.equinox.common' range='0.0.0'/>
- <required namespace='org.eclipse.equinox.p2.iunamespace' name='org.eclipse.equinox.registry' range='0.0.0'/>
- <required namespace='osgi.packages' name='com.thoughtworks.xstream' range='0.0.0'/>
- <required namespace='osgi.packages' name='org.eclipse.equinox.prov.artifact.repository' range='0.0.0'/>
- <required namespace='osgi.packages' name='org.eclipse.equinox.prov.core.eventbus' range='0.0.0'/>
- <required namespace='osgi.packages' name='org.eclipse.equinox.prov.core.helpers' range='0.0.0'/>
- <required namespace='osgi.packages' name='org.eclipse.equinox.prov.core.location' range='0.0.0'/>
- <required namespace='osgi.packages' name='org.eclipse.equinox.prov.download' range='0.0.0'/>
- <required namespace='osgi.packages' name='org.eclipse.equinox.prov.metadata' range='0.0.0'/>
- <required namespace='osgi.packages' name='org.eclipse.equinox.prov.query' range='0.0.0'/>
- <required namespace='osgi.packages' name='org.eclipse.osgi.service.datalocation' range='1.0.0'/>
- <required namespace='osgi.packages' name='org.eclipse.osgi.service.resolver' range='1.1.0'/>
- <required namespace='osgi.packages' name='org.eclipse.osgi.util' range='1.0.0'/>
- <required namespace='osgi.packages' name='org.osgi.framework' range='1.3.0'/>
- <required namespace='osgi.packages' name='org.osgi.util.tracker' range='1.3.3'/>
- </requires>
- <artifacts size='1'>
- <artifact namespace='eclipse' classifier='plugin' id='org.eclipse.equinox.prov.engine' version='0.1.0.200709241631'/>
- </artifacts>
- <touchpoint id='eclipse' version='1.0.0'/>
- <touchpointData size='1'>
- <instructions size='1'>
- <instruction key='manifest'>
- Require-Bundle: org.eclipse.equinox.common,org.eclipse.equinox.registry
-Bundle-Activator: org.eclipse.equinox.internal.prov.engine.EngineActivator
-Manifest-Version: 1.0
-Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,J2SE-1.4
-Import-Package: com.thoughtworks.xstream,org.eclipse.equinox.prov.artifact.repository,org.eclipse.equinox.prov.core.eventbus,org.eclipse.equinox.prov.core.helpers,org.eclipse.equinox.prov.core.location,org.eclipse.equinox.prov.download,org.eclipse.equinox.prov.metadata,org.eclipse.equinox.prov.query,org.eclipse.osgi.service.datalocation;version=&quot;1.0.0&quot;,org.eclipse.osgi.service.resolver;version=&quot;1.1.0&quot;,org.eclipse.osgi.util;version=&quot;1.0.0&quot;,org.osgi.framework;version=&quot;1.3.0&quot;,org.osgi.util.tracker;version=&quot;1.3.3&quot;
-Eclipse-LazyStart: true
-Bundle-Name: Engine Plug-in (Incubation)
-Ant-Version: Apache Ant 1.7.0
-Export-Package: org.eclipse.equinox.internal.prov.engine;x-internal:=true,org.eclipse.equinox.prov.engine,org.eclipse.equinox.prov.engine.phases,org.eclipse.equinox.prov.installregistry
-Created-By: 1.6.0_02-b06 (Sun Microsystems Inc.)
-Bundle-Version: 0.1.0.200709241631
-eclipse.p2.bundle.format: jar
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.equinox.prov.engine;singleton:=true
-
- </instruction>
- </instructions>
- </touchpointData>
- </unit>
- <unit id='config.a.jre' version='0.0.0' singleton='false' fragment='true' hostId='a.jre' hostRange='0.0.0'>
- <provides size='2'>
- <provided namespace='org.eclipse.equinox.p2.type' name='iu.fragment' version='1.0.0'/>
- <provided namespace='org.eclipse.equinox.p2.iunamespace' name='config.a.jre' version='0.0.0'/>
- </provides>
- <requires size='1'>
- <required namespace='org.eclipse.equinox.p2.iunamespace' name='a.jre' range='0.0.0'/>
- </requires>
- <touchpoint id='native' version='1.0.0'/>
- <touchpointData size='1'>
- <instructions size='1'>
- <instruction key='install'>
-
- </instruction>
- </instructions>
- </touchpointData>
- </unit>
- <unit id='testdata' version='1.0.0.1' singleton='false'>
- <properties size='3'>
- <property name='equinox.p2.update.from' value='testdata'/>
- <property name='equinox.p2.update.range' value='0.0.0'/>
- <property name='equinox.p2.name' value='Testdata Plug-in'/>
- </properties>
- <provides size='2'>
- <provided namespace='org.eclipse.equinox.p2.iunamespace' name='testdata' version='1.0.0.1'/>
- <provided namespace='org.eclipse.equinox.p2.eclipsetouchpoint.types' name='bundle' version='1.0.0'/>
- </provides>
- <requires size='1'>
- <required namespace='osgi.packages' name='org.osgi.framework' range='1.3.0'/>
- </requires>
- <artifacts size='1'>
- <artifact namespace='eclipse' classifier='plugin' id='testdata' version='1.0.0.1'/>
- </artifacts>
- <touchpoint id='eclipse' version='1.0.0'/>
- <touchpointData size='1'>
- <instructions size='1'>
- <instruction key='manifest'>
- Manifest-Version: 1.0
-Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1
-Import-Package: org.osgi.framework;version=&quot;1.3.0&quot;
-Eclipse-LazyStart: true
-Ant-Version: Apache Ant 1.7.0
-Bundle-Name: Testdata Plug-in
-Created-By: 2.3 (IBM Corporation)
-Bundle-Version: 1.0.0.1
-eclipse.p2.bundle.format: jar
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: testdata
-
- </instruction>
- </instructions>
- </touchpointData>
- </unit>
- <unit id='testdata' version='1.0.0.2' singleton='false'>
- <properties size='3'>
- <property name='equinox.p2.update.from' value='testdata'/>
- <property name='equinox.p2.update.range' value='0.0.0'/>
- <property name='equinox.p2.name' value='Testdata Plug-in'/>
- </properties>
- <provides size='2'>
- <provided namespace='org.eclipse.equinox.p2.iunamespace' name='testdata' version='1.0.0.2'/>
- <provided namespace='org.eclipse.equinox.p2.eclipsetouchpoint.types' name='bundle' version='1.0.0'/>
- </provides>
- <requires size='1'>
- <required namespace='osgi.packages' name='org.osgi.framework' range='1.3.0'/>
- </requires>
- <artifacts size='1'>
- <artifact namespace='eclipse' classifier='plugin' id='testdata' version='1.0.0.2'/>
- </artifacts>
- <touchpoint id='eclipse' version='1.0.0'/>
- <touchpointData size='1'>
- <instructions size='1'>
- <instruction key='manifest'>
- Manifest-Version: 1.0
-Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1
-Import-Package: org.osgi.framework;version=&quot;1.3.0&quot;
-Eclipse-LazyStart: true
-Ant-Version: Apache Ant 1.7.0
-Bundle-Name: Testdata Plug-in
-Created-By: 2.3 (IBM Corporation)
-Bundle-Version: 1.0.0.2
-eclipse.p2.bundle.format: jar
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: testdata
-
- </instruction>
- </instructions>
- </touchpointData>
- </unit>
- </units>
-</repository>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/org.eclipse.equinox.prov.engine_0.1.0.200709241631.jar b/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/org.eclipse.equinox.prov.engine_0.1.0.200709241631.jar
deleted file mode 100644
index d53ff00d9..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/org.eclipse.equinox.prov.engine_0.1.0.200709241631.jar
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/testdata_1.0.0.1.jar b/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/testdata_1.0.0.1.jar
deleted file mode 100644
index 49e7f90a2..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/testdata_1.0.0.1.jar
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/testdata_1.0.0.2.jar b/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/testdata_1.0.0.2.jar
deleted file mode 100644
index 3515b0f46..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/testData/enginerepo/plugins/testdata_1.0.0.2.jar
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/delta/eclipse-3.2-3.3.jbdiff b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/eclipse-3.2-3.3.jbdiff
index b507a8cc1..b507a8cc1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/testData/delta/eclipse-3.2-3.3.jbdiff
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/eclipse-3.2-3.3.jbdiff
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/delta/eclipse-3.2.exe b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/eclipse-3.2.exe
index 7826d1ed8..7826d1ed8 100644
--- a/bundles/org.eclipse.equinox.p2.tests/testData/delta/eclipse-3.2.exe
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/eclipse-3.2.exe
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/delta/eclipse-3.3.exe b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/eclipse-3.3.exe
index c5cd8f038..c5cd8f038 100644
--- a/bundles/org.eclipse.equinox.p2.tests/testData/delta/eclipse-3.3.exe
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/eclipse-3.3.exe
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar
new file mode 100644
index 000000000..0c809eeed
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar.pack.gz b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar.pack.gz
new file mode 100644
index 000000000..b586d3cc8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.equinox.app_1.0.100.v20071015.jar.pack.gz
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/delta/org.eclipse.jdt_3.2.0-3.3.0.jbdiff b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.jdt_3.2.0-3.3.0.jbdiff
index 394803033..394803033 100644
--- a/bundles/org.eclipse.equinox.p2.tests/testData/delta/org.eclipse.jdt_3.2.0-3.3.0.jbdiff
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.jdt_3.2.0-3.3.0.jbdiff
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/delta/org.eclipse.jdt_3.2.0.v20060605-1400.njar b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.jdt_3.2.0.v20060605-1400.njar
index 41ee47bcc..41ee47bcc 100644
--- a/bundles/org.eclipse.equinox.p2.tests/testData/delta/org.eclipse.jdt_3.2.0.v20060605-1400.njar
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.jdt_3.2.0.v20060605-1400.njar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/delta/org.eclipse.jdt_3.3.0.v20070607-1300.njar b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.jdt_3.3.0.v20070607-1300.njar
index 9deec2f0e..9deec2f0e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/testData/delta/org.eclipse.jdt_3.3.0.v20070607-1300.njar
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/org.eclipse.jdt_3.3.0.v20070607-1300.njar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/testdata_1.0.0.1-2.jar b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/testdata_1.0.0.1-2.jar
new file mode 100644
index 000000000..71a546b02
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/testdata_1.0.0.1-2.jar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/rawData/testdata_1.0.0.1.jar b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/testdata_1.0.0.1.jar
index 49e7f90a2..49e7f90a2 100644
--- a/bundles/org.eclipse.equinox.p2.tests/rawData/testdata_1.0.0.1.jar
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/testdata_1.0.0.1.jar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/rawData/testdata_1.0.0.2.jar b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/testdata_1.0.0.2.jar
index 3515b0f46..3515b0f46 100644
--- a/bundles/org.eclipse.equinox.p2.tests/rawData/testdata_1.0.0.2.jar
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/testdata_1.0.0.2.jar
Binary files differ

Back to the top