Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JarDeltaOptimizerTest.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JarDeltaOptimizerTest.java66
1 files changed, 36 insertions, 30 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JarDeltaOptimizerTest.java b/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JarDeltaOptimizerTest.java
index 3f9faf65a..c682ef5d9 100644
--- a/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JarDeltaOptimizerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.optimizers/src/org/eclipse/equinox/p2/tests/artifact/optimizers/JarDeltaOptimizerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 compeople AG and others.
+ * Copyright (c) 2007, 2018 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
@@ -26,31 +26,37 @@ import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor;
import org.eclipse.equinox.p2.tests.artifact.processors.ArtifactRepositoryMock;
import org.eclipse.equinox.p2.tests.optimizers.TestData;
+import org.junit.Test;
/**
* Test the <code>JarDelta</code> processing step.
*/
public class JarDeltaOptimizerTest extends OptimizerTest {
- // 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", Version.create("1.0.0.2"));
- // ArtifactDescriptor descriptor = new ArtifactDescriptor(key);
- // step.initialize(stepDescriptor, descriptor);
- // ByteArrayOutputStream destination = new ByteArrayOutputStream();
- // step.link(destination, new NullProgressMonitor());
+ // 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",
+ // Version.create("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 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);
- // }
+ // inputStream = new ByteArrayInputStream(destination.toByteArray());
+ // FileOutputStream file = new FileOutputStream("d:/jardelta.jar");
+ // FileUtils.copyStream(inputStream, true, file, true);
+ // }
+ @Test
public void testOptimization() throws IOException {
IArtifactRepository repoMock = ArtifactRepositoryMock.getMock("testData/optimizers/testdata_1.0.0.1.jar");
ProcessingStep step = new MockableJarDeltaOptimizerStep(repoMock);
@@ -58,22 +64,22 @@ public class JarDeltaOptimizerTest extends OptimizerTest {
IArtifactKey key = new ArtifactKey("cl", "id1", Version.create("1.0.0.2"));
ArtifactDescriptor descriptor = new ArtifactDescriptor(key);
step.initialize(getAgent(), stepDescriptor, descriptor);
- ByteArrayOutputStream destination = new ByteArrayOutputStream();
- step.link(destination, new NullProgressMonitor());
+ try (ByteArrayOutputStream destination = new ByteArrayOutputStream()) {
+ step.link(destination, new NullProgressMonitor());
- InputStream inputStream = TestData.get("optimizers", "testdata_1.0.0.2.jar");
- FileUtils.copyStream(inputStream, true, step, true);
- destination.close();
+ InputStream inputStream = TestData.get("optimizers", "testdata_1.0.0.2.jar");
+ FileUtils.copyStream(inputStream, true, step, true);
+ destination.close();
- inputStream = TestData.get("optimizers", "testdata_1.0.0.1-2.jar");
- ByteArrayOutputStream expected = new ByteArrayOutputStream();
- FileUtils.copyStream(inputStream, true, expected, true);
+ inputStream = TestData.get("optimizers", "testdata_1.0.0.1-2.jar");
+ 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()));
- TestData.assertEquals(expectedJar, testJar);
- expectedJar.close();
- testJar.close();
+ try (ZipInputStream expectedJar = new ZipInputStream(new ByteArrayInputStream(expected.toByteArray()));
+ ZipInputStream testJar = new ZipInputStream(new ByteArrayInputStream(destination.toByteArray()))) {
+ TestData.assertEquals(expectedJar, testJar);
+ }
+ }
}
/**

Back to the top