cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1460691 - in /cxf/trunk/rt/core/src: main/java/org/apache/cxf/service/factory/ test/java/org/apache/cxf/service/ test/java/org/apache/cxf/service/factory/
Date Mon, 25 Mar 2013 14:46:53 GMT
Author: ay
Date: Mon Mar 25 14:46:53 2013
New Revision: 1460691

URL: http://svn.apache.org/r1460691
Log:
[CXF-4922] NPE is thrown at EP creation when no service class specified and the provided wsdl
not loaded

Added:
    cxf/trunk/rt/core/src/test/java/org/apache/cxf/service/
    cxf/trunk/rt/core/src/test/java/org/apache/cxf/service/factory/
    cxf/trunk/rt/core/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactorBeanTest.java
Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties?rev=1460691&r1=1460690&r2=1460691&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties Mon
Mar 25 14:46:53 2013
@@ -34,5 +34,6 @@ JAXWS_ANNOTATION_FOUND=A JAX-WS Annotati
 XSD_VALIDATION_ERROR= Error in W3C XML Schema associated with service: {0}
 COULD_NOT_UNWRAP=Could not unwrap Operation {0} to match method "{1}"
 NO_WSDL_PROVIDED=WSDL is required for services created from class {0}, but no WSDL location
specified. 
+NO_WSDL_NO_SERVICE_CLASS_PROVIDED=No valid WSDL {0} nor service class is specified.
 NO_FAULT_PART = Could not find a fault part for {0}. The fault message must have a single
part.
 INVALID_BARE_METHOD= Method {0} is configured as BARE but there are more than one parameters
with wrong @Webparam annotated or without @WebParam annotated.

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=1460691&r1=1460690&r2=1460691&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Mon Mar 25 14:46:53 2013
@@ -536,8 +536,10 @@ public class ReflectionServiceFactoryBea
 
         if (isFromWsdl()) {
             buildServiceFromWSDL(wsdlurl);
-        } else {
+        } else if (getServiceClass() != null) {
             buildServiceFromClass();
+        } else {
+            throw new ServiceConstructionException(new Message("NO_WSDL_NO_SERVICE_CLASS_PROVIDED",
LOG, wsdlurl));
         }
 
         if (isValidate()) {

Added: cxf/trunk/rt/core/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactorBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactorBeanTest.java?rev=1460691&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactorBeanTest.java
(added)
+++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/service/factory/ReflectionServiceFactorBeanTest.java
Mon Mar 25 14:46:53 2013
@@ -0,0 +1,76 @@
+/**
+ * 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.cxf.service.factory;
+
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.wsdl.WSDLManager;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class ReflectionServiceFactorBeanTest extends Assert {
+    protected IMocksControl control;
+    
+    @Before
+    public void setUp() throws Exception {
+        control = EasyMock.createNiceControl();
+    }
+    
+    @After 
+    public void tearDown() throws Exception {
+        control.verify();
+    }
+    
+    @Test
+    public void testEmptyWsdlAndNoServiceClass() throws Exception {
+        final String dummyWsdl = "target/dummy.wsdl";
+        ReflectionServiceFactoryBean bean = new ReflectionServiceFactoryBean();
+        Bus bus = control.createMock(Bus.class);
+        
+        WSDLManager wsdlmanager = control.createMock(WSDLManager.class);
+        EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(wsdlmanager);
+        EasyMock.expect(wsdlmanager.getDefinition(dummyWsdl))
+            .andThrow(new WSDLException("PARSER_ERROR", "Problem parsing '" + dummyWsdl +
"'."));
+        EasyMock.expect(bus.getExtension(FactoryBeanListenerManager.class)).andReturn(null);
+        
+        control.replay();
+        
+        bean.setWsdlURL(dummyWsdl);
+        bean.setServiceName(new QName("http://cxf.apache.org/hello_world_soap_http", "GreeterService"));
+        bean.setBus(bus);
+        
+        try {
+            bean.create();
+            fail("no valid wsdl nor service class specified");
+        } catch (ServiceConstructionException e) {
+            // ignore
+        }
+    }
+}



Mime
View raw message