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 2017/02/21 08:28:20 UTC

[3/4] camel git commit: CAMEL-8162 - UTs to invalidate the issue with cs fixes

CAMEL-8162 - UTs to invalidate the issue with cs fixes


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

Branch: refs/heads/master
Commit: 2fd971997ebb4cb35f655d49e4eb10d620d3dafa
Parents: b1c5766
Author: onders86 <on...@gmail.com>
Authored: Mon Feb 20 16:19:07 2017 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 21 09:23:01 2017 +0100

----------------------------------------------------------------------
 components/camel-spring-ws/pom.xml              |  11 ++
 .../javacrumbs/calc/model/ObjectFactory.java    |  26 ++--
 .../net/javacrumbs/calc/model/PlusRequest.java  |  66 +++++-----
 .../net/javacrumbs/calc/model/PlusResponse.java |  35 +++---
 .../ProducerWss4JSecurityHeaderTest.java        | 126 +++++++++----------
 ...ducerWss4JSecurityHeaderTestInterceptor.java |  28 ++---
 .../src/test/resources/log4j2.properties        |   1 +
 7 files changed, 152 insertions(+), 141 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2fd97199/components/camel-spring-ws/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-ws/pom.xml b/components/camel-spring-ws/pom.xml
index 0f5ba65..96bd68d 100644
--- a/components/camel-spring-ws/pom.xml
+++ b/components/camel-spring-ws/pom.xml
@@ -67,6 +67,17 @@
       <artifactId>spring-ws-support</artifactId>
       <version>${spring-ws-version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.springframework.ws</groupId>
+      <artifactId>spring-ws-security</artifactId>
+      <version>${spring-ws-version}</version>
+      <exclusions>
+            <exclusion>
+                <groupId>xalan</groupId>
+                <artifactId>xalan</artifactId>
+            </exclusion>
+      </exclusions>
+    </dependency>
 
     <!-- test dependencies -->
     <dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/2fd97199/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/ObjectFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/ObjectFactory.java b/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/ObjectFactory.java
index 2df1574..39ee886 100644
--- a/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/ObjectFactory.java
+++ b/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/ObjectFactory.java
@@ -46,20 +46,20 @@ import javax.xml.bind.annotation.XmlRegistry;
 public class ObjectFactory {
 
 
-  /**
-   * Create a new ObjectFactory that can be used to create new instances of 
-   * schema derived classes for package: net.javacrumbs.calc.model
-   * 
-   */
-  public ObjectFactory() {
-  }
+    /**
+     * Create a new ObjectFactory that can be used to create new instances of 
+     * schema derived classes for package: net.javacrumbs.calc.model
+     * 
+     */
+    public ObjectFactory() {
+    }
 
-  public PlusResponse createPlusResponse() {
-    return new PlusResponse();
-  }
+    public PlusResponse createPlusResponse() {
+        return new PlusResponse();
+    }
 
-  public PlusRequest createPlusRequest() {
-    return new PlusRequest();
-  }
+    public PlusRequest createPlusRequest() {
+        return new PlusRequest();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/2fd97199/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/PlusRequest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/PlusRequest.java b/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/PlusRequest.java
index 2d6426e..57ade88 100644
--- a/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/PlusRequest.java
+++ b/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/PlusRequest.java
@@ -59,39 +59,39 @@ import javax.xml.bind.annotation.XmlType;
 @XmlRootElement(name = "plusRequest")
 public class PlusRequest {
 
-  protected int a;
-  protected int b;
+    protected int a;
+    protected int b;
 
-  /**
-   * Gets the value of the a property.
-   * 
-   */
-  public int getA() {
-    return a;
-  }
-
-  /**
-   * Sets the value of the a property.
-   * 
-   */
-  public void setA(int value) {
-    this.a = value;
-  }
-
-  /**
-   * Gets the value of the b property.
-   * 
-   */
-  public int getB() {
-    return b;
-  }
-
-  /**
-   * Sets the value of the b property.
-   * 
-   */
-  public void setB(int value) {
-    this.b = value;
-  }
+    /**
+     * Gets the value of the a property.
+     * 
+     */
+    public int getA() {
+        return a;
+    }
+    
+    /**
+     * Sets the value of the a property.
+     * 
+     */
+    public void setA(int value) {
+        this.a = value;
+    }
+    
+    /**
+     * Gets the value of the b property.
+     * 
+     */
+    public int getB() {
+        return b;
+    }
+    
+    /**
+     * Sets the value of the b property.
+     * 
+     */
+    public void setB(int value) {
+        this.b = value;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/2fd97199/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/PlusResponse.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/PlusResponse.java b/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/PlusResponse.java
index 11a6a5e..4c25d8d 100644
--- a/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/PlusResponse.java
+++ b/components/camel-spring-ws/src/test/java/net/javacrumbs/calc/model/PlusResponse.java
@@ -1,4 +1,3 @@
-//
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -57,22 +56,22 @@ import javax.xml.bind.annotation.XmlType;
 @XmlRootElement(name = "plusResponse")
 public class PlusResponse {
 
-  protected int result;
-
-  /**
-   * Gets the value of the result property.
-   * 
-   */
-  public int getResult() {
-    return result;
-  }
-
-  /**
-   * Sets the value of the result property.
-   * 
-   */
-  public void setResult(int value) {
-    this.result = value;
-  }
+    protected int result;
+    
+    /**
+     * Gets the value of the result property.
+     * 
+     */
+    public int getResult() {
+        return result;
+    }
+    
+    /**
+     * Sets the value of the result property.
+     * 
+     */
+    public void setResult(int value) {
+        this.result = value;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/2fd97199/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTest.java b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTest.java
index 6e6c724..671848a 100644
--- a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTest.java
+++ b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTest.java
@@ -37,71 +37,71 @@ import org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor;
         + " secured ws on j2ee-compliant application server")
 public class ProducerWss4JSecurityHeaderTest extends CamelSpringTestSupport {
 
-  @Produce
-  private ProducerTemplate template;
-
-  private WebServiceTemplate webServiceTemplate;
-  
-  @Override
-  public void setUp() throws Exception {
-    super.setUp();
-    webServiceTemplate = applicationContext.getBean("webServiceTemplate", WebServiceTemplate.class);
-  }
-
-  @Test
-  public void testResponseUsingWss4jSampleInterceptorWithoutHeadersRemoved() throws Exception {
-
-    setRemoveHeaders(false);
-
-    PlusResponse result = createSampleRequestResponsePair();
+    @Produce
+    private ProducerTemplate template;
     
-    assertNotNull(result);
-    assertEquals(3, result.getResult());
+    private WebServiceTemplate webServiceTemplate;
     
-    assertTrue(ProducerWss4JSecurityHeaderTestInterceptor.isX509DataPresent);
-
-  }
-
-  @Test
-  public void testResponseUsingWss4jSampleInterceptorWithHeadersRemoved() throws Exception {
-
-    setRemoveHeaders(true);
-
-    PlusResponse result = createSampleRequestResponsePair();
-
-    assertNotNull(result);
-    assertEquals(3, result.getResult());
-
-    assertTrue(ProducerWss4JSecurityHeaderTestInterceptor.isX509DataPresent);
-
-  }
-
-  private PlusResponse createSampleRequestResponsePair() {
-    PlusRequest request = new PlusRequest();
-    request.setA(new Integer(1));
-    request.setB(new Integer(2));
-
-    PlusResponse result = (PlusResponse) template.requestBody("direct:testHeader", request);
-
-    return result;
-  }
-
-  private void setRemoveHeaders(boolean isRemoved) {
-    ClientInterceptor[] clientInterceptors = webServiceTemplate.getInterceptors();
-
-    for (int i = 0; i < clientInterceptors.length; i++) {
-      if (clientInterceptors[i] instanceof Wss4jSecurityInterceptor) {
-        Wss4jSecurityInterceptor wss4jSampleInterceptor 
-                                     = (Wss4jSecurityInterceptor) clientInterceptors[i];
-        wss4jSampleInterceptor.setRemoveSecurityHeader(isRemoved);
-      }
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        webServiceTemplate = applicationContext.getBean("webServiceTemplate", WebServiceTemplate.class);
+    }
+    
+    @Test
+    public void testResponseUsingWss4jSampleInterceptorWithoutHeadersRemoved() throws Exception {
+    
+        setRemoveHeaders(false);
+         
+        PlusResponse result = createSampleRequestResponsePair();
+         
+        assertNotNull(result);
+        assertEquals(3, result.getResult());
+         
+        assertTrue(ProducerWss4JSecurityHeaderTestInterceptor.isX509DataPresent);
+    
+    }
+    
+    @Test
+    public void testResponseUsingWss4jSampleInterceptorWithHeadersRemoved() throws Exception {
+        
+        setRemoveHeaders(true);
+        
+        PlusResponse result = createSampleRequestResponsePair();
+        
+        assertNotNull(result);
+        assertEquals(3, result.getResult());
+        
+        assertTrue(ProducerWss4JSecurityHeaderTestInterceptor.isX509DataPresent);
+    
+    }
+    
+    private PlusResponse createSampleRequestResponsePair() {
+        PlusRequest request = new PlusRequest();
+        request.setA(new Integer(1));
+        request.setB(new Integer(2));
+        
+        PlusResponse result = (PlusResponse) template.requestBody("direct:testHeader", request);
+        
+        return result;
+    }
+    
+    private void setRemoveHeaders(boolean isRemoved) {
+        ClientInterceptor[] clientInterceptors = webServiceTemplate.getInterceptors();
+        
+        for (int i = 0; i < clientInterceptors.length; i++) {
+            if (clientInterceptors[i] instanceof Wss4jSecurityInterceptor) {
+                Wss4jSecurityInterceptor wss4jSampleInterceptor 
+                                           = (Wss4jSecurityInterceptor) clientInterceptors[i];
+                wss4jSampleInterceptor.setRemoveSecurityHeader(isRemoved);
+            }
+        }
+    }
+    
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext(
+          "org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTest-context.xml");
     }
-  }
-
-  @Override
-  protected AbstractXmlApplicationContext createApplicationContext() {
-    return new ClassPathXmlApplicationContext(
-      "org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTest-context.xml");
-  }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/2fd97199/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTestInterceptor.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTestInterceptor.java b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTestInterceptor.java
index 33a02a3..98f146c 100644
--- a/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTestInterceptor.java
+++ b/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/security/ProducerWss4JSecurityHeaderTestInterceptor.java
@@ -24,21 +24,21 @@ import org.springframework.ws.context.MessageContext;
 import org.springframework.ws.soap.SoapMessage;
 import org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor;
 
-public class ProducerWss4JSecurityHeaderTestInterceptor extends Wss4jSecurityInterceptor{
+public class ProducerWss4JSecurityHeaderTestInterceptor extends Wss4jSecurityInterceptor {
 
-  public static boolean isX509DataPresent = false;
-  
-  protected void validateMessage(SoapMessage soapMessage, MessageContext messageContext) {
-    ByteArrayOutputStream out = new ByteArrayOutputStream();
-    try {
-      soapMessage.writeTo(out);
-    } catch (IOException exception) {
-      // do nothing - because this is a sample class
+    public static boolean isX509DataPresent;
+    
+    protected void validateMessage(SoapMessage soapMessage, MessageContext messageContext) {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try {
+            soapMessage.writeTo(out);
+        } catch (IOException exception) {
+          // do nothing - because this is a sample class
+        }
+        String strMsg = new String(out.toByteArray());
+          
+        isX509DataPresent = strMsg.contains("X509Data");
+        super.validateMessage(soapMessage, messageContext);
     }
-    String strMsg = new String(out.toByteArray());
-      
-    isX509DataPresent = strMsg.contains("X509Data");
-    super.validateMessage(soapMessage, messageContext);
-  }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/2fd97199/components/camel-spring-ws/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-spring-ws/src/test/resources/log4j2.properties b/components/camel-spring-ws/src/test/resources/log4j2.properties
index aa2649d..453a261 100644
--- a/components/camel-spring-ws/src/test/resources/log4j2.properties
+++ b/components/camel-spring-ws/src/test/resources/log4j2.properties
@@ -25,4 +25,5 @@ appender.out.name = out
 appender.out.layout.type = PatternLayout
 appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
 rootLogger.level = INFO
+org.springframework.ws.client.MessageTracing=DEBUG
 rootLogger.appenderRef.file.ref = file