You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by ev...@apache.org on 2003/04/24 15:50:27 UTC

cvs commit: maven-new/src/test/org/apache/maven PomInterpolationAspectTest.java

evenisse    2003/04/24 06:50:27

  Modified:    src/aspect/org/apache/maven PomInheritanceAspect.java
                        PomInterpolationAspect.java
  Added:       src/test/org/apache/maven PomInterpolationAspectTest.java
  Log:
  "replaced the reflection in the PomAspects' advices by the target() pointcut. I
  have one TestCase for PomInterpolationAspect but dont have any for
  PomInheritanceAspect because i have no way to verify the aspect does the job
  since the advice does nothing but call proceed()."
  Thanks to Gilles Dodinet.
  
  Revision  Changes    Path
  1.2       +6 -6      maven-new/src/aspect/org/apache/maven/PomInheritanceAspect.java
  
  Index: PomInheritanceAspect.java
  ===================================================================
  RCS file: /home/cvs/maven-new/src/aspect/org/apache/maven/PomInheritanceAspect.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PomInheritanceAspect.java	15 Apr 2003 01:16:30 -0000	1.1
  +++ PomInheritanceAspect.java	24 Apr 2003 13:50:27 -0000	1.2
  @@ -1,7 +1,6 @@
   package org.apache.maven;
   
   import org.apache.maven.project.Project;
  -import org.apache.plexus.util.StringUtils;
   
   /**
    *  @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  @@ -10,16 +9,17 @@
    */
   aspect PomInheritanceAspect
   {
  -    pointcut projectGetters(): call( * Project.get*( .. ) );
  +    pointcut projectGetters(Project p): call( * Project.get*( .. ) ) 
  +                                        && target(p);
   
  -    Object around(): projectGetters()
  +    Object around(Project p ): projectGetters(p)
       {
           // Let's grab the value that would normally be returned.
  -        Object o = proceed();
  +        Object o = proceed(p);
           
           // If the value is not defined and this project has a parent then
           // we will try to retrieve the value from the parent.
  -        if ( o == null && ((Project) thisJoinPoint.getTarget()).hasParent() )
  +        if ( o == null && p.hasParent() )
           {
               // Use reflection given the target method and lookup the value
               // in the parent. No biggie.
  
  
  
  1.2       +6 -5      maven-new/src/aspect/org/apache/maven/PomInterpolationAspect.java
  
  Index: PomInterpolationAspect.java
  ===================================================================
  RCS file: /home/cvs/maven-new/src/aspect/org/apache/maven/PomInterpolationAspect.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PomInterpolationAspect.java	15 Apr 2003 01:16:30 -0000	1.1
  +++ PomInterpolationAspect.java	24 Apr 2003 13:50:27 -0000	1.2
  @@ -16,12 +16,13 @@
    */
   aspect PomInterpolationAspect
   {
  -    pointcut projectGetters(): call( String Project.get*( .. ) );
  +    pointcut projectGetters(Project p): call( String Project.get*( .. ) )
  +                                        && target(p);
   
  -    String around(): projectGetters()
  +    String around(Project p): projectGetters(p)
       {
           // Let's grab the value that would normally be returned.
  -        String s = proceed();
  +        String s = proceed(p);
   
           // Let's see if we need to do any value interpolation.
           if ( s.indexOf( "${pom" ) >= 0 )
  @@ -31,7 +32,7 @@
           }
           else if ( s.indexOf( "${" ) >= 0 )
           {
  -            return StringUtils.interpolate( s, ((Project)thisJoinPoint.getTarget()).getProperties() );
  +            return StringUtils.interpolate( s, p.getProperties() );
           }
   
           return s;
  
  
  
  1.1                  maven-new/src/test/org/apache/maven/PomInterpolationAspectTest.java
  
  Index: PomInterpolationAspectTest.java
  ===================================================================
  package org.apache.maven;
  
  /* ----------------------------------------------------------------------------
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Maven", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ----------------------------------------------------------------------------
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ----------------------------------------------------------------------------
   */
  
  import org.apache.maven.project.Project;
  
  import junit.framework.TestCase;
  
  
  public class PomInterpolationAspectTest extends TestCase {
      private Project project;
      
      protected void setUp() throws Exception
      {
          project = new Project();
          project.setInceptionYear("${year}");
          project.addProperty("year", "2003");
      }
      
      protected void tearDown() throws Exception
      {
          project = null;
      }
      
      public void testInterpolate()
      {
          String s = project.getInceptionYear();
          assertEquals("2003", s);
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: cvs commit: maven-new/src/test/org/apache/maven PomInterpolationAspectTest.java

Posted by "michal.maczka" <mi...@cqs.ch>.
Question:

What is the convention for naming aspectj files?

In Eclipse (which is this case can be good reference) per default 
they have extension ".aj"

It think that it would be good to use this convention so any 
IDE can differentiate them from ordinary java file.

Michal

> -----Original Message-----
> From: evenisse@apache.org [mailto:evenisse@apache.org]
> Sent: Thursday, April 24, 2003 3:50 PM
> To: maven-new-cvs@apache.org
> Subject: cvs commit: maven-new/src/test/org/apache/maven
> PomInterpolationAspectTest.java
> 
> 
> evenisse    2003/04/24 06:50:27
> 
>   Modified:    src/aspect/org/apache/maven PomInheritanceAspect.java
>                         PomInterpolationAspect.java
>   Added:       src/test/org/apache/maven PomInterpolationAspectTest.java
>   Log:
>   "replaced the reflection in the PomAspects' advices by the 
> target() pointcut. I
>   have one TestCase for PomInterpolationAspect but dont have any for
>   PomInheritanceAspect because i have no way to verify the aspect 
> does the job
>   since the advice does nothing but call proceed()."
>   Thanks to Gilles Dodinet.
>   
>   Revision  Changes    Path
>   1.2       +6 -6      
> maven-new/src/aspect/org/apache/maven/PomInheritanceAspect.java
>   
>   Index: PomInheritanceAspect.java
>   ===================================================================
>   RCS file: 
> /home/cvs/maven-new/src/aspect/org/apache/maven/PomInheritanceAspe
> ct.java,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- PomInheritanceAspect.java	15 Apr 2003 01:16:30 -0000	1.1
>   +++ PomInheritanceAspect.java	24 Apr 2003 13:50:27 -0000	1.2
>   @@ -1,7 +1,6 @@
>    package org.apache.maven;
>    
>    import org.apache.maven.project.Project;
>   -import org.apache.plexus.util.StringUtils;
>    
>    /**
>     *  @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
>   @@ -10,16 +9,17 @@
>     */
>    aspect PomInheritanceAspect
>    {
>   -    pointcut projectGetters(): call( * Project.get*( .. ) );
>   +    pointcut projectGetters(Project p): call( * Project.get*( .. ) ) 
>   +                                        && target(p);
>    
>   -    Object around(): projectGetters()
>   +    Object around(Project p ): projectGetters(p)
>        {
>            // Let's grab the value that would normally be returned.
>   -        Object o = proceed();
>   +        Object o = proceed(p);
>            
>            // If the value is not defined and this project has a 
> parent then
>            // we will try to retrieve the value from the parent.
>   -        if ( o == null && ((Project) 
> thisJoinPoint.getTarget()).hasParent() )
>   +        if ( o == null && p.hasParent() )
>            {
>                // Use reflection given the target method and 
> lookup the value
>                // in the parent. No biggie.
>   
>   
>   
>   1.2       +6 -5      
> maven-new/src/aspect/org/apache/maven/PomInterpolationAspect.java
>   
>   Index: PomInterpolationAspect.java
>   ===================================================================
>   RCS file: 
> /home/cvs/maven-new/src/aspect/org/apache/maven/PomInterpolationAs
> pect.java,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- PomInterpolationAspect.java	15 Apr 2003 01:16:30 -0000	1.1
>   +++ PomInterpolationAspect.java	24 Apr 2003 13:50:27 -0000	1.2
>   @@ -16,12 +16,13 @@
>     */
>    aspect PomInterpolationAspect
>    {
>   -    pointcut projectGetters(): call( String Project.get*( .. ) );
>   +    pointcut projectGetters(Project p): call( String 
> Project.get*( .. ) )
>   +                                        && target(p);
>    
>   -    String around(): projectGetters()
>   +    String around(Project p): projectGetters(p)
>        {
>            // Let's grab the value that would normally be returned.
>   -        String s = proceed();
>   +        String s = proceed(p);
>    
>            // Let's see if we need to do any value interpolation.
>            if ( s.indexOf( "${pom" ) >= 0 )
>   @@ -31,7 +32,7 @@
>            }
>            else if ( s.indexOf( "${" ) >= 0 )
>            {
>   -            return StringUtils.interpolate( s, 
> ((Project)thisJoinPoint.getTarget()).getProperties() );
>   +            return StringUtils.interpolate( s, p.getProperties() );
>            }
>    
>            return s;
>   
>   
>   
>   1.1                  
> maven-new/src/test/org/apache/maven/PomInterpolationAspectTest.java
>   
>   Index: PomInterpolationAspectTest.java
>   ===================================================================
>   package org.apache.maven;
>   
>   /* 
> ------------------------------------------------------------------
> ----------
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
>    * reserved.
>    *
>    * Redistribution and use in source and binary forms, with or without
>    * modification, are permitted provided that the following conditions
>    * are met:
>    *
>    * 1. Redistributions of source code must retain the above copyright
>    *    notice, this list of conditions and the following disclaimer.
>    *
>    * 2. Redistributions in binary form must reproduce the above copyright
>    *    notice, this list of conditions and the following disclaimer in
>    *    the documentation and/or other materials provided with the
>    *    distribution.
>    *
>    * 3. The end-user documentation included with the redistribution, if
>    *    any, must include the following acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the 
> software itself,
>    *    if and wherever such third-party acknowlegements normally appear.
>    *
>    * 4. The names "The Jakarta Project", "Maven", and "Apache Software
>    *    Foundation" must not be used to endorse or promote 
> products derived
>    *    from this software without prior written permission. For written
>    *    permission, please contact apache@apache.org.
>    *
>    * 5. Products derived from this software may not be called "Apache"
>    *    nor may "Apache" appear in their names without prior written
>    *    permission of the Apache Group.
>    *
>    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>    * SUCH DAMAGE.
>    * 
> ------------------------------------------------------------------
> ----------
>    *
>    * This software consists of voluntary contributions made by many
>    * individuals on behalf of the Apache Software Foundation.  For more
>    * information on the Apache Software Foundation, please see
>    * <http://www.apache.org/>.
>    *
>    * 
> ------------------------------------------------------------------
> ----------
>    */
>   
>   import org.apache.maven.project.Project;
>   
>   import junit.framework.TestCase;
>   
>   
>   public class PomInterpolationAspectTest extends TestCase {
>       private Project project;
>       
>       protected void setUp() throws Exception
>       {
>           project = new Project();
>           project.setInceptionYear("${year}");
>           project.addProperty("year", "2003");
>       }
>       
>       protected void tearDown() throws Exception
>       {
>           project = null;
>       }
>       
>       public void testInterpolate()
>       {
>           String s = project.getInceptionYear();
>           assertEquals("2003", s);
>       }
>   }
>   
>   
>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org