You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/06/11 16:47:46 UTC

svn commit: r783803 - in /maven/core-integration-testing/trunk/core-it-suite/src/test: java/org/apache/maven/it/ resources/mng-2562/ resources/mng-2562/custom/ resources/mng-2562/default/

Author: bentmann
Date: Thu Jun 11 14:47:46 2009
New Revision: 783803

URL: http://svn.apache.org/viewvc?rev=783803&view=rev
Log:
[MNG-2562] expose current time as a property for POM interpolation

o Extended IT to check custom format support as well

Added:
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/custom/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/custom/pom.xml
      - copied, changed from r783444, maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/pom.xml
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/default/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/default/pom.xml
      - copied, changed from r783444, maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/pom.xml
Removed:
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/pom.xml
Modified:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2562TimestampTest.java

Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2562TimestampTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2562TimestampTest.java?rev=783803&r1=783802&r2=783803&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2562TimestampTest.java (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2562TimestampTest.java Thu Jun 11 14:47:46 2009
@@ -36,10 +36,10 @@
         super( "[2.1.0-M1,)" ); // 2.1.0+ only
     }
 
-    public void testitMNG2562()
+    public void testitDefaultFormat()
         throws Exception
     {
-        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2562" );
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2562/default" );
 
         Verifier verifier = new Verifier( testDir.getAbsolutePath() );
         verifier.setAutoclean( false );
@@ -48,11 +48,38 @@
         verifier.verifyErrorFreeLog();
         verifier.resetStreams();
 
+        Date now = new Date();
+
+        Properties props = verifier.loadProperties( "target/pom.properties" );
+
+        String timestamp1 = props.getProperty( "project.properties.timestamp1", "" );
+        assertTrue( timestamp1, timestamp1.matches( "[0-9]{8}-[0-9]{4}" ) );
+        Date date = new SimpleDateFormat( "yyyyMMdd-HHmm" ).parse( timestamp1 );
+        assertTrue( now + " vs " + date, Math.abs( now.getTime() - date.getTime() ) < 24 * 60 * 60 * 1000 );
+
+        String timestamp2 = props.getProperty( "project.properties.timestamp2", "" );
+        assertEquals( timestamp1, timestamp2 );
+    }
+
+    public void testitCustomFormat()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2562/custom" );
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        Date now = new Date();
+
         Properties props = verifier.loadProperties( "target/pom.properties" );
-        String timestamp = props.getProperty( "project.properties.timestamp", "" );
-        assertTrue( timestamp, timestamp.matches( "[0-9]{8}-[0-9]{4}" ) );
-        Date date = new SimpleDateFormat( "yyyyMMdd-HHmm" ).parse( timestamp );
-        assertTrue( new Date() + " vs " + date, Math.abs( System.currentTimeMillis() - date.getTime() ) < 24 * 60 * 60 * 1000 );
+
+        String timestamp1 = props.getProperty( "project.properties.timestamp", "" );
+        Date date = new SimpleDateFormat( "mm:HH dd-MM-yyyy" ).parse( timestamp1 );
+        assertTrue( now + " vs " + date, Math.abs( now.getTime() - date.getTime() ) < 24 * 60 * 60 * 1000 );
     }
 
 }

Copied: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/custom/pom.xml (from r783444, maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/pom.xml)
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/custom/pom.xml?p2=maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/custom/pom.xml&p1=maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/pom.xml&r1=783444&r2=783803&rev=783803&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/pom.xml (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/custom/pom.xml Thu Jun 11 14:47:46 2009
@@ -28,11 +28,12 @@
 
   <name>Maven Integration Test :: MNG-2562</name> 
   <description>
-    Verify that the property build.timestamp is available for POM interpolation.
+    Verify that the format of the timestamp can be customized via maven.build.timestamp.format.
   </description>
 
   <properties>
-    <timestamp>${build.timestamp}</timestamp>
+    <timestamp>${maven.build.timestamp}</timestamp>
+    <maven.build.timestamp.format>mm:HH dd-MM-yyyy</maven.build.timestamp.format>
   </properties>
 
   <build>

Copied: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/default/pom.xml (from r783444, maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/pom.xml)
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/default/pom.xml?p2=maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/default/pom.xml&p1=maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/pom.xml&r1=783444&r2=783803&rev=783803&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/pom.xml (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2562/default/pom.xml Thu Jun 11 14:47:46 2009
@@ -32,7 +32,8 @@
   </description>
 
   <properties>
-    <timestamp>${build.timestamp}</timestamp>
+    <timestamp1>${maven.build.timestamp}</timestamp1>
+    <timestamp2>${build.timestamp}</timestamp2>
   </properties>
 
   <build>