From 988d0c2fa1d2c4ccb8eeee885936e4ac478155a0 Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 17 Dec 2010 22:01:59 +0000 Subject: [PATCH] Fix remaining warnings in unit tests (with recently documented settings) git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1050500 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/catalina/filters/TesterResponse.java | 12 ++++----- .../catalina/tribes/demos/IntrospectionUtils.java | 29 +++------------------- test/org/apache/catalina/tribes/demos/MapDemo.java | 1 + .../tribes/demos/MembersWithProperties.java | 1 + 4 files changed, 12 insertions(+), 31 deletions(-) diff --git a/test/org/apache/catalina/filters/TesterResponse.java b/test/org/apache/catalina/filters/TesterResponse.java index 715f0531e..f784c4fa1 100644 --- a/test/org/apache/catalina/filters/TesterResponse.java +++ b/test/org/apache/catalina/filters/TesterResponse.java @@ -105,7 +105,7 @@ public class TesterResponse * @param b * @throws IOException */ - public void write(@SuppressWarnings("unused") int b) throws IOException { + public void write(int b) throws IOException { // NOOP } /** @@ -113,8 +113,8 @@ public class TesterResponse * @param b * @throws IOException */ - public void write(@SuppressWarnings("unused") byte b[]) throws IOException { - // NOOP + public void write(byte b[]) throws IOException { + // NOOP } /** * @@ -123,9 +123,9 @@ public class TesterResponse * @param len * @throws IOException */ - public void write(@SuppressWarnings("unused") byte b[], - @SuppressWarnings("unused") int off, - @SuppressWarnings("unused") int len) throws IOException {/* NOOP */} + public void write(byte b[], int off, int len) throws IOException { + // NOOP + } @Override public void flushBuffer() throws IOException {/* NOOP */} @Override diff --git a/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java b/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java index 8118b9996..3ab087c70 100644 --- a/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java +++ b/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java @@ -258,6 +258,7 @@ public final class IntrospectionUtils { * int or boolean we'll convert value to the right type before) - that means * you can have setDebug(1). */ + @SuppressWarnings("null") public static boolean setProperty(Object o, String name, String value) { if (log.isDebugEnabled()) log.debug("IntrospectionUtils: setProperty(" + @@ -355,7 +356,8 @@ public final class IntrospectionUtils { params[1] = value; if (setPropertyMethodBool != null) { try { - return (Boolean) setPropertyMethodBool.invoke(o, params); + return ((Boolean) setPropertyMethodBool.invoke(o, + params)).booleanValue(); }catch (IllegalArgumentException biae) { //the boolean method had the wrong //parameter types. lets try the other @@ -712,6 +714,7 @@ public final class IntrospectionUtils { return methods; } + @SuppressWarnings("null") public static Method findMethod(Class c, String name, Class params[]) { Method methods[] = findMethods(c); @@ -777,30 +780,6 @@ public final class IntrospectionUtils { m.invoke(c, new Object[] { args }); } - public static Object callMethod1(Object target, String methodN, - Object param1, String typeParam1, ClassLoader cl) throws Exception { - if (target == null || param1 == null) { - if (log.isDebugEnabled()) - log.debug("IntrospectionUtils: Assert: Illegal params " + - target + " " + param1); - } - if (log.isDebugEnabled()) - log.debug("IntrospectionUtils: callMethod1 " + - target.getClass().getName() + " " + - param1.getClass().getName() + " " + typeParam1); - - Class params[] = new Class[1]; - if (typeParam1 == null) - params[0] = param1.getClass(); - else - params[0] = cl.loadClass(typeParam1); - Method m = findMethod(target.getClass(), methodN, params); - if (m == null) - throw new NoSuchMethodException(target.getClass().getName() + " " - + methodN); - return m.invoke(target, new Object[] { param1 }); - } - public static Object callMethod0(Object target, String methodN) throws Exception { if (target == null) { diff --git a/test/org/apache/catalina/tribes/demos/MapDemo.java b/test/org/apache/catalina/tribes/demos/MapDemo.java index 5ecc4c9ff..0a49a840f 100644 --- a/test/org/apache/catalina/tribes/demos/MapDemo.java +++ b/test/org/apache/catalina/tribes/demos/MapDemo.java @@ -137,6 +137,7 @@ public class MapDemo implements ChannelListener, MembershipListener{ * @param args * @throws Exception */ + @SuppressWarnings("unused") public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); //create a channel object diff --git a/test/org/apache/catalina/tribes/demos/MembersWithProperties.java b/test/org/apache/catalina/tribes/demos/MembersWithProperties.java index 85d0e792d..488854e7c 100644 --- a/test/org/apache/catalina/tribes/demos/MembersWithProperties.java +++ b/test/org/apache/catalina/tribes/demos/MembersWithProperties.java @@ -86,6 +86,7 @@ public class MembersWithProperties implements MembershipListener{ "java MembersWithProperties -bind 192.168.0.45 -port 4005 -mbind 192.168.0.45 -count 100 -stats 10\n"); } + @SuppressWarnings("unused") public static void main(String[] args) throws Exception { if (args.length==0) usage(); main = Thread.currentThread(); -- 2.11.0