Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2020-09-17 05:30:58 +0000
committerAlexander Kurtakov2020-09-17 05:30:58 +0000
commita8324786b26c6fa6ca155f8f606bb1333fd4ae53 (patch)
tree0d1b96c8f018038059d127924b10cea2a1947b20
parent70eab47b416cd93a4c17d214e0f0ec3309c56855 (diff)
downloadrt.equinox.p2-a8324786b26c6fa6ca155f8f606bb1333fd4ae53.tar.gz
rt.equinox.p2-a8324786b26c6fa6ca155f8f606bb1333fd4ae53.tar.xz
rt.equinox.p2-a8324786b26c6fa6ca155f8f606bb1333fd4ae53.zip
Modernize ProcessingStepHandlerTest tests.
Change-Id: Ie9243698c67864c0bada2698efee03ab72c5cab5 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java51
1 files changed, 22 insertions, 29 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 0aff0f192..749403ee0 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
@@ -16,6 +16,7 @@
package org.eclipse.equinox.p2.tests.artifact.repository.processing;
import static org.eclipse.equinox.p2.tests.AbstractProvisioningTest.getAgent;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -26,7 +27,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.Arrays;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -114,7 +114,7 @@ public class ProcessingStepHandlerTest {
try (OutputStream testStream = handler.link(steps, result, monitor)) {
testStream.write(new byte[] {1});
}
- assertTrue(Arrays.equals(new byte[] {2}, result.toByteArray()));
+ assertArrayEquals(new byte[] { 2 }, result.toByteArray());
}
@Test
@@ -124,7 +124,7 @@ public class ProcessingStepHandlerTest {
try (OutputStream testStream = handler.link(steps, result, monitor)) {
testStream.write(new byte[] {1});
}
- assertTrue(Arrays.equals(new byte[] {8}, result.toByteArray()));
+ assertArrayEquals(new byte[] { 8 }, result.toByteArray());
}
@Test
@@ -139,17 +139,14 @@ public class ProcessingStepHandlerTest {
@Test
public void testExecuteOneMD5VerifierPSFails() throws IOException {
- ProcessingStep[] steps = new ProcessingStep[] {new MD5Verifier("9cbc6611f5540bd0809a388dc95a615b")};
+ ProcessingStep[] steps = new ProcessingStep[] { new MD5Verifier("9cbc6611f5540bd0809a388dc95a615b") };
ByteArrayOutputStream result = new ByteArrayOutputStream(10);
- OutputStream testStream = handler.link(steps, result, monitor);
+ OutputStream testStream=handler.link(steps, result, monitor);
+ try (testStream) {
testStream.write("Test".getBytes());
- try {
- testStream.close();
- assertEquals("Test", result.toString());
- assertTrue((ProcessingStepHandler.checkStatus(testStream).getSeverity() == IStatus.ERROR));
- } catch (IOException e) {
- assertTrue(true);
}
+ assertEquals("Test", result.toString());
+ assertEquals(IStatus.ERROR, ProcessingStepHandler.checkStatus(testStream).getSeverity());
}
@Test
@@ -160,7 +157,7 @@ public class ProcessingStepHandlerTest {
try (OutputStream testStream = handler.link(steps, result, monitor)) {
testStream.write(new byte[] {1, 2, 3, 4, 5});
}
- assertTrue(Arrays.equals(new byte[] {2, 4, 6, 8, 10}, result.toByteArray()));
+ assertArrayEquals(new byte[] { 2, 4, 6, 8, 10 }, result.toByteArray());
}
@Test
@@ -169,14 +166,11 @@ public class ProcessingStepHandlerTest {
ProcessingStep[] steps = new ProcessingStep[] {new MD5Verifier("af476bbaf152a4c39ca4e5c498a88aa0"), new ByteShifter(1)};
ByteArrayOutputStream result = new ByteArrayOutputStream(10);
OutputStream testStream = handler.link(steps, result, monitor);
- testStream.write(new byte[] {1, 2, 3, 4, 5});
- try {
- testStream.close();
- assertTrue(Arrays.equals(new byte[] {2, 4, 6, 8, 10}, result.toByteArray()));
- assertTrue((ProcessingStepHandler.checkStatus(testStream).getSeverity() == IStatus.ERROR));
- } catch (IOException e) {
- assertTrue(true);
+ try (testStream) {
+ testStream.write(new byte[] { 1, 2, 3, 4, 5 });
}
+ assertArrayEquals(new byte[] { 2, 4, 6, 8, 10 }, result.toByteArray());
+ assertEquals(IStatus.ERROR, ProcessingStepHandler.checkStatus(testStream).getSeverity());
}
@Test
@@ -186,7 +180,7 @@ public class ProcessingStepHandlerTest {
try (OutputStream testStream = handler.link(steps, result, monitor)) {
testStream.write(new byte[] {1, 2, 3, 4, 5});
}
- assertTrue(Arrays.equals(new byte[] {4, 6, 8, 10, 12}, result.toByteArray()));
+ assertArrayEquals(new byte[] { 4, 6, 8, 10, 12 }, result.toByteArray());
}
@Test
@@ -197,8 +191,7 @@ public class ProcessingStepHandlerTest {
testStream.write(new byte[] {1, 2, 3, 4, 5});
}
- assertTrue(Arrays.equals(new byte[] {3, 5, 7, 9, 11}, result.toByteArray()));
-
+ assertArrayEquals(new byte[] { 3, 5, 7, 9, 11 }, result.toByteArray());
}
@Test
@@ -286,7 +279,7 @@ public class ProcessingStepHandlerTest {
try (OutputStream testStream = handler.link(steps, result, monitor)) {
testStream.write(new byte[] {1, 2, 3, 4, 5});
}
- assertTrue(Arrays.equals(new byte[] {4, 6, 8, 10, 12}, result.toByteArray()));
+ assertArrayEquals(new byte[] { 4, 6, 8, 10, 12 }, result.toByteArray());
}
@Test
@@ -299,7 +292,7 @@ public class ProcessingStepHandlerTest {
try (OutputStream testStream = handler.link(steps, result, monitor)) {
testStream.write(new byte[] {1, 2, 3, 4, 5});
}
- assertTrue(Arrays.equals(new byte[] {3, 5, 7, 9, 11}, result.toByteArray()));
+ assertArrayEquals(new byte[] { 3, 5, 7, 9, 11 }, result.toByteArray());
}
@Test
@@ -311,7 +304,7 @@ public class ProcessingStepHandlerTest {
try (OutputStream testStream = handler.createAndLink(getAgent(), descriptors, null, result, monitor)) {
testStream.write(new byte[] {1, 2, 3, 4, 5});
}
- assertTrue(Arrays.equals(new byte[] {4, 6, 8, 10, 12}, result.toByteArray()));
+ assertArrayEquals(new byte[] { 4, 6, 8, 10, 12 }, result.toByteArray());
}
@Test
@@ -334,8 +327,8 @@ public class ProcessingStepHandlerTest {
IStatus status = ProcessingStepHandler.getStatus(testStream);
IStatus errStatus = ProcessingStepHandler.getStatus(testStream);
assertTrue(status.isOK() && errStatus.isOK());
- assertTrue(!status.isMultiStatus());
- assertTrue(!errStatus.isMultiStatus());
+ assertFalse(status.isMultiStatus());
+ assertFalse(errStatus.isMultiStatus());
}
@Test
@@ -370,7 +363,7 @@ public class ProcessingStepHandlerTest {
};
OutputStream testStream = handler.link(new ProcessingStep[] {info, ok, error, warning}, null, monitor);
- assertTrue(ProcessingStepHandler.getErrorStatus(testStream).getChildren().length == 2);
- assertTrue(ProcessingStepHandler.getStatus(testStream, true).getChildren().length == 4);
+ assertEquals(2, ProcessingStepHandler.getErrorStatus(testStream).getChildren().length);
+ assertEquals(4, ProcessingStepHandler.getStatus(testStream, true).getChildren().length);
}
}

Back to the top