Package org.mockitousage

Examples of org.mockitousage.IMethods


        // when
        ByteArrayOutputStream serialized = serializeMock(imethodsMock);

        // then
        IMethods readObject = deserializeMock(serialized, IMethods.class);
        assertEquals(value, readObject.objectReturningMethodNoArgs());
    }
View Full Code Here


        // when
        ByteArrayOutputStream serialized = serializeMock(imethodsMock);

        // then
        IMethods readObject = deserializeMock(serialized, IMethods.class);
        assertEquals(value, readObject.objectArgMethod(value));
    }
View Full Code Here

        // when
        ByteArrayOutputStream serialized = serializeMock(imethodsMock);

        // then
        IMethods readObject = deserializeMock(serialized, IMethods.class);
        assertEquals(value, readObject.objectArgMethod(""));
    }
View Full Code Here

        // when
        ByteArrayOutputStream serialized = serializeMock(imethodsMock);

        // then
        IMethods readObject = deserializeMock(serialized, IMethods.class);
        verify(readObject, times(1)).objectArgMethod("");
    }
View Full Code Here

    public void should_verify_even_if_some_methods_called_after_serialization() throws Exception {

        // when
      imethodsMock.simpleMethod(1);
        ByteArrayOutputStream serialized = serializeMock(imethodsMock);
        IMethods readObject = deserializeMock(serialized, IMethods.class);
        readObject.simpleMethod(1);

        // then
        verify(readObject, times(2)).simpleMethod(1);

        //this test is working because it seems that java serialization mechanism replaces all instances
View Full Code Here

    public void should_stub_even_if_some_methods_called_after_serialization() throws Exception {
        //given
        // when
        when(imethodsMock.simpleMethod(1)).thenReturn("foo");
        ByteArrayOutputStream serialized = serializeMock(imethodsMock);
        IMethods readObject = deserializeMock(serialized, IMethods.class);
        when(readObject.simpleMethod(2)).thenReturn("bar");

        // then
        assertEquals("foo", readObject.simpleMethod(1));
        assertEquals("bar", readObject.simpleMethod(2));
    }
View Full Code Here

        // when
        ByteArrayOutputStream serialized = serializeMock(imethodsMock);
        ByteArrayOutputStream serialized2 = serializeMock(imethodsMock2);

        // then
        IMethods readObject = deserializeMock(serialized, IMethods.class);
        IMethods readObject2 = deserializeMock(serialized2, IMethods.class);
        InOrder inOrder = inOrder(readObject, readObject2);
        inOrder.verify(readObject).arrayReturningMethod();
        inOrder.verify(readObject2).arrayReturningMethod();
    }
View Full Code Here

        // when
        ByteArrayOutputStream serialized = serializeMock(imethodsMock);

        // then
        IMethods readObject = deserializeMock(serialized, IMethods.class);
        verify(readObject, never()).objectArgMethod("never happened");
    }
View Full Code Here

        // when
        ByteArrayOutputStream serialized = serializeMock(imethodsMock);

        // then
        IMethods readObject = deserializeMock(serialized, IMethods.class);
        assertEquals(answer.string, readObject.objectArgMethod(""));
    }
View Full Code Here

    }

    @Test
    public void should_allow_mock_to_be_serializable() throws Exception {
        // given
        IMethods mock = mock(IMethods.class, withSettings().serializable());

        // when-serialize then-deserialize
        serializeAndBack(mock);
    }
View Full Code Here

TOP

Related Classes of org.mockitousage.IMethods

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.