Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2008-05-30 02:06:29 +0000
committerPascal Rapicault2008-05-30 02:06:29 +0000
commit44e0e1f9e32746016c41810ca24f3dbadd088679 (patch)
treeb5e46b5ea4a6db74283ba52e49817334e1df9342 /bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests
parent7ef02d845b9c410d3fb120c16a0b0ca0c317c188 (diff)
downloadrt.equinox.p2-44e0e1f9e32746016c41810ca24f3dbadd088679.tar.gz
rt.equinox.p2-44e0e1f9e32746016c41810ca24f3dbadd088679.tar.xz
rt.equinox.p2-44e0e1f9e32746016c41810ca24f3dbadd088679.zip
add test for ZipVerifierProcessor
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/AllTests.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/ZipVerifierProcessorTest.java104
2 files changed, 105 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/AllTests.java b/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/AllTests.java
index 16b65a62b..d7d12981e 100644
--- a/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/AllTests.java
@@ -21,7 +21,7 @@ public class AllTests extends TestCase {
TestSuite suite = new TestSuite(AllTests.class.getName());
suite.addTestSuite(JBPatchStepTest.class);
suite.addTestSuite(JBPatchZipStepTest.class);
- // suite.addTestSuite(JarDeltaProcessorTest.class);
+ suite.addTestSuite(JarDeltaProcessorTest.class);
suite.addTestSuite(Pack200ProcessorTest.class);
suite.addTestSuite(ZipVerifierProcessorTest.class);
return suite;
diff --git a/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/ZipVerifierProcessorTest.java b/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/ZipVerifierProcessorTest.java
new file mode 100644
index 000000000..b8906dd07
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/processors/ZipVerifierProcessorTest.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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 junit.framework.TestCase;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ZipVerifierStep;
+import org.eclipse.equinox.p2.tests.optimizers.TestActivator;
+import org.osgi.framework.Bundle;
+
+public class ZipVerifierProcessorTest extends TestCase {
+
+ public ZipVerifierProcessorTest(String name) {
+ super(name);
+ }
+
+ public ZipVerifierProcessorTest() {
+ super("");
+ }
+
+ public void testGoodZip() throws IOException {
+ // Setup the processor
+ ProcessingStep step = new ZipVerifierStep();
+ 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/zipValidation/a.zip").openStream();
+ FileUtils.copyStream(inputStream, true, step, true);
+
+ assertEquals(step.getStatus().getSeverity(), IStatus.OK);
+ }
+
+ public void testBogusFile() throws IOException {
+ // Setup the processor
+ ProcessingStep step = new ZipVerifierStep();
+ 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/zipValidation/a.txt").openStream();
+ FileUtils.copyStream(inputStream, true, step, true);
+
+ assertEquals(step.getStatus().getSeverity(), IStatus.ERROR);
+ }
+
+ public void testBogusFile2() throws IOException {
+ // Setup the processor
+ ProcessingStep step = new ZipVerifierStep();
+ 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/zipValidation/org.eclipse.mylyn.bugzilla.core_2.3.2.v20080402-2100.jar").openStream();
+ FileUtils.copyStream(inputStream, true, step, true);
+
+ assertEquals(step.getStatus().getSeverity(), IStatus.ERROR);
+ }
+
+ public void testBogusFile3() throws IOException {
+ // Setup the processor
+ ProcessingStep step = new ZipVerifierStep();
+ 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/zipValidation/bogusa.zip").openStream();
+ FileUtils.copyStream(inputStream, true, step, true);
+
+ assertEquals(step.getStatus().getSeverity(), IStatus.ERROR);
+ }
+
+ public void testPackGZFile() throws IOException {
+
+ // Setup the processor
+ ProcessingStep step = new ZipVerifierStep();
+ 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/zipValidation/org.eclipse.equinox.p2.updatechecker.source_1.0.0.v20080427-2136.jar.pack.gz").openStream();
+ FileUtils.copyStream(inputStream, true, step, true);
+
+ assertEquals(step.getStatus().getSeverity(), IStatus.ERROR);
+
+ }
+}

Back to the top