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 2012/11/12 10:14:00 UTC
svn commit: r1408194 - in /camel/branches/camel-2.10.x: ./
components/camel-cxf/src/test/java/org/apache/camel/component/cxf/
components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/
components/camel-cxf/src/test/resources/org/apache/ca...
Author: davsclaus
Date: Mon Nov 12 09:13:59 2012
New Revision: 1408194
URL: http://svn.apache.org/viewvc?rev=1408194&view=rev
Log:
Fixed test and polished
Added:
camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCache2Test.java
- copied unchanged from r1408185, camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCache2Test.java
Modified:
camel/branches/camel-2.10.x/ (props changed)
camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerResponseTest.java
camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java
camel/branches/camel-2.10.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest2.xml
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1408185
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerResponseTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerResponseTest.java?rev=1408194&r1=1408193&r2=1408194&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerResponseTest.java (original)
+++ camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerResponseTest.java Mon Nov 12 09:13:59 2012
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.component.cxf;
import java.util.HashMap;
@@ -35,7 +34,6 @@ import org.apache.cxf.frontend.ClientFac
import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.junit.Test;
-
public class CxfConsumerResponseTest extends CamelTestSupport {
private static final String ECHO_OPERATION = "echo";
@@ -44,9 +42,9 @@ public class CxfConsumerResponseTest ext
private static final String TEST_MESSAGE = "Hello World!";
private static int pingCounter;
-
protected final String simpleEndpointAddress = "http://localhost:"
+ CXFTestSupport.getPort1() + "/" + getClass().getSimpleName() + "/test";
+
protected final String simpleEndpointURI = "cxf://" + simpleEndpointAddress
+ "?serviceClass=org.apache.camel.component.cxf.HelloService"
+ "&publishedEndpointUrl=http://www.simple.com/services/test";
@@ -56,48 +54,50 @@ public class CxfConsumerResponseTest ext
public boolean isCreateCamelContextPerClass() {
return true;
}
+
// START SNIPPET: example
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from(simpleEndpointURI).inOnly("log:test").choice().when(header(CxfConstants.OPERATION_NAME).isEqualTo(ECHO_OPERATION)).process(new Processor() {
- public void process(final Exchange exchange) {
- assertEquals(DataFormat.POJO, exchange.getProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.class));
- Message in = exchange.getIn();
- // check the remote IP from the cxfMessage
- org.apache.cxf.message.Message cxfMessage = in.getHeader(CxfConstants.CAMEL_CXF_MESSAGE, org.apache.cxf.message.Message.class);
- assertNotNull("Should get the cxfMessage instance from message header", cxfMessage);
- ServletRequest request = (ServletRequest)cxfMessage.get("HTTP.REQUEST");
- assertNotNull("Should get the ServletRequest", request);
- assertNotNull("Should get the RemoteAddress" + request.getRemoteAddr());
- // Get the parameter list
- List<?> parameter = in.getBody(List.class);
- // Get the operation name
- String operation = (String)in.getHeader(CxfConstants.OPERATION_NAME);
- Object result = operation + " " + (String)parameter.get(0);
- // Put the result back
- exchange.getIn().setBody(result);
- // set up the response context which force start document
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("org.apache.cxf.stax.force-start-document", Boolean.TRUE);
- exchange.getIn().setHeader(Client.RESPONSE_CONTEXT, map);
- }
- })
- .when(header(CxfConstants.OPERATION_NAME).isEqualTo(ECHO_BOOLEAN_OPERATION)).process(new Processor() {
- public void process(final Exchange exchange) {
- Message in = exchange.getIn();
- // Get the parameter list
- List<?> parameter = in.getBody(List.class);
- // Put the result back
- exchange.getOut().setBody(parameter.get(0));
- }
- })
- .when(header(CxfConstants.OPERATION_NAME).isEqualTo(PING_OPERATION)).process(new Processor() {
- public void process(final Exchange exchange) {
- pingCounter++;
- }
-
- });
+ from(simpleEndpointURI).inOnly("log:test")
+ .choice().when(header(CxfConstants.OPERATION_NAME).isEqualTo(ECHO_OPERATION)).process(new Processor() {
+ public void process(final Exchange exchange) {
+ assertEquals(DataFormat.POJO, exchange.getProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.class));
+ Message in = exchange.getIn();
+ // check the remote IP from the cxfMessage
+ org.apache.cxf.message.Message cxfMessage = in.getHeader(CxfConstants.CAMEL_CXF_MESSAGE, org.apache.cxf.message.Message.class);
+ assertNotNull("Should get the cxfMessage instance from message header", cxfMessage);
+ ServletRequest request = (ServletRequest)cxfMessage.get("HTTP.REQUEST");
+ assertNotNull("Should get the ServletRequest", request);
+ assertNotNull("Should get the RemoteAddress" + request.getRemoteAddr());
+ // Get the parameter list
+ List<?> parameter = in.getBody(List.class);
+ // Get the operation name
+ String operation = (String)in.getHeader(CxfConstants.OPERATION_NAME);
+ Object result = operation + " " + (String)parameter.get(0);
+ // Put the result back
+ exchange.getIn().setBody(result);
+ // set up the response context which force start document
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("org.apache.cxf.stax.force-start-document", Boolean.TRUE);
+ exchange.getIn().setHeader(Client.RESPONSE_CONTEXT, map);
+ }
+ })
+ .when(header(CxfConstants.OPERATION_NAME).isEqualTo(ECHO_BOOLEAN_OPERATION)).process(new Processor() {
+ public void process(final Exchange exchange) {
+ Message in = exchange.getIn();
+ // Get the parameter list
+ List<?> parameter = in.getBody(List.class);
+ // Put the result back
+ exchange.getOut().setBody(parameter.get(0));
+ }
+ })
+ .when(header(CxfConstants.OPERATION_NAME).isEqualTo(PING_OPERATION)).process(new Processor() {
+ public void process(final Exchange exchange) {
+ pingCounter++;
+ }
+
+ });
}
};
@@ -113,6 +113,7 @@ public class CxfConsumerResponseTest ext
clientBean.setBus(BusFactory.getDefaultBus());
HelloService client = (HelloService) proxyFactory.create();
+ assertNotNull(client);
String result = client.echo(TEST_MESSAGE);
assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);
Modified: camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java?rev=1408194&r1=1408193&r2=1408194&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java (original)
+++ camel/branches/camel-2.10.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java Mon Nov 12 09:13:59 2012
@@ -38,12 +38,9 @@ import org.springframework.context.suppo
*/
public class CxfRsProducerClientFactoryCacheTest extends Assert {
private static int port1 = CXFTestSupport.getPort1();
- private static int port2 = CXFTestSupport.getPort2();
private CamelContext context1;
- private CamelContext context2;
private ProducerTemplate template1;
- private ProducerTemplate template2;
@Before
public void setUp() throws Exception {
@@ -52,13 +49,6 @@ public class CxfRsProducerClientFactoryC
context1.start();
template1 = context1.createProducerTemplate();
template1.start();
-
- ac = new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest2.xml");
- context2 = SpringCamelContext.springCamelContext(ac, false);
- context2.start();
-
- template2 = context2.createProducerTemplate();
- template2.start();
}
@After
@@ -67,20 +57,14 @@ public class CxfRsProducerClientFactoryC
context1.stop();
template1.stop();
}
-
- if (context2 != null) {
- context2.stop();
- template2.stop();
- }
}
@Test
public void testGetCostumerWithHttpCentralClientAPI() throws Exception {
- doRunTest(template2);
- doRunTest(template1);
+ doRunTest(template1, getPort1());
}
- private void doRunTest(ProducerTemplate template) {
+ private void doRunTest(ProducerTemplate template, final int clientPort) {
Exchange exchange = template.send("direct://http", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
@@ -89,7 +73,7 @@ public class CxfRsProducerClientFactoryC
inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
inMessage.setHeader(Exchange.HTTP_PATH, "/customerservice/customers/123");
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Customer.class);
- inMessage.setHeader("port", getPort2());
+ inMessage.setHeader("clientPort", clientPort);
inMessage.setBody(null);
}
});
@@ -107,7 +91,4 @@ public class CxfRsProducerClientFactoryC
return port1;
}
- public int getPort2() {
- return port2;
- }
}
Modified: camel/branches/camel-2.10.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest2.xml
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest2.xml?rev=1408194&r1=1408193&r2=1408194&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest2.xml (original)
+++ camel/branches/camel-2.10.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest2.xml Mon Nov 12 09:13:59 2012
@@ -28,7 +28,7 @@
http://cxf.apache.org/schemas/configuration/http-conf.xsd ">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
- <jaxrs:server id="restService" address="https://localhost:${CXFTestSupport.port2}/CxfRsProducerTest/"
+ <jaxrs:server id="restService" address="https://localhost:${mySecurePort}/CxfRsProducerTest/"
staticSubresourceResolution="true">
<jaxrs:serviceBeans>
<ref bean="customerService"/>
@@ -41,13 +41,13 @@
<route>
<from uri="direct://http"/>
<recipientList>
- <simple>cxfrs://https://localhost:${header.port}/CxfRsProducerTest/</simple>
+ <simple>cxfrs://https://localhost:${header.clientPort}/CxfRsProducerTest/</simple>
</recipientList>
</route>
</camelContext>
<httpj:engine-factory id="tls-config">
- <httpj:engine port="${CXFTestSupport.port2}">
+ <httpj:engine port="${mySecurePort}">
<httpj:tlsServerParameters>
<sec:keyManagers keyPassword="password">
<sec:keyStore type="JKS" password="password" file="src/test/resources/org/apache/camel/component/cxf/jaxrs/Bethal.jks"/>