Coverage Report - org.apache.maven.wagon.CommandExecutorTestCase
 
Classes in this File Line Coverage Branch Coverage Complexity
CommandExecutorTestCase
0 %
0/32
0 %
0/2
1,25
 
 1  
 package org.apache.maven.wagon;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
 5  
  * agreements. See the NOTICE file distributed with this work for additional information regarding
 6  
  * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance with the License. You may obtain a
 8  
  * copy of the License at
 9  
  * 
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  * 
 12  
  * Unless required by applicable law or agreed to in writing, software distributed under the License
 13  
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 14  
  * or implied. See the License for the specific language governing permissions and limitations under
 15  
  * the License.
 16  
  */
 17  
 
 18  
 import org.codehaus.plexus.PlexusTestCase;
 19  
 import org.apache.maven.wagon.repository.Repository;
 20  
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
 21  
 
 22  
 /**
 23  
  * Base class for command executor tests.
 24  
  *
 25  
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
 26  
  * @version $Id: CommandExecutorTestCase.java 658720 2008-05-21 14:49:22Z bentmann $
 27  
  */
 28  0
 public abstract class CommandExecutorTestCase
 29  
     extends PlexusTestCase
 30  
 {
 31  
     public void testErrorInCommandExecuted()
 32  
         throws Exception
 33  
     {
 34  0
         CommandExecutor exec = (CommandExecutor) lookup( CommandExecutor.ROLE );
 35  
 
 36  0
         Repository repository = getTestRepository();
 37  
 
 38  0
         AuthenticationInfo authenticationInfo = new AuthenticationInfo();
 39  0
         authenticationInfo.setUserName( System.getProperty( "user.name" ) );
 40  
 
 41  0
         exec.connect( repository, authenticationInfo );
 42  
 
 43  
         try
 44  
         {
 45  0
             exec.executeCommand( "fail" );
 46  0
             fail( "Command should have failed" );
 47  
         }
 48  0
         catch ( CommandExecutionException e )
 49  
         {
 50  0
             assertTrue( e.getMessage().trim().endsWith( "fail: command not found" ) );
 51  
         }
 52  
         finally
 53  
         {
 54  0
             exec.disconnect();
 55  0
         }
 56  0
     }
 57  
 
 58  
     public void testIgnoreFailuresInCommandExecuted()
 59  
         throws Exception
 60  
     {
 61  0
         CommandExecutor exec = (CommandExecutor) lookup( CommandExecutor.ROLE );
 62  
 
 63  0
         Repository repository = getTestRepository();
 64  
 
 65  0
         AuthenticationInfo authenticationInfo = new AuthenticationInfo();
 66  0
         authenticationInfo.setUserName( System.getProperty( "user.name" ) );
 67  
 
 68  0
         exec.connect( repository, authenticationInfo );
 69  
 
 70  
         try
 71  
         {
 72  0
             Streams streams = exec.executeCommand( "fail", true );
 73  
             //expect no exception, and stderr has something.
 74  0
             assertTrue( streams.getErr().length() > 0 );
 75  
         }
 76  
         finally
 77  
         {
 78  0
             exec.disconnect();
 79  0
         }
 80  0
     }
 81  
 
 82  
     public void testExecuteSuccessfulCommand()
 83  
         throws Exception
 84  
     {
 85  0
         CommandExecutor exec = (CommandExecutor) lookup( CommandExecutor.ROLE );
 86  
 
 87  0
         Repository repository = getTestRepository();
 88  
 
 89  0
         AuthenticationInfo authenticationInfo = new AuthenticationInfo();
 90  0
         authenticationInfo.setUserName( System.getProperty( "user.name" ) );
 91  
 
 92  0
         exec.connect( repository, authenticationInfo );
 93  
 
 94  
         try
 95  
         {
 96  0
             exec.executeCommand( "ls" );
 97  
         }
 98  
         finally
 99  
         {
 100  0
             exec.disconnect();
 101  0
         }
 102  0
     }
 103  
 
 104  
     protected abstract Repository getTestRepository();
 105  
 }