From 09db0e6e3a5ea16fa3042c1d8e89a81e250cd9f1 Mon Sep 17 00:00:00 2001 From: vmassol Date: Fri, 7 May 2004 23:09:22 +0000 Subject: [PATCH] added unit tests git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115202 13f79535-47bb-0310-9956-ffa450edef68 --- aspectj/src/plugin-test/maven.xml | 26 ++++++++ aspectj/src/plugin-test/project.properties | 15 +++++ aspectj/src/plugin-test/project.xml | 66 +++++++++++++++++++ .../aspect/org/apache/maven/aspectj/Sample.aj | 29 ++++++++ .../main/org/apache/maven/aspectj/Dummy.java | 25 +++++++ .../org/apache/maven/aspectj/AspectTest.java | 36 ++++++++++ 6 files changed, 197 insertions(+) create mode 100644 aspectj/src/plugin-test/maven.xml create mode 100644 aspectj/src/plugin-test/project.properties create mode 100644 aspectj/src/plugin-test/project.xml create mode 100644 aspectj/src/plugin-test/src/aspect/org/apache/maven/aspectj/Sample.aj create mode 100644 aspectj/src/plugin-test/src/main/org/apache/maven/aspectj/Dummy.java create mode 100644 aspectj/src/plugin-test/src/test/org/apache/maven/aspectj/AspectTest.java diff --git a/aspectj/src/plugin-test/maven.xml b/aspectj/src/plugin-test/maven.xml new file mode 100644 index 00000000..35fa7b94 --- /dev/null +++ b/aspectj/src/plugin-test/maven.xml @@ -0,0 +1,26 @@ + + + + + + + + + + \ No newline at end of file diff --git a/aspectj/src/plugin-test/project.properties b/aspectj/src/plugin-test/project.properties new file mode 100644 index 00000000..b0e4191e --- /dev/null +++ b/aspectj/src/plugin-test/project.properties @@ -0,0 +1,15 @@ +# ------------------------------------------------------------------- +# Copyright 2004 The Apache Software Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ------------------------------------------------------------------- diff --git a/aspectj/src/plugin-test/project.xml b/aspectj/src/plugin-test/project.xml new file mode 100644 index 00000000..750c29b8 --- /dev/null +++ b/aspectj/src/plugin-test/project.xml @@ -0,0 +1,66 @@ + + + + + + 3 + test-maven-aspectj-plugin + Test project for Maven AspectJ Plugin + maven + 1.0-SNAPSHOT + + Apache Software Foundation + http://www.apache.org/ + http://maven.apache.org/images/jakarta-logo-blue.gif + + 2001 + org.apache.maven + http://maven.apache.org/images/maven.jpg + Test for Maven AspectJ plugin + Test for Maven AspectJ plugin + http://maven.apache.org/reference/plugins/aspectj/ + /www/maven.apache.org/reference/plugins/aspectj/ + + scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven/src/plugins-build/aspectj/ + http://cvs.apache.org/viewcvs/maven/src/plugins-build/aspectj/ + + + + Vincent Massol + vmassol + vmassol@pivolis.com + Pivolis + + Java Developer + + + + + + aspectj + aspectjrt + 1.2rc1 + + + + src/main + src/test + src/aspect + + 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 new file mode 100644 index 00000000..22062e18 --- /dev/null +++ b/aspectj/src/plugin-test/src/aspect/org/apache/maven/aspectj/Sample.aj @@ -0,0 +1,29 @@ +package org.apache.maven.aspectj; + +/* ==================================================================== + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +public aspect Sample +{ + pointcut testPointcut() : + execution(public * org.apache.maven.aspectj.Dummy.someMethod()); + + before() : testPointcut() + { + throw new RuntimeException("test exception voluntarily raised and that should caught in the test case"); + } +} \ No newline at end of file diff --git a/aspectj/src/plugin-test/src/main/org/apache/maven/aspectj/Dummy.java b/aspectj/src/plugin-test/src/main/org/apache/maven/aspectj/Dummy.java new file mode 100644 index 00000000..95c77893 --- /dev/null +++ b/aspectj/src/plugin-test/src/main/org/apache/maven/aspectj/Dummy.java @@ -0,0 +1,25 @@ +package org.apache.maven.aspectj; + +/* ==================================================================== + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +public class Dummy +{ + public void someMethod() + { + } +} \ 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 new file mode 100644 index 00000000..999544fb --- /dev/null +++ b/aspectj/src/plugin-test/src/test/org/apache/maven/aspectj/AspectTest.java @@ -0,0 +1,36 @@ +package org.apache.maven.aspectj; + +/* ==================================================================== + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +import junit.framework.TestCase; + +public class AspectTest extends TestCase +{ + public void testAspectIsCorrectlyWeaved() + { + Dummy dummy = new Dummy(); + try + { + dummy.someMethod(); + 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()); + } + } +} \ No newline at end of file