You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by wt...@apache.org on 2009/09/18 23:23:30 UTC
svn commit: r816789 - in /camel/trunk/components/camel-cxf/src:
main/java/org/apache/camel/component/cxf/
test/java/org/apache/camel/component/cxf/
Author: wtam
Date: Fri Sep 18 21:23:28 2009
New Revision: 816789
URL: http://svn.apache.org/viewvc?rev=816789&view=rev
Log:
[CAMEL-2025] apply provided by Stan Lewis to address serviceClass-less cxf endpoint creation issue
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java (with props)
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java (with props)
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java
Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=816789&r1=816788&r2=816789&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java Fri Sep 18 21:23:28 2009
@@ -281,8 +281,14 @@
Client createClient() throws Exception {
// get service class
- ObjectHelper.notEmpty(getServiceClass(), CxfConstants.SERVICE_CLASS);
- Class<?> cls = ClassLoaderUtils.loadClass(getServiceClass(), getClass());
+ if (getDataFormat().equals(DataFormat.POJO)) {
+ ObjectHelper.notEmpty(getServiceClass(), CxfConstants.SERVICE_CLASS);
+ }
+
+ Class<?> cls = null;
+ if (getServiceClass() != null) {
+ cls = ClassLoaderUtils.loadClass(getServiceClass(), getClass());
+ }
// create client factory bean
ClientProxyFactoryBean factoryBean = createClientFactoryBean(cls);
@@ -290,7 +296,12 @@
// setup client factory bean
setupClientFactoryBean(factoryBean, cls);
- return ((ClientProxy)Proxy.getInvocationHandler(factoryBean.create())).getClient();
+ if (cls == null) {
+ return (Client)factoryBean.create();
+ } else {
+ return ((ClientProxy)Proxy.getInvocationHandler(factoryBean.create())).getClient();
+ }
+
}
@@ -298,10 +309,13 @@
* Create a CXF server factory bean
*/
ServerFactoryBean createServerFactoryBean() throws Exception {
-
- // get service class
- ObjectHelper.notEmpty(getServiceClass(), CxfConstants.SERVICE_CLASS);
- Class<?> cls = ClassLoaderUtils.loadClass(getServiceClass(), getClass());
+
+ Class<?> cls = null;
+ if (getDataFormat() == DataFormat.POJO || getServiceClass() != null) {
+ // get service class
+ ObjectHelper.notEmpty(getServiceClass(), CxfConstants.SERVICE_CLASS);
+ cls = ClassLoaderUtils.loadClass(getServiceClass(), getClass());
+ }
// create server factory bean
// Shouldn't use CxfEndpointUtils.getServerFactoryBean(cls) as it is for
Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java?rev=816789&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java (added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java Fri Sep 18 21:23:28 2009
@@ -0,0 +1,27 @@
+/**
+ * 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.cxf;
+
+public class CXFWsdlOnlyMessageModeNoSpringTest extends CXFWsdlOnlyPayloadModeNoSpringTest {
+
+ @Override
+ protected String getDataFormat() {
+ return "MESSAGE";
+
+ }
+
+}
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java?rev=816789&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java (added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java Fri Sep 18 21:23:28 2009
@@ -0,0 +1,81 @@
+/**
+ * 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.cxf;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Holder;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.wsdl_first.Person;
+import org.apache.camel.wsdl_first.PersonImpl;
+import org.apache.camel.wsdl_first.PersonService;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CXFWsdlOnlyPayloadModeNoSpringTest extends CamelTestSupport {
+
+ private Endpoint endpoint;
+
+ @Before
+ public void startService() {
+ endpoint = Endpoint.publish("http://localhost:8092/PersonService/", new PersonImpl());
+ }
+
+ @After
+ public void stopService() {
+ if (endpoint != null) {
+ endpoint.stop();
+ }
+
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("cxf://http://localhost:8092/PersonService?wsdlURL=classpath:person.wsdl&dataFormat=" + getDataFormat())
+ .to("cxf://http://localhost:8093/PersonService?wsdlURL=classpath:person.wsdl&dataFormat=" + getDataFormat());
+ }
+ };
+ }
+
+ protected String getDataFormat() {
+ return "PAYLOAD";
+ }
+
+ @Test
+ public void testRoutes() throws Exception {
+ URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
+ PersonService ss = new PersonService(wsdlURL, new QName("http://camel.apache.org/wsdl-first",
+ "PersonService"));
+ Person client = ss.getSoap();
+ Holder<String> personId = new Holder<String>();
+ personId.value = "hello";
+ Holder<String> ssn = new Holder<String>();
+ Holder<String> name = new Holder<String>();
+ client.getPerson(personId, ssn, name);
+ assertEquals("Bonjour", name.value);
+
+ }
+
+}
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java?rev=816789&r1=816788&r2=816789&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java Fri Sep 18 21:23:28 2009
@@ -23,20 +23,21 @@
import javax.xml.ws.Holder;
import org.apache.camel.CamelContext;
-import org.apache.camel.component.cxf.spring.CxfEndpointBean;
import org.apache.camel.test.junit4.CamelSpringTestSupport;
-import org.apache.camel.util.ObjectHelper;
import org.apache.camel.wsdl_first.Person;
import org.apache.camel.wsdl_first.PersonImpl;
import org.apache.camel.wsdl_first.PersonService;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-
public class CXFWsdlOnlyTest extends CamelSpringTestSupport {
+ private Endpoint endpoint1;
+ private Endpoint endpoint2;
+
protected ClassPathXmlApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/WsdlOnlyBeans.xml");
}
@@ -45,20 +46,25 @@
assertNotNull("No context found!", context);
}
- @BeforeClass
- public static void startService() {
+ @Before
+ public void startServices() {
Object implementor = new PersonImpl();
String address = "http://localhost:9000/PersonService/";
- Endpoint.publish(address, implementor);
+ endpoint1 = Endpoint.publish(address, implementor);
address = "http://localhost:9001/PersonService/";
- Endpoint.publish(address, implementor);
+ endpoint2 = Endpoint.publish(address, implementor);
}
-
- @Test
- public void testCreateWSDLOnly() {
- CxfEndpointBean ep = getMandatoryBean(CxfEndpointBean.class, "serviceEndpoint");
-
+
+ @After
+ public void stopServices() {
+ if (endpoint1 != null) {
+ endpoint1.stop();
+ }
+
+ if (endpoint2 != null) {
+ endpoint2.stop();
+ }
}
@Test
@@ -72,7 +78,6 @@
Holder<String> ssn = new Holder<String>();
Holder<String> name = new Holder<String>();
client.getPerson(personId, ssn, name);
- System.out.println("NAME: " + name.value);
assertEquals("Bonjour", name.value);
Person client2 = ss.getSoap2();
@@ -80,21 +85,9 @@
personId2.value = "hello";
Holder<String> ssn2 = new Holder<String>();
Holder<String> name2 = new Holder<String>();
- client.getPerson(personId2, ssn2, name2);
- System.out.println("NAME: " + name2.value);
+ client2.getPerson(personId2, ssn2, name2);
assertEquals("Bonjour", name2.value);
}
- public <T> T getMandatoryBean(Class<T> type, String name) {
- Object value = applicationContext.getBean(name);
- assertNotNull("No spring bean found for name <" + name + ">", value);
- if (type.isInstance(value)) {
- return type.cast(value);
- } else {
- fail("Spring bean <" + name + "> is not an instanceof " + type.getName() + " but is of type "
- + ObjectHelper.className(value));
- return null;
- }
- }
}