View Javadoc
1   package org.apache.maven.execution;
2   
3   import java.util.List;
4   
5   import javax.inject.Inject;
6   
7   import org.apache.maven.artifact.repository.ArtifactRepository;
8   import org.apache.maven.settings.Profile;
9   import org.apache.maven.settings.Repository;
10  import org.apache.maven.settings.Settings;
11  import org.eclipse.sisu.launch.InjectedTestCase;
12  
13  /*
14   * Licensed to the Apache Software Foundation (ASF) under one
15   * or more contributor license agreements.  See the NOTICE file
16   * distributed with this work for additional information
17   * regarding copyright ownership.  The ASF licenses this file
18   * to you under the Apache License, Version 2.0 (the
19   * "License"); you may not use this file except in compliance
20   * with the License.  You may obtain a copy of the License at
21   *
22   *  http://www.apache.org/licenses/LICENSE-2.0
23   *
24   * Unless required by applicable law or agreed to in writing,
25   * software distributed under the License is distributed on an
26   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
27   * KIND, either express or implied.  See the License for the
28   * specific language governing permissions and limitations
29   * under the License.
30   */
31  
32  public class DefaultMavenExecutionRequestPopulatorTest
33      extends InjectedTestCase
34  {
35      @Inject
36      MavenExecutionRequestPopulator testee;
37          
38      public void testPluginRepositoryInjection()
39          throws Exception
40      {
41          MavenExecutionRequest request = new DefaultMavenExecutionRequest();
42  
43          Repository r = new Repository();
44          r.setId( "test" );
45          r.setUrl( "file:///test" );
46  
47          Profile p = new Profile();
48          p.setId( "test" );
49          p.addPluginRepository( r );
50  
51          Settings settings = new Settings();
52          settings.addProfile( p );
53          settings.addActiveProfile( p.getId() );
54  
55          testee.populateFromSettings( request, settings );
56  
57          List<ArtifactRepository> repositories = request.getPluginArtifactRepositories();
58          assertEquals( 1, repositories.size() );
59          assertEquals( r.getId(), repositories.get( 0 ).getId() );
60          assertEquals( r.getUrl(), repositories.get( 0 ).getUrl() );
61      }
62  }