From 8946b135626cc328f3eb5ba99c9c34d49fdecb93 Mon Sep 17 00:00:00 2001 From: carlos Date: Thu, 8 Jul 2004 11:27:58 +0000 Subject: [PATCH] Added test for aspectj:test-compile git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115707 13f79535-47bb-0310-9956-ffa450edef68 --- aspectj/src/plugin-test/maven.xml | 7 ++++-- .../aspect/org/apache/maven/aspectj/Sample.aj | 11 ++++++-- .../org/apache/maven/aspectj/AspectTest.java | 25 ++++++++++++++++--- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/aspectj/src/plugin-test/maven.xml b/aspectj/src/plugin-test/maven.xml index 35fa7b94..05bdafb2 100644 --- a/aspectj/src/plugin-test/maven.xml +++ b/aspectj/src/plugin-test/maven.xml @@ -17,10 +17,13 @@ --> - + - + + + + \ No newline at end of file diff --git a/aspectj/src/plugin-test/src/aspect/org/apache/maven/aspectj/Sample.aj b/aspectj/src/plugin-test/src/aspect/org/apache/maven/aspectj/Sample.aj index 22062e18..2553192e 100644 --- a/aspectj/src/plugin-test/src/aspect/org/apache/maven/aspectj/Sample.aj +++ b/aspectj/src/plugin-test/src/aspect/org/apache/maven/aspectj/Sample.aj @@ -19,11 +19,18 @@ package org.apache.maven.aspectj; public aspect Sample { - pointcut testPointcut() : + pointcut srcPointcut() : execution(public * org.apache.maven.aspectj.Dummy.someMethod()); + pointcut testPointcut() : + execution(public * org.apache.maven.aspectj.AspectTest.someMethod()); + + before() : srcPointcut() + { + throw new RuntimeException("test exception voluntarily raised and that should be caught in the test case"); + } before() : testPointcut() { - throw new RuntimeException("test exception voluntarily raised and that should caught in the test case"); + throw new RuntimeException("test exception voluntarily raised and that should be caught in the test case"); } } \ No newline at end of file diff --git a/aspectj/src/plugin-test/src/test/org/apache/maven/aspectj/AspectTest.java b/aspectj/src/plugin-test/src/test/org/apache/maven/aspectj/AspectTest.java index 999544fb..4db09d36 100644 --- a/aspectj/src/plugin-test/src/test/org/apache/maven/aspectj/AspectTest.java +++ b/aspectj/src/plugin-test/src/test/org/apache/maven/aspectj/AspectTest.java @@ -20,7 +20,11 @@ import junit.framework.TestCase; public class AspectTest extends TestCase { - public void testAspectIsCorrectlyWeaved() + + private static final String EXCEPTION_MESSAGE = "test exception " + + "voluntarily raised and that should be caught in the test case"; + + public void testSourceIsCorrectlyWeaved() { Dummy dummy = new Dummy(); try @@ -29,8 +33,23 @@ public class AspectTest extends TestCase fail("The Aspect should have thrown an exception"); } catch (Exception expected) { - assertEquals("test exception voluntarily raised and that should " - + "caught in the test case", expected.getMessage()); + assertEquals(EXCEPTION_MESSAGE, expected.getMessage()); } } + + public void testTestIsCorrectlyWeaved() + { + try + { + this.someMethod(); + fail("The Aspect should have thrown an exception"); + } catch (Exception expected) + { + assertEquals(EXCEPTION_MESSAGE, expected.getMessage()); + } + } + + public void someMethod() + { + } } \ No newline at end of file