1 package org.apache.maven.it; 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.List; 24 25 import org.apache.maven.it.util.ResourceExtractor; 26 27 /** 28 * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-6240">MNG-6240</a>. 29 * 30 * @author gboue 31 */ 32 public class MavenITmng6240PluginExtensionAetherProvider 33 extends AbstractMavenIntegrationTestCase 34 { 35 public MavenITmng6240PluginExtensionAetherProvider() 36 { 37 super( "[3.5.1,)" ); 38 } 39 40 /** 41 * <p> 42 * Checks that there are no duplicate classes from maven-aether-provider on the classpath, when the build has a 43 * plugin extension that depends on the former maven-aether-provider, renamed to maven-resolver-provider. 44 * <p> 45 * One way to do this is to look at MetadataGeneratorFactory, which is a class of this module: there should only be 46 * two instances (one of SnapshotMetadataGeneratorFactory and VersionsMetadataGeneratorFactory). When there are 47 * more, the Deploy Plugin will perform the download / upload of artifact metadata multiple times. This can be 48 * verified easily from the logs. 49 * 50 * @throws Exception in case of failure 51 */ 52 public void testPluginExtensionDependingOnMavenAetherProvider() 53 throws Exception 54 { 55 File testDir = 56 ResourceExtractor.simpleExtractResources( getClass(), "/mng-6240-plugin-extension-aether-provider" ); 57 File pluginDir = new File( testDir, "plugin-extension" ); 58 File projectDir = new File( testDir, "project" ); 59 60 Verifier verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" ); 61 verifier.executeGoal( "install" ); 62 verifier.resetStreams(); 63 verifier.verifyErrorFreeLog(); 64 65 verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); 66 verifier.executeGoal( "deploy" ); 67 verifier.resetStreams(); 68 verifier.verifyErrorFreeLog(); 69 70 List<String> lines = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false ); 71 int count = 0; 72 for ( String line : lines ) 73 { 74 if ( line.endsWith( "/repo/org/apache/maven/its/mng6240/project/1.0-SNAPSHOT/maven-metadata.xml" ) ) 75 { 76 count++; 77 } 78 } 79 assertEquals( 2, count ); // 1 from download, 1 from upload 80 81 } 82 83 }