You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/06/06 19:33:03 UTC

git commit: CAMEL-6428: camel-salesforce component. Thanks to Dhiraj Bokde for the contribution.

Updated Branches:
  refs/heads/master c0dd0c599 -> 077eb3ab6


CAMEL-6428: camel-salesforce component. Thanks to Dhiraj Bokde for the contribution.


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

Branch: refs/heads/master
Commit: 077eb3ab6d18cac9152414b642ed3ab27aa78403
Parents: c0dd0c5
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jun 6 19:32:52 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jun 6 19:32:52 2013 +0200

----------------------------------------------------------------------
 .../component/salesforce/LoginConfigHelper.java    |   58 +++++++++------
 .../maven/CamelSalesforceMojoIntegrationTest.java  |   39 ++++++----
 2 files changed, 56 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/077eb3ab/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 365639d..4d10618 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
@@ -16,44 +16,54 @@
  */
 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;
 
-import org.junit.Assert;
-
 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.");
+                + " for a Salesforce account with Merchandise and Invoice objects 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/077eb3ab/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 3a3d8b6..e3af8d3 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
@@ -16,16 +16,13 @@
  */
 package org.apache.camel.maven;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
 import org.apache.maven.plugin.logging.SystemStreamLog;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.io.*;
+import java.util.Properties;
+
 public class CamelSalesforceMojoIntegrationTest {
 
     private static final String TEST_LOGIN_PROPERTIES = "test-salesforce-login.properties";
@@ -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"
-                    + " for a Salesforce account with the Merchandise object from Salesforce Guides.");
+        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, password"
+                    + " for a Salesforce account with Merchandise and Invoice objects 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");
     }
 
 }