001package org.apache.maven.execution;
002
003import java.util.List;
004
005import javax.inject.Inject;
006
007import org.apache.maven.artifact.repository.ArtifactRepository;
008import org.apache.maven.settings.Profile;
009import org.apache.maven.settings.Repository;
010import org.apache.maven.settings.Settings;
011import org.eclipse.sisu.launch.InjectedTestCase;
012
013/*
014 * Licensed to the Apache Software Foundation (ASF) under one
015 * or more contributor license agreements.  See the NOTICE file
016 * distributed with this work for additional information
017 * regarding copyright ownership.  The ASF licenses this file
018 * to you under the Apache License, Version 2.0 (the
019 * "License"); you may not use this file except in compliance
020 * with the License.  You may obtain a copy of the License at
021 *
022 *  http://www.apache.org/licenses/LICENSE-2.0
023 *
024 * Unless required by applicable law or agreed to in writing,
025 * software distributed under the License is distributed on an
026 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
027 * KIND, either express or implied.  See the License for the
028 * specific language governing permissions and limitations
029 * under the License.
030 */
031
032public class DefaultMavenExecutionRequestPopulatorTest
033    extends InjectedTestCase
034{
035    @Inject
036    MavenExecutionRequestPopulator testee;
037        
038    public void testPluginRepositoryInjection()
039        throws Exception
040    {
041        MavenExecutionRequest request = new DefaultMavenExecutionRequest();
042
043        Repository r = new Repository();
044        r.setId( "test" );
045        r.setUrl( "file:///test" );
046
047        Profile p = new Profile();
048        p.setId( "test" );
049        p.addPluginRepository( r );
050
051        Settings settings = new Settings();
052        settings.addProfile( p );
053        settings.addActiveProfile( p.getId() );
054
055        testee.populateFromSettings( request, settings );
056
057        List<ArtifactRepository> repositories = request.getPluginArtifactRepositories();
058        assertEquals( 1, repositories.size() );
059        assertEquals( r.getId(), repositories.get( 0 ).getId() );
060        assertEquals( r.getUrl(), repositories.get( 0 ).getUrl() );
061    }
062}