View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.artifact.factory;
20  
21  import org.apache.maven.artifact.Artifact;
22  import org.apache.maven.artifact.versioning.VersionRange;
23  import org.codehaus.plexus.PlexusTestCase;
24  
25  public class DefaultArtifactFactoryTest extends PlexusTestCase {
26  
27      public void testPropagationOfSystemScopeRegardlessOfInheritedScope() throws Exception {
28          ArtifactFactory factory = (ArtifactFactory) lookup(ArtifactFactory.ROLE);
29  
30          Artifact artifact = factory.createDependencyArtifact(
31                  "test-grp", "test-artifact", VersionRange.createFromVersion("1.0"), "type", null, "system", "provided");
32          Artifact artifact2 = factory.createDependencyArtifact(
33                  "test-grp", "test-artifact-2", VersionRange.createFromVersion("1.0"), "type", null, "system", "test");
34          Artifact artifact3 = factory.createDependencyArtifact(
35                  "test-grp",
36                  "test-artifact-3",
37                  VersionRange.createFromVersion("1.0"),
38                  "type",
39                  null,
40                  "system",
41                  "runtime");
42          Artifact artifact4 = factory.createDependencyArtifact(
43                  "test-grp",
44                  "test-artifact-4",
45                  VersionRange.createFromVersion("1.0"),
46                  "type",
47                  null,
48                  "system",
49                  "compile");
50  
51          // this one should never happen in practice...
52          Artifact artifact5 = factory.createDependencyArtifact(
53                  "test-grp", "test-artifact-5", VersionRange.createFromVersion("1.0"), "type", null, "system", "system");
54  
55          assertEquals("system", artifact.getScope());
56          assertEquals("system", artifact2.getScope());
57          assertEquals("system", artifact3.getScope());
58          assertEquals("system", artifact4.getScope());
59          assertEquals("system", artifact5.getScope());
60      }
61  }