SQOOP-3399: TestS3ImportWithHadoopCredProvider fails if credential generator command...
authorSzabolcs Vasas <vasas@apache.org>
Thu, 25 Oct 2018 06:40:00 +0000 (08:40 +0200)
committerSzabolcs Vasas <vasas@apache.org>
Thu, 25 Oct 2018 06:40:00 +0000 (08:40 +0200)
(Szabolcs Vasas)

src/test/org/apache/sqoop/s3/TestS3ImportWithHadoopCredProvider.java

index e03eb64..3a0d636 100644 (file)
@@ -78,11 +78,11 @@ public class TestS3ImportWithHadoopCredProvider extends ImportJobTestCase {
         String generatorCommand = S3TestUtils.getGeneratorCommand();
         if (generatorCommand != null) {
             s3CredentialGenerator = new DefaultS3CredentialGenerator(generatorCommand);
+            generateTempProviderFileNames();
+            fillCredentialProviderDefault();
+            fillCredentialProviderPwdFile();
+            fillCredentialProviderEnv();
         }
-        generateTempProviderFileNames();
-        fillCredentialProviderDefault();
-        fillCredentialProviderPwdFile();
-        fillCredentialProviderEnv();
     }
 
     @Before
@@ -102,9 +102,9 @@ public class TestS3ImportWithHadoopCredProvider extends ImportJobTestCase {
 
     @AfterClass
     public static void deleteTemporaryCredFiles() {
-        providerFileDefault.deleteOnExit();
-        providerFileEnvPwd.deleteOnExit();
-        providerFilePwdFile.deleteOnExit();
+        deleteFileOnExit(providerFileDefault);
+        deleteFileOnExit(providerFileEnvPwd);
+        deleteFileOnExit(providerFilePwdFile);
     }
 
     @Test
@@ -210,4 +210,10 @@ public class TestS3ImportWithHadoopCredProvider extends ImportJobTestCase {
     private static void setHadoopCredStorePwdEnvVar() {
         environmentVariables.set(HADOOP_CREDSTORE_PASSWORD_ENV_NAME, "credProviderPwd");
     }
+
+    private static void deleteFileOnExit(File file) {
+        if (file != null) {
+            file.deleteOnExit();
+        }
+    }
 }