public class BrilhoTest { public static void main(String[] args) throws Exception { Class type; try { type = Class.forName("br.carinha.rosto.BrilhoRepouso"); } catch (ClassNotFoundException e) { throw new AssertionError("Economia de tela ainda não implementada"); } java.lang.reflect.Method method = type.getMethod("nivel", boolean.class, float.class, float.class, long.class, long.class, boolean.class, boolean.class); check(method, .08f, true, .7f, .08f, 31000L, 30000L, false, false); check(method, .7f, true, .7f, .08f, 0L, 30000L, false, false); check(method, .7f, true, .7f, .08f, 31000L, 30000L, true, false); check(method, .08f, true, .7f, .08f, 1000L, 30000L, false, true); check(method, .7f, false, .7f, .08f, 60000L, 30000L, false, true); System.out.println("Brilho em repouso, retorno e economia desligada: OK"); } static void check(java.lang.reflect.Method m, float want, Object... args) throws Exception { float actual = (Float) m.invoke(null, args); if (Math.abs(actual - want) > .001f) throw new AssertionError(actual + " != " + want); } }