org.apache.maven.wagon
Class WagonTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.codehaus.plexus.PlexusTestCase
              extended by org.apache.maven.wagon.WagonTestCase
All Implemented Interfaces:
Test
Direct Known Subclasses:
StreamingWagonTestCase

public abstract class WagonTestCase
extends org.codehaus.plexus.PlexusTestCase

Version:
$Id: WagonTestCase.java 1173679 2011-09-21 14:32:35Z olamy $
Author:
Jason van Zyl

Field Summary
protected  File artifactDestFile
           
protected  File artifactSourceFile
           
protected  ChecksumObserver checksumObserver
           
protected  File destFile
           
protected  Repository localRepository
           
protected  String localRepositoryPath
           
protected static Logger logger
           
protected  TransferListener mockTransferListener
           
protected  org.easymock.MockControl mockTransferListenerControl
           
protected static String POM
           
protected  String resource
           
protected  File sourceFile
           
protected  Repository testRepository
           
 
Constructor Summary
WagonTestCase()
           
 
Method Summary
protected  void assertGetIfNewerTest(org.apache.maven.wagon.WagonTestCase.ProgressArgumentMatcher progressArgumentMatcher, boolean expectedResult, int expectedSize)
           
protected  void assertNotExists(Wagon wagon, String resourceName)
          Assert that a resource does not exist in the remote wagon system
protected  void assertResourcesAreInRemoteSide(Wagon wagon, List<String> resourceNames)
           
protected  void connectWagon(Wagon wagon)
           
protected  void createDirectory(Wagon wagon, String resourceToCreate, String dirName)
          Create a directory with a resource and check that the other ones don't exist
protected  Repository createFileRepository(String url)
           
protected  TransferEvent createTransferEvent(Wagon wagon, Resource resource, int eventType, int requestType, File file)
           
protected  void customizeContext()
           
protected  void disconnectWagon(Wagon wagon)
           
protected  void fileRoundTripTesting()
           
protected  AuthenticationInfo getAuthInfo()
           
protected  int getExpectedContentLengthOnGet(int expectedSize)
           
protected  long getExpectedLastModifiedOnGet(Repository repository, Resource resource)
           
protected  void getFile(int expectedSize)
           
protected  RepositoryPermissions getPermissions()
           
protected abstract  String getProtocol()
          Protocol id of the Wagon to use, eg.
protected abstract  int getTestRepositoryPort()
          The number of the port which should get used to start the test server
protected abstract  String getTestRepositoryUrl()
          URL of the repository.
protected  Wagon getWagon()
           
protected  void message(String message)
           
protected  int putFile()
           
protected  void putFile(String resourceName, String testFileName, String content)
           
protected  org.apache.maven.wagon.WagonTestCase.ProgressArgumentMatcher replaceMockForGet(Wagon wagon, int expectedSize)
           
protected  org.apache.maven.wagon.WagonTestCase.ProgressArgumentMatcher replayMockForPut(String resourceName, String content, Wagon wagon)
           
protected  void setUp()
           
protected  org.apache.maven.wagon.WagonTestCase.ProgressArgumentMatcher setupGetIfNewerTest(Wagon wagon, boolean expectedResult, int expectedSize)
           
protected  void setupRepositories()
           
protected  void setupWagonTestingFixtures()
           
protected  boolean supportsGetIfNewer()
           
protected  void tearDownWagonTestingFixtures()
           
 void testFailedGet()
           
 void testFailedGetIfNewer()
           
 void testWagon()
           
 void testWagonGetFileList()
          Test Wagon.getFileList(String).
 void testWagonGetFileListWhenDirectoryDoesNotExist()
          Test Wagon.getFileList(String) when the directory does not exist.
 void testWagonGetIfNewerIsNewer()
           
 void testWagonGetIfNewerIsOlder()
           
 void testWagonGetIfNewerIsSame()
           
 void testWagonPutDirectory()
           
 void testWagonPutDirectoryDeepDestination()
          Test for putting a directory with a destination that multiple directories deep, all of which haven't been created.
 void testWagonPutDirectoryForDot()
          Test that when putting a directory that already exists new files get also copied and destination is "."
 void testWagonPutDirectoryWhenDirectoryAlreadyExists()
          Test that when putting a directory that already exists new files get also copied
 void testWagonResourceExists()
          Test for an existing resource.
 void testWagonResourceNotExists()
          Test for an invalid resource.
protected  void verifyMock(org.apache.maven.wagon.WagonTestCase.ProgressArgumentMatcher progressArgumentMatcher, int length)
           
 
Methods inherited from class org.codehaus.plexus.PlexusTestCase
customizeComponentConfiguration, customizeContainerConfiguration, customizeContext, getBasedir, getClassLoader, getConfiguration, getConfiguration, getConfigurationName, getContainer, getCustomConfigurationName, getResourceAsStream, getTestConfiguration, getTestConfiguration, getTestFile, getTestFile, getTestPath, getTestPath, lookup, lookup, lookup, lookup, release, setupContainer, tearDown
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static Logger logger

POM

protected static String POM

localRepository

protected Repository localRepository

testRepository

protected Repository testRepository

localRepositoryPath

protected String localRepositoryPath

sourceFile

protected File sourceFile

destFile

protected File destFile

resource

protected String resource

artifactSourceFile

protected File artifactSourceFile

artifactDestFile

protected File artifactDestFile

checksumObserver

protected ChecksumObserver checksumObserver

mockTransferListener

protected TransferListener mockTransferListener

mockTransferListenerControl

protected org.easymock.MockControl mockTransferListenerControl
Constructor Detail

WagonTestCase

public WagonTestCase()
Method Detail

setUp

protected void setUp()
              throws Exception
Overrides:
setUp in class org.codehaus.plexus.PlexusTestCase
Throws:
Exception

getTestRepositoryUrl

protected abstract String getTestRepositoryUrl()
                                        throws IOException
URL of the repository. For a complete test it should point to a non existing folder so we also check for the creation of new folders in the remote site.

return the URL of the repository as specified by Wagon syntax

Throws:
IOException

getProtocol

protected abstract String getProtocol()
Protocol id of the Wagon to use, eg. scp, ftp

Returns:
the protocol id

getTestRepositoryPort

protected abstract int getTestRepositoryPort()
The number of the port which should get used to start the test server

Returns:
the port number for the test server

setupRepositories

protected void setupRepositories()
                          throws Exception
Throws:
Exception

customizeContext

protected void customizeContext()
                         throws Exception
Throws:
Exception

setupWagonTestingFixtures

protected void setupWagonTestingFixtures()
                                  throws Exception
Throws:
Exception

tearDownWagonTestingFixtures

protected void tearDownWagonTestingFixtures()
                                     throws Exception
Throws:
Exception

getAuthInfo

protected AuthenticationInfo getAuthInfo()

getPermissions

protected RepositoryPermissions getPermissions()

getWagon

protected Wagon getWagon()
                  throws Exception
Throws:
Exception

message

protected void message(String message)

testWagon

public void testWagon()
               throws Exception
Throws:
Exception

testWagonGetIfNewerIsNewer

public void testWagonGetIfNewerIsNewer()
                                throws Exception
Throws:
Exception

supportsGetIfNewer

protected boolean supportsGetIfNewer()

testWagonGetIfNewerIsOlder

public void testWagonGetIfNewerIsOlder()
                                throws Exception
Throws:
Exception

testWagonGetIfNewerIsSame

public void testWagonGetIfNewerIsSame()
                               throws Exception
Throws:
Exception

assertGetIfNewerTest

protected void assertGetIfNewerTest(org.apache.maven.wagon.WagonTestCase.ProgressArgumentMatcher progressArgumentMatcher,
                                    boolean expectedResult,
                                    int expectedSize)
                             throws IOException
Throws:
IOException

setupGetIfNewerTest

protected org.apache.maven.wagon.WagonTestCase.ProgressArgumentMatcher setupGetIfNewerTest(Wagon wagon,
                                                                                           boolean expectedResult,
                                                                                           int expectedSize)
                                                                                    throws NoSuchAlgorithmException,
                                                                                           IOException
Throws:
NoSuchAlgorithmException
IOException

testWagonPutDirectory

public void testWagonPutDirectory()
                           throws Exception
Throws:
Exception

testWagonPutDirectoryDeepDestination

public void testWagonPutDirectoryDeepDestination()
                                          throws Exception
Test for putting a directory with a destination that multiple directories deep, all of which haven't been created.

Throws:
Exception
Since:
1.0-beta-2

testWagonPutDirectoryWhenDirectoryAlreadyExists

public void testWagonPutDirectoryWhenDirectoryAlreadyExists()
                                                     throws Exception
Test that when putting a directory that already exists new files get also copied

Throws:
Exception
Since:
1.0-beta-1

testWagonPutDirectoryForDot

public void testWagonPutDirectoryForDot()
                                 throws Exception
Test that when putting a directory that already exists new files get also copied and destination is "."

Throws:
Exception
Since:
1.0-beta-1

createDirectory

protected void createDirectory(Wagon wagon,
                               String resourceToCreate,
                               String dirName)
                        throws Exception
Create a directory with a resource and check that the other ones don't exist

Parameters:
wagon -
resourceToCreate - name of the resource to be created
dirName - directory name to create
Throws:
Exception

assertResourcesAreInRemoteSide

protected void assertResourcesAreInRemoteSide(Wagon wagon,
                                              List<String> resourceNames)
                                       throws IOException,
                                              TransferFailedException,
                                              ResourceDoesNotExistException,
                                              AuthorizationException
Throws:
IOException
TransferFailedException
ResourceDoesNotExistException
AuthorizationException

assertNotExists

protected void assertNotExists(Wagon wagon,
                               String resourceName)
                        throws IOException,
                               TransferFailedException,
                               AuthorizationException
Assert that a resource does not exist in the remote wagon system

Parameters:
wagon - wagon to get the resource from
resourceName - name of the resource
Throws:
IOException - if a temp file can't be created
AuthorizationException
TransferFailedException
Since:
1.0-beta-1

testFailedGet

public void testFailedGet()
                   throws Exception
Throws:
Exception

testFailedGetIfNewer

public void testFailedGetIfNewer()
                          throws Exception
Throws:
Exception

testWagonGetFileList

public void testWagonGetFileList()
                          throws Exception
Test Wagon.getFileList(String).

Throws:
Exception
Since:
1.0-beta-2

testWagonGetFileListWhenDirectoryDoesNotExist

public void testWagonGetFileListWhenDirectoryDoesNotExist()
                                                   throws Exception
Test Wagon.getFileList(String) when the directory does not exist.

Throws:
Exception
Since:
1.0-beta-2

testWagonResourceExists

public void testWagonResourceExists()
                             throws Exception
Test for an existing resource.

Throws:
Exception
Since:
1.0-beta-2

testWagonResourceNotExists

public void testWagonResourceNotExists()
                                throws Exception
Test for an invalid resource.

Throws:
Exception
Since:
1.0-beta-2

putFile

protected void putFile(String resourceName,
                       String testFileName,
                       String content)
                throws Exception
Throws:
Exception

replayMockForPut

protected org.apache.maven.wagon.WagonTestCase.ProgressArgumentMatcher replayMockForPut(String resourceName,
                                                                                        String content,
                                                                                        Wagon wagon)

createTransferEvent

protected TransferEvent createTransferEvent(Wagon wagon,
                                            Resource resource,
                                            int eventType,
                                            int requestType,
                                            File file)

putFile

protected int putFile()
               throws Exception
Throws:
Exception

getFile

protected void getFile(int expectedSize)
                throws Exception
Throws:
Exception

verifyMock

protected void verifyMock(org.apache.maven.wagon.WagonTestCase.ProgressArgumentMatcher progressArgumentMatcher,
                          int length)

disconnectWagon

protected void disconnectWagon(Wagon wagon)
                        throws ConnectionException
Throws:
ConnectionException

connectWagon

protected void connectWagon(Wagon wagon)
                     throws ConnectionException,
                            AuthenticationException
Throws:
ConnectionException
AuthenticationException

replaceMockForGet

protected org.apache.maven.wagon.WagonTestCase.ProgressArgumentMatcher replaceMockForGet(Wagon wagon,
                                                                                         int expectedSize)

getExpectedContentLengthOnGet

protected int getExpectedContentLengthOnGet(int expectedSize)

getExpectedLastModifiedOnGet

protected long getExpectedLastModifiedOnGet(Repository repository,
                                            Resource resource)

fileRoundTripTesting

protected void fileRoundTripTesting()
                             throws Exception
Throws:
Exception

createFileRepository

protected Repository createFileRepository(String url)


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.