-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} ); | ||
} | ||
|
||
} |