This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 04cd418  NIFI-8312: Support PKCS12 and BCFKS truststores in Atlas 
reporting task
04cd418 is described below

commit 04cd4186189c6b4e458b38f5d96459945c9c0dfe
Author: Peter Turcsanyi <[email protected]>
AuthorDate: Fri Mar 12 19:30:27 2021 +0100

    NIFI-8312: Support PKCS12 and BCFKS truststores in Atlas reporting task
    
    - Generate ssl-client.xml on NiFi side in order to be able to configure 
non-JKS truststores.
    - Close FileOutputStream in tests to prevent error during clean-up.
    - Removed generating Hadoop Credential Store.
    - The credential store is not related to Atlas REST API SSL connection but 
would eliminate a warning from Atlas Kafka client. Removed because it caused 
test failure on Windows due to missing Hadoop native libraries.
    
    This closes #4893
    
    Signed-off-by: David Handermann <[email protected]>
---
 .../nifi-atlas-reporting-task/pom.xml              |   6 +
 .../nifi/atlas/reporting/ReportLineageToAtlas.java |  59 ++++---
 .../atlas/reporting/TestReportLineageToAtlas.java  | 185 +++++++++++++++------
 3 files changed, 178 insertions(+), 72 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/pom.xml 
b/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/pom.xml
index 6ffea8d..f03122a 100644
--- a/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/pom.xml
+++ b/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/pom.xml
@@ -106,5 +106,11 @@
             <artifactId>jetty-servlet</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.xmlunit</groupId>
+            <artifactId>xmlunit-core</artifactId>
+            <version>2.8.2</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
diff --git 
a/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/reporting/ReportLineageToAtlas.java
 
b/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/reporting/ReportLineageToAtlas.java
index 72c7599..fb0a850 100644
--- 
a/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/reporting/ReportLineageToAtlas.java
+++ 
b/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/reporting/ReportLineageToAtlas.java
@@ -24,8 +24,6 @@ import org.apache.atlas.security.SecurityProperties;
 import org.apache.atlas.utils.AtlasPathExtractorUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.security.alias.CredentialProvider;
-import org.apache.hadoop.security.alias.LocalJavaKeyStoreProvider;
 import org.apache.kafka.clients.producer.ProducerConfig;
 import org.apache.kafka.common.config.SslConfigs;
 import org.apache.nifi.annotation.behavior.DynamicProperty;
@@ -71,17 +69,16 @@ import org.apache.nifi.reporting.AbstractReportingTask;
 import org.apache.nifi.reporting.EventAccess;
 import org.apache.nifi.reporting.ReportingContext;
 import org.apache.nifi.reporting.util.provenance.ProvenanceEventConsumer;
-import org.apache.nifi.security.util.KeystoreType;
 import org.apache.nifi.ssl.SSLContextService;
 import org.apache.nifi.util.StringSelector;
 
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
-import java.net.URI;
 import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -368,16 +365,14 @@ public class ReportLineageToAtlas extends 
AbstractReportingTask {
     private static final String ATLAS_PROPERTY_CLUSTER_NAME = 
"atlas.cluster.name";
     private static final String ATLAS_PROPERTY_REST_ADDRESS = 
"atlas.rest.address";
     private static final String ATLAS_PROPERTY_ENABLE_TLS = 
SecurityProperties.TLS_ENABLED;
-    private static final String ATLAS_PROPERTY_TRUSTSTORE_FILE = 
SecurityProperties.TRUSTSTORE_FILE_KEY;
-    private static final String ATLAS_PROPERTY_CRED_STORE_PATH = 
SecurityProperties.CERT_STORES_CREDENTIAL_PROVIDER_PATH;
     private static final String ATLAS_KAFKA_PREFIX = "atlas.kafka.";
     private static final String ATLAS_PROPERTY_KAFKA_BOOTSTRAP_SERVERS = 
ATLAS_KAFKA_PREFIX + "bootstrap.servers";
     private static final String ATLAS_PROPERTY_KAFKA_CLIENT_ID = 
ATLAS_KAFKA_PREFIX + ProducerConfig.CLIENT_ID_CONFIG;
 
-    private static final String CRED_STORE_FILENAME = "atlas.jceks";
     private static final String SSL_CLIENT_XML_FILENAME = 
SecurityProperties.SSL_CLIENT_PROPERTIES;
-
-    private static final String TRUSTSTORE_PASSWORD_ALIAS = 
"ssl.client.truststore.password";
+    private static final String SSL_CLIENT_XML_TRUSTSTORE_LOCATION = 
"ssl.client.truststore.location";
+    private static final String SSL_CLIENT_XML_TRUSTSTORE_PASSWORD = 
"ssl.client.truststore.password";
+    private static final String SSL_CLIENT_XML_TRUSTSTORE_TYPE = 
"ssl.client.truststore.type";
 
     private final ServiceLoader<NamespaceResolver> namespaceResolverLoader = 
ServiceLoader.load(NamespaceResolver.class);
     private volatile AtlasAuthN atlasAuthN;
@@ -704,11 +699,7 @@ public class ReportLineageToAtlas extends 
AbstractReportingTask {
         boolean isAtlasApiSecure = urls.stream().anyMatch(url -> 
url.toLowerCase().startsWith("https"));
         atlasProperties.put(ATLAS_PROPERTY_ENABLE_TLS, 
String.valueOf(isAtlasApiSecure));
 
-        // ssl-client.xml must be deleted, Atlas will not regenerate it 
otherwise
-        Path credStorePath = new File(confDir, CRED_STORE_FILENAME).toPath();
-        Files.deleteIfExists(credStorePath);
-        Path sslClientXmlPath = new File(confDir, 
SSL_CLIENT_XML_FILENAME).toPath();
-        Files.deleteIfExists(sslClientXmlPath);
+        deleteSslClientXml(confDir);
 
         if (isAtlasApiSecure) {
             SSLContextService sslContextService = 
context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
@@ -716,21 +707,39 @@ public class ReportLineageToAtlas extends 
AbstractReportingTask {
                 getLogger().warn("No SSLContextService configured, the system 
default truststore will be used.");
             } else if (!sslContextService.isTrustStoreConfigured()) {
                 getLogger().warn("No truststore configured on 
SSLContextService, the system default truststore will be used.");
-            } else if 
(!KeystoreType.JKS.getType().equalsIgnoreCase(sslContextService.getTrustStoreType()))
 {
-                getLogger().warn("The configured truststore type is not 
supported by Atlas (not JKS), the system default truststore will be used.");
             } else {
-                atlasProperties.put(ATLAS_PROPERTY_TRUSTSTORE_FILE, 
sslContextService.getTrustStoreFile());
+                // create ssl-client.xml config file for Hadoop Security used 
by Atlas REST client,
+                // Atlas would generate this file with hardcoded JKS keystore 
type,
+                // in order to support other keystore types, we generate it 
ourselves
+                createSslClientXml(confDir, sslContextService);
+            }
+        }
+    }
+
+    private void deleteSslClientXml(File confDir) throws Exception {
+        Path sslClientXmlPath = new File(confDir, 
SSL_CLIENT_XML_FILENAME).toPath();
+        try {
+            Files.deleteIfExists(sslClientXmlPath);
+        } catch (Exception e) {
+            getLogger().error("Unable to delete SSL Client Configuration File 
{}", sslClientXmlPath, e);
+            throw e;
+        }
+    }
 
-                String password = sslContextService.getTrustStorePassword();
-                // Hadoop Credential Provider JCEKS URI format: 
localjceks://file/PATH/TO/JCEKS
-                String credStoreUri = 
credStorePath.toUri().toString().replaceFirst("^file://", "localjceks://file");
+    private void createSslClientXml(File confDir, SSLContextService 
sslContextService) throws Exception {
+        File sslClientXmlFile = new File(confDir, SSL_CLIENT_XML_FILENAME);
 
-                CredentialProvider credentialProvider = new 
LocalJavaKeyStoreProvider.Factory().createProvider(new URI(credStoreUri), new 
Configuration());
-                
credentialProvider.createCredentialEntry(TRUSTSTORE_PASSWORD_ALIAS, 
password.toCharArray());
-                credentialProvider.flush();
+        Configuration configuration = new Configuration(false);
 
-                atlasProperties.put(ATLAS_PROPERTY_CRED_STORE_PATH, 
credStoreUri);
-            }
+        configuration.set(SSL_CLIENT_XML_TRUSTSTORE_LOCATION, 
sslContextService.getTrustStoreFile());
+        configuration.set(SSL_CLIENT_XML_TRUSTSTORE_PASSWORD, 
sslContextService.getTrustStorePassword());
+        configuration.set(SSL_CLIENT_XML_TRUSTSTORE_TYPE, 
sslContextService.getTrustStoreType());
+
+        try (FileWriter fileWriter = new FileWriter(sslClientXmlFile)) {
+            configuration.writeXml(fileWriter);
+        } catch (Exception e) {
+            getLogger().error("Unable to create SSL Client Configuration File 
{}", sslClientXmlFile, e);
+            throw e;
         }
     }
 
diff --git 
a/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/test/java/org/apache/nifi/atlas/reporting/TestReportLineageToAtlas.java
 
b/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/test/java/org/apache/nifi/atlas/reporting/TestReportLineageToAtlas.java
index da39acc..507660a 100644
--- 
a/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/test/java/org/apache/nifi/atlas/reporting/TestReportLineageToAtlas.java
+++ 
b/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/test/java/org/apache/nifi/atlas/reporting/TestReportLineageToAtlas.java
@@ -25,18 +25,26 @@ import org.apache.nifi.atlas.NiFiAtlasClient;
 import org.apache.nifi.components.PropertyDescriptor;
 import org.apache.nifi.components.ValidationResult;
 import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.controller.ControllerServiceLookup;
 import org.apache.nifi.processor.exception.ProcessException;
 import org.apache.nifi.reporting.ReportingContext;
 import org.apache.nifi.reporting.ReportingInitializationContext;
+import org.apache.nifi.ssl.SSLContextService;
 import org.apache.nifi.util.MockComponentLog;
 import org.apache.nifi.util.MockConfigurationContext;
+import org.apache.nifi.util.MockControllerServiceLookup;
 import org.apache.nifi.util.MockProcessContext;
 import org.apache.nifi.util.MockPropertyValue;
 import org.apache.nifi.util.MockValidationContext;
+import org.apache.nifi.util.file.FileUtils;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.w3c.dom.Node;
+import org.xmlunit.builder.Input;
+import org.xmlunit.xpath.JAXPXPathEngine;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -50,6 +58,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
+import java.util.UUID;
 import java.util.function.BiConsumer;
 import java.util.function.Consumer;
 
@@ -63,6 +72,7 @@ import static 
org.apache.nifi.atlas.reporting.ReportLineageToAtlas.ATLAS_READ_TI
 import static org.apache.nifi.atlas.reporting.ReportLineageToAtlas.ATLAS_URLS;
 import static org.apache.nifi.atlas.reporting.ReportLineageToAtlas.ATLAS_USER;
 import static 
org.apache.nifi.atlas.reporting.ReportLineageToAtlas.KAFKA_BOOTSTRAP_SERVERS;
+import static 
org.apache.nifi.atlas.reporting.ReportLineageToAtlas.SSL_CONTEXT_SERVICE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -75,10 +85,13 @@ public class TestReportLineageToAtlas {
 
     private final Logger logger = 
LoggerFactory.getLogger(TestReportLineageToAtlas.class);
 
+    private static final String ATLAS_CONF_DIR_BASE = "target/atlasConfDir-";
+
     private ReportLineageToAtlas testSubject;
     private MockComponentLog componentLogger;
     private ReportingInitializationContext initializationContext;
     private ReportingContext reportingContext;
+    private String atlasConfDir;
 
     @Before
     public void setUp() throws Exception {
@@ -87,6 +100,25 @@ public class TestReportLineageToAtlas {
 
         initializationContext = mock(ReportingInitializationContext.class);
         when(initializationContext.getLogger()).thenReturn(componentLogger);
+
+        atlasConfDir = createAtlasConfDir();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        cleanUpAtlasConfDir();
+    }
+
+    private String createAtlasConfDir() throws IOException {
+        String atlasConfDir = ATLAS_CONF_DIR_BASE + UUID.randomUUID();
+        FileUtils.ensureDirectoryExistAndCanAccess(new File(atlasConfDir));
+        return atlasConfDir;
+    }
+
+    private void cleanUpAtlasConfDir() throws IOException {
+        if (atlasConfDir != null) {
+            FileUtils.deleteFile(new File(atlasConfDir), true);
+        }
     }
 
     @Test
@@ -204,13 +236,7 @@ public class TestReportLineageToAtlas {
         };
 
         Runnable assertion = () -> {
-            Properties atlasProperties = new Properties();
-            final File atlasPropertiesFile = new File("target/atlasConfDir", 
"atlas-application.properties");
-            try (InputStream in = new FileInputStream(atlasPropertiesFile)) {
-                atlasProperties.load(in);
-            } catch (Exception e) {
-                throw new AssertionError(e);
-            }
+            Properties atlasProperties = loadGeneratedAtlasProperties();
 
             assertEquals(atlasUrls, 
atlasProperties.getProperty("atlas.rest.address"));
         };
@@ -241,13 +267,7 @@ public class TestReportLineageToAtlas {
         };
 
         Runnable assertion = () -> {
-            Properties atlasProperties = new Properties();
-            final File atlasPropertiesFile = new File("target/atlasConfDir", 
"atlas-application.properties");
-            try (InputStream in = new FileInputStream(atlasPropertiesFile)) {
-                atlasProperties.load(in);
-            } catch (Exception e) {
-                throw new AssertionError(e);
-            }
+            Properties atlasProperties = loadGeneratedAtlasProperties();
 
             assertEquals(atlasMetadataNamespace, 
atlasProperties.getProperty("atlas.metadata.namespace"));
         };
@@ -265,24 +285,112 @@ public class TestReportLineageToAtlas {
         );
     }
 
+    @Test
+    public void testAtlasSSLConfig() throws Exception {
+        // GIVEN
+        String atlasUrls = "https://atlasUrl1";;
+
+        String sslContextServiceId = "ssl-context-service";
+        String truststoreLocation = "truststore-location";
+        String truststorePassword = "truststore-password";
+        String truststoreType = "truststore-type";
+
+        Properties atlasConf = new Properties();
+
+        Consumer<Map<PropertyDescriptor, String>> propertiesAdjustment = 
properties -> {
+            properties.put(ATLAS_CONF_CREATE, "true");
+            properties.put(ATLAS_URLS, atlasUrls);
+            properties.put(SSL_CONTEXT_SERVICE, sslContextServiceId);
+        };
+
+        SSLContextService sslContextService = 
mockSSLContextServiceWithTruststore(sslContextServiceId, truststoreLocation, 
truststorePassword, truststoreType);
+        MockControllerServiceLookup controllerServiceLookup = new 
MockControllerServiceLookup() {};
+        controllerServiceLookup.addControllerService(sslContextService);
+
+        Runnable assertion = () -> {
+            Properties atlasProperties = loadGeneratedAtlasProperties();
+
+            assertEquals("true", 
atlasProperties.getProperty("atlas.enableTLS"));
+
+            assertGeneratedSslClientXml(truststoreLocation, 
truststorePassword, truststoreType);
+        };
+
+        // WHEN
+        // THEN
+        testSetup(
+                atlasConf,
+                propertiesAdjustment,
+                controllerServiceLookup,
+                assertion,
+                e -> {
+                    throw new AssertionError(e);
+                }
+        );
+    }
+
+    private SSLContextService mockSSLContextServiceWithTruststore(String 
sslContextServiceId, String truststoreLocation, String truststorePassword, 
String truststoreType) {
+        SSLContextService sslContextService = mock(SSLContextService.class);
+
+        
when(sslContextService.getIdentifier()).thenReturn(sslContextServiceId);
+        
when(sslContextService.getTrustStoreFile()).thenReturn(truststoreLocation);
+        
when(sslContextService.getTrustStorePassword()).thenReturn(truststorePassword);
+        when(sslContextService.getTrustStoreType()).thenReturn(truststoreType);
+        when(sslContextService.isTrustStoreConfigured()).thenReturn(true);
+
+        return sslContextService;
+    }
+
+    private void assertGeneratedSslClientXml(String truststoreLocation, String 
truststorePassword, String truststoreType) {
+        File sslClientXmlFile = new File(atlasConfDir, "ssl-client.xml");
+        assertTrue(sslClientXmlFile.exists());
+        assertTrue(sslClientXmlFile.isFile());
+
+        Map<String, String> sslClientXmlProperties = new HashMap<>();
+        JAXPXPathEngine xPathEngine = new JAXPXPathEngine();
+        Iterable<Node> propertyNodes = 
xPathEngine.selectNodes("/configuration/property", 
Input.fromFile(sslClientXmlFile).build());
+        for (Node propertyNode: propertyNodes) {
+            String propertyName = xPathEngine.evaluate("name", propertyNode);
+            String propertyValue = xPathEngine.evaluate("value", propertyNode);
+            sslClientXmlProperties.put(propertyName, propertyValue);
+        }
+
+        assertEquals(truststoreLocation, 
sslClientXmlProperties.get("ssl.client.truststore.location"));
+        assertEquals(truststorePassword, 
sslClientXmlProperties.get("ssl.client.truststore.password"));
+        assertEquals(truststoreType, 
sslClientXmlProperties.get("ssl.client.truststore.type"));
+    }
+
+    private Properties loadGeneratedAtlasProperties() {
+        Properties atlasProperties = new Properties();
+        File atlasPropertiesFile = new File(atlasConfDir, 
"atlas-application.properties");
+        try (InputStream in = new FileInputStream(atlasPropertiesFile)) {
+            atlasProperties.load(in);
+        } catch (Exception e) {
+            throw new AssertionError(e);
+        }
+        return atlasProperties;
+    }
+
+    private void testSetup(
+            Properties atlasConf,
+            Consumer<Map<PropertyDescriptor, String>> propertiesAdjustment,
+            Runnable onSuccess, Consumer<Exception> onError
+    ) throws Exception {
+        testSetup(atlasConf, propertiesAdjustment, null, onSuccess, onError);
+    }
+
     private void testSetup(
         Properties atlasConf,
         Consumer<Map<PropertyDescriptor, String>> propertiesAdjustment,
-        Runnable onSuccess, Consumer<Exception> exceptionConsumer
+        ControllerServiceLookup controllerServiceLookup,
+        Runnable onSuccess, Consumer<Exception> onError
     ) throws Exception {
         // GIVEN
-        String atlasConfDir = createAtlasConfDir();
-
         Map<PropertyDescriptor, String> properties = 
initReportingTaskProperties(atlasConfDir);
         propertiesAdjustment.accept(properties);
 
-        saveAtlasConf(atlasConfDir, atlasConf);
+        saveAtlasConf(atlasConf);
 
-        reportingContext = mock(ReportingContext.class);
-        when(reportingContext.getProperties()).thenReturn(properties);
-        when(reportingContext.getProperty(any())).then(invocation -> new 
MockPropertyValue(properties.get(invocation.getArguments()[0])));
-
-        ConfigurationContext configurationContext = new 
MockConfigurationContext(properties, null);
+        ConfigurationContext configurationContext = new 
MockConfigurationContext(properties, controllerServiceLookup);
 
         testSubject.initialize(initializationContext);
 
@@ -293,15 +401,14 @@ public class TestReportLineageToAtlas {
 
             // THEN
         } catch (Exception e) {
-            exceptionConsumer.accept(e);
+            onError.accept(e);
         }
     }
 
+
     @Test
     public void testDefaultConnectAndReadTimeout() throws Exception {
         // GIVEN
-        String atlasConfDir = createAtlasConfDir();
-
         Map<PropertyDescriptor, String> properties = 
initReportingTaskProperties(atlasConfDir);
 
         // WHEN
@@ -315,8 +422,6 @@ public class TestReportLineageToAtlas {
         int expectedConnectTimeoutMs = 10000;
         int expectedReadTimeoutMs = 5000;
 
-        String atlasConfDir = createAtlasConfDir();
-
         Map<PropertyDescriptor, String> properties = 
initReportingTaskProperties(atlasConfDir);
         properties.put(ATLAS_CONNECT_TIMEOUT, (expectedConnectTimeoutMs / 
1000) + " sec");
         properties.put(ATLAS_READ_TIMEOUT, (expectedReadTimeoutMs / 1000) + " 
sec");
@@ -363,8 +468,6 @@ public class TestReportLineageToAtlas {
 
     @Test
     public void testNotificationSendingIsSynchronousWhenAtlasConfIsGenerated() 
throws Exception {
-        String atlasConfDir = createAtlasConfDir();
-
         Map<PropertyDescriptor, String> properties = 
initReportingTaskProperties(atlasConfDir);
 
         testNotificationSendingIsSynchronous(properties);
@@ -372,11 +475,9 @@ public class TestReportLineageToAtlas {
 
     @Test
     public void 
testNotificationSendingIsSynchronousWhenAtlasConfIsProvidedAndSynchronousModeHasBeenSet()
 throws Exception {
-        String atlasConfDir = createAtlasConfDir();
-
         Properties atlasConf = new Properties();
         atlasConf.setProperty(AtlasHook.ATLAS_NOTIFICATION_ASYNCHRONOUS, 
"false");
-        saveAtlasConf(atlasConfDir, atlasConf);
+        saveAtlasConf(atlasConf);
 
         Map<PropertyDescriptor, String> properties = 
initReportingTaskProperties(atlasConfDir);
         properties.put(ATLAS_CONF_CREATE, "false");
@@ -397,10 +498,8 @@ public class TestReportLineageToAtlas {
 
     @Test(expected = ProcessException.class)
     public void 
testThrowExceptionWhenAtlasConfIsProvidedButSynchronousModeHasNotBeenSet() 
throws Exception {
-        String atlasConfDir = createAtlasConfDir();
-
         Properties atlasConf = new Properties();
-        saveAtlasConf(atlasConfDir, atlasConf);
+        saveAtlasConf(atlasConf);
 
         Map<PropertyDescriptor, String> properties = 
initReportingTaskProperties(atlasConfDir);
         properties.put(ATLAS_CONF_CREATE, "false");
@@ -411,18 +510,10 @@ public class TestReportLineageToAtlas {
         testSubject.setup(configurationContext);
     }
 
-    private String createAtlasConfDir() {
-        String atlasConfDir = "target/atlasConfDir";
-        File directory = new File(atlasConfDir);
-        if (!directory.exists()) {
-            directory.mkdirs();
+    private void saveAtlasConf(Properties atlasConf) throws IOException {
+        try (FileOutputStream fos = new FileOutputStream(atlasConfDir + 
File.separator + ApplicationProperties.APPLICATION_PROPERTIES)) {
+            atlasConf.store(fos, "Atlas test config");
         }
-        return atlasConfDir;
-    }
-
-    private void saveAtlasConf(String atlasConfDir, Properties atlasConf) 
throws IOException {
-        FileOutputStream fos = new FileOutputStream(atlasConfDir + 
File.separator + ApplicationProperties.APPLICATION_PROPERTIES);
-        atlasConf.store(fos, "Atlas test config");
     }
 
     private Map<PropertyDescriptor, String> initReportingTaskProperties(String 
atlasConfDir) {

Reply via email to