Revision: 5860 Author: [email protected] Date: Fri Jul 31 13:54:03 2009 Log: Add test for getting parameter names from interface source.
http://code.google.com/p/google-web-toolkit/source/detail?r=5860 Modified: /changes/jat/ihm/dev/core/test/com/google/gwt/dev/javac/JavaSourceParserTest.java ======================================= --- /changes/jat/ihm/dev/core/test/com/google/gwt/dev/javac/JavaSourceParserTest.java Fri Jul 31 10:13:46 2009 +++ /changes/jat/ihm/dev/core/test/com/google/gwt/dev/javac/JavaSourceParserTest.java Fri Jul 31 13:54:03 2009 @@ -75,6 +75,18 @@ } }; + private static final MockJavaResource FOO_INT = new MockJavaResource("test.FooInt") { + @Override + protected CharSequence getContent() { + StringBuffer code = new StringBuffer(); + code.append("package test;\n"); + code.append("public interface FooInt {\n"); + code.append(" String value(String a, int val);\n"); + code.append("}\n"); + return code; + } + }; + /** * Test method for {...@link JavaSourceParser#getClassChain(java.lang.String)}. */ @@ -147,6 +159,21 @@ assertEquals(1, arguments.length); assertEquals("a", arguments[0]); } + + public void testParamNames() throws NotFoundException { + JavaSourceParser parser = new JavaSourceParser(); + addGeneratedUnits(FOO_INT); + JClassType string = state.getTypeOracle().getType("java.lang.String"); + JClassType fooInt = state.getTypeOracle().getType("test.FooInt"); + parser.addSourceForType(fooInt, FOO_INT); + JMethod method = fooInt.getMethod("value", new JType[] { string, + JPrimitiveType.INT }); + String[] arguments = parser.getArguments(method); + assertNotNull(arguments); + assertEquals(2, arguments.length); + assertEquals("a", arguments[0]); + assertEquals("val", arguments[1]); + } private void assertExpected(List<char[]> actual, String... expected) { if (actual.size() != expected.length) { --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
