1 package org.apache.maven.artifact.versioning;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.fail;
24
25 import java.io.IOException;
26 import java.nio.file.FileVisitResult;
27 import java.nio.file.Files;
28 import java.nio.file.Path;
29 import java.nio.file.Paths;
30 import java.nio.file.SimpleFileVisitor;
31 import java.nio.file.attribute.BasicFileAttributes;
32 import java.util.regex.Pattern;
33
34 import org.junit.Test;
35
36 public class ComparableVersionIT
37 {
38
39 @Test
40 public void test()
41 throws Exception
42 {
43 Files.walkFileTree( Paths.get( "target" ), new SimpleFileVisitor<Path>()
44 {
45 Pattern mavenArtifactJar = Pattern.compile( "maven-artifact-[\\d.]+(-SNAPSHOT)?\\.jar" );
46
47 @Override
48 public FileVisitResult visitFile( Path file, BasicFileAttributes attrs )
49 throws IOException
50 {
51 String filename = file.getFileName().toString();
52 if ( mavenArtifactJar.matcher( filename ).matches() )
53 {
54 Process p = Runtime.getRuntime().exec( new String[] {
55 Paths.get( System.getProperty( "java.home" ), "bin/java" ).toString(),
56 "-jar",
57 file.toAbsolutePath().toString(),
58 "5.32",
59 "5.27" } );
60
61 try
62 {
63 assertEquals( "Unexpected exit code", 0, p.waitFor() );
64 }
65 catch ( InterruptedException e )
66 {
67 fail( e.getMessage() );
68 }
69 return FileVisitResult.TERMINATE;
70 }
71 else
72 {
73 return FileVisitResult.CONTINUE;
74 }
75 }
76
77 @Override
78 public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs )
79 throws IOException
80 {
81 if ( Paths.get( "target" ).equals( dir ) )
82 {
83 return FileVisitResult.CONTINUE;
84 }
85 else
86 {
87 return FileVisitResult.SKIP_SUBTREE;
88 }
89 }
90 } );
91 }
92
93 }