You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ni...@apache.org on 2010/09/27 11:53:15 UTC
svn commit: r1001649 - in /cxf/trunk/rt/core/src:
main/java/org/apache/cxf/wsdl11/Messages.properties
main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java
test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java
Author: ningjiang
Date: Mon Sep 27 09:53:15 2010
New Revision: 1001649
URL: http://svn.apache.org/viewvc?rev=1001649&view=rev
Log:
CXF-3007 WSDLServiceFactory should throw exception if the service factory cannot build the service with a wrong port name
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/Messages.properties
cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java
cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/Messages.properties?rev=1001649&r1=1001648&r2=1001649&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/Messages.properties (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/Messages.properties Mon Sep 27 09:53:15 2010
@@ -26,6 +26,7 @@ WSDL_GENERATION_BAD_RESULT_MSG = Generat
EXTENSION_ADD_FAILED_MSG = Failed to add extension element.
SERVICE_CREATION_MSG = Failed to create service.
NO_SUCH_SERVICE_EXC = Could not find definition for service {0}.
+NO_SUCH_ENDPOINT_EXC = Could not find definition for port {0}.
FAIL_TO_CREATE_WSDL_DEFINITION = Fail to create wsdl definition from : {0}\r\nCaused by : {1}
MISSING_DESTINATION_FACTORY = Cannot find the destination factory, check the port //wsdl:port[@name=''{0}'']
MISSING_SERVICE= No definition of service {0} in the WSDL.
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java?rev=1001649&r1=1001648&r2=1001649&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java Mon Sep 27 09:53:15 2010
@@ -134,6 +134,10 @@ public class WSDLServiceFactory extends
services = new WSDLServiceBuilder(getBus()).buildServices(definition,
wsdlService,
endpointName);
+ if (services.size() == 0) {
+ throw new ServiceConstructionException(
+ new Message("NO_SUCH_ENDPOINT_EXC", LOG, endpointName));
+ }
} catch (XmlSchemaException ex) {
throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
}
Modified: cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java?rev=1001649&r1=1001648&r2=1001649&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java (original)
+++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java Mon Sep 27 09:53:15 2010
@@ -69,6 +69,7 @@ import org.apache.cxf.wsdl.EndpointRefer
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.easymock.classextension.EasyMock;
import org.easymock.classextension.IMocksControl;
+
import org.junit.Assert;
import org.junit.Test;
@@ -104,8 +105,13 @@ public class WSDLServiceBuilderTest exte
public void setUpBasic() throws Exception {
setUpWSDL(WSDL_PATH, 0);
}
-
+
private void setUpWSDL(String wsdl, int serviceSeq) throws Exception {
+ setUpDefinition(wsdl, serviceSeq);
+ buildService();
+ }
+
+ private void setUpDefinition(String wsdl, int serviceSeq) throws Exception {
URL url = getClass().getResource(wsdl);
assertNotNull("could not find wsdl " + wsdl, url);
String wsdlUrl = url.toString();
@@ -127,7 +133,13 @@ public class WSDLServiceBuilderTest exte
}
}
}
+ }
+
+ private void buildService() throws Exception {
+ buildService(null);
+ }
+ private void buildService(QName endpointName) throws Exception {
control = EasyMock.createNiceControl();
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
@@ -148,10 +160,23 @@ public class WSDLServiceBuilderTest exte
control.replay();
- serviceInfos = wsdlServiceBuilder.buildServices(def, service);
- serviceInfo = serviceInfos.get(0);
+ serviceInfos = wsdlServiceBuilder.buildServices(def, service, endpointName);
+ if (serviceInfos.size() > 0) {
+ serviceInfo = serviceInfos.get(0);
+ } else {
+ serviceInfo = null;
+ }
}
+
+ @Test
+ public void testBuildServiceWithWrongEndpointName() throws Exception {
+ setUpWSDL(WSDL_PATH, 0);
+ buildService(new QName("http://apache.org/hello_world_soap_http",
+ "NoExitSoapPort"));
+ assertEquals("Should not build any serviceInfo.", 0, serviceInfos.size());
+ assertEquals("Should not build any serviceInfo.", null, serviceInfo);
+ }
@Test
public void testMultiPorttype() throws Exception {