@Test public void testReadNext() throws Exception { when(objectInputStreamMock1.readNext()).thenReturn(RETURN_VALUE1); assertThat(subject.readNext(), is(RETURN_VALUE1)); verify(objectInputStreamMock1).readNext(); when(objectInputStreamMock1.readNext()).thenReturn(null); when(objectInputStreamMock2.readNext()).thenReturn(RETURN_VALUE2); assertThat(subject.readNext(), is(RETURN_VALUE2)); verify(objectInputStreamMock2).readNext(); verify(objectInputStreamMock1).close(); when(objectInputStreamMock2.readNext()).thenReturn(null); assertThat(subject.readNext(), is(nullValue())); verify(objectInputStreamMock2).close(); }
@Test public void testClose() throws Exception { subject.close(); verify(objectInputStreamMock1).close(); verify(objectInputStreamMock2).close(); }