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 2015/07/08 08:33:13 UTC

[1/5] camel git commit: Added set of fromEndpoint in producing exchanges to prevent a NPE using the component through camel uri binding in switchyard

Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x f9245e2f5 -> ad675c18c
  refs/heads/camel-2.15.x 9efa1cb85 -> 501d5c556
  refs/heads/master 42b542a7e -> b9bcff279


Added set of fromEndpoint in producing exchanges to prevent a NPE using the component through camel uri binding in switchyard


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

Branch: refs/heads/master
Commit: 2ddca935c9bebf5e29ddde53683eec08879b6f18
Parents: 75b813a
Author: Andrea Tarocchi <at...@redhat.com>
Authored: Wed Jul 8 00:15:54 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jul 8 08:33:20 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/jt400/Jt400DataQueueConsumer.java   | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2ddca935/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
index 2bdc7d4..825af3c 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
@@ -108,6 +108,7 @@ public class Jt400DataQueueConsumer extends PollingConsumerSupport {
         }
 
         Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
+        exchange.setFromEndpoint(endpoint);
         if (entry != null) {
             exchange.getIn().setHeader(Jt400Endpoint.SENDER_INFORMATION, entry.getSenderInformation());
             if (endpoint.getFormat() == Jt400Configuration.Format.binary) {
@@ -134,6 +135,7 @@ public class Jt400DataQueueConsumer extends PollingConsumerSupport {
         }
 
         Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
+        exchange.setFromEndpoint(endpoint);
         if (entry != null) {
             exchange.getIn().setHeader(Jt400Endpoint.SENDER_INFORMATION, entry.getSenderInformation());
             if (endpoint.getFormat() == Jt400Configuration.Format.binary) {


[3/5] camel git commit: Fixed CS

Posted by da...@apache.org.
Fixed CS


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

Branch: refs/heads/master
Commit: b9bcff2794133776cbdfedc06108208a112d7cd7
Parents: 2ddca93
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Jul 8 08:38:17 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jul 8 08:38:17 2015 +0200

----------------------------------------------------------------------
 .../component/jt400/Jt400Configuration.java     | 36 ++++----------------
 .../component/jt400/Jt400ComponentTest.java     |  4 +--
 .../component/jt400/Jt400ConfigurationTest.java |  2 +-
 .../jt400/MockAS400SecureConnectionPool.java    |  5 ++-
 4 files changed, 11 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b9bcff27/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Configuration.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Configuration.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Configuration.java
index 631beb9..b33a25d 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Configuration.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Configuration.java
@@ -46,6 +46,7 @@ public class Jt400Configuration {
      * Enumeration of supported data formats
      */
     public enum Format {
+
         /**
          * Using <code>String</code> for transferring data
          */
@@ -68,54 +69,29 @@ public class Jt400Configuration {
      */
     private static final int DEFAULT_SYSTEM_CCSID = -1;
 
-    /**
-     * Pool from which physical connections to the system are obtained.
-     */
     private final AS400ConnectionPool connectionPool;
 
-    /**
-     * ID of the AS/400 user.
-     */
     @UriPath @Metadata(required = "true")
     private String userID;
 
-    /**
-     * Password of the AS/400 user.
-     */
     @UriPath @Metadata(required = "true")
     private String password;
 
-    /**
-     * Name of the AS/400 system.
-     */
     @UriPath @Metadata(required = "true")
     private String systemName;
 
-    /**
-     * Fully qualified integrated file system path name of the target object of
-     * this endpoint (either data queue or program).
-     */
     @UriPath @Metadata(required = "true")
     private String objectPath;
 
     @UriPath @Metadata(required = "true")
     private Jt400Type type;
 
-    /**
-     * CCSID to use for the connection with the AS/400 system.
-     */
     @UriParam
     private int ccsid = DEFAULT_SYSTEM_CCSID;
     
-    /**
-     * Data format for sending messages.
-     */
     @UriParam(defaultValue = "text")
     private Format format = Format.text;
     
-    /**
-     * Whether AS/400 prompting is enabled in the environment running Camel.
-     */
     @UriParam
     private boolean guiAvailable;
 
@@ -128,9 +104,6 @@ public class Jt400Configuration {
     @UriParam(defaultValue = "EQ")
     private SearchType searchType = SearchType.EQ;
 
-    /**
-     * Whether connections to AS/400 are secured with SSL.
-     */
     @UriParam
     private boolean secured;
 
@@ -303,6 +276,9 @@ public class Jt400Configuration {
         return secured;
     }
 
+    /**
+     * Whether connections to AS/400 are secured with SSL.
+     */
     public void setSecured(boolean secured) {
         this.secured = secured;
     }
@@ -364,9 +340,9 @@ public class Jt400Configuration {
                 LOG.debug("Getting an AS400 object for '{}' from {}.", systemName + '/' + userID, connectionPool);
             }
 
-            if(isSecured()){
+            if (isSecured()) {
                 system = connectionPool.getSecureConnection(systemName, userID, password);
-            }else{
+            } else {
                 system = connectionPool.getConnection(systemName, userID, password);
             }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/b9bcff27/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
index 0509037..0a37ec0 100644
--- a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
@@ -80,7 +80,7 @@ public class Jt400ComponentTest extends Jt400TestSupport {
                 .createEndpoint("jt400://user:password@host/qsys.lib/library.lib/queue.dtaq?connectionPool=#mockPool&secured=true");
         assertNotNull(endpoint);
         assertTrue(endpoint instanceof Jt400Endpoint);
-        assertTrue( ((Jt400Endpoint)endpoint).isSecured() );
+        assertTrue(((Jt400Endpoint) endpoint).isSecured());
     }
 
     /**
@@ -92,7 +92,7 @@ public class Jt400ComponentTest extends Jt400TestSupport {
                 .createEndpoint("jt400://user:password@host/qsys.lib/library.lib/queue.pgm?connectionPool=#mockPool&secured=true");
         assertNotNull(endpoint);
         assertTrue(endpoint instanceof Jt400Endpoint);
-        assertTrue( ((Jt400Endpoint)endpoint).isSecured() );
+        assertTrue(((Jt400Endpoint) endpoint).isSecured());
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b9bcff27/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationTest.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationTest.java
index 5e4768c..8d8cbd4 100644
--- a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationTest.java
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationTest.java
@@ -31,7 +31,7 @@ public class Jt400ConfigurationTest extends Jt400TestSupport {
 
     @Test
     public void testDefaultSecured() {
-        assertFalse( jt400Configuration.isSecured());
+        assertFalse(jt400Configuration.isSecured());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/camel/blob/b9bcff27/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/MockAS400SecureConnectionPool.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/MockAS400SecureConnectionPool.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/MockAS400SecureConnectionPool.java
index 3c3d21f..effd867 100644
--- a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/MockAS400SecureConnectionPool.java
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/MockAS400SecureConnectionPool.java
@@ -16,19 +16,18 @@
  */
 package org.apache.camel.component.jt400;
 
+import java.util.Locale;
+
 import com.ibm.as400.access.AS400;
 import com.ibm.as400.access.AS400ConnectionPool;
 import com.ibm.as400.access.ConnectionPoolException;
 import com.ibm.as400.security.auth.ProfileTokenCredential;
 
-import java.util.Locale;
-
 /**
  * Mock {@code AS400ConnectionPool} implementation, useful in unit testing JT400 endpoints with secure option=true.
  */
 public class MockAS400SecureConnectionPool extends AS400ConnectionPool {
 
-
     public MockAS400SecureConnectionPool() {
         setRunMaintenance(false);
         setThreadUsed(false);


[5/5] camel git commit: Added set of fromEndpoint in producing exchanges to prevent a NPE using the component through camel uri binding in switchyard

Posted by da...@apache.org.
Added set of fromEndpoint in producing exchanges to prevent a NPE using the component through camel uri binding in switchyard


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

Branch: refs/heads/camel-2.14.x
Commit: ad675c18ce23dfae2641c7efc31f702bd4b24573
Parents: f9245e2
Author: Andrea Tarocchi <at...@redhat.com>
Authored: Wed Jul 8 00:15:54 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jul 8 08:39:21 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/jt400/Jt400DataQueueConsumer.java   | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ad675c18/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
index 3d7769e..8ed3776 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
@@ -109,6 +109,7 @@ public class Jt400DataQueueConsumer extends PollingConsumerSupport {
         }
 
         Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
+        exchange.setFromEndpoint(endpoint);
         if (entry != null) {
             exchange.getIn().setHeader(Jt400DataQueueEndpoint.SENDER_INFORMATION, entry.getSenderInformation());
             if (endpoint.getFormat() == Format.binary) {
@@ -135,6 +136,7 @@ public class Jt400DataQueueConsumer extends PollingConsumerSupport {
         }
 
         Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
+        exchange.setFromEndpoint(endpoint);
         if (entry != null) {
             exchange.getIn().setHeader(Jt400DataQueueEndpoint.SENDER_INFORMATION, entry.getSenderInformation());
             if (endpoint.getFormat() == Format.binary) {


[2/5] camel git commit: Added support for SSL connection encryption through secured URL option

Posted by da...@apache.org.
Added support for SSL connection encryption through secured URL option


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

Branch: refs/heads/master
Commit: 75b813aedee88e170a4f76f729a2ecd732a2d9c8
Parents: 42b542a
Author: Andrea Tarocchi <at...@redhat.com>
Authored: Wed Jul 8 00:14:19 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jul 8 08:33:20 2015 +0200

----------------------------------------------------------------------
 .../component/jt400/Jt400Configuration.java     |  22 +++-
 .../camel/component/jt400/Jt400Endpoint.java    |   5 +
 ...omponentDefaultSecureConnectionPoolTest.java |  62 ++++++++++++
 .../component/jt400/Jt400ComponentTest.java     |  24 +++++
 .../Jt400ConfigurationSecureConnectionTest.java |  67 ++++++++++++
 .../component/jt400/Jt400ConfigurationTest.java |   5 +
 .../component/jt400/Jt400SecureTestSupport.java |  69 +++++++++++++
 .../jt400/MockAS400SecureConnectionPool.java    | 101 +++++++++++++++++++
 8 files changed, 354 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/75b813ae/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Configuration.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Configuration.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Configuration.java
index 18d67d1..631beb9 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Configuration.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Configuration.java
@@ -128,6 +128,12 @@ public class Jt400Configuration {
     @UriParam(defaultValue = "EQ")
     private SearchType searchType = SearchType.EQ;
 
+    /**
+     * Whether connections to AS/400 are secured with SSL.
+     */
+    @UriParam
+    private boolean secured;
+
     @UriParam
     private Integer[] outputFieldsIdxArray;
 
@@ -293,6 +299,14 @@ public class Jt400Configuration {
         return outputFieldsIdxArray;
     }
 
+    public boolean isSecured() {
+        return secured;
+    }
+
+    public void setSecured(boolean secured) {
+        this.secured = secured;
+    }
+
     /**
      * Specifies which fields (program parameters) are output parameters.
      */
@@ -349,7 +363,13 @@ public class Jt400Configuration {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Getting an AS400 object for '{}' from {}.", systemName + '/' + userID, connectionPool);
             }
-            system = connectionPool.getConnection(systemName, userID, password);
+
+            if(isSecured()){
+                system = connectionPool.getSecureConnection(systemName, userID, password);
+            }else{
+                system = connectionPool.getConnection(systemName, userID, password);
+            }
+
             if (ccsid != DEFAULT_SYSTEM_CCSID) {
                 system.setCcsid(ccsid);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/75b813ae/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
index 20705ca..1e89550 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
@@ -246,4 +246,9 @@ public class Jt400Endpoint extends DefaultPollingEndpoint {
     public void setSystemName(String systemName) {
         configuration.setSystemName(systemName);
     }
+
+    public void setSecured(boolean secured) { configuration.setSecured(secured); }
+
+    public boolean isSecured() { return configuration.isSecured(); }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/75b813ae/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultSecureConnectionPoolTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultSecureConnectionPoolTest.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultSecureConnectionPoolTest.java
new file mode 100644
index 0000000..ad6e157
--- /dev/null
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultSecureConnectionPoolTest.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jt400;
+
+import com.ibm.as400.access.AS400ConnectionPool;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class Jt400ComponentDefaultSecureConnectionPoolTest extends Jt400TestSupport {
+    private Jt400Component component;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        component = new Jt400Component();
+        component.setCamelContext(context);
+        try {
+            // Use an invalid object type so that endpoints are never created
+            // and actual connections are never requested
+            component.createEndpoint("jt400://user:password@host/qsys.lib/library.lib/program.xxx?secured=true");
+            Assert.fail("Should have thrown exception");
+        } catch (Exception e) {
+            /* Expected */
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        if (component != null) {
+            component.stop();
+        }
+    }
+
+    @Test
+    public void testDefaultConnectionPoolIsCreated() {
+        assertNotNull(component.getConnectionPool());
+    }
+
+    /**
+     * Note: white-box testing.
+     */
+    @Test
+    public void testDefaultConnectionPoolIsOfExpectedType() {
+        assertEquals(AS400ConnectionPool.class, component.getConnectionPool().getClass());
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/75b813ae/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
index 29bb4db..0509037 100644
--- a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
@@ -71,4 +71,28 @@ public class Jt400ComponentTest extends Jt400TestSupport {
         }
     }
 
+    /**
+     * Test creation of a {@link Jt400Endpoint} secured for Datq
+     */
+    @Test
+    public void testCreateDatqSecuredEndpoint() throws Exception {
+        Endpoint endpoint = component
+                .createEndpoint("jt400://user:password@host/qsys.lib/library.lib/queue.dtaq?connectionPool=#mockPool&secured=true");
+        assertNotNull(endpoint);
+        assertTrue(endpoint instanceof Jt400Endpoint);
+        assertTrue( ((Jt400Endpoint)endpoint).isSecured() );
+    }
+
+    /**
+     * Test creation of a {@link Jt400Endpoint} secured for pgm calls
+     */
+    @Test
+    public void testCreatePgmSecuredEndpoint() throws Exception {
+        Endpoint endpoint = component
+                .createEndpoint("jt400://user:password@host/qsys.lib/library.lib/queue.pgm?connectionPool=#mockPool&secured=true");
+        assertNotNull(endpoint);
+        assertTrue(endpoint instanceof Jt400Endpoint);
+        assertTrue( ((Jt400Endpoint)endpoint).isSecured() );
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/75b813ae/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationSecureConnectionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationSecureConnectionTest.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationSecureConnectionTest.java
new file mode 100644
index 0000000..e860115
--- /dev/null
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationSecureConnectionTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jt400;
+
+import com.ibm.as400.access.AS400;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class Jt400ConfigurationSecureConnectionTest extends Jt400SecureTestSupport {
+
+    private Jt400Configuration jt400Configuration;
+    private AS400 connection;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+
+        jt400Configuration = new Jt400Configuration("jt400://USER:password@host/QSYS.LIB/LIBRARY.LIB/QUEUE.DTAQ", getConnectionPool());
+        jt400Configuration.setCcsid(37);
+        jt400Configuration.setSecured(true);
+        connection = jt400Configuration.getConnection();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        if (connection != null) {
+            jt400Configuration.releaseConnection(connection);
+        }
+        super.tearDown();
+    }
+
+    @Test
+    public void testSystemName() {
+        assertEquals("host", connection.getSystemName());
+    }
+
+    @Test
+    public void testUserId() {
+        assertEquals("USER", connection.getUserId());
+    }
+
+    @Test
+    public void testCssid() {
+        assertEquals(37, connection.getCcsid());
+    }
+
+    @Test
+    public void testGuiAvailable() {
+        assertFalse(connection.isGuiAvailable());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/75b813ae/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationTest.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationTest.java
index 523628a..5e4768c 100644
--- a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationTest.java
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ConfigurationTest.java
@@ -30,6 +30,11 @@ public class Jt400ConfigurationTest extends Jt400TestSupport {
     }
 
     @Test
+    public void testDefaultSecured() {
+        assertFalse( jt400Configuration.isSecured());
+    }
+
+    @Test
     public void testSystemName() {
         assertEquals("host", jt400Configuration.getSystemName());
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/75b813ae/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400SecureTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400SecureTestSupport.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400SecureTestSupport.java
new file mode 100644
index 0000000..b9e98ab
--- /dev/null
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400SecureTestSupport.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jt400;
+
+import com.ibm.as400.access.AS400ConnectionPool;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * Useful base class for JT400 secured component unit tests. It creates a mock
+ * secured connection pool, registers it under the ID {@code "mockPool"} and releases it
+ * after the test runs.
+ */
+public abstract class Jt400SecureTestSupport extends CamelTestSupport {
+
+    private AS400ConnectionPool connectionPool;
+
+    protected Jt400SecureTestSupport() {
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        connectionPool = new MockAS400SecureConnectionPool();
+        super.setUp();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (connectionPool != null) {
+            connectionPool.close();
+        }
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        ObjectHelper.notNull(connectionPool, "connectionPool");
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("mockPool", connectionPool);
+        return registry;
+    }
+
+    /**
+     * Returns the mock connection pool.
+     *
+     * @return the mock connection pool
+     */
+    public AS400ConnectionPool getConnectionPool() {
+        return connectionPool;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/75b813ae/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/MockAS400SecureConnectionPool.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/MockAS400SecureConnectionPool.java b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/MockAS400SecureConnectionPool.java
new file mode 100644
index 0000000..3c3d21f
--- /dev/null
+++ b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/MockAS400SecureConnectionPool.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jt400;
+
+import com.ibm.as400.access.AS400;
+import com.ibm.as400.access.AS400ConnectionPool;
+import com.ibm.as400.access.ConnectionPoolException;
+import com.ibm.as400.security.auth.ProfileTokenCredential;
+
+import java.util.Locale;
+
+/**
+ * Mock {@code AS400ConnectionPool} implementation, useful in unit testing JT400 endpoints with secure option=true.
+ */
+public class MockAS400SecureConnectionPool extends AS400ConnectionPool {
+
+
+    public MockAS400SecureConnectionPool() {
+        setRunMaintenance(false);
+        setThreadUsed(false);
+    }
+
+    @Override
+    public AS400 getSecureConnection(String systemName, String userID, String password) throws ConnectionPoolException {
+        return new AS400(systemName, userID, password);
+    }
+
+    @Deprecated
+    @Override
+    public AS400 getSecureConnection(String systemName, String userID) throws ConnectionPoolException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public AS400 getSecureConnection(String systemName, String userID, String password, int i) throws ConnectionPoolException {
+        return new AS400(systemName, userID, password);
+    }
+
+    @Deprecated
+    @Override
+    public AS400 getSecureConnection(String systemName, String userID, int i) throws ConnectionPoolException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public AS400 getSecureConnection(String systemName, String userID, ProfileTokenCredential profileTokenCredential) throws ConnectionPoolException {
+        return new AS400(systemName, userID);
+    }
+
+    @Override
+    public AS400 getSecureConnection(String systemName, String userID, ProfileTokenCredential profileTokenCredential, int i) throws ConnectionPoolException {
+        return new AS400(systemName, userID);
+    }
+
+    @Deprecated
+    @Override
+    public AS400 getConnection(String systemName, String userID) throws ConnectionPoolException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Deprecated
+    @Override
+    public AS400 getConnection(String systemName, String userID, int service) throws ConnectionPoolException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public AS400 getConnection(String systemName, String userID, String password) throws ConnectionPoolException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public AS400 getConnection(String systemName, String userID, String password, int service) throws ConnectionPoolException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public AS400 getConnection(String systemName, String userID, String password, int service, Locale locale) throws ConnectionPoolException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public AS400 getConnection(String systemName, String userID, String password, Locale locale) throws ConnectionPoolException {
+        throw new UnsupportedOperationException();
+    }
+
+}


[4/5] camel git commit: Added set of fromEndpoint in producing exchanges to prevent a NPE using the component through camel uri binding in switchyard

Posted by da...@apache.org.
Added set of fromEndpoint in producing exchanges to prevent a NPE using the component through camel uri binding in switchyard


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

Branch: refs/heads/camel-2.15.x
Commit: 501d5c556dfa29f2e647487f4746ec323000ac24
Parents: 9efa1cb
Author: Andrea Tarocchi <at...@redhat.com>
Authored: Wed Jul 8 00:15:54 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jul 8 08:39:04 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/jt400/Jt400DataQueueConsumer.java   | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/501d5c55/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
index 2bdc7d4..825af3c 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueConsumer.java
@@ -108,6 +108,7 @@ public class Jt400DataQueueConsumer extends PollingConsumerSupport {
         }
 
         Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
+        exchange.setFromEndpoint(endpoint);
         if (entry != null) {
             exchange.getIn().setHeader(Jt400Endpoint.SENDER_INFORMATION, entry.getSenderInformation());
             if (endpoint.getFormat() == Jt400Configuration.Format.binary) {
@@ -134,6 +135,7 @@ public class Jt400DataQueueConsumer extends PollingConsumerSupport {
         }
 
         Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
+        exchange.setFromEndpoint(endpoint);
         if (entry != null) {
             exchange.getIn().setHeader(Jt400Endpoint.SENDER_INFORMATION, entry.getSenderInformation());
             if (endpoint.getFormat() == Jt400Configuration.Format.binary) {