You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2016/03/27 23:29:15 UTC

svn commit: r1736816 - in /maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src: main/java/org/apache/maven/doxia/tools/ site/apt/ test/java/org/apache/maven/doxia/tools/ test/resources/unit/interpolation-child-test/ test/resources/unit/interp...

Author: hboutemy
Date: Sun Mar 27 21:29:15 2016
New Revision: 1736816

URL: http://svn.apache.org/viewvc?rev=1736816&view=rev
Log:
extended unit tests: must remove early env vars interpolation to get consistent result

Modified:
    maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
    maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/site/apt/index.apt
    maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
    maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/pom.xml
    maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/src/site/site.xml
    maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml
    maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/src/site/site.xml

Modified: maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java?rev=1736816&r1=1736815&r2=1736816&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java Sun Mar 27 21:29:15 2016
@@ -522,17 +522,17 @@ public class DefaultSiteTool
         {
             interpolator.addValueSource( new ObjectBasedValueSource( aProject ) );
             interpolator.addValueSource( new MapBasedValueSource( aProject.getProperties() ) );
-        }
 
-        try
-        {
-            interpolator.addValueSource( new EnvarBasedValueSource() );
-        }
-        catch ( IOException e )
-        {
-            // Prefer logging?
-            throw new SiteToolException( "IOException: cannot interpolate environment properties: " + e.getMessage(),
-                                         e );
+            try
+            {
+                interpolator.addValueSource( new EnvarBasedValueSource() );
+            }
+            catch ( IOException e )
+            {
+                // Prefer logging?
+                throw new SiteToolException( "IOException: cannot interpolate environment properties: " + e.getMessage(),
+                                             e );
+            }
         }
 
         try

Modified: maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/site/apt/index.apt?rev=1736816&r1=1736815&r2=1736816&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/site/apt/index.apt (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/site/apt/index.apt Sun Mar 27 21:29:15 2016
@@ -2,8 +2,9 @@
  Introduction
  ------
  Dennis Lundberg
+ Hervé Boutemy
  ------
- 2008-04-27
+ 2016-03-27
  ------
 
  ~~ Licensed to the Apache Software Foundation (ASF) under one
@@ -68,6 +69,5 @@ Maven Doxia Integration Tools
               |              |                    | <<<$\{this.any.key\}>>>
 *-------------+--------------+--------------------+------------------+
 | <<<env.*>>>\
-<<<*>>>       | <<<env.*>>>\
-              | <<<*>>>      | environment variables | <<<$\{env.PATH\}>>>\
+<<<*>>>       |              | environment variables | <<<$\{env.PATH\}>>>\
 *-------------+--------------+--------------------+------------------+

Modified: maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java?rev=1736816&r1=1736815&r2=1736816&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java Sun Mar 27 21:29:15 2016
@@ -374,16 +374,25 @@ public class SiteToolTest
         // href rebase
         assertEquals( "../../index.html", model.getBody().getBreadcrumbs().iterator().next().getHref() );
         Iterator<LinkItem> links = model.getBody().getLinks().iterator();
+        // late interpolation of pom content (which happens first: properties can't override)
+        assertEquals( "project.name = MSHARED-217 Child", links.next().getName() );
+        assertEquals( "name = MSHARED-217 Child", links.next().getName() );
         // early interpolation: DOXIASITETOOLS-158
         assertEquals( "this.name = MSHARED-217 Parent", links.next().getName() );
-        // Env Var interpolation
-        String val = links.next().getName();
-        assertTrue( val.startsWith( "PATH = " ) );
-        assertFalse( val.contains( "${" ) );
+
         // late interpolation of project properties
         assertEquals( "my_property = from child pom.xml", links.next().getName() );
         // early interpolation of project properties: DOXIASITETOOLS-158
         assertEquals( "this.my_property = from parent pom.xml", links.next().getName() );
+
+        // Env Var interpolation
+        String envPath = links.next().getName();
+        assertTrue( envPath.startsWith( "env.PATH = " ) );
+        assertFalse( envPath.contains( "${" ) );
+        assertNotSame( "env.PATH = PATH property from pom", envPath );
+
+        // property overrides env
+        assertEquals( "PATH = PATH property from pom", links.next().getName() );
     }
 
     private void writeModel( DecorationModel model, String to )

Modified: maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/pom.xml?rev=1736816&r1=1736815&r2=1736816&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/pom.xml (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/pom.xml Sun Mar 27 21:29:15 2016
@@ -31,5 +31,7 @@ under the License.
 
   <properties>
     <my_property>from child pom.xml</my_property>
+    <PATH>PATH property from pom</PATH>
+    <name>name property</name>
   </properties>
 </project>

Modified: maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/src/site/site.xml?rev=1736816&r1=1736815&r2=1736816&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/src/site/site.xml (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/src/site/site.xml Sun Mar 27 21:29:15 2016
@@ -18,7 +18,7 @@ KIND, either express or implied.  See th
 specific language governing permissions and limitations
 under the License.
 -->
-<project name="${project.name}" xmlns="http://maven.apache.org/DECORATION/1.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
+<project xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"
+    name="${project.name}">
 </project>
\ No newline at end of file

Modified: maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml?rev=1736816&r1=1736815&r2=1736816&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml Sun Mar 27 21:29:15 2016
@@ -31,5 +31,6 @@ under the License.
 
   <properties>
     <my_property>from parent pom.xml</my_property>
+    <name>name property</name>
   </properties>
 </project>

Modified: maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/src/site/site.xml?rev=1736816&r1=1736815&r2=1736816&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/src/site/site.xml (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/src/site/site.xml Sun Mar 27 21:29:15 2016
@@ -31,13 +31,18 @@ under the License.
 
   <body>
     <links>
+      <!-- late interpolation from project model -->
+      <item name="project.name = ${project.name}" href="${this.url}" />
+      <item name="name = ${name}" href="${this.url}" />
+      <!-- early interpolation from project model -->
       <item name="this.name = ${this.name}" href="${this.url}" />
-      <!-- interpolation of env vars -->
-      <item name="PATH = ${PATH}" href="${this.url}" />
       <!-- late interpolation of properties -->
       <item name="my_property = ${my_property}" href="." />
       <!-- early interpolation of properties -->
       <item name="this.my_property = ${this.my_property}" href="." />
+      <!-- interpolation of env vars -->
+      <item name="env.PATH = ${env.PATH}" href="${this.url}" />
+      <item name="PATH = ${PATH}" href="${this.url}" /><!-- property interpolated before env var in child -->
     </links>
     <breadcrumbs>
       <item name="Maven"  href="../index.html" />