mirror of https://github.com/apache/maven.git
[MNG-4254] Adding integration tests for CLI-specified and settings-configured wagon providers.
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@797278 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d8456559f4
commit
a6759006c5
|
@ -91,8 +91,9 @@ public class IntegrationTestSuite
|
|||
// suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class );
|
||||
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
||||
|
||||
suite.addTestSuite( MavenITmng4254SelectableWagonProvidersTest.class );
|
||||
suite.addTestSuite( MavenITmng4238ArtifactHandlerExtensionUsageTest.class );
|
||||
//suite.addTestSuite( MavenITmng4235HttpAuthDeploymentChecksumsTest.class );
|
||||
suite.addTestSuite( MavenITmng4235HttpAuthDeploymentChecksumsTest.class );
|
||||
suite.addTestSuite( MavenITmng4231SnapshotUpdatePolicyTest.class );
|
||||
suite.addTestSuite( MavenITmng4214MirroredParentSearchReposTest.class );
|
||||
suite.addTestSuite( MavenITmng4208InterpolationPrefersCliOverProjectPropsTest.class );
|
||||
|
|
|
@ -53,25 +53,7 @@ public class MavenITmng3506ArtifactHandlersFromPluginsTest
|
|||
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
|
||||
// remove the artifact+POM that should be installed here.
|
||||
verifier.deleteArtifact( GID, AID, VERSION, "pom" );
|
||||
|
||||
// first child
|
||||
verifier.deleteArtifact( GID, AID + ".1", VERSION, "pom" );
|
||||
verifier.deleteArtifact( GID, AID + ".1", VERSION, TYPE );
|
||||
|
||||
// shouldn't exist, but we want to make sure we're testing the current pass properly...
|
||||
verifier.deleteArtifact( GID, AID + ".1", VERSION, BAD_TYPE1 );
|
||||
verifier.deleteArtifact( GID, AID + ".1", VERSION, BAD_TYPE2 );
|
||||
|
||||
|
||||
// second child
|
||||
verifier.deleteArtifact( GID, AID + ".2", VERSION, "pom" );
|
||||
verifier.deleteArtifact( GID, AID + ".2", VERSION, TYPE );
|
||||
|
||||
// shouldn't exist, but we want to make sure we're testing the current pass properly...
|
||||
verifier.deleteArtifact( GID, AID + ".2", VERSION, BAD_TYPE1 );
|
||||
verifier.deleteArtifact( GID, AID + ".2", VERSION, BAD_TYPE2 );
|
||||
verifier.deleteArtifacts( GID );
|
||||
|
||||
verifier.executeGoal( "install" );
|
||||
|
||||
|
|
|
@ -52,12 +52,7 @@ public class MavenITmng4238ArtifactHandlerExtensionUsageTest
|
|||
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
|
||||
// remove the artifact+POM that should be installed here.
|
||||
verifier.deleteArtifact( GID, AID, VERSION, "pom" );
|
||||
verifier.deleteArtifact( GID, AID, VERSION, TYPE );
|
||||
|
||||
// shouldn't exist, but we want to make sure we're testing the current pass properly...
|
||||
verifier.deleteArtifact( GID, AID, VERSION, BAD_TYPE );
|
||||
verifier.deleteArtifacts( GID );
|
||||
|
||||
verifier.executeGoal( "install" );
|
||||
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package org.apache.maven.it;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3506">MNG-3506</a>.
|
||||
*
|
||||
* @author John Casey
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MavenITmng4254SelectableWagonProvidersTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
|
||||
public MavenITmng4254SelectableWagonProvidersTest()
|
||||
{
|
||||
super( "(2.2.0,)" );
|
||||
}
|
||||
|
||||
public void testCliUsage()
|
||||
throws IOException, VerificationException
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4254" );
|
||||
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "-Dmaven.wagon.provider.http=coreit" );
|
||||
|
||||
verifier.setLogFileName( "log-cli.txt" );
|
||||
verifier.executeGoal( "deploy" );
|
||||
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
assertTrue( "target/wagon.properties should exist.", new File( testDir, "target/wagon.properties" ).exists() );
|
||||
}
|
||||
|
||||
public void testSettingsUsage()
|
||||
throws IOException, VerificationException
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4254" );
|
||||
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "--settings" );
|
||||
cliOptions.add( "settings.xml" );
|
||||
|
||||
verifier.setLogFileName( "log-settings.txt" );
|
||||
verifier.executeGoal( "deploy" );
|
||||
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
assertTrue( "target/wagon.properties should exist.", new File( testDir, "target/wagon.properties" ).exists() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.its.mng4254</groupId>
|
||||
<artifactId>mng-4254</artifactId>
|
||||
<version>1</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>test</id>
|
||||
<url>http://dummyhost.com/repository</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.its</groupId>
|
||||
<artifactId>core-it-wagon</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,10 @@
|
|||
<settings>
|
||||
<servers>
|
||||
<server>
|
||||
<id>test</id>
|
||||
<configuration>
|
||||
<wagonProvider>coreit</wagonProvider>
|
||||
</configuration>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
|
@ -0,0 +1,180 @@
|
|||
package org.apache.maven.wagon.providers.coreit;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.wagon.AbstractWagon;
|
||||
import org.apache.maven.wagon.ConnectionException;
|
||||
import org.apache.maven.wagon.InputData;
|
||||
import org.apache.maven.wagon.OutputData;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
import org.apache.maven.wagon.TransferFailedException;
|
||||
import org.apache.maven.wagon.authentication.AuthenticationException;
|
||||
import org.apache.maven.wagon.authorization.AuthorizationException;
|
||||
import org.apache.maven.wagon.resource.Resource;
|
||||
|
||||
/**
|
||||
* Shamelessly copied from ScpExternalWagon in this same project...
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="http-coreit"
|
||||
*/
|
||||
public class CoreItHttpWagon
|
||||
extends AbstractWagon
|
||||
{
|
||||
public void get( String resourceName, File destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
|
||||
{
|
||||
InputData inputData = new InputData();
|
||||
|
||||
Resource resource = new Resource( resourceName );
|
||||
|
||||
fireGetInitiated( resource, destination );
|
||||
|
||||
inputData.setResource( resource );
|
||||
|
||||
fillInputData( inputData );
|
||||
|
||||
InputStream is = inputData.getInputStream();
|
||||
|
||||
if ( is == null )
|
||||
{
|
||||
throw new TransferFailedException( getRepository().getUrl()
|
||||
+ " - Could not open input stream for resource: '" + resource + "'" );
|
||||
}
|
||||
|
||||
createParentDirectories( destination );
|
||||
|
||||
getTransfer( inputData.getResource(), destination, is );
|
||||
}
|
||||
|
||||
public boolean getIfNewer( String resourceName, File destination, long timestamp )
|
||||
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void put( File source, String resourceName )
|
||||
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
|
||||
{
|
||||
OutputData outputData = new OutputData();
|
||||
|
||||
Resource resource = new Resource( resourceName );
|
||||
|
||||
firePutInitiated( resource, source );
|
||||
|
||||
outputData.setResource( resource );
|
||||
|
||||
fillOutputData( outputData );
|
||||
|
||||
OutputStream os = outputData.getOutputStream();
|
||||
|
||||
if ( os == null )
|
||||
{
|
||||
throw new TransferFailedException( getRepository().getUrl()
|
||||
+ " - Could not open output stream for resource: '" + resource + "'" );
|
||||
}
|
||||
|
||||
putTransfer( outputData.getResource(), source, os, true );
|
||||
}
|
||||
|
||||
public void closeConnection()
|
||||
throws ConnectionException
|
||||
{
|
||||
File f = new File( "target/wagon-data" );
|
||||
try
|
||||
{
|
||||
f.createNewFile();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ConnectionException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
public void fillInputData( InputData inputData )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
try
|
||||
{
|
||||
inputData.setInputStream( new ByteArrayInputStream( "<metadata />".getBytes( "UTF-8" ) ) );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new TransferFailedException( "Broken JVM", e );
|
||||
}
|
||||
}
|
||||
|
||||
public void fillOutputData( OutputData outputData )
|
||||
throws TransferFailedException
|
||||
{
|
||||
Properties props = new Properties();
|
||||
if ( getRepository().getPermissions() != null )
|
||||
{
|
||||
String dirPerms = getRepository().getPermissions().getDirectoryMode();
|
||||
|
||||
if ( dirPerms != null )
|
||||
{
|
||||
props.setProperty( "directory.mode", dirPerms );
|
||||
}
|
||||
|
||||
String filePerms = getRepository().getPermissions().getFileMode();
|
||||
if ( filePerms != null )
|
||||
{
|
||||
props.setProperty( "file.mode", filePerms );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
new File( "target" ).mkdirs();
|
||||
|
||||
OutputStream os = new FileOutputStream( "target/wagon.properties" );
|
||||
try
|
||||
{
|
||||
props.store( os, "MAVEN-CORE-IT-WAGON" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new TransferFailedException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
outputData.setOutputStream( new ByteArrayOutputStream() );
|
||||
}
|
||||
|
||||
public void openConnection()
|
||||
throws ConnectionException, AuthenticationException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue