Skip to content

Commit

Permalink
Minor changes around method names
Browse files Browse the repository at this point in the history
  • Loading branch information
chetanmeh committed Feb 3, 2014
1 parent a21401d commit 78280dc
Showing 1 changed file with 9 additions and 9 deletions.
Expand Up @@ -47,7 +47,7 @@ public void testDelegate() throws Exception {
SubstitutableLogger log = new SubstitutableLogger("foo");
assertTrue(log.delegate() instanceof NOPLogger);

Set<String> methodSignatures = determinemethodSignatures(Logger.class);
Set<String> expectedMethodSignatures = determineMethodSignatures(Logger.class);
LoggerInvocationHandler ih = new LoggerInvocationHandler();
Logger proxyLogger = (Logger) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class[]{Logger.class}, ih);
Expand All @@ -56,9 +56,9 @@ public void testDelegate() throws Exception {
invokeMethods(log);

//Assert that all methods are delegated
methodSignatures.removeAll(ih.getMethodSignatures());
if (!methodSignatures.isEmpty()) {
fail("Following methods are not delegated " + methodSignatures.toString());
expectedMethodSignatures.removeAll(ih.getInvokedMethodSignatures());
if (!expectedMethodSignatures.isEmpty()) {
fail("Following methods are not delegated " + expectedMethodSignatures.toString());
}
}

Expand All @@ -71,22 +71,22 @@ private void invokeMethods(Logger proxyLogger) throws InvocationTargetException,
}

private class LoggerInvocationHandler implements InvocationHandler {
private final Set<String> methodSignatures = new HashSet<String>();
private final Set<String> invokedMethodSignatures = new HashSet<String>();

public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
methodSignatures.add(getMethodSignature(method));
invokedMethodSignatures.add(getMethodSignature(method));
if (method.getName().startsWith("is")) {
return true;
}
return null;
}

public Set<String> getMethodSignatures() {
return methodSignatures;
public Set<String> getInvokedMethodSignatures() {
return invokedMethodSignatures;
}
}

private static Set<String> determinemethodSignatures(Class<Logger> loggerClass) {
private static Set<String> determineMethodSignatures(Class<Logger> loggerClass) {
Set<String> methodSignatures = new HashSet<String>();
for (Method m : loggerClass.getDeclaredMethods()) {
if (!EXCLUDED_METHODS.contains(m.getName())) {
Expand Down

0 comments on commit 78280dc

Please sign in to comment.