Skip to content

Commit

Permalink
WW-4846 Fixes unit tests for JDK8
Browse files Browse the repository at this point in the history
  • Loading branch information
yasserzamani committed Nov 4, 2017
1 parent 9250251 commit fb0a612
Showing 1 changed file with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,34 +162,29 @@ public void testNotTraverseOrIncludeProxyInfo() throws Exception {
JSONWriter writer = new DefaultJSONWriter();
jsonUtil.setWriter(writer);
result.setJsonUtil(jsonUtil);
ProxyFactory factory = new ProxyFactory(new TestAction2());
factory.addAdvice(new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
// fail on any traverse except TestAction2.getName()
if (!TestAction2.class.getMethod("getName").equals(invocation.getMethod())) {
throw new Throwable(invocation.getMethod() + " should not traversed!");
}
return invocation.proceed();
}
});
Object proxiedAction = factory.getProxy();
Object proxiedAction = new ProxyFactory(new TestAction2()).getProxy();
stack.push(proxiedAction);

this.invocation.setAction(proxiedAction);
try {
result.execute(this.invocation);
fail("An exception expected via proxy info traverse because writer.excludeProxyProperties is false!");
} catch (Exception ignored) {
}

writer.setExcludeProxyProperties(true);
result.execute(this.invocation);

String out = response.getContentAsString();

String normalizedActual = TestUtils.normalize(out, true);
String normalizedExpected = "{\"name\":\"name\"}";
assertNotSame(normalizedExpected, normalizedActual);
response.setCommitted(false);
response.reset();

writer.setExcludeProxyProperties(true);
result.execute(this.invocation);

out = response.getContentAsString();

normalizedActual = TestUtils.normalize(out, true);
assertEquals(normalizedExpected, normalizedActual);
}

Expand Down

0 comments on commit fb0a612

Please sign in to comment.