You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by co...@apache.org on 2019/11/04 12:40:11 UTC

[camel] branch camel-2.24.x updated (0db2676 -> 0339829)

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

coheigea pushed a change to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 0db2676  Updating CXF
     new ef4527c  Fixing camel-ahc tests
     new 0339829  CAMEL-13563: Fix AHC tests after Jetty upgrade

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 components/camel-ahc/pom.xml                       | 75 ----------------------
 .../camel/component/ahc/DefaultAhcBinding.java     | 28 ++++----
 .../apache/camel/component/ahc/BaseAhcTest.java    | 31 ++++-----
 3 files changed, 29 insertions(+), 105 deletions(-)


[camel] 01/02: Fixing camel-ahc tests

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ef4527c4a291068b0d990b5215afc539bf4e3aa3
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Mon Nov 4 12:37:51 2019 +0000

    Fixing camel-ahc tests
---
 components/camel-ahc/pom.xml                       | 75 ----------------------
 .../component/ahc/AhcProducerSessionTest.java      |  2 +
 .../apache/camel/component/ahc/BaseAhcTest.java    | 31 ++++-----
 3 files changed, 16 insertions(+), 92 deletions(-)

diff --git a/components/camel-ahc/pom.xml b/components/camel-ahc/pom.xml
index 82006df..b6a51f4 100644
--- a/components/camel-ahc/pom.xml
+++ b/components/camel-ahc/pom.xml
@@ -77,82 +77,7 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-jetty9</artifactId>
       <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>org.eclipse.jetty</groupId>
-          <artifactId>jetty-server</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.eclipse.jetty</groupId>
-          <artifactId>jetty-servlet</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.eclipse.jetty</groupId>
-          <artifactId>jetty-security</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.eclipse.jetty</groupId>
-          <artifactId>jetty-servlets</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.eclipse.jetty</groupId>
-          <artifactId>jetty-client</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.eclipse.jetty</groupId>
-          <artifactId>jetty-jmx</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.eclipse.jetty</groupId>
-          <artifactId>jetty-util</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
-
-    <!-- requires jetty 9.2 for testing -->
-    <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-server</artifactId>
-      <version>${jetty92-version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-servlet</artifactId>
-      <version>${jetty92-version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-security</artifactId>
-      <version>${jetty92-version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-servlets</artifactId>
-      <version>${jetty92-version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-client</artifactId>
-      <version>${jetty92-version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-jmx</artifactId>
-      <version>${jetty92-version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.eclipse.jetty</groupId>
-      <artifactId>jetty-util</artifactId>
-      <version>${jetty92-version}</version>
-      <scope>test</scope>
-    </dependency>
-
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java
index d94db24..79e149e 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java
@@ -57,6 +57,7 @@ public class AhcProducerSessionTest extends BaseAhcTest {
     }
 
     @Test
+    @org.junit.Ignore("Failing cookie test with Jetty 9.4")
     public void testProducerInstanceSession() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Old New World", "Old Old World");
         template.sendBody("direct:instance", "World");
@@ -65,6 +66,7 @@ public class AhcProducerSessionTest extends BaseAhcTest {
     }
 
     @Test
+    @org.junit.Ignore("Failing cookie test with Jetty 9.4")
     public void testProducerExchangeSession() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Old New World", "Old New World");
         template.sendBody("direct:exchange", "World");
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java
index 800108f..24d0317 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java
@@ -31,9 +31,9 @@ import org.apache.camel.util.jsse.TrustManagersParameters;
 import org.junit.BeforeClass;
 
 public abstract class BaseAhcTest extends CamelTestSupport {
-    
+
     protected static final String KEY_STORE_PASSWORD = "changeit";
-    
+
     private static volatile int port;
 
     @BeforeClass
@@ -55,14 +55,14 @@ public abstract class BaseAhcTest extends CamelTestSupport {
         Properties prop = new Properties();
         prop.setProperty("port", "" + getPort());
         jndi.bind("prop", prop);
-        
+
         if (isHttps()) {
             addSslContextParametersToRegistry(jndi);
         }
 
         return jndi;
     }
-    
+
     protected void addSslContextParametersToRegistry(JndiRegistry registry) {
         registry.bind("sslContextParameters", createSSLContextParameters());
     }
@@ -88,55 +88,52 @@ public abstract class BaseAhcTest extends CamelTestSupport {
         sslContextParameters.setKeyManagers(kmp);
         sslContextParameters.setTrustManagers(tmp);
         sslContextParameters.setServerParameters(scsp);
-        // use SSLv3 to avoid issue with (eg disable TLS)
-        // Caused by: javax.net.ssl.SSLException: bad record MAC
-        sslContextParameters.setSecureSocketProtocol("SSLv3");
 
         return sslContextParameters;
     }
-    
+
     /**
      * Indicates if the URIs returned from {@link #getTestServerEndpointUri()} and
      * {@link #getAhcEndpointUri()} should use the HTTPS protocol instead of
      * the HTTP protocol.
-     * 
+     *
      * If true, an {@link SSLContextParameters} is also placed in the registry under the
      * key {@code sslContextParameters}.  The parameters are not added to the endpoint URIs
      * as that is test specific.
-     * 
+     *
      * @return false by default
      */
     protected boolean isHttps() {
         return false;
     }
-    
+
     protected String getProtocol() {
         String protocol = "http";
         if (isHttps()) {
             protocol = protocol + "s";
         }
-        
+
         return protocol;
     }
-    
+
     protected String getTestServerEndpointUrl() {
         return getProtocol() + "://localhost:{{port}}/foo";
     }
-    
+
     protected String getTestServerEndpointUri() {
         return "jetty:" + getTestServerEndpointUrl();
     }
-    
+
     protected String getTestServerEndpointTwoUrl() {
         // Don't use the property placeholder here since we use the value outside of a
         // field that supports the placeholders.
         return getProtocol() + "://localhost:" + getPort() + "/bar";
     }
-    
+
     protected String getTestServerEndpointTwoUri() {
         return "jetty:" + getTestServerEndpointTwoUrl();
     }
-    
+
     protected String getAhcEndpointUri() {
         return "ahc:" + getProtocol() + "://localhost:{{port}}/foo";
     }


[camel] 02/02: CAMEL-13563: Fix AHC tests after Jetty upgrade

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 03398298189df8eb67e5c20dbec5310c8009737e
Author: Denis Istomin <is...@gmail.com>
AuthorDate: Fri Aug 2 18:38:47 2019 +0500

    CAMEL-13563: Fix AHC tests after Jetty upgrade
---
 .../camel/component/ahc/DefaultAhcBinding.java     | 28 ++++++++++++----------
 .../component/ahc/AhcProducerSessionTest.java      |  2 --
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java
index 94ae301..ffea5f7 100644
--- a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java
+++ b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java
@@ -25,6 +25,7 @@ import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.nio.charset.Charset;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -82,8 +83,7 @@ public class DefaultAhcBinding implements AhcBinding {
         log.trace("Setting method {}", method);
         builder.setMethod(method);
 
-        populateHeaders(builder, endpoint, exchange);
-        populateCookieHeaders(builder, endpoint, exchange, uri);
+        populateHeaders(builder, endpoint, exchange, uri);
         populateBody(builder, endpoint, exchange);
 
         return builder.build();
@@ -101,9 +101,10 @@ public class DefaultAhcBinding implements AhcBinding {
         return hasBody ? "POST" : "GET";
     }
 
-    protected void populateHeaders(RequestBuilder builder, AhcEndpoint endpoint, Exchange exchange) {
-        HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
+    protected void populateHeaders(RequestBuilder builder, AhcEndpoint endpoint, Exchange exchange, URI uri) throws CamelExchangeException {
+        Map<String, Object> headers = new HashMap<>();
 
+        HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
         // propagate headers as HTTP headers
         for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
             String headerValue = exchange.getIn().getHeader(entry.getKey(), String.class);
@@ -111,16 +112,11 @@ public class DefaultAhcBinding implements AhcBinding {
                 if (log.isTraceEnabled()) {
                     log.trace("Adding header {} = {}", entry.getKey(), headerValue);
                 }
-                builder.addHeader(entry.getKey(), headerValue);
+
+                headers.put(entry.getKey(), headerValue);
             }
         }
-        
-        if (endpoint.isConnectionClose()) {
-            builder.addHeader("Connection", "close");
-        }
-    }
 
-    private void populateCookieHeaders(RequestBuilder builder, AhcEndpoint endpoint, Exchange exchange, URI uri) throws CamelExchangeException {
         if (endpoint.getCookieHandler() != null) {
             try {
                 Map<String, List<String>> cookieHeaders = endpoint.getCookieHandler().loadCookies(exchange, uri);
@@ -133,12 +129,18 @@ public class DefaultAhcBinding implements AhcBinding {
                     if (log.isTraceEnabled()) {
                         log.trace("Adding header {} = {}", key, joiner.toString());
                     }
-                    builder.addHeader(key, joiner.toString());
+                    headers.put(key, joiner.toString());
                 }
             } catch (IOException e) {
                 throw new CamelExchangeException("Error loading cookies", exchange, e);
             }
         }
+
+        if (endpoint.isConnectionClose()) {
+            builder.addHeader("Connection", "close");
+        }
+
+        headers.forEach(builder::addHeader);
     }
 
     protected void populateBody(RequestBuilder builder, AhcEndpoint endpoint, Exchange exchange) throws CamelExchangeException {
@@ -278,7 +280,7 @@ public class DefaultAhcBinding implements AhcBinding {
 
         Object body = is;
         // if content type is a serialized java object then de-serialize it back to a Java object but only if its allowed
-        // an exception can also be transffered as java object
+        // an exception can also be transferred as java object
         if (contentType != null && contentType.equals(AhcConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT)) {
             if (endpoint.getComponent().isAllowJavaSerializedObject() || endpoint.isTransferException()) {
                 body = AhcHelper.deserializeJavaObjectFromStream(is);
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java
index 79e149e..d94db24 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerSessionTest.java
@@ -57,7 +57,6 @@ public class AhcProducerSessionTest extends BaseAhcTest {
     }
 
     @Test
-    @org.junit.Ignore("Failing cookie test with Jetty 9.4")
     public void testProducerInstanceSession() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Old New World", "Old Old World");
         template.sendBody("direct:instance", "World");
@@ -66,7 +65,6 @@ public class AhcProducerSessionTest extends BaseAhcTest {
     }
 
     @Test
-    @org.junit.Ignore("Failing cookie test with Jetty 9.4")
     public void testProducerExchangeSession() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Old New World", "Old New World");
         template.sendBody("direct:exchange", "World");