Search in sources :

Example 1 with SimplePrivateFieldServiceClass

use of samples.privatefield.SimplePrivateFieldServiceClass in project powermock by powermock.

the class EasyMockAndPowerMockMixTest method testSimplePrivateFieldServiceClass.

@Test
public void testSimplePrivateFieldServiceClass() throws Exception {
    SimplePrivateFieldServiceClass tested = new SimplePrivateFieldServiceClass();
    Service serviceMock = createMock(Service.class);
    setInternalState(tested, "service", serviceMock, SimplePrivateFieldServiceClass.class);
    final String expected = "Hello world!";
    expect(serviceMock.getServiceMessage()).andReturn(expected);
    replay(serviceMock);
    final String actual = tested.useService();
    verify(serviceMock);
    assertEquals(expected, actual);
}
Also used : Service(samples.Service) SimplePrivateFieldServiceClass(samples.privatefield.SimplePrivateFieldServiceClass) Test(org.junit.Test)

Example 2 with SimplePrivateFieldServiceClass

use of samples.privatefield.SimplePrivateFieldServiceClass in project powermock by powermock.

the class SimplePrivateFieldServiceClassTest method testSimplePrivateFieldServiceClass.

@Test
public void testSimplePrivateFieldServiceClass() throws Exception {
    SimplePrivateFieldServiceClass tested = new SimplePrivateFieldServiceClass();
    Service serviceMock = createMock(Service.class);
    setInternalState(tested, "service", serviceMock, SimplePrivateFieldServiceClass.class);
    final String expected = "Hello world!";
    expect(serviceMock.getServiceMessage()).andReturn(expected);
    replay(serviceMock);
    final String actual = tested.useService();
    verify(serviceMock);
    assertEquals(expected, actual);
}
Also used : Service(samples.Service) SimplePrivateFieldServiceClass(samples.privatefield.SimplePrivateFieldServiceClass) Test(org.junit.Test)

Example 3 with SimplePrivateFieldServiceClass

use of samples.privatefield.SimplePrivateFieldServiceClass in project powermock by powermock.

the class SimplePrivateFieldServiceClassTest method testSimplePrivateFieldServiceClassTypeSafe.

@Test
public void testSimplePrivateFieldServiceClassTypeSafe() throws Exception {
    SimplePrivateFieldServiceClass tested = new SimplePrivateFieldServiceClass();
    Service serviceMock = createMock(Service.class);
    setInternalState(tested, serviceMock);
    final String expected = "Hello world!";
    expect(serviceMock.getServiceMessage()).andReturn(expected);
    replay(serviceMock);
    final String actual = tested.useService();
    verify(serviceMock);
    assertEquals(expected, actual);
}
Also used : Service(samples.Service) SimplePrivateFieldServiceClass(samples.privatefield.SimplePrivateFieldServiceClass) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 Service (samples.Service)3 SimplePrivateFieldServiceClass (samples.privatefield.SimplePrivateFieldServiceClass)3