1 package org.apache.maven.plugin.dependency;
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.util.Set;
24
25 import org.apache.maven.artifact.Artifact;
26 import org.apache.maven.project.MavenProject;
27
28 public class TestPropertiesMojo
29 extends AbstractDependencyMojoTestCase
30 {
31 protected void setUp()
32 throws Exception
33 {
34 // required for mojo lookups to work
35 super.setUp( "markers", true );
36 }
37
38 /**
39 * tests the proper discovery and configuration of the mojo
40 *
41 * @throws Exception
42 */
43 public void testSetProperties()
44 throws Exception
45 {
46 File testPom = new File( getBasedir(), "target/test-classes/unit/properties-test/plugin-config.xml" );
47 PropertiesMojo mojo = (PropertiesMojo) lookupMojo( "properties", testPom );
48
49 assertNotNull( mojo );
50 assertNotNull( mojo.getProject() );
51 MavenProject project = mojo.getProject();
52
53 Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
54 Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
55 artifacts.addAll( directArtifacts );
56
57 project.setArtifacts( artifacts );
58 project.setDependencyArtifacts( directArtifacts );
59
60 // this.assertNull( project.getProperties().getProperty( "org.apacha ) )
61 mojo.execute();
62
63 for ( Artifact artifact : artifacts )
64 {
65 File artifactFile = artifact.getFile();
66 assertNotNull( artifact.getDependencyConflictId() );
67 assertTrue( artifactFile.isFile() );
68
69 }
70
71 }
72
73 }