You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GetReflectMembersTest.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* *******************************************************************
  2. * Copyright (c) 2005 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Adrian Colyer Initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.apache.bcel.classfile.tests;
  13. import org.aspectj.apache.bcel.classfile.JavaClass;
  14. import org.aspectj.apache.bcel.util.ClassLoaderRepository;
  15. import org.aspectj.apache.bcel.util.Repository;
  16. import junit.framework.TestCase;
  17. /**
  18. * @author colyer
  19. *
  20. */
  21. public class GetReflectMembersTest extends TestCase {
  22. private Repository bcelRepository;
  23. private JavaClass jc;
  24. public void testGetMethod() throws Exception {
  25. assertNotNull(jc.getMethod(GetMe.class.getMethod("foo",new Class[] {String.class})));
  26. }
  27. public void testGetConstructor() throws Exception {
  28. assertNotNull(jc.getMethod(GetMe.class.getConstructor(new Class[] {int.class})));
  29. }
  30. public void testGetField() throws Exception {
  31. assertNotNull(jc.getField(GetMe.class.getDeclaredField("x")));
  32. }
  33. protected void setUp() throws Exception {
  34. super.setUp();
  35. this.bcelRepository = new ClassLoaderRepository(getClass().getClassLoader());
  36. this.jc = bcelRepository.loadClass(GetMe.class);
  37. }
  38. protected void tearDown() throws Exception {
  39. super.tearDown();
  40. this.bcelRepository.clear();
  41. }
  42. private static class GetMe {
  43. private int x;
  44. public GetMe(int x) { this.x = x;}
  45. public void foo(String s) {};
  46. }
  47. }