extended unit tests: must remove early env vars interpolation to get consistent result

git-svn-id: https://svn.apache.org/repos/asf/maven/doxia/doxia-sitetools/trunk@1736816 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
index 6790330..0ff7038 100644
--- a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
+++ b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
@@ -522,17 +522,17 @@
         {
             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
diff --git a/doxia-integration-tools/src/site/apt/index.apt b/doxia-integration-tools/src/site/apt/index.apt
index e681081..ff336c2 100644
--- a/doxia-integration-tools/src/site/apt/index.apt
+++ b/doxia-integration-tools/src/site/apt/index.apt
@@ -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 @@
               |              |                    | <<<$\{this.any.key\}>>>
 *-------------+--------------+--------------------+------------------+
 | <<<env.*>>>\
-<<<*>>>       | <<<env.*>>>\
-              | <<<*>>>      | environment variables | <<<$\{env.PATH\}>>>\
+<<<*>>>       |              | environment variables | <<<$\{env.PATH\}>>>\
 *-------------+--------------+--------------------+------------------+
diff --git a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
index 430b276..978a86a 100644
--- a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
+++ b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
@@ -374,16 +374,25 @@
         // 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 )
diff --git a/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/pom.xml b/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/pom.xml
index e4479fc..b27a814 100644
--- a/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/pom.xml
+++ b/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/pom.xml
@@ -31,5 +31,7 @@
 

   <properties>

     <my_property>from child pom.xml</my_property>

+    <PATH>PATH property from pom</PATH>

+    <name>name property</name>

   </properties>

 </project>

diff --git a/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/src/site/site.xml b/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/src/site/site.xml
index 570ab9a..091ed51 100644
--- a/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/src/site/site.xml
+++ b/doxia-integration-tools/src/test/resources/unit/interpolation-child-test/src/site/site.xml
@@ -18,7 +18,7 @@
 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
diff --git a/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml b/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml
index 0ffabc2..28545f8 100644
--- a/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml
+++ b/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml
@@ -31,5 +31,6 @@
 

   <properties>

     <my_property>from parent pom.xml</my_property>

+    <name>name property</name>

   </properties>

 </project>

diff --git a/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/src/site/site.xml b/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/src/site/site.xml
index 21dc887..27a2913 100644
--- a/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/src/site/site.xml
+++ b/doxia-integration-tools/src/test/resources/unit/interpolation-parent-test/src/site/site.xml
@@ -31,13 +31,18 @@
 
   <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" />