camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhira...@apache.org
Subject [10/23] camel git commit: Fixed test-salesforce-login.properties check
Date Mon, 06 Apr 2015 20:38:02 GMT
Fixed test-salesforce-login.properties check


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ec0e3a73
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ec0e3a73
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ec0e3a73

Branch: refs/heads/trunk
Commit: ec0e3a736c6660aee5123cdbe99a7581ead7dec6
Parents: 8a39820
Author: Dhiraj Bokde <dbokde@fusesource.com>
Authored: Wed Jun 5 14:38:25 2013 -0700
Committer: Dhiraj Bokde <dbokde@fusesource.com>
Committed: Wed Jun 5 14:38:25 2013 -0700

----------------------------------------------------------------------
 .../component/salesforce/LoginConfigHelper.java | 52 ++++++++++++--------
 .../CamelSalesforceMojoIntegrationTest.java     | 33 +++++++------
 2 files changed, 50 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ec0e3a73/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/LoginConfigHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/LoginConfigHelper.java
b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/LoginConfigHelper.java
index 1f8b480..e3c07a9 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/LoginConfigHelper.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/LoginConfigHelper.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.salesforce;
 import org.junit.Assert;
 
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
@@ -27,33 +28,42 @@ public class LoginConfigHelper extends Assert {
 
     private static final String TEST_LOGIN_PROPERTIES = "test-salesforce-login.properties";
 
-    public static SalesforceLoginConfig getLoginConfig() throws IllegalAccessException, IOException
{
+    public static SalesforceLoginConfig getLoginConfig() throws IOException {
 
         // load test-salesforce-login properties
         Properties properties = new Properties();
-        InputStream stream = new FileInputStream(TEST_LOGIN_PROPERTIES);
-        if (null == stream) {
-            throw new IllegalArgumentException("Create a properties file named " +
+        InputStream stream = null;
+        try {
+            stream = new FileInputStream(TEST_LOGIN_PROPERTIES);
+            properties.load(stream);
+
+            final SalesforceLoginConfig config = new SalesforceLoginConfig(
+                properties.getProperty("loginUrl", SalesforceLoginConfig.DEFAULT_LOGIN_URL),
+                properties.getProperty("clientId"),
+                properties.getProperty("clientSecret"),
+                properties.getProperty("userName"),
+                properties.getProperty("password"),
+                Boolean.parseBoolean(properties.getProperty("lazyLogin", "false")));
+
+            assertNotNull("Null loginUrl", config.getLoginUrl());
+            assertNotNull("Null clientId", config.getClientId());
+            assertNotNull("Null clientSecret", config.getClientSecret());
+            assertNotNull("Null userName", config.getUserName());
+            assertNotNull("Null password", config.getPassword());
+
+            return config;
+
+        } catch (FileNotFoundException e) {
+            throw new FileNotFoundException("Create a properties file named " +
                 TEST_LOGIN_PROPERTIES + " with clientId, clientSecret, userName, and password"
+
                 " for a Salesforce account with the Merchandise object from Salesforce Guides.");
+        } finally {
+            if (stream != null) {
+                try {
+                    stream.close();
+                } catch (IOException ignore) {}
+            }
         }
-        properties.load(stream);
-
-        final SalesforceLoginConfig config = new SalesforceLoginConfig(
-            properties.getProperty("loginUrl", SalesforceLoginConfig.DEFAULT_LOGIN_URL),
-            properties.getProperty("clientId"),
-            properties.getProperty("clientSecret"),
-            properties.getProperty("userName"),
-            properties.getProperty("password"),
-            Boolean.parseBoolean(properties.getProperty("lazyLogin", "false")));
-
-        assertNotNull("Null loginUrl", config.getLoginUrl());
-        assertNotNull("Null clientId", config.getClientId());
-        assertNotNull("Null clientSecret", config.getClientSecret());
-        assertNotNull("Null userName", config.getUserName());
-        assertNotNull("Null password", config.getPassword());
-
-        return config;
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/ec0e3a73/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoIntegrationTest.java
b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoIntegrationTest.java
index 781c592..b580436 100644
--- a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoIntegrationTest.java
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoIntegrationTest.java
@@ -20,10 +20,7 @@ import org.apache.maven.plugin.logging.SystemStreamLog;
 import org.junit.Assert;
 import org.junit.Test;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.util.Properties;
 
 public class CamelSalesforceMojoIntegrationTest {
@@ -66,20 +63,28 @@ public class CamelSalesforceMojoIntegrationTest {
         // TODO check that the generated code compiles
     }
 
-    private void setLoginProperties(CamelSalesforceMojo mojo) throws IllegalAccessException,
IOException {
+    private void setLoginProperties(CamelSalesforceMojo mojo) throws IOException {
         // load test-salesforce-login properties
         Properties properties = new Properties();
-        InputStream stream = new FileInputStream(TEST_LOGIN_PROPERTIES);
-        if (null == stream) {
-            throw new IllegalAccessException("Create a properties file named " +
-                TEST_LOGIN_PROPERTIES + " with clientId, clientSecret, userName, password
and a testId" +
+        InputStream stream = null;
+        try {
+            stream = new FileInputStream(TEST_LOGIN_PROPERTIES);
+            properties.load(stream);
+            mojo.clientId= properties.getProperty("clientId");
+            mojo.clientSecret= properties.getProperty("clientSecret");
+            mojo.userName= properties.getProperty("userName");
+            mojo.password= properties.getProperty("password");
+        } catch (FileNotFoundException e) {
+            throw new FileNotFoundException("Create a properties file named " +
+                TEST_LOGIN_PROPERTIES + " with clientId, clientSecret, userName, and password"
+
                 " for a Salesforce account with the Merchandise object from Salesforce Guides.");
+        } finally {
+            if (stream != null) {
+                try {
+                    stream.close();
+                } catch (IOException ignore) {}
+            }
         }
-        properties.load(stream);
-        mojo.clientId= properties.getProperty("clientId");
-        mojo.clientSecret= properties.getProperty("clientSecret");
-        mojo.userName= properties.getProperty("userName");
-        mojo.password= properties.getProperty("password");
     }
 
 }


Mime
View raw message