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.

ReferenceTypeTestCase.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.weaver;
  13. import org.aspectj.weaver.bcel.BcelWorld;
  14. import junit.framework.TestCase;
  15. // test cases for Adrian's additions to ReferenceType
  16. // XXX - couldn't find any unit test cases for the rest of the ReferenceType class
  17. public class ReferenceTypeTestCase extends TestCase {
  18. public void testIsRawTrue() {
  19. BcelWorld world = new BcelWorld();
  20. world.setBehaveInJava5Way(true);
  21. UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class");
  22. ResolvedType rtx = world.resolve(javaLangClass);
  23. assertTrue("Resolves to reference type",(rtx instanceof ReferenceType));
  24. ReferenceType rt = (ReferenceType) rtx;
  25. assertTrue("java.lang.Class is raw",rt.isRawType());
  26. }
  27. public void testIsRawFalse() {
  28. BcelWorld world = new BcelWorld();
  29. world.setBehaveInJava5Way(true);
  30. UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object");
  31. ResolvedType rtx = world.resolve(javaLangObject);
  32. assertTrue("Resolves to reference type",(rtx instanceof ReferenceType));
  33. ReferenceType rt = (ReferenceType) rtx;
  34. assertFalse("java.lang.Object is not raw",rt.isRawType());
  35. }
  36. public void testIsGenericTrue() {
  37. BcelWorld world = new BcelWorld();
  38. world.setBehaveInJava5Way(true);
  39. UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class");
  40. ResolvedType rtx = world.resolve(javaLangClass);
  41. assertTrue("java.lang.Class has underpinning generic type",rtx.getGenericType().isGenericType());
  42. }
  43. public void testIsGenericFalse() {
  44. BcelWorld world = new BcelWorld();
  45. world.setBehaveInJava5Way(true);
  46. UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object");
  47. ResolvedType rtx = world.resolve(javaLangObject);
  48. assertFalse(rtx.isGenericType());
  49. }
  50. }