use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class SuppressMethodTest method testInvokeVoid.
@Test
public void testInvokeVoid() throws Exception {
suppress(method(SuppressMethod.class, "invokeVoid", new Class<?>[] { StringBuilder.class }));
SuppressMethod tested = new SuppressMethod();
// Should not cause an NPE when suppressing code.
tested.invokeVoid(null);
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class ProxyMethodTest method mockingAndMethodProxyAtTheSameTimeWorks.
@Test
public void mockingAndMethodProxyAtTheSameTimeWorks() throws Exception {
replace(method(SuppressMethod.class, "getObjectStatic")).with(new DelegatingInvocationHandler());
SuppressMethod tested = mock(SuppressMethod.class);
when(tested.getObject()).thenReturn("Hello world");
assertSame(SuppressMethod.OBJECT, SuppressMethod.getObjectStatic());
assertEquals("Hello world", tested.getObject());
verify(tested).getObject();
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class ProxyMethodTest method replaceInstanceMethodsWork.
@Test
@Ignore("Doesn't work atm")
public void replaceInstanceMethodsWork() throws Exception {
replace(method(SuppressMethod.class, "getObject")).with(method(SuppressMethodExample.class, "getStringObject"));
SuppressMethod tested = new SuppressMethod();
assertEquals("test", tested.getObject());
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class ProxyMethodTest method expectionThrowingMethodProxyWorksForMethodNames.
@Test(expected = ArrayStoreException.class)
public void expectionThrowingMethodProxyWorksForMethodNames() throws Exception {
replace(method(SuppressMethod.class, "getObject")).with(new ThrowingInvocationHandler());
new SuppressMethod().getObject();
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class ProxyMethodTest method expectionThrowingMethodProxyWorksForJavaLangReflectMethods.
@Test(expected = ArrayStoreException.class)
public void expectionThrowingMethodProxyWorksForJavaLangReflectMethods() throws Exception {
replace(method(SuppressMethod.class, "getObject")).with(new ThrowingInvocationHandler());
new SuppressMethod().getObject();
}
Aggregations