View Javadoc
1   package org.apache.maven.resolver.internal.ant;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.io.IOException;
24  
25  import org.apache.maven.resolver.internal.ant.ProjectWorkspaceReader;
26  import org.eclipse.aether.artifact.Artifact;
27  import org.eclipse.aether.artifact.DefaultArtifact;
28  
29  public class ReactorTest
30      extends AntBuildsTest
31  {
32  
33      private Artifact artifact( String coords )
34      {
35          return new DefaultArtifact( coords );
36      }
37  
38      public void testPom()
39          throws IOException
40      {
41          executeTarget( "testPom" );
42          ProjectWorkspaceReader reader = ProjectWorkspaceReader.getInstance();
43          File found = reader.findArtifact( artifact( "test:test:pom:0.1-SNAPSHOT" ) );
44          assertNotNull( found );
45          assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
46      }
47  
48      public void testArtifact()
49          throws IOException
50      {
51          executeTarget( "testArtifact" );
52          ProjectWorkspaceReader reader = ProjectWorkspaceReader.getInstance();
53          File found = reader.findArtifact( artifact( "test:test:pom:0.1-SNAPSHOT" ) );
54          assertNotNull( found );
55          assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
56  
57          found = reader.findArtifact( artifact( "test:test:xml:0.1-SNAPSHOT" ) );
58          assertNotNull( found );
59          assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
60      }
61  
62      public void testArtifactInMemoryPom()
63          throws IOException
64      {
65          executeTarget( "testArtifactInMemoryPom" );
66          ProjectWorkspaceReader reader = ProjectWorkspaceReader.getInstance();
67          File found = reader.findArtifact( artifact( "test:test:pom:0.1-SNAPSHOT" ) );
68          assertNull( found );
69  
70          found = reader.findArtifact( artifact( "test:test:xml:0.1-SNAPSHOT" ) );
71          assertNotNull( found );
72          assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
73      }
74  
75      public void testResolveArtifact()
76          throws IOException
77      {
78          executeTarget( "testResolveArtifact" );
79          String prop = project.getProperty( "resolve.test:test:jar" );
80          assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
81      }
82  
83      public void testResolveArtifactInMemoryPom()
84          throws IOException
85      {
86          executeTarget( "testResolveArtifactInMemoryPom" );
87          String prop = project.getProperty( "resolve.test:test:jar" );
88          assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
89          assertLogContaining( "The POM for test:test:jar:0.1-SNAPSHOT is missing, no dependency information available" );
90      }
91  
92      public void testResolveVersionRange()
93          throws IOException
94      {
95          executeTarget( "testResolveVersionRange" );
96          String prop = project.getProperty( "resolve.test:test:jar" );
97          assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
98      }
99  
100 }