Class WGetMojoTest
java.lang.Object
com.googlecode.download.maven.plugin.internal.WGetMojoTest
Unit tests for
WGetMojo- Author:
- Andrzej Jarmoniuk
-
Field Summary
FieldsModifier and TypeFieldDescriptionorg.junit.rules.TemporaryFoldercom.github.tomakehurst.wiremock.junit.WireMockRule -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetUp()voidtearDown()voidThe plugin should always overwrite the output file (even if it has the same content) ifoverwriteistrue.voidPlugin execution should fail if code >= 400 was returned by the resource being downloaded.voidVerifies the cache is not used ifskipCacheistruevoidVerifies that there is no exception thrown should the cache directory not exist if no file is retrievedvoidVerifies the exception message should the cache directory not a directory.voidVerifies that the cache directory should remain empty if the WGetMojo.execute() execution ended abruptly.voidVerifies that a concurrent invocation of two mojos with, the resulting cache index will keep note of both files.voidThe plugin should echo headers given in theheadersparameter to the resource.voidTestingalwaysVerifyChecksumwith an already existing file.voidPlugin should ignore a download failure if instructed to do so.voidThe plugin should always overwrite the output file (even if it has the same content) ifoverwriteistrueandskipCacheistrue.voidThe plugin should follow permanent redirectsvoidThe plugin should pass query parameters in the URL to the resourcevoidVerifies that the same file is read from cache as it was previously been downloaded by another invocation of the mojo.voidPlugin execution should fail only after all retries have been exhausted if a 500+ code was returned by the resource being downloaded.voidPlugin should be able to cache large filesvoidPlugin should follow redirectsvoidPlugin should not repeat if download succeeds.voidPlugin should follow redirectsvoidThe plugin, if provided themd5,sha1,sha256,sha512parameters, should verify if the signature is correct.voidThe plugin should follow temporary redirectsvoidTestingalwaysVerifyChecksumwith an already existing file.voidThe plugin, if provided themd5,sha1,sha256,sha512parameters, should verify if the signature is incorrect.
-
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
- Throws:
Exception
-
tearDown
public void tearDown() -
testCacheDirectoryNotCreated
public void testCacheDirectoryNotCreated() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionVerifies the cache is not used ifskipCacheistrue- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
testCacheInANonExistingDirectory
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
Verifies the exception message should the cache directory not a directory.- Throws:
Exception- should any exception be thrown
-
testCacheNotWrittenToIfFailed
Verifies that the cache directory should remain empty if the WGetMojo.execute() execution ended abruptly. Does so by keepingwagonManagernull. As it's being dereferenced, an NPE is raised.- Throws:
Exception- should any exception be thrown
-
testReadingFromCache
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
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.MojoFailureExceptionThe plugin should echo headers given in theheadersparameter to the resource.- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
testQuery
public void testQuery() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionThe plugin should pass query parameters in the URL to the resource- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
testTemporaryRedirect
public void testTemporaryRedirect() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionThe plugin should follow temporary redirects- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
testPermanentRedirect
public void testPermanentRedirect() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionThe plugin should follow permanent redirects- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
testAlwaysOverwrite
public void testAlwaysOverwrite() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, IOException, InterruptedExceptionThe plugin should always overwrite the output file (even if it has the same content) ifoverwriteistrue.- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionIOExceptionInterruptedException
-
testOverwriteWithSkipCache
public void testOverwriteWithSkipCache() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, IOException, InterruptedExceptionThe plugin should always overwrite the output file (even if it has the same content) ifoverwriteistrueandskipCacheistrue.- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionIOExceptionInterruptedException- See Also:
-
testSignatures
public void testSignatures()The plugin, if provided themd5,sha1,sha256,sha512parameters, should verify if the signature is correct. -
testWrongSignatures
public void testWrongSignatures() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, IOExceptionThe plugin, if provided themd5,sha1,sha256,sha512parameters, should verify if the signature is incorrect.- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionIOException
-
testExistingFileSignatures
public void testExistingFileSignatures()TestingalwaysVerifyChecksumwith an already existing file. The plugin, if provided themd5,sha1,sha256,sha512parameters, should verify if the signature of the existing file is correct. -
testWrongSignatureOfExistingFile
public void testWrongSignatureOfExistingFile()TestingalwaysVerifyChecksumwith an already existing file. The plugin, if provided themd5,sha1,sha256,sha512parameters, 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.MojoFailureExceptionPlugin should ignore a download failure if instructed to do so. It should not repeat the query.- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
testShouldNotRetrySuccessfulDownload
public void testShouldNotRetrySuccessfulDownload() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionPlugin should not repeat if download succeeds.- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
testShouldCacheLargeFiles
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
-