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.

TjpWeaveTestCase.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  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://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver.bcel;
  13. import java.io.IOException;
  14. import java.util.Arrays;
  15. import org.aspectj.weaver.Advice;
  16. import org.aspectj.weaver.AdviceKind;
  17. import org.aspectj.weaver.MemberImpl;
  18. import org.aspectj.weaver.TestUtils;
  19. import org.aspectj.weaver.ResolvedType;
  20. import org.aspectj.weaver.UnresolvedType;
  21. public class TjpWeaveTestCase extends WeaveTestCase {
  22. {
  23. regenerate = false;
  24. }
  25. public TjpWeaveTestCase(String name) {
  26. super(name);
  27. }
  28. public void setUp() {
  29. super.setUp();
  30. behave15=true;
  31. }
  32. public void tearDown() throws Exception {
  33. super.tearDown();
  34. behave15=false;
  35. }
  36. public void testStaticTjp() throws IOException {
  37. BcelAdvice munger = new BcelAdvice(
  38. AdviceKind.stringToKind("before"),
  39. makePointcutAll(),
  40. TestUtils.methodFromString("static void Aspect.ajc_before(org.aspectj.lang.JoinPoint$StaticPart)"),
  41. Advice.ThisJoinPointStaticPart, -1, -1, null, null);
  42. weaveTest("HelloWorld", "StaticTjpBeforeHelloWorld", munger);
  43. }
  44. public void testEnclosingStaticTjp() throws IOException {
  45. BcelAdvice munger = new BcelAdvice(
  46. AdviceKind.stringToKind("before"),
  47. makePointcutAll(),
  48. TestUtils.methodFromString("static void Aspect.ajc_before(org.aspectj.lang.JoinPoint$StaticPart)"),
  49. Advice.ThisEnclosingJoinPointStaticPart, -1, -1, null, null);
  50. weaveTest("HelloWorld", "StaticEnclosingTjpBeforeHelloWorld", munger);
  51. }
  52. public void testTjp() throws IOException {
  53. BcelAdvice munger = new BcelAdvice(
  54. AdviceKind.stringToKind("before"),
  55. makePointcutAll(),
  56. TestUtils.methodFromString("static void Aspect.ajc_before(org.aspectj.lang.JoinPoint)"),
  57. Advice.ThisJoinPoint, -1, -1, null, null);
  58. weaveTest("HelloWorld", "TjpBeforeHelloWorld", munger);
  59. }
  60. public void testAroundTjp() throws IOException {
  61. BcelAdvice munger = new BcelAdvice(
  62. AdviceKind.stringToKind("around"),
  63. makePointcutAll(),
  64. TestUtils.methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"),
  65. Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null, null);
  66. weaveTest("HelloWorld", "TjpAroundHelloWorld", munger);
  67. }
  68. public void testAround2Tjp() throws IOException {
  69. ResolvedType rtx = world.resolve(UnresolvedType.forName("Aspect"),true);
  70. assertTrue("Couldnt find type Aspect",!rtx.isMissing());
  71. BcelAdvice munger1 = new BcelAdvice(
  72. AdviceKind.stringToKind("around"),
  73. makePointcutAll(),
  74. TestUtils.methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"),
  75. Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null,
  76. rtx);
  77. BcelAdvice munger2 = new BcelAdvice(
  78. AdviceKind.stringToKind("around"),
  79. makePointcutAll(),
  80. TestUtils.methodFromString("static java.lang.Object Aspect.ajc_around(org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint)"),
  81. Advice.ThisJoinPoint | Advice.ExtraArgument, -1, -1, null,
  82. rtx);
  83. weaveTest("HelloWorld", "TjpAround2HelloWorld", Arrays.asList(new BcelAdvice[] {munger1, munger2}));
  84. }
  85. }