From 90f4649c17b17959839cf566501e53376978d8dc Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 27 Mar 2024 11:42:48 +0100 Subject: [PATCH] fixed ObjectStreamSocketTest Closes https://github.com/pitest/pitclipse/issues/215 --- .../org.pitest.pitclipse.runner.tests.launch | 5 ++- .../runner/io/ObjectStreamSocketTest.java | 37 +++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/tests/org.pitest.pitclipse.runner.tests/org.pitest.pitclipse.runner.tests.launch b/tests/org.pitest.pitclipse.runner.tests/org.pitest.pitclipse.runner.tests.launch index f763eb53..a725531e 100644 --- a/tests/org.pitest.pitclipse.runner.tests/org.pitest.pitclipse.runner.tests.launch +++ b/tests/org.pitest.pitclipse.runner.tests/org.pitest.pitclipse.runner.tests.launch @@ -14,6 +14,7 @@ + @@ -24,7 +25,9 @@ - + + + diff --git a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/io/ObjectStreamSocketTest.java b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/io/ObjectStreamSocketTest.java index 74c56d44..4e69538e 100644 --- a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/io/ObjectStreamSocketTest.java +++ b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/io/ObjectStreamSocketTest.java @@ -16,22 +16,6 @@ package org.pitest.pitclipse.runner.io; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.io.Serializable; -import java.net.Socket; - import static org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals; import static org.apache.commons.lang3.builder.HashCodeBuilder.reflectionHashCode; import static org.hamcrest.CoreMatchers.equalTo; @@ -43,10 +27,25 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.io.Serializable; +import java.net.Socket; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + @RunWith(MockitoJUnitRunner.class) public class ObjectStreamSocketTest { @@ -121,7 +120,7 @@ public void makeThrowsException() throws IOException { @Test public void readThrowsException() throws IOException, ClassNotFoundException { - InputStream inputStream = spy(new ByteArrayInputStream(asBytes(expectedObject))); + InputStream inputStream = new ByteArrayInputStream(asBytes(expectedObject)); OutputStream outputStream = new ByteArrayOutputStream(); when(underlyingSocket.getInputStream()).thenReturn(inputStream); when(underlyingSocket.getOutputStream()).thenReturn(outputStream); @@ -138,7 +137,7 @@ public void readThrowsException() throws IOException, ClassNotFoundException { @Test public void writeThrowsException() throws IOException, ClassNotFoundException { - InputStream inputStream = spy(new ByteArrayInputStream(asBytes(expectedObject))); + InputStream inputStream = new ByteArrayInputStream(asBytes(expectedObject)); OutputStream outputStream = new ByteArrayOutputStream(); when(underlyingSocket.getInputStream()).thenReturn(inputStream); when(underlyingSocket.getOutputStream()).thenReturn(outputStream);