Class WGetMojoTest

java.lang.Object
com.googlecode.download.maven.plugin.internal.WGetMojoTest

public class WGetMojoTest extends Object
Unit tests for WGetMojo
Author:
Andrzej Jarmoniuk
  • Field Details

    • wireMock

      public com.github.tomakehurst.wiremock.junit.WireMockRule wireMock
    • temporaryFolder

      public org.junit.rules.TemporaryFolder temporaryFolder
  • Constructor Details

    • WGetMojoTest

      public WGetMojoTest()
  • Method Details

    • setUp

      public void setUp() throws Exception
      Throws:
      Exception
    • tearDown

      public void tearDown()
    • testCacheDirectoryNotCreated

      public void testCacheDirectoryNotCreated() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Verifies the cache is not used if skipCache is true
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • testCacheInANonExistingDirectory

      public void testCacheInANonExistingDirectory() throws Exception
      Verifies that there is no exception thrown should the cache directory not exist if no file is retrieved
      Throws:
      Exception - should any exception be thrown
    • testCacheInNotADirectory

      public void testCacheInNotADirectory() throws Exception
      Verifies the exception message should the cache directory not a directory.
      Throws:
      Exception - should any exception be thrown
    • testCacheNotWrittenToIfFailed

      public void testCacheNotWrittenToIfFailed() throws Exception
      Verifies that the cache directory should remain empty if the WGetMojo.execute() execution ended abruptly. Does so by keeping wagonManager null. As it's being dereferenced, an NPE is raised.
      Throws:
      Exception - should any exception be thrown
    • testReadingFromCache

      public void testReadingFromCache() throws Exception
      Verifies that the same file is read from cache as it was previously been downloaded by another invocation of the mojo.
      Throws:
      Exception - should any exception be thrown
    • testCacheRetainingValuesFromTwoConcurrentCalls

      public void testCacheRetainingValuesFromTwoConcurrentCalls() throws Exception
      Verifies that a concurrent invocation of two mojos with, the resulting cache index will keep note of both files. One of the processes starts first, then gets held up while another process downloads another file. Once the second process finishes, the first process saves its file as well. The test verifies that both files are present in the cache index. Finally, the test also verifies that the content of the cached files matches the "downloaded" content.
      Throws:
      Exception - should any exception be thrown
    • testCustomHeaders

      public void testCustomHeaders() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      The plugin should echo headers given in the headers parameter to the resource.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • testQuery

      public void testQuery() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      The plugin should pass query parameters in the URL to the resource
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • testTemporaryRedirect

      public void testTemporaryRedirect() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      The plugin should follow temporary redirects
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • testPermanentRedirect

      public void testPermanentRedirect() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      The plugin should follow permanent redirects
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • testAlwaysOverwrite

      public void testAlwaysOverwrite() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, IOException, InterruptedException
      The plugin should always overwrite the output file (even if it has the same content) if overwrite is true.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
      IOException
      InterruptedException
    • testOverwriteWithSkipCache

      public void testOverwriteWithSkipCache() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, IOException, InterruptedException
      The plugin should always overwrite the output file (even if it has the same content) if overwrite is true and skipCache is true.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
      IOException
      InterruptedException
      See Also:
    • testSignatures

      public void testSignatures()
      The plugin, if provided the md5, sha1, sha256, sha512 parameters, should verify if the signature is correct.
    • testWrongSignatures

      public void testWrongSignatures() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, IOException
      The plugin, if provided the md5, sha1, sha256, sha512 parameters, should verify if the signature is incorrect.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
      IOException
    • testExistingFileSignatures

      public void testExistingFileSignatures()
      Testing alwaysVerifyChecksum with an already existing file. The plugin, if provided the md5, sha1, sha256, sha512 parameters, should verify if the signature of the existing file is correct.
    • testWrongSignatureOfExistingFile

      public void testWrongSignatureOfExistingFile()
      Testing alwaysVerifyChecksum with an already existing file. The plugin, if provided the md5, sha1, sha256, sha512 parameters, should log a warning message if the signature of the existing file is incorrect.
    • testBuildShouldFailIfDownloadFails

      public void testBuildShouldFailIfDownloadFails()
      Plugin execution should fail if code >= 400 was returned by the resource being downloaded. It should not repeat the query.
    • testRetriedAfterDownloadFailsWithCode500

      public void testRetriedAfterDownloadFailsWithCode500()
      Plugin execution should fail only after all retries have been exhausted if a 500+ code was returned by the resource being downloaded. It should repeat the query exactly 3 times.
    • testIgnoreDownloadFailure

      public void testIgnoreDownloadFailure() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Plugin should ignore a download failure if instructed to do so. It should not repeat the query.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • testShouldNotRetrySuccessfulDownload

      public void testShouldNotRetrySuccessfulDownload() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Plugin should not repeat if download succeeds.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • testShouldCacheLargeFiles

      public void testShouldCacheLargeFiles() throws Exception
      Plugin should be able to cache large files
      Throws:
      Exception
    • testShouldFollowRedirects

      public void testShouldFollowRedirects()
      Plugin should follow redirects
    • testShouldWarnOnRedirectsIfDisabled

      public void testShouldWarnOnRedirectsIfDisabled()
      Plugin should follow redirects