Author: ningjiang
Date: Tue Jun 7 12:54:39 2011
New Revision: 1132988
URL: http://svn.apache.org/viewvc?rev=1132988&view=rev
Log:
CXF-3571 CXF HTTPTransportFactory should throw exception when it can't find a
right HTTPDestinationFactory to use
Added:
cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPTransportFactoryTest.java
(with props)
Modified:
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties
Modified:
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java?rev=1132988&r1=1132987&r2=1132988&view=diff
==============================================================================
---
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
(original)
+++
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
Tue Jun 7 12:54:39 2011
@@ -27,6 +27,8 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.wsdl.extensions.http.HTTPAddress;
@@ -35,6 +37,7 @@ import javax.xml.namespace.QName;
import org.apache.cxf.Bus;
import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.configuration.Configurer;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.model.BindingInfo;
@@ -58,7 +61,7 @@ import org.apache.cxf.wsdl11.WSDLEndpoin
public class HTTPTransportFactory
extends AbstractTransportFactory
implements WSDLEndpointFactory, ConduitInitiator, DestinationFactory {
-
+
public static final List<String> DEFAULT_NAMESPACES
= Arrays.asList(
"http://cxf.apache.org/transports/http",
@@ -67,6 +70,7 @@ public class HTTPTransportFactory
"http://schemas.xmlsoap.org/wsdl/http/"
);
+ private static final Logger LOG =
LogUtils.getL7dLogger(HTTPTransportFactory.class);
/**
* This constant holds the prefixes served by this factory.
@@ -254,12 +258,20 @@ public class HTTPTransportFactory
AbstractHTTPDestination d =
registry.getDestinationForPath(endpointInfo.getAddress());
if (d == null) {
HttpDestinationFactory jettyFactory =
bus.getExtension(HttpDestinationFactory.class);
- HttpDestinationFactory servletFactory = new
ServletDestinationFactory();
String addr = endpointInfo.getAddress();
+ if (jettyFactory == null && addr != null &&
addr.startsWith("http")) {
+ String m =
+ new
org.apache.cxf.common.i18n.Message("NO_HTTP_DESTINATION_FACTORY_FOUND"
+ , LOG).toString();
+ LOG.log(Level.SEVERE, m);
+ throw new IOException(m);
+ }
+ HttpDestinationFactory servletFactory = new
ServletDestinationFactory();
HttpDestinationFactory factory = servletFactory;
if (jettyFactory != null && (addr == null ||
addr.startsWith("http"))) {
factory = jettyFactory;
}
+
d = factory.createDestination(endpointInfo, getBus(), registry);
registry.addDestination(d);
configure(d);
Modified:
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties?rev=1132988&r1=1132987&r2=1132988&view=diff
==============================================================================
---
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties
(original)
+++
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Messages.properties
Tue Jun 7 12:54:39 2011
@@ -25,3 +25,4 @@ DECOUPLED_RESPONSE_FAILED_MSG = Decouple
MISSING_PATH_INFO = PATH_INFO not present in message context, multiplex id is
unavailable. Ensure the portName passed to getCurrentEndpointReferenceId is
correct if the service has multiple ports
INVALID_ENCODING_MSG = Invalid character set {0} in request.
INVALID_TIMEOUT_FORMAT = Invalid name/value pair {0}={1} set in RequestConext
+NO_HTTP_DESTINATION_FACTORY_FOUND = Cannot find any registered
HttpDestinationFactory from the Bus.
\ No newline at end of file
Added:
cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPTransportFactoryTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPTransportFactoryTest.java?rev=1132988&view=auto
==============================================================================
---
cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPTransportFactoryTest.java
(added)
+++
cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPTransportFactoryTest.java
Tue Jun 7 12:54:39 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.transport.http;
+
+import java.io.IOException;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.service.model.EndpointInfo;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class HTTPTransportFactoryTest extends Assert {
+ @Test
+ public void testGetDestination() {
+ Bus bus = BusFactory.getDefaultBus();
+ EndpointInfo ei = new EndpointInfo();
+ ei.setAddress("http://nowhere.com/bar/foo");
+ HTTPTransportFactory factory =
bus.getExtension(HTTPTransportFactory.class);
+ try {
+ factory.getDestination(ei);
+ fail("Expect exception here.");
+ } catch (IOException ex) {
+ assertTrue("We should find some exception related to the
HttpDestination"
+ , ex.getMessage().indexOf("HttpDestinationFactory") >
0);
+ }
+ }
+
+}
Propchange:
cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPTransportFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPTransportFactoryTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date