1 package org.apache.maven.resolver.internal.ant;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.io.IOException;
24
25 import junit.framework.JUnit4TestAdapter;
26 import org.apache.maven.resolver.internal.ant.ProjectWorkspaceReader;
27 import org.eclipse.aether.artifact.Artifact;
28 import org.eclipse.aether.artifact.DefaultArtifact;
29 import org.junit.Test;
30
31 import static org.junit.Assert.*;
32
33 public class ReactorTest
34 extends AntBuildsTest
35 {
36 public static junit.framework.Test suite()
37 {
38 return new JUnit4TestAdapter( ReactorTest.class );
39 }
40
41 private Artifact artifact( String coords )
42 {
43 return new DefaultArtifact( coords );
44 }
45
46 @Test
47 public void testPom()
48 throws IOException
49 {
50 executeTarget( "testPom" );
51 ProjectWorkspaceReader reader = ProjectWorkspaceReader.getInstance();
52 File found = reader.findArtifact( artifact( "test:test:pom:0.1-SNAPSHOT" ) );
53 assertNotNull( found );
54 assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
55 }
56
57 @Test
58 public void testArtifact()
59 throws IOException
60 {
61 executeTarget( "testArtifact" );
62 ProjectWorkspaceReader reader = ProjectWorkspaceReader.getInstance();
63 File found = reader.findArtifact( artifact( "test:test:pom:0.1-SNAPSHOT" ) );
64 assertNotNull( found );
65 assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
66
67 found = reader.findArtifact( artifact( "test:test:xml:0.1-SNAPSHOT" ) );
68 assertNotNull( found );
69 assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
70 }
71
72 @Test
73 public void testArtifactInMemoryPom()
74 throws IOException
75 {
76 executeTarget( "testArtifactInMemoryPom" );
77 ProjectWorkspaceReader reader = ProjectWorkspaceReader.getInstance();
78 File found = reader.findArtifact( artifact( "test:test:pom:0.1-SNAPSHOT" ) );
79 assertNull( found );
80
81 found = reader.findArtifact( artifact( "test:test:xml:0.1-SNAPSHOT" ) );
82 assertNotNull( found );
83 assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
84 }
85
86 @Test
87 public void testResolveArtifact()
88 throws IOException
89 {
90 executeTarget( "testResolveArtifact" );
91 String prop = getProject().getProperty( "resolve.test:test:jar" );
92 assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
93 }
94
95 @Test
96 public void testResolveArtifactInMemoryPom()
97 throws IOException
98 {
99 executeTarget( "testResolveArtifactInMemoryPom" );
100 String prop = getProject().getProperty( "resolve.test:test:jar" );
101 assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
102 assertLogContaining( "The POM for test:test:jar:0.1-SNAPSHOT is missing, no dependency information available" );
103 }
104
105 @Test
106 public void testResolveVersionRange()
107 throws IOException
108 {
109 executeTarget( "testResolveVersionRange" );
110 String prop = getProject().getProperty( "resolve.test:test:jar" );
111 assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
112 }
113
114 }