/** Test that method/constructor signatures are constructed correctly. */ public void testSignatures() { boolean onjava5 = true; // String majorVersion = System.getProperty("java.specification.version"); // boolean onjava6 = majorVersion.compareTo("1.6") >= 0; Method sampleMeth = null; Class<? extends JavaUtilTests> thisClass = getClass(); try { sampleMeth = thisClass.getMethod("sampleMethod", new Class[] {int.class, int.class}); } catch (NoSuchMethodException nsme) { fail(); } String sig = JavaUtils.getSignature(sampleMeth); assertEquals(sig, "void sampleMethod(int, int)"); if (onjava5) { // test a varargs method Class<?> clazz = Class.class; try { sampleMeth = clazz.getMethod("getConstructor", new Class[] {Class[].class}); } catch (NoSuchMethodException nsme) { fail(); } sig = JavaUtils.getSignature(sampleMeth); assertEquals("java.lang.reflect.Constructor getConstructor(java.lang.Class[])", sig); } try { sampleMeth = thisClass.getMethod("sampleMethod2", new Class[] {String[].class}); } catch (NoSuchMethodException nsme) { fail(); } sig = JavaUtils.getSignature(sampleMeth); assertEquals("void sampleMethod2(java.lang.String[])", sig); }