1 6 7 package org.netbeans.modules.classfile; 8 9 import java.io.IOException ; 10 import java.io.InputStream ; 11 import java.util.Arrays ; 12 import java.util.Iterator ; 13 import java.util.List ; 14 import junit.framework.TestCase; 15 import junit.textui.TestRunner; 16 17 23 public class ParamNameTest extends TestCase { 24 ClassFile classFile; 25 List results; 26 27 String [] result = { 28 "void assertTrue(String message, boolean condition)", 29 "void assertTrue(boolean condition)", 30 "void assertFalse(String message, boolean condition)", 31 "void assertFalse(boolean condition)", 32 "void fail(String message)", 33 "void fail()", 34 "void assertEquals(String message, Object expected, Object actual)", 35 "void assertEquals(Object expected, Object actual)", 36 "void assertEquals(String message, String expected, String actual)", 37 "void assertEquals(String expected, String actual)", 38 "void assertEquals(String message, double expected, double actual, double delta)", 39 "void assertEquals(double expected, double actual, double delta)", 40 "void assertEquals(String message, float expected, float actual, float delta)", 41 "void assertEquals(float expected, float actual, float delta)", 42 "void assertEquals(String message, long expected, long actual)", 43 "void assertEquals(long expected, long actual)", 44 "void assertEquals(String message, boolean expected, boolean actual)", 45 "void assertEquals(boolean expected, boolean actual)", 46 "void assertEquals(String message, byte expected, byte actual)", 47 "void assertEquals(byte expected, byte actual)", 48 "void assertEquals(String message, char expected, char actual)", 49 "void assertEquals(char expected, char actual)", 50 "void assertEquals(String message, short expected, short actual)", 51 "void assertEquals(short expected, short actual)", 52 "void assertEquals(String message, int expected, int actual)", 53 "void assertEquals(int expected, int actual)", 54 "void assertNotNull(Object object)", 55 "void assertNotNull(String message, Object object)", 56 "void assertNull(Object object)", 57 "void assertNull(String message, Object object)", 58 "void assertSame(String message, Object expected, Object actual)", 59 "void assertSame(Object expected, Object actual)", 60 "void assertNotSame(String message, Object expected, Object actual)", 61 "void assertNotSame(Object expected, Object actual)", 62 "void failSame(String message)", 63 "void failNotSame(String message, Object expected, Object actual)", 64 "void failNotEquals(String message, Object expected, Object actual)", 65 "java.lang.String format(String message, Object expected, Object actual)" 66 }; 67 68 69 public ParamNameTest(String testName) { 70 super(testName); 71 } 72 73 protected void setUp() throws IOException { 74 ClassLoader loader = ParamNameTest.class.getClassLoader(); 75 InputStream is = loader.getResourceAsStream("junit/framework/Assert.class"); 76 classFile = new ClassFile(is); 77 is.close(); 78 results = Arrays.asList(result); 79 } 80 81 public void test() { 82 int counter = 0; 83 for (Iterator it = classFile.getMethods().iterator(); it.hasNext(); ) { 84 Method m = (Method) it.next(); 85 if (m.getName().equals("<init>")) 86 continue; 87 String s = m.getReturnSignature() + ' ' + m.getName() + '('; 88 for (Iterator itPar = m.getParameters().iterator(); itPar.hasNext(); ) { 89 Parameter p = (Parameter) itPar.next(); 90 s += p.getDeclaration(); 91 if (itPar.hasNext()) { 92 s += ", "; 93 } 94 } 95 s += ')'; 96 97 assertTrue("has \"" + s + "\"", results.contains(s)); 98 counter++; 99 } 100 } 101 102 public static void main(String [] args) { 103 TestRunner.run(ParamNameTest.class); 104 } 105 } 106 | Popular Tags |