Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 65DF117AE8 for ; Mon, 6 Apr 2015 20:37:54 +0000 (UTC) Received: (qmail 3059 invoked by uid 500); 6 Apr 2015 20:37:54 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 2926 invoked by uid 500); 6 Apr 2015 20:37:54 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 2493 invoked by uid 99); 6 Apr 2015 20:37:54 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Apr 2015 20:37:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 96F69E1868; Mon, 6 Apr 2015 20:37:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dhirajsb@apache.org To: commits@camel.apache.org Date: Mon, 06 Apr 2015 20:38:02 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [10/23] camel git commit: Fixed test-salesforce-login.properties check 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 Authored: Wed Jun 5 14:38:25 2013 -0700 Committer: Dhiraj Bokde 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"); } }