Author: dvaleri
Date: Fri Apr 20 03:13:51 2012
New Revision: 1328185
URL: http://svn.apache.org/viewvc?rev=1328185&view=rev
Log:
[CAMEL-4297] Moved message sender initialization to producer initialization,
corrected problematic WebServiceTemplate sharing in tests, and fixed issue with
setting timeout on certain message sender implementations.
Modified:
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTest.java
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTimeOutTest.java
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ProducerRemoteRouteTimeOutTest-context.xml
Modified:
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java?rev=1328185&r1=1328184&r2=1328185&view=diff
==============================================================================
---
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java
(original)
+++
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java
Fri Apr 20 03:13:51 2012
@@ -56,6 +56,7 @@ public class SpringWebserviceProducer ex
public SpringWebserviceProducer(Endpoint endpoint) {
super(endpoint);
+ prepareMessageSenders(getEndpoint().getConfiguration());
}
@Override
@@ -72,9 +73,6 @@ public class SpringWebserviceProducer ex
String soapAction =
exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION,
String.class);
URI wsAddressingAction =
exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION,
URI.class);
- // Populate the given (read) timeout if any
- prepareMessageSenders(getEndpoint().getConfiguration());
-
WebServiceMessageCallback callback = new
DefaultWebserviceMessageCallback(soapAction, wsAddressingAction,
getEndpoint().getConfiguration());
Object body = null;
if (endpointUri != null) {
@@ -88,7 +86,7 @@ public class SpringWebserviceProducer ex
}
}
- private static void prepareMessageSenders(SpringWebserviceConfiguration
configuration) throws Exception {
+ private static void prepareMessageSenders(SpringWebserviceConfiguration
configuration) {
// Skip this whole thing if none of the relevant config options are
set.
if (!(configuration.getTimeout() > -1) &&
configuration.getSslContextParameters() == null) {
return;
@@ -108,7 +106,13 @@ public class SpringWebserviceProducer ex
}
if (configuration.getTimeout() > -1) {
-
((CommonsHttpMessageSender)messageSender).setReadTimeout(configuration.getTimeout());
+ if
(messageSender.getClass().equals(CommonsHttpMessageSender.class)) {
+
((CommonsHttpMessageSender)messageSender).setReadTimeout(configuration.getTimeout());
+ } else {
+ LOG.warn("Not applying timeout configuration to
CommonsHttpMessageSender based implementation. "
+ + "You are using what appears to be a custom
MessageSender, which you are not doing by default. "
+ + "You will need configure timeout on your
own.");
+ }
}
} else if
(messageSender.getClass().equals(HttpUrlConnectionMessageSender.class)) {
// Only if exact match denoting likely use of default
configuration. We don't want to get
Modified:
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTest.java?rev=1328185&r1=1328184&r2=1328185&view=diff
==============================================================================
---
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTest.java
(original)
+++
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTest.java
Fri Apr 20 03:13:51 2012
@@ -28,7 +28,7 @@ import org.springframework.test.context.
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-
+@Ignore("Run manually, makes connection to external webservice")
@ContextConfiguration
public class ProducerRemoteRouteTest extends AbstractJUnit4SpringContextTests {
@@ -38,7 +38,6 @@ public class ProducerRemoteRouteTest ext
@Produce
private ProducerTemplate template;
- @Ignore("Run manually, makes connection to external webservice")
@Test(timeout = 5000)
public void consumeStockQuoteWebserviceWithDefaultTemplate() throws
Exception {
Object result =
template.requestBody("direct:stockQuoteWebserviceWithDefaultTemplate",
xmlRequestForGoogleStockQuote);
@@ -47,7 +46,6 @@ public class ProducerRemoteRouteTest ext
assertTrue(result instanceof Source);
}
- @Ignore("Run manually, makes connection to external webservice")
@Test(timeout = 5000)
public void consumeStockQuoteWebservice() throws Exception {
Object result = template.requestBody("direct:stockQuoteWebservice",
xmlRequestForGoogleStockQuote);
@@ -56,7 +54,6 @@ public class ProducerRemoteRouteTest ext
assertTrue(result instanceof Source);
}
- @Ignore("Run manually, makes connection to external webservice")
@Test(timeout = 5000)
public void consumeStockQuoteWebserviceWithCamelStringSourceInput() throws
Exception {
Object result = template.requestBody("direct:stockQuoteWebservice",
new StringSource(xmlRequestForGoogleStockQuote));
@@ -65,7 +62,6 @@ public class ProducerRemoteRouteTest ext
assertTrue(result instanceof Source);
}
- @Ignore("Run manually, makes connection to external webservice")
@Test(timeout = 5000)
public void consumeStockQuoteWebserviceWithNonDefaultMessageFactory()
throws Exception {
Object result =
template.requestBody("direct:stockQuoteWebserviceWithNonDefaultMessageFactory",
xmlRequestForGoogleStockQuote);
@@ -74,7 +70,6 @@ public class ProducerRemoteRouteTest ext
assertTrue(result instanceof Source);
}
- @Ignore("Run manually, makes connection to external webservice")
@Test(timeout = 5000)
public void consumeStockQuoteWebserviceAndConvertResult() throws Exception
{
Object result =
template.requestBody("direct:stockQuoteWebserviceAsString",
xmlRequestForGoogleStockQuote);
@@ -85,7 +80,6 @@ public class ProducerRemoteRouteTest ext
assertTrue(resultMessage.contains("Google Inc."));
}
- @Ignore("Run manually, makes connection to external webservice")
@Test(timeout = 5000)
public void consumeStockQuoteWebserviceAndProvideEndpointUriByHeader()
throws Exception {
Object result =
template.requestBodyAndHeader("direct:stockQuoteWebserviceWithoutDefaultUri",
xmlRequestForGoogleStockQuote,
Modified:
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTimeOutTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTimeOutTest.java?rev=1328185&r1=1328184&r2=1328185&view=diff
==============================================================================
---
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTimeOutTest.java
(original)
+++
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTimeOutTest.java
Fri Apr 20 03:13:51 2012
@@ -32,6 +32,7 @@ import static org.junit.Assert.assertNot
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+@Ignore("Run manually, makes connection to external webservice")
@ContextConfiguration
public class ProducerRemoteRouteTimeOutTest extends
AbstractJUnit4SpringContextTests {
@@ -40,9 +41,8 @@ public class ProducerRemoteRouteTimeOutT
@Produce
private ProducerTemplate template;
- @Ignore("Run manually, makes connection to external webservice")
@Test
- public void callStockQuoteWebserviceCommonsHttpWith3MillSecondsTimeout()
throws Exception {
+ public void callStockQuoteWebserviceCosmmonsHttpWith3MillSecondsTimeout()
throws Exception {
try {
template.requestBody("direct:stockQuoteWebserviceCommonsHttpWith3MillSecondsTimeout",
xmlRequestForGoogleStockQuote);
fail("Miss the expected exception in chain");
@@ -50,8 +50,7 @@ public class ProducerRemoteRouteTimeOutT
assertTrue(hasThrowableInChain(cee, SocketTimeoutException.class));
}
}
-
- @Ignore("Run manually, makes connection to external webservice")
+
@Test
public void
callStockQuoteWebserviceCommonsHttpWith5000MillSecondsTimeout() throws
Exception {
Object result =
template.requestBody("direct:stockQuoteWebserviceCommonsHttpWith5000MillSecondsTimeout",
xmlRequestForGoogleStockQuote);
@@ -61,8 +60,7 @@ public class ProducerRemoteRouteTimeOutT
String resultMessage = (String) result;
assertTrue(resultMessage.contains("Google Inc."));
}
-
- @Ignore("Run manually, makes connection to external webservice")
+
@Test
public void callStockQuoteWebserviceJDKWith3MillSecondsTimeout() throws
Exception {
try {
@@ -73,7 +71,6 @@ public class ProducerRemoteRouteTimeOutT
}
}
- @Ignore("Run manually, makes connection to external webservice")
@Test
public void callStockQuoteWebserviceJDKWith5000MillSecondsTimeout() throws
Exception {
Object result =
template.requestBody("direct:stockQuoteWebserviceJDKWith5000MillSecondsTimeout",
xmlRequestForGoogleStockQuote);
Modified:
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ProducerRemoteRouteTimeOutTest-context.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ProducerRemoteRouteTimeOutTest-context.xml?rev=1328185&r1=1328184&r2=1328185&view=diff
==============================================================================
---
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ProducerRemoteRouteTimeOutTest-context.xml
(original)
+++
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ProducerRemoteRouteTimeOutTest-context.xml
Fri Apr 20 03:13:51 2012
@@ -23,40 +23,44 @@
<bean id="messageFactory"
class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />
- <bean id="commonsHttpWebServiceTemplate"
class="org.springframework.ws.client.core.WebServiceTemplate">
+ <bean id="commonsHttpWebServiceTemplate1"
class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory" />
<property name="messageSender">
<bean
class="org.springframework.ws.transport.http.CommonsHttpMessageSender" />
</property>
</bean>
-
- <bean id="jdkHttpWebServiceTemplate"
class="org.springframework.ws.client.core.WebServiceTemplate">
- <constructor-arg ref="messageFactory" />
- </bean>
+
+ <bean id="commonsHttpWebServiceTemplate2"
class="org.springframework.ws.client.core.WebServiceTemplate">
+ <constructor-arg ref="messageFactory" />
+ <property name="messageSender">
+ <bean
+
class="org.springframework.ws.transport.http.CommonsHttpMessageSender" />
+ </property>
+ </bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from
uri="direct:stockQuoteWebserviceCommonsHttpWith3MillSecondsTimeout" />
- <to
uri="spring-ws:http://www.webservicex.net/stockquote.asmx?timeout=3&webServiceTemplate=#commonsHttpWebServiceTemplate&soapAction=http://www.webserviceX.NET/GetQuote"
/>
+ <to
uri="spring-ws:http://www.webservicex.net/stockquote.asmx?timeout=3&webServiceTemplate=#commonsHttpWebServiceTemplate1&soapAction=http://www.webserviceX.NET/GetQuote"
/>
<convertBodyTo type="java.lang.String"/>
</route>
<route>
<from
uri="direct:stockQuoteWebserviceCommonsHttpWith5000MillSecondsTimeout" />
- <to
uri="spring-ws:http://www.webservicex.net/stockquote.asmx?timeout=5000&webServiceTemplate=#commonsHttpWebServiceTemplate&soapAction=http://www.webserviceX.NET/GetQuote"
/>
+ <to
uri="spring-ws:http://www.webservicex.net/stockquote.asmx?timeout=5000&webServiceTemplate=#commonsHttpWebServiceTemplate2&soapAction=http://www.webserviceX.NET/GetQuote"
/>
<convertBodyTo type="java.lang.String"/>
</route>
<route>
<from
uri="direct:stockQuoteWebserviceJDKWith3MillSecondsTimeout" />
- <to
uri="spring-ws:http://www.webservicex.net/stockquote.asmx?timeout=3&webServiceTemplate=#jdkHttpWebServiceTemplate&soapAction=http://www.webserviceX.NET/GetQuote"
/>
+ <to
uri="spring-ws:http://www.webservicex.net/stockquote.asmx?timeout=3&soapAction=http://www.webserviceX.NET/GetQuote"
/>
<convertBodyTo type="java.lang.String"/>
</route>
<route>
<from
uri="direct:stockQuoteWebserviceJDKWith5000MillSecondsTimeout" />
- <to
uri="spring-ws:http://www.webservicex.net/stockquote.asmx?timeout=5000&webServiceTemplate=#jdkHttpWebServiceTemplate&soapAction=http://www.webserviceX.NET/GetQuote"
/>
+ <to
uri="spring-ws:http://www.webservicex.net/stockquote.asmx?timeout=5000&soapAction=http://www.webserviceX.NET/GetQuote"
/>
<convertBodyTo type="java.lang.String"/>
</route>
</camelContext>