mirror of https://github.com/apache/maven.git
[MNG-3600] add integration test to confirm the wagon settings
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@738733 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
496cb624c6
commit
1cb3277843
|
@ -0,0 +1,110 @@
|
|||
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.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MavenITmng3600DeploymentModeDefaultsTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
public MavenITmng3600DeploymentModeDefaultsTest()
|
||||
{
|
||||
super( "(2.1.0-M1,)" );
|
||||
}
|
||||
|
||||
public void testitMNG3600NoSettings()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3600" );
|
||||
|
||||
Verifier verifier;
|
||||
|
||||
verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
|
||||
List cliOptions = new ArrayList();
|
||||
verifier.setCliOptions( cliOptions );
|
||||
verifier.executeGoal( "deploy" );
|
||||
|
||||
verifier.assertFilePresent( "target/wagon.properties" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
|
||||
verifier.resetStreams();
|
||||
|
||||
Properties props = verifier.loadProperties( "target/wagon.properties" );
|
||||
assertNull( props.get( "directory.mode" ) );
|
||||
assertNull( props.get( "file.mode" ) );
|
||||
}
|
||||
|
||||
public void testitMNG3600ServerDefaults()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3600" );
|
||||
|
||||
Verifier verifier;
|
||||
|
||||
verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "--settings" );
|
||||
cliOptions.add( "settings-server-defaults.xml" );
|
||||
verifier.setCliOptions( cliOptions );
|
||||
verifier.executeGoal( "deploy" );
|
||||
|
||||
verifier.assertFilePresent( "target/wagon.properties" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
|
||||
verifier.resetStreams();
|
||||
|
||||
Properties props = verifier.loadProperties( "target/wagon.properties" );
|
||||
assertNull( props.get( "directory.mode" ) );
|
||||
assertNull( props.get( "file.mode" ) );
|
||||
}
|
||||
|
||||
public void testitMNG3600ModesSet()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3600" );
|
||||
|
||||
Verifier verifier;
|
||||
|
||||
verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "--settings" );
|
||||
cliOptions.add( "settings-modes-set.xml" );
|
||||
verifier.setCliOptions( cliOptions );
|
||||
verifier.executeGoal( "deploy" );
|
||||
|
||||
verifier.assertFilePresent( "target/wagon.properties" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
|
||||
verifier.resetStreams();
|
||||
|
||||
Properties props = verifier.loadProperties( "target/wagon.properties" );
|
||||
assertEquals( "700", props.get( "directory.mode" ) );
|
||||
assertEquals( "600", props.get( "file.mode" ) );
|
||||
}
|
||||
}
|
|
@ -34,6 +34,7 @@ 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;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.codehaus.plexus.util.StringInputStream;
|
||||
|
||||
/**
|
||||
|
@ -124,6 +125,31 @@ public class ScpExternalWagon
|
|||
public void fillOutputData( OutputData outputData )
|
||||
throws TransferFailedException
|
||||
{
|
||||
String content = "";
|
||||
if ( getRepository().getPermissions() != null )
|
||||
{
|
||||
String dirPerms = getRepository().getPermissions().getDirectoryMode();
|
||||
|
||||
if ( dirPerms != null )
|
||||
{
|
||||
content += "directory.mode = " + dirPerms + "\n";
|
||||
}
|
||||
|
||||
String filePerms = getRepository().getPermissions().getFileMode();
|
||||
if ( filePerms != null )
|
||||
{
|
||||
content += "file.mode = " + filePerms + "\n";
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
FileUtils.fileWrite( "target/wagon.properties", content );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new TransferFailedException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
outputData.setOutputStream( new ByteArrayOutputStream() );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue