Skip to content

Commit

Permalink
fixed ObjectStreamSocketTest
Browse files Browse the repository at this point in the history
Closes #215
  • Loading branch information
LorenzoBettini committed Mar 27, 2024
1 parent d86bbf0 commit 90f4649
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.pitest.pitclipse.runner.tests"/>
</listAttribute>
Expand All @@ -24,7 +25,9 @@
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.pitest.pitclipse.runner.tests"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 90f4649

Please sign in to comment.