Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2018-06-26 09:24:37 +0000
committerMykola Nikishov2018-12-20 19:12:48 +0000
commitb8b794603e2cc67f4b2d7e5c392b6f1f8b534d86 (patch)
treeefee6c0e7134cd3d9e80ee46e6a0202f9f556921 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java
parent27630805f3b5764e05f4101744f94caff0947099 (diff)
downloadrt.equinox.p2-b8b794603e2cc67f4b2d7e5c392b6f1f8b534d86.tar.gz
rt.equinox.p2-b8b794603e2cc67f4b2d7e5c392b6f1f8b534d86.tar.xz
rt.equinox.p2-b8b794603e2cc67f4b2d7e5c392b6f1f8b534d86.zip
Bug 536282 - Check whether processing step is availableI20181220-1800
Extend ProcessingStep with isEnabled() method that checks if step's dependencies are available. ProcessingStepHandler's canProcess will ensure that all required processing steps are enabled and skip this check for optional processing steps. MirrorRequest's perform(IArtifactRepository, IProgressMonitor) method will skip optimized artifact if it can't be processed and chose canonical one. Pack200ProcessorStep's isEnabled() checks if 'unpack200' CLI utility is available by calling UnpackStep's canUnpack(). Change-Id: I048db3b833f6e0881cca06ad48be37ad6d17a0c9 Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java44
1 files changed, 43 insertions, 1 deletions
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 04216eb73..c8df6b48d 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
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2007, 2017 compeople AG and others.
+* Copyright (c) 2007, 2018 compeople AG and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
* IBM - continuing development
+* Mykola Nikishov - continuing development
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository.processing;
@@ -27,9 +28,11 @@ import org.eclipse.equinox.internal.p2.artifact.processors.md5.MD5Verifier;
import org.eclipse.equinox.internal.p2.artifact.processors.pack200.Pack200ProcessorStep;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.internal.p2.jarprocessor.PackStep;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler;
import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
@@ -41,6 +44,45 @@ public class ProcessingStepHandlerTest extends AbstractProvisioningTest {
ProcessingStepHandler handler = new ProcessingStepHandler();
IProgressMonitor monitor = new NullProgressMonitor();
+ public void testCanProcess_Ok() {
+ ArtifactDescriptor descriptor = new ArtifactDescriptor(ArtifactKey.parse("classifier,id,1.0.0"));
+ descriptor.setProcessingSteps(new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)});
+
+ assertTrue(ProcessingStepHandler.canProcess(descriptor));
+ }
+
+ public void testCanProcess_FailNoSuchStep() {
+ String noSuchStepId = "org.eclipse.equinox.p2.processing.test.Dummy";
+ ArtifactDescriptor descriptor = new ArtifactDescriptor(ArtifactKey.parse("classifier,id,1.0.0"));
+ descriptor.setProcessingSteps(new ProcessingStepDescriptor[] {new ProcessingStepDescriptor(noSuchStepId, null, true), new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.ByteShifter", "1", true)});
+
+ assertFalse(ProcessingStepHandler.canProcess(descriptor));
+ }
+
+ public void testCanProcess_FailAlwaysDisabled() {
+ ArtifactDescriptor descriptor = new ArtifactDescriptor(ArtifactKey.parse("classifier,id,1.0.0"));
+ String processorId = "org.eclipse.equinox.p2.processing.AlwaysDisabled";
+ descriptor.setProcessingSteps(new ProcessingStepDescriptor[] {new ProcessingStepDescriptor(processorId, null, true), new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.ByteShifter", "1", true)});
+
+ assertFalse(ProcessingStepHandler.canProcess(descriptor));
+ }
+
+ public void testCanProcess_OkOptionalAlwaysDisabled() {
+ ArtifactDescriptor descriptor = new ArtifactDescriptor(ArtifactKey.parse("classifier,id,1.0.0"));
+ String processorId = "org.eclipse.equinox.p2.processing.AlwaysDisabled";
+ descriptor.setProcessingSteps(new ProcessingStepDescriptor[] {new ProcessingStepDescriptor(processorId, null, false), new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.ByteShifter", "1", true)});
+
+ assertTrue("Not enabled optional step should not block processing", ProcessingStepHandler.canProcess(descriptor));
+ }
+
+ public void testCanProcess_FailMultipleSteps() {
+ ArtifactDescriptor descriptor = new ArtifactDescriptor(ArtifactKey.parse("classifier,id,1.0.0"));
+ String processorId = "org.eclipse.equinox.p2.processing.MultipleSteps";
+ descriptor.setProcessingSteps(new ProcessingStepDescriptor[] {new ProcessingStepDescriptor(processorId, null, true), new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.ByteShifter", "1", true)});
+
+ assertFalse(String.format("Multiple step attributes in %s are not supported", processorId), ProcessingStepHandler.canProcess(descriptor));
+ }
+
public void testExecuteNoPSs() throws IOException {
IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[0];
OutputStream result = new ByteArrayOutputStream(10);

Back to the top