You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/04/29 21:28:00 UTC

[maven] 01/01: [MNG-6643] Integration test

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch MNG-6643
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 4ff24e3678cc2ba50f4df3d9711b723870d40cf8
Author: rfscholte <rf...@apache.org>
AuthorDate: Mon Apr 29 23:27:58 2019 +0200

    [MNG-6643] Integration test
---
 maven-artifact/pom.xml                             | 12 +++
 .../artifact/versioning/ComparableVersionIT.java   | 93 ++++++++++++++++++++++
 2 files changed, 105 insertions(+)

diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml
index 85b99ea..f447520 100644
--- a/maven-artifact/pom.xml
+++ b/maven-artifact/pom.xml
@@ -60,6 +60,18 @@ under the License.
           </archive>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-failsafe-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>integration-test</goal>
+              <goal>verify</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 </project>
diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionIT.java b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionIT.java
new file mode 100644
index 0000000..33b744b
--- /dev/null
+++ b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionIT.java
@@ -0,0 +1,93 @@
+package org.apache.maven.artifact.versioning;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.regex.Pattern;
+
+import org.junit.Test;
+
+public class ComparableVersionIT
+{
+
+    @Test
+    public void test()
+        throws Exception
+    {
+        Files.walkFileTree( Paths.get( "target" ), new SimpleFileVisitor<Path>()
+        {
+            Pattern mavenArtifactJar = Pattern.compile( "maven-artifact-[\\d.]+(-SNAPSHOT)?\\.jar" );
+
+            @Override
+            public FileVisitResult visitFile( Path file, BasicFileAttributes attrs )
+                throws IOException
+            {
+                String filename = file.getFileName().toString();
+                if ( mavenArtifactJar.matcher( filename ).matches() )
+                {
+                    Process p = Runtime.getRuntime().exec( new String[] {
+                        Paths.get( System.getProperty( "java.home" ), "bin/java" ).toString(), 
+                        "-jar",
+                        file.toAbsolutePath().toString(), 
+                        "5.32", 
+                        "5.27" } );
+
+                    try
+                    {
+                        assertEquals( "Unexpected exit code", 0, p.waitFor() );
+                    }
+                    catch ( InterruptedException e )
+                    {
+                        fail( e.getMessage() );
+                    }
+                    return FileVisitResult.TERMINATE;
+                }
+                else
+                {
+                    return FileVisitResult.CONTINUE;
+                }
+            }
+
+            @Override
+            public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs )
+                throws IOException
+            {
+                if ( Paths.get( "target" ).equals( dir ) )
+                {
+                    return FileVisitResult.CONTINUE;
+                }
+                else
+                {
+                    return FileVisitResult.SKIP_SUBTREE;
+                }
+            }
+        } );
+    }
+
+}