You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/11/20 15:44:13 UTC
svn commit: r1411687 - in /camel/trunk/components/camel-spring-ws/src:
main/java/org/apache/camel/component/spring/ws/filter/impl/
test/java/org/apache/camel/component/spring/ws/
test/java/org/apache/camel/component/spring/ws/filter/impl/ test/java/org...
Author: ningjiang
Date: Tue Nov 20 14:44:08 2012
New Revision: 1411687
URL: http://svn.apache.org/viewvc?rev=1411687&view=rev
Log:
CAMEL-5724 Fixed the CS errors
Modified:
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilter.java
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/MessageFilterResolvingDefaultsTest.java
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/MessageFilterResolvingTest.java
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilterTest.java
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/EmptyMessageFilter.java
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/GlobalMessageFilter.java
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/LocalMessageFilter.java
Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilter.java?rev=1411687&r1=1411686&r2=1411687&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilter.java (original)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilter.java Tue Nov 20 14:44:08 2012
@@ -1,3 +1,19 @@
+/**
+ * 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.spring.ws.filter.impl;
import java.util.HashSet;
@@ -16,118 +32,111 @@ import org.springframework.ws.soap.SoapH
import org.springframework.ws.soap.SoapMessage;
/**
- * This class populates a SOAP header and attachments in the WebServiceMessage instance.
- *
- * @author andrej@chocolatejar.eu
- *
+ * This class populates a SOAP header and attachments in the WebServiceMessage
+ * instance.
*/
public class BasicMessageFilter implements MessageFilter {
- private static final String LOWERCASE_BREADCRUMB_ID = "breadcrumbid";
+ private static final String LOWERCASE_BREADCRUMB_ID = "breadcrumbid";
- @Override
- public void filterProducer(Exchange exchange, WebServiceMessage response) {
- if (exchange != null) {
- processHeaderAndAttachments(exchange.getIn(), response);
- }
- }
-
- @Override
- public void filterConsumer(Exchange exchange, WebServiceMessage response) {
- if (exchange != null) {
- processHeaderAndAttachments(exchange.getOut(), response);
- }
- }
-
- /**
- * If applicable this method adds a SOAP headers and attachments.
- *
- * @param inOrOut
- * @param response
- */
- protected void processHeaderAndAttachments(Message inOrOut,
- WebServiceMessage response) {
-
- if (response instanceof SoapMessage) {
- SoapMessage soapMessage = (SoapMessage) response;
- processSoapHeader(inOrOut, soapMessage);
- doProcessSoapAttachments(inOrOut, soapMessage);
- }
- }
-
- /**
- * If applicable this method adds a SOAP header.
- *
- * @param inOrOut
- * @param soapMessage
- */
- protected void processSoapHeader(Message inOrOut, SoapMessage soapMessage) {
- boolean isHeaderAvailable = inOrOut != null
- && inOrOut.getHeaders() != null
- && !inOrOut.getHeaders().isEmpty();
-
- if (isHeaderAvailable) {
- doProcessSoapHeader(inOrOut, soapMessage);
- }
- }
-
- /**
- * The SOAP header is populated from exchange.getOut().getHeaders() if this
- * class is used by the consumer or exchange.getIn().getHeaders() if this
- * class is used by the producer.
- *
- * If .getHeaders() contains under a certain key a value with the QName
- * object, it is directly added as a new header element. If it contains only
- * a String value, it is transformed into a header attribute.
- *
- * Following headers are excluded: {@code LOWERCASE_BREADCRUMB_ID}
- *
- * @see SpringWebserviceConstants.SPRING_WS_SOAP_ACTION, @see
- * SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION), @see
- * SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI
- *
- * This the convinient method for overriding.
- * @param inOrOut
- * @param soapMessage
- */
- protected void doProcessSoapHeader(Message inOrOut, SoapMessage soapMessage) {
- SoapHeader soapHeader = soapMessage.getSoapHeader();
-
- Map<String, Object> headers = inOrOut.getHeaders();
-
- HashSet<String> headerKeySet = new HashSet<String>(headers.keySet());
-
- headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION.toLowerCase());
- headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION.toLowerCase());
- headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI.toLowerCase());
-
- headerKeySet.remove(LOWERCASE_BREADCRUMB_ID);
-
- for (String name : headerKeySet) {
- Object value = headers.get(name);
-
- if (value instanceof QName) {
- soapHeader.addHeaderElement((QName) value);
- } else {
- if (value instanceof String) {
- soapHeader.addAttribute(new QName(name), value + "");
- }
- }
- }
- }
-
- /**
- * Populate SOAP attachments from in or out exchange message. This the convenient method for overriding.
- *
- * @param inOrOut
- * @param response
- */
- protected void doProcessSoapAttachments(Message inOrOut, SoapMessage response) {
- Map<String, DataHandler> attachments = inOrOut.getAttachments();
-
- Set<String> keySet = new HashSet<String>(attachments.keySet());
- for (String key : keySet) {
- response.addAttachment(key, attachments.get(key));
- }
- }
+ @Override
+ public void filterProducer(Exchange exchange, WebServiceMessage response) {
+ if (exchange != null) {
+ processHeaderAndAttachments(exchange.getIn(), response);
+ }
+ }
+
+ @Override
+ public void filterConsumer(Exchange exchange, WebServiceMessage response) {
+ if (exchange != null) {
+ processHeaderAndAttachments(exchange.getOut(), response);
+ }
+ }
+
+ /**
+ * If applicable this method adds a SOAP headers and attachments.
+ *
+ * @param inOrOut
+ * @param response
+ */
+ protected void processHeaderAndAttachments(Message inOrOut, WebServiceMessage response) {
+
+ if (response instanceof SoapMessage) {
+ SoapMessage soapMessage = (SoapMessage)response;
+ processSoapHeader(inOrOut, soapMessage);
+ doProcessSoapAttachments(inOrOut, soapMessage);
+ }
+ }
+
+ /**
+ * If applicable this method adds a SOAP header.
+ *
+ * @param inOrOut
+ * @param soapMessage
+ */
+ protected void processSoapHeader(Message inOrOut, SoapMessage soapMessage) {
+ boolean isHeaderAvailable = inOrOut != null && inOrOut.getHeaders() != null && !inOrOut.getHeaders().isEmpty();
+
+ if (isHeaderAvailable) {
+ doProcessSoapHeader(inOrOut, soapMessage);
+ }
+ }
+
+ /**
+ * The SOAP header is populated from exchange.getOut().getHeaders() if this
+ * class is used by the consumer or exchange.getIn().getHeaders() if this
+ * class is used by the producer. If .getHeaders() contains under a certain
+ * key a value with the QName object, it is directly added as a new header
+ * element. If it contains only a String value, it is transformed into a
+ * header attribute. Following headers are excluded:
+ * {@code LOWERCASE_BREADCRUMB_ID}
+ *
+ * @see SpringWebserviceConstants.SPRING_WS_SOAP_ACTION, @see
+ * SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION), @see
+ * SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI This the convinient
+ * method for overriding.
+ * @param inOrOut
+ * @param soapMessage
+ */
+ protected void doProcessSoapHeader(Message inOrOut, SoapMessage soapMessage) {
+ SoapHeader soapHeader = soapMessage.getSoapHeader();
+
+ Map<String, Object> headers = inOrOut.getHeaders();
+
+ HashSet<String> headerKeySet = new HashSet<String>(headers.keySet());
+
+ headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION.toLowerCase());
+ headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION.toLowerCase());
+ headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI.toLowerCase());
+
+ headerKeySet.remove(LOWERCASE_BREADCRUMB_ID);
+
+ for (String name : headerKeySet) {
+ Object value = headers.get(name);
+
+ if (value instanceof QName) {
+ soapHeader.addHeaderElement((QName)value);
+ } else {
+ if (value instanceof String) {
+ soapHeader.addAttribute(new QName(name), value + "");
+ }
+ }
+ }
+ }
+
+ /**
+ * Populate SOAP attachments from in or out exchange message. This the
+ * convenient method for overriding.
+ *
+ * @param inOrOut
+ * @param response
+ */
+ protected void doProcessSoapAttachments(Message inOrOut, SoapMessage response) {
+ Map<String, DataHandler> attachments = inOrOut.getAttachments();
+
+ Set<String> keySet = new HashSet<String>(attachments.keySet());
+ for (String key : keySet) {
+ response.addAttachment(key, attachments.get(key));
+ }
+ }
}
Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/MessageFilterResolvingDefaultsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/MessageFilterResolvingDefaultsTest.java?rev=1411687&r1=1411686&r2=1411687&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/MessageFilterResolvingDefaultsTest.java (original)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/MessageFilterResolvingDefaultsTest.java Tue Nov 20 14:44:08 2012
@@ -1,3 +1,19 @@
+/**
+ * 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.spring.ws;
import java.io.IOException;
@@ -19,57 +35,49 @@ import org.springframework.ws.WebService
import org.springframework.ws.test.client.RequestMatcher;
/**
- * Check if the MessageFilter is used and resolved from endpoint uri or global context configuration.
- *
- *
+ * Check if the MessageFilter is used and resolved from endpoint uri or global
+ * context configuration.
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:org/apache/camel/component/spring/ws/DefaultMessageFilter-context.xml" })
+@ContextConfiguration(locations = {"classpath:org/apache/camel/component/spring/ws/DefaultMessageFilter-context.xml"})
public class MessageFilterResolvingDefaultsTest extends AbstractSmockClientTest {
- private String body = "<customerCountRequest xmlns='http://springframework.org/spring-ws'>"
- + "<customerName>John Doe</customerName>"
- + "</customerCountRequest>";
-
-
- @Test
- public void isUsedDefaultFilter() {
- expect(soapHeader(new QName("http://newHeaderSupport/", "testHeaderValue1")))
- .andExpect(doesntContains(soapHeader(new QName("http://virtualCheck/", "localFilter"))))
- .andExpect(doesntContains(soapHeader(new QName("http://virtualCheck/", "globalFilter"))));
-
- template.sendBodyAndHeader("direct:sendDefault", body,
- "headerKey", new QName("http://newHeaderSupport/", "testHeaderValue1"));
-
- }
-
-
- private RequestMatcher doesntContains(final RequestMatcher soapHeader) {
- return new RequestMatcher() {
- public void match(URI uri, WebServiceMessage request)
- throws IOException, AssertionError {
- try {
- soapHeader.match(uri, request);
-
- } catch (AssertionError e) {
- // ok
- return;
- }
- throw new AssertionError("Should failed!");
- }
- };
- }
-
- @Autowired
- private ProducerTemplate template;
-
- @Autowired
- public void setApplicationContext(ApplicationContext applicationContext) {
- createServer(applicationContext);
- }
-
- @After
- public void verify() {
- super.verify();
- }
-}
\ No newline at end of file
+ @Autowired
+ private ProducerTemplate template;
+
+ private String body = "<customerCountRequest xmlns='http://springframework.org/spring-ws'>" + "<customerName>John Doe</customerName>" + "</customerCountRequest>";
+
+ @Test
+ public void isUsedDefaultFilter() {
+ expect(soapHeader(new QName("http://newHeaderSupport/", "testHeaderValue1"))).andExpect(doesntContains(soapHeader(new QName("http://virtualCheck/", "localFilter"))))
+ .andExpect(doesntContains(soapHeader(new QName("http://virtualCheck/", "globalFilter"))));
+
+ template.sendBodyAndHeader("direct:sendDefault", body, "headerKey", new QName("http://newHeaderSupport/", "testHeaderValue1"));
+
+ }
+
+ private RequestMatcher doesntContains(final RequestMatcher soapHeader) {
+ return new RequestMatcher() {
+ public void match(URI uri, WebServiceMessage request) throws IOException, AssertionError {
+ try {
+ soapHeader.match(uri, request);
+
+ } catch (AssertionError e) {
+ // ok
+ return;
+ }
+ throw new AssertionError("Should failed!");
+ }
+ };
+ }
+
+ @Autowired
+ public void setApplicationContext(ApplicationContext applicationContext) {
+ createServer(applicationContext);
+ }
+
+ @After
+ public void verify() {
+ super.verify();
+ }
+}
Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/MessageFilterResolvingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/MessageFilterResolvingTest.java?rev=1411687&r1=1411686&r2=1411687&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/MessageFilterResolvingTest.java (original)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/MessageFilterResolvingTest.java Tue Nov 20 14:44:08 2012
@@ -1,3 +1,19 @@
+/**
+ * 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.spring.ws;
import java.io.IOException;
@@ -19,74 +35,62 @@ import org.springframework.ws.WebService
import org.springframework.ws.test.client.RequestMatcher;
/**
- * Check if the MessageFilter is used and resolved from endpoint uri or global context configuration.
- *
- *
+ * Check if the MessageFilter is used and resolved from endpoint uri or global
+ * context configuration.
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:org/apache/camel/component/spring/ws/MessageFilter-context.xml" })
+@ContextConfiguration(locations = {"classpath:org/apache/camel/component/spring/ws/MessageFilter-context.xml"})
public class MessageFilterResolvingTest extends AbstractSmockClientTest {
+ @Autowired
+ private ProducerTemplate template;
+
+ private String body = "<customerCountRequest xmlns='http://springframework.org/spring-ws'>" + "<customerName>John Doe</customerName>" + "</customerCountRequest>";
- private String body = "<customerCountRequest xmlns='http://springframework.org/spring-ws'>"
- + "<customerName>John Doe</customerName>"
- + "</customerCountRequest>";
-
- @Test
- public void global_testHeaderAttribute() {
- expect(soapHeader(new QName("http://newHeaderSupport/", "testHeaderValue1")))
- .andExpect(soapHeader(new QName("http://virtualCheck/", "globalFilter")));
-
- template.sendBodyAndHeader("direct:sendWithGlobalFilter", body,
- "headerKey", new QName("http://newHeaderSupport/", "testHeaderValue1"));
- }
-
- @Test
- public void local_testHeaderAttribute() {
- expect(soapHeader(new QName("http://newHeaderSupport/", "testHeaderValue1")))
- .andExpect(soapHeader(new QName("http://virtualCheck/", "localFilter")));
-
- template.sendBodyAndHeader("direct:sendWithLocalFilter", body,
- "headerKey", new QName("http://newHeaderSupport/", "testHeaderValue1"));
-
- }
-
-
- @Test
- public void empty_testHeaderAttribute() {
- expect(doesntContains(soapHeader(new QName("http://newHeaderSupport/",
- "testHeaderValue1"))));
-
- template.sendBodyAndHeader("direct:sendWithoutFilter", body,
- "headerKey", new QName("http://newHeaderSupport/", "testHeaderValue1"));
-
- }
-
- private RequestMatcher doesntContains(final RequestMatcher soapHeader) {
- return new RequestMatcher() {
- public void match(URI uri, WebServiceMessage request)
- throws IOException, AssertionError {
- try {
- soapHeader.match(uri, request);
-
- } catch (AssertionError e) {
- // ok
- return;
- }
- throw new AssertionError("Should failed!");
- }
- };
- }
-
- @Autowired
- private ProducerTemplate template;
-
- @Autowired
- public void setApplicationContext(ApplicationContext applicationContext) {
- createServer(applicationContext);
- }
-
- @After
- public void verify() {
- super.verify();
- }
-}
\ No newline at end of file
+ @Test
+ public void globalTestHeaderAttribute() {
+ expect(soapHeader(new QName("http://newHeaderSupport/", "testHeaderValue1"))).andExpect(soapHeader(new QName("http://virtualCheck/", "globalFilter")));
+
+ template.sendBodyAndHeader("direct:sendWithGlobalFilter", body, "headerKey", new QName("http://newHeaderSupport/", "testHeaderValue1"));
+ }
+
+ @Test
+ public void localTestHeaderAttribute() {
+ expect(soapHeader(new QName("http://newHeaderSupport/", "testHeaderValue1"))).andExpect(soapHeader(new QName("http://virtualCheck/", "localFilter")));
+
+ template.sendBodyAndHeader("direct:sendWithLocalFilter", body, "headerKey", new QName("http://newHeaderSupport/", "testHeaderValue1"));
+
+ }
+
+ @Test
+ public void emptyTestHeaderAttribute() {
+ expect(doesntContains(soapHeader(new QName("http://newHeaderSupport/", "testHeaderValue1"))));
+
+ template.sendBodyAndHeader("direct:sendWithoutFilter", body, "headerKey", new QName("http://newHeaderSupport/", "testHeaderValue1"));
+
+ }
+
+ private RequestMatcher doesntContains(final RequestMatcher soapHeader) {
+ return new RequestMatcher() {
+ public void match(URI uri, WebServiceMessage request) throws IOException, AssertionError {
+ try {
+ soapHeader.match(uri, request);
+
+ } catch (AssertionError e) {
+ // ok
+ return;
+ }
+ throw new AssertionError("Should failed!");
+ }
+ };
+ }
+
+ @Autowired
+ public void setApplicationContext(ApplicationContext applicationContext) {
+ createServer(applicationContext);
+ }
+
+ @After
+ public void verify() {
+ super.verify();
+ }
+}
Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilterTest.java?rev=1411687&r1=1411686&r2=1411687&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilterTest.java (original)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilterTest.java Tue Nov 20 14:44:08 2012
@@ -1,3 +1,19 @@
+/**
+ * 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.spring.ws.filter.impl;
import javax.activation.DataHandler;
@@ -18,150 +34,125 @@ import org.springframework.ws.soap.saaj.
@RunWith(value = JUnit4.class)
public class BasicMessageFilterTest extends ExchangeTestSupport {
- private BasicMessageFilter filter;
- private SoapMessage message;
+ private BasicMessageFilter filter;
+ private SoapMessage message;
- @Before
- public void Before() {
- filter = new BasicMessageFilter();
- SaajSoapMessageFactory saajSoapMessageFactory = new SaajSoapMessageFactory();
- saajSoapMessageFactory.afterPropertiesSet();
- message = saajSoapMessageFactory.createWebServiceMessage();
- }
-
- @Test
- public void testNulls() throws Exception {
- filter.filterConsumer(null, null);
- filter.filterProducer(null, null);
- }
-
- @Test
- public void testNullsWithExchange() throws Exception {
- filter.filterConsumer(exchange, null);
- filter.filterProducer(exchange, null);
- }
-
- @Test
- public void NonSoapMessageShouldBeSkipped() throws Exception {
- DomPoxMessage domPoxMessage = new DomPoxMessageFactory()
- .createWebServiceMessage();
- filter.filterConsumer(exchange, domPoxMessage);
- filter.filterProducer(exchange, domPoxMessage);
-
- }
-
- @Test
- public void withoutHeader() throws Exception {
- exchange.getIn().getHeaders().clear();
- exchange.getOut().getHeaders().clear();
-
- exchange.getIn().getAttachments().clear();
- exchange.getOut().getAttachments().clear();
-
- filter.filterProducer(exchange, message);
- filter.filterConsumer(exchange, message);
-
- Assertions.assertThat(message.getAttachments()).isEmpty();
- Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements()).isEmpty();
-
- Assertions.assertThat(message.getSoapHeader().getAllAttributes()).isEmpty();
- }
-
-
- @Test
- public void removeCamelInternalHeaderAttributes() throws Exception {
- exchange.getOut()
- .getHeaders()
- .put(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION,
- "mustBeRemoved");
- exchange.getOut()
- .getHeaders()
- .put(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION,
- "mustBeRemoved");
- exchange.getOut()
- .getHeaders()
- .put(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI,
- "mustBeRemoved");
-
- exchange.getOut().getHeaders().put("breadcrumbId", "mustBeRemoved");
-
- filter.filterConsumer(exchange, message);
-
- Assertions.assertThat(message.getAttachments()).isEmpty();
- Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements()).isEmpty();
-
- Assertions.assertThat(message.getSoapHeader().getAllAttributes()).isEmpty();
- }
-
- @Test
- public void consumer_withHeader() throws Exception {
- exchange.getOut().getHeaders()
- .put("headerAttributeKey", "testAttributeValue");
- exchange.getOut()
- .getHeaders()
- .put("headerAttributeElement",
- new QName("http://shouldBeInHeader", "<myElement />"));
- filter.filterConsumer(exchange, message);
-
- Assertions.assertThat(message.getAttachments()).isEmpty();
-
- Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements())
- .isNotEmpty().hasSize(1);
-
- Assertions.assertThat(message.getSoapHeader().getAllAttributes())
- .isNotEmpty().hasSize(1);
-
- }
-
- @Test
- public void producer_withHeader() throws Exception {
- // foo is already in the header.in from the parent ExchangeTestSupport
- exchange.getIn().getHeaders()
- .put("headerAttributeKey", "testAttributeValue");
- exchange.getIn()
- .getHeaders()
- .put("headerAttributeElement",
- new QName("http://shouldBeInHeader", "<myElement />"));
-
- filter.filterProducer(exchange, message);
-
- Assertions.assertThat(message.getAttachments()).isEmpty();
-
- Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements())
- .isNotEmpty().hasSize(1);
-
- Assertions.assertThat(message.getSoapHeader().getAllAttributes())
- .isNotEmpty().hasSize(2);
-
- }
-
- @Test
- public void withoutAttachment() throws Exception {
- filter.filterConsumer(exchange, message);
- filter.filterProducer(exchange, message);
-
- Assertions.assertThat(message.getAttachments()).isEmpty();
- }
-
- @Test
- public void producer_withAttachment() throws Exception {
- exchange.getIn().addAttachment( "testAttachment",
- new DataHandler(this.getClass().getResource("/sampleAttachment.txt")));
-
- filter.filterProducer(exchange, message);
-
- Assertions.assertThat(message.getAttachments()).isNotNull().isNotEmpty();
- Assertions.assertThat(message.getAttachment("testAttachment")).isNotNull();
- }
-
- @Test
- public void consumer_withAttachment() throws Exception {
- exchange.getOut().addAttachment( "testAttachment",
- new DataHandler(this.getClass().getResource("/sampleAttachment.txt")));
-
- filter.filterConsumer(exchange, message);
-
- Assertions.assertThat(message.getAttachments()).isNotNull().isNotEmpty();
- Assertions.assertThat(message.getAttachment("testAttachment")).isNotNull();
- }
+ @Before
+ public void before() {
+ filter = new BasicMessageFilter();
+ SaajSoapMessageFactory saajSoapMessageFactory = new SaajSoapMessageFactory();
+ saajSoapMessageFactory.afterPropertiesSet();
+ message = saajSoapMessageFactory.createWebServiceMessage();
+ }
+
+ @Test
+ public void testNulls() throws Exception {
+ filter.filterConsumer(null, null);
+ filter.filterProducer(null, null);
+ }
+
+ @Test
+ public void testNullsWithExchange() throws Exception {
+ filter.filterConsumer(exchange, null);
+ filter.filterProducer(exchange, null);
+ }
+
+ @Test
+ public void nonSoapMessageShouldBeSkipped() throws Exception {
+ DomPoxMessage domPoxMessage = new DomPoxMessageFactory().createWebServiceMessage();
+ filter.filterConsumer(exchange, domPoxMessage);
+ filter.filterProducer(exchange, domPoxMessage);
+
+ }
+
+ @Test
+ public void withoutHeader() throws Exception {
+ exchange.getIn().getHeaders().clear();
+ exchange.getOut().getHeaders().clear();
+
+ exchange.getIn().getAttachments().clear();
+ exchange.getOut().getAttachments().clear();
+
+ filter.filterProducer(exchange, message);
+ filter.filterConsumer(exchange, message);
+
+ Assertions.assertThat(message.getAttachments()).isEmpty();
+ Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements()).isEmpty();
+
+ Assertions.assertThat(message.getSoapHeader().getAllAttributes()).isEmpty();
+ }
+
+ @Test
+ public void removeCamelInternalHeaderAttributes() throws Exception {
+ exchange.getOut().getHeaders().put(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION, "mustBeRemoved");
+ exchange.getOut().getHeaders().put(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION, "mustBeRemoved");
+ exchange.getOut().getHeaders().put(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI, "mustBeRemoved");
+
+ exchange.getOut().getHeaders().put("breadcrumbId", "mustBeRemoved");
+
+ filter.filterConsumer(exchange, message);
+
+ Assertions.assertThat(message.getAttachments()).isEmpty();
+ Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements()).isEmpty();
+
+ Assertions.assertThat(message.getSoapHeader().getAllAttributes()).isEmpty();
+ }
+
+ @Test
+ public void consumerWithHeader() throws Exception {
+ exchange.getOut().getHeaders().put("headerAttributeKey", "testAttributeValue");
+ exchange.getOut().getHeaders().put("headerAttributeElement", new QName("http://shouldBeInHeader", "<myElement />"));
+ filter.filterConsumer(exchange, message);
+
+ Assertions.assertThat(message.getAttachments()).isEmpty();
+
+ Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements()).isNotEmpty().hasSize(1);
+
+ Assertions.assertThat(message.getSoapHeader().getAllAttributes()).isNotEmpty().hasSize(1);
+
+ }
+
+ @Test
+ public void producerWithHeader() throws Exception {
+ // foo is already in the header.in from the parent ExchangeTestSupport
+ exchange.getIn().getHeaders().put("headerAttributeKey", "testAttributeValue");
+ exchange.getIn().getHeaders().put("headerAttributeElement", new QName("http://shouldBeInHeader", "<myElement />"));
+
+ filter.filterProducer(exchange, message);
+
+ Assertions.assertThat(message.getAttachments()).isEmpty();
+
+ Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements()).isNotEmpty().hasSize(1);
+
+ Assertions.assertThat(message.getSoapHeader().getAllAttributes()).isNotEmpty().hasSize(2);
+
+ }
+
+ @Test
+ public void withoutAttachment() throws Exception {
+ filter.filterConsumer(exchange, message);
+ filter.filterProducer(exchange, message);
+
+ Assertions.assertThat(message.getAttachments()).isEmpty();
+ }
+
+ @Test
+ public void producerWithAttachment() throws Exception {
+ exchange.getIn().addAttachment("testAttachment", new DataHandler(this.getClass().getResource("/sampleAttachment.txt")));
+
+ filter.filterProducer(exchange, message);
+
+ Assertions.assertThat(message.getAttachments()).isNotNull().isNotEmpty();
+ Assertions.assertThat(message.getAttachment("testAttachment")).isNotNull();
+ }
+
+ @Test
+ public void consumerWithAttachment() throws Exception {
+ exchange.getOut().addAttachment("testAttachment", new DataHandler(this.getClass().getResource("/sampleAttachment.txt")));
+
+ filter.filterConsumer(exchange, message);
+
+ Assertions.assertThat(message.getAttachments()).isNotNull().isNotEmpty();
+ Assertions.assertThat(message.getAttachment("testAttachment")).isNotNull();
+ }
}
Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/EmptyMessageFilter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/EmptyMessageFilter.java?rev=1411687&r1=1411686&r2=1411687&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/EmptyMessageFilter.java (original)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/EmptyMessageFilter.java Tue Nov 20 14:44:08 2012
@@ -1,3 +1,19 @@
+/**
+ * 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.spring.ws.testfilters;
import org.apache.camel.Exchange;
@@ -6,18 +22,16 @@ import org.springframework.ws.WebService
public class EmptyMessageFilter implements MessageFilter {
- @Override
- public void filterProducer(Exchange exchange,
- WebServiceMessage produceResponse) {
- // Do nothing
-
- }
-
- @Override
- public void filterConsumer(Exchange exchange,
- WebServiceMessage consumerResponse) {
- // Do nothing
+ @Override
+ public void filterProducer(Exchange exchange, WebServiceMessage produceResponse) {
+ // Do nothing
- }
+ }
+
+ @Override
+ public void filterConsumer(Exchange exchange, WebServiceMessage consumerResponse) {
+ // Do nothing
+
+ }
}
Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/GlobalMessageFilter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/GlobalMessageFilter.java?rev=1411687&r1=1411686&r2=1411687&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/GlobalMessageFilter.java (original)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/GlobalMessageFilter.java Tue Nov 20 14:44:08 2012
@@ -1,3 +1,19 @@
+/**
+ * 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.spring.ws.testfilters;
import javax.xml.namespace.QName;
@@ -8,16 +24,12 @@ import org.springframework.ws.soap.SoapM
public class GlobalMessageFilter extends BasicMessageFilter {
- /**
- * Add a test marker so the test method is aware which filter we are using.
- */
- @Override
- protected void doProcessSoapAttachments(Message inOrOut,
- SoapMessage response) {
- super.doProcessSoapAttachments(inOrOut, response);
- response.getEnvelope()
- .getHeader()
- .addHeaderElement(
- new QName("http://virtualCheck/", "globalFilter"));
- }
+ /**
+ * Add a test marker so the test method is aware which filter we are using.
+ */
+ @Override
+ protected void doProcessSoapAttachments(Message inOrOut, SoapMessage response) {
+ super.doProcessSoapAttachments(inOrOut, response);
+ response.getEnvelope().getHeader().addHeaderElement(new QName("http://virtualCheck/", "globalFilter"));
+ }
}
Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/LocalMessageFilter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/LocalMessageFilter.java?rev=1411687&r1=1411686&r2=1411687&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/LocalMessageFilter.java (original)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/testfilters/LocalMessageFilter.java Tue Nov 20 14:44:08 2012
@@ -1,3 +1,19 @@
+/**
+ * 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.spring.ws.testfilters;
import javax.xml.namespace.QName;
@@ -8,17 +24,13 @@ import org.springframework.ws.soap.SoapM
public class LocalMessageFilter extends BasicMessageFilter {
- /**
- * Add a test marker so the test method is aware which filter we are using.
- */
- @Override
- protected void doProcessSoapAttachments(Message inOrOut,
- SoapMessage response) {
- super.doProcessSoapAttachments(inOrOut, response);
- response.getEnvelope()
- .getHeader()
- .addHeaderElement(
- new QName("http://virtualCheck/", "localFilter"));
- }
+ /**
+ * Add a test marker so the test method is aware which filter we are using.
+ */
+ @Override
+ protected void doProcessSoapAttachments(Message inOrOut, SoapMessage response) {
+ super.doProcessSoapAttachments(inOrOut, response);
+ response.getEnvelope().getHeader().addHeaderElement(new QName("http://virtualCheck/", "localFilter"));
+ }
}