diff options
author | Pascal Rapicault | 2008-05-30 02:06:29 +0000 |
---|---|---|
committer | Pascal Rapicault | 2008-05-30 02:06:29 +0000 |
commit | 44e0e1f9e32746016c41810ca24f3dbadd088679 (patch) | |
tree | b5e46b5ea4a6db74283ba52e49817334e1df9342 /bundles/org.eclipse.equinox.p2.tests.optimizers | |
parent | 7ef02d845b9c410d3fb120c16a0b0ca0c317c188 (diff) | |
download | rt.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')
8 files changed, 113 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); + + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/a.txt b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/a.txt new file mode 100644 index 000000000..97896a0bc --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/a.txt @@ -0,0 +1 @@ +nothing
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/a.zip b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/a.zip Binary files differnew file mode 100644 index 000000000..09292688e --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/a.zip diff --git a/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/bogusa.zip b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/bogusa.zip Binary files differnew file mode 100644 index 000000000..3eae9a358 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/bogusa.zip diff --git a/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/bogusa2.zip b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/bogusa2.zip Binary files differnew file mode 100644 index 000000000..ccf133040 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/bogusa2.zip diff --git a/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/org.eclipse.equinox.p2.updatechecker.source_1.0.0.v20080427-2136.jar.pack.gz b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/org.eclipse.equinox.p2.updatechecker.source_1.0.0.v20080427-2136.jar.pack.gz Binary files differnew file mode 100644 index 000000000..034ae0cf1 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/org.eclipse.equinox.p2.updatechecker.source_1.0.0.v20080427-2136.jar.pack.gz diff --git a/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/org.eclipse.mylyn.bugzilla.core_2.3.2.v20080402-2100.jar b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/org.eclipse.mylyn.bugzilla.core_2.3.2.v20080402-2100.jar new file mode 100644 index 000000000..fbf83f243 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests.optimizers/testData/zipValidation/org.eclipse.mylyn.bugzilla.core_2.3.2.v20080402-2100.jar @@ -0,0 +1,7 @@ +<HTML><HEAD><TITLE>Authentication Proxy Login Page</TITLE><script language="JavaScript"><!-- Begin +var pxypromptwindow1;var pxysubmitted = false;function doreload() {if(pxypromptwindow1.closed) {window.location.reload(true);} else {reloadtimeout=setTimeout("doreload()", 500);}}function submitreload() {if(pxysubmitted == false) {pxypromptwindow1=window.open('', 'pxywindow1','resizable=no,width=300,height=300,scrollbars=yes');reloadtimeout=setTimeout("doreload()", 1000);pxysubmitted = true;return true;} else {alert("This page can not be submitted twice.");return false;}}// --> +</script> +</HEAD> +<BODY onLoad="document.AuthenForm.uname.focus()" BGCOLOR="#FFFFFF" LINK="#ffcc00" ALINK="#ffffff" VLINK="#ffcc00" ><H1>SWG RTP B500 BSO: Enter your IBM intranet credentials <BR><BR> HTTPS Authentication<BR><BR><p><FORM name="AuthenForm" method=post action="https://9.42.96.226:443" target="pxywindow1"><input type=hidden name=au_pxytimetag value="281014010">Username: <input type=text name=uname><BR><BR>Password: <input type=password name=pwd><BR><BR><input type=submit name=ok value=OK onClick="return submitreload()"></H1></FORM></script></BODY></HTML>
+
+
|