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 javax.inject.Inject;
22  
23  import org.apache.maven.artifact.Artifact;
24  import org.apache.maven.artifact.versioning.VersionRange;
25  import org.codehaus.plexus.testing.PlexusTest;
26  import org.junit.jupiter.api.Test;
27  
28  import static org.junit.jupiter.api.Assertions.assertEquals;
29  
30  @PlexusTest
31  @Deprecated
32  class DefaultArtifactFactoryTest {
33  
34      @Inject
35      ArtifactFactory factory;
36  
37      @Test
38      void testPropagationOfSystemScopeRegardlessOfInheritedScope() {
39          Artifact artifact = factory.createDependencyArtifact(
40                  "test-grp", "test-artifact", VersionRange.createFromVersion("1.0"), "type", null, "system", "provided");
41          Artifact artifact2 = factory.createDependencyArtifact(
42                  "test-grp", "test-artifact-2", VersionRange.createFromVersion("1.0"), "type", null, "system", "test");
43          Artifact artifact3 = factory.createDependencyArtifact(
44                  "test-grp",
45                  "test-artifact-3",
46                  VersionRange.createFromVersion("1.0"),
47                  "type",
48                  null,
49                  "system",
50                  "runtime");
51          Artifact artifact4 = factory.createDependencyArtifact(
52                  "test-grp",
53                  "test-artifact-4",
54                  VersionRange.createFromVersion("1.0"),
55                  "type",
56                  null,
57                  "system",
58                  "compile");
59  
60          // this one should never happen in practice...
61          Artifact artifact5 = factory.createDependencyArtifact(
62                  "test-grp", "test-artifact-5", VersionRange.createFromVersion("1.0"), "type", null, "system", "system");
63  
64          assertEquals("system", artifact.getScope());
65          assertEquals("system", artifact2.getScope());
66          assertEquals("system", artifact3.getScope());
67          assertEquals("system", artifact4.getScope());
68          assertEquals("system", artifact5.getScope());
69      }
70  }