Added:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionScopePolicy.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionScopePolicy.java?view=auto&rev=446583
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionScopePolicy.java
(added)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionScopePolicy.java
Fri Sep 15 04:51:40 2006
@@ -0,0 +1,86 @@
+/**
+ * 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.invoker;
+
+import org.apache.cxf.common.util.factory.AbstractPool;
+import org.apache.cxf.common.util.factory.Factory;
+import org.apache.cxf.common.util.factory.Pool;
+import org.apache.cxf.common.util.factory.PooledFactory;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.transport.Session;
+
+/**
+ * This scope policy implements one servant instance per session.
+ * <p>
+ *
+ * @author Ben Yu Feb 6, 2006 11:41:08 AM
+ */
+public class SessionScopePolicy implements ScopePolicy {
+
+ private static SessionScopePolicy singleton = new SessionScopePolicy();
+
+ /**
+ * Get the key for caching a service.
+ *
+ * @param service the service.
+ * @return the key.
+ */
+ protected Object getServiceKey(Service service) {
+ return service.getName();
+ }
+
+ public Factory applyScope(Factory f, Exchange ex) {
+ Service s = ex.get(Service.class);
+ return new PooledFactory(f, getSessionScope(getServiceKey(s),
ex.getSession()));
+ }
+
+ public String toString() {
+ return "session scope";
+ }
+
+ private static Pool getSessionScope(final Object key, final Session
session) {
+ return new AbstractPool() {
+ public Object get() {
+ return session.get(key);
+ }
+
+ public void set(Object val) {
+ session.put(key, val);
+ }
+
+ public String toString() {
+ return "session scope";
+ }
+
+ /*
+ * This is not guaranteed to be safe with concurrent access to
+ * HttpSession. But better than nothing.
+ */
+ protected Object getMutex() {
+ return Service.class;
+ }
+ };
+ }
+
+ public static ScopePolicy instance() {
+ return singleton;
+ }
+}
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionScopePolicy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionScopePolicy.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionScopePolicy.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java?view=diff&rev=446583&r1=446582&r2=446583
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
Fri Sep 15 04:51:40 2006
@@ -95,12 +95,14 @@
OutputStream os = m.getContent(OutputStream.class);
InputStream is = getResourceAsStream(message);
+ if (is == null) {
+ throw new RuntimeException("Could not find resource " + message);
+ }
+
copy(is, os, 8096);
byte[] bs = obs.getResponseStream().toByteArray();
- if (bs.length == 0) {
- throw new RuntimeException("No response was received!");
- }
+
ByteArrayInputStream input = new ByteArrayInputStream(bs);
return DOMUtils.readXml(input);
}
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java?view=diff&rev=446583&r1=446582&r2=446583
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java
Fri Sep 15 04:51:40 2006
@@ -19,11 +19,13 @@
package org.apache.cxf.test;
+import java.io.ByteArrayOutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.xml.namespace.NamespaceContext;
+import javax.xml.transform.TransformerException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -59,15 +61,21 @@
NodeList nodes = (NodeList)createXPath(namespaces).evaluate(xpath,
node, XPathConstants.NODESET);
if (nodes.getLength() == 0) {
- throw new AssertionFailedError("Failed to select any nodes for
expression:\n" + xpath);
+ throw new AssertionFailedError("Failed to select any nodes for
expression:\n" + xpath
+ + "From document:\n" +
writeNodeToString(node));
}
return nodes;
}
private static String writeNodeToString(Node node) {
- // TODO Auto-generated method stub
- return null;
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ try {
+ DOMUtils.writeXml(node, bos);
+ } catch (TransformerException e) {
+ throw new RuntimeException(e);
+ }
+ return bos.toString();
}
/**
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java?view=diff&rev=446583&r1=446582&r2=446583
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
Fri Sep 15 04:51:40 2006
@@ -44,7 +44,6 @@
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(message);
message.setExchange(exchange);
- setMessageProperties(message);
setExchangProperties(exchange, message);
// setup chain
@@ -57,15 +56,10 @@
chain.add(endpoint.getInInterceptors());
chain.add(endpoint.getBinding().getInInterceptors());
chain.add(endpoint.getService().getInInterceptors());
- chain.setFaultInterceptor(endpoint.getFaultInterceptor());
-
+ chain.setFaultInterceptor(endpoint.getFaultInterceptor());
+
chain.doIntercept(message);
- }
-
- protected void setMessageProperties(Message m) {
- // when configuration is ready, using config bean instead
- m.put(Message.MTOM_ENABLED, Boolean.TRUE);
}
protected void setExchangProperties(Exchange exchange, Message m) {
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ConduitInitiatorManagerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ConduitInitiatorManagerImpl.java?view=diff&rev=446583&r1=446582&r2=446583
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ConduitInitiatorManagerImpl.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ConduitInitiatorManagerImpl.java
Fri Sep 15 04:51:40 2006
@@ -36,7 +36,6 @@
private static final ResourceBundle BUNDLE =
BundleUtils.getBundle(ConduitInitiatorManager.class);
-
final Map<String, ConduitInitiator> conduitInitiators;
Properties factoryNamespaceMappings;
Modified:
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java?view=diff&rev=446583&r1=446582&r2=446583
==============================================================================
---
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java
(original)
+++
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java
Fri Sep 15 04:51:40 2006
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import org.apache.cxf.Bus;
+import org.apache.cxf.binding.Binding;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.ExchangeImpl;
@@ -51,6 +52,7 @@
private MessageInfo mInfo;
private List<Phase> phases;
private List<Interceptor> empty;
+ private Binding binding;
protected void setUp() throws Exception {
super.setUp();
@@ -68,6 +70,11 @@
service = control.createMock(Service.class);
endpoint = control.createMock(Endpoint.class);
+ binding = control.createMock(Binding.class);
+ EasyMock.expect(endpoint.getBinding()).andStubReturn(binding);
+ MessageImpl m = new MessageImpl();
+ EasyMock.expect(binding.createMessage()).andStubReturn(m);
+
EasyMock.expect(endpoint.getService()).andReturn(service);
EasyMock.expect(endpoint.getOutInterceptors()).andReturn(empty);
EasyMock.expect(service.getOutInterceptors()).andReturn(empty);
@@ -95,10 +102,10 @@
MessageImpl m = new MessageImpl();
Exchange exchange = new ExchangeImpl();
m.setExchange(exchange);
- exchange.setOutMessage(m);
exchange.put(Bus.class, bus);
exchange.put(Endpoint.class, endpoint);
exchange.put(BindingOperationInfo.class, bopInfo);
+ exchange.setOutMessage(m);
setupIntc.handleMessage(m);
intc.handleMessage(m);
}
Added:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/OutFaultConverterInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/OutFaultConverterInterceptor.java?view=auto&rev=446583
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/OutFaultConverterInterceptor.java
(added)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/OutFaultConverterInterceptor.java
Fri Sep 15 04:51:40 2006
@@ -0,0 +1,39 @@
+/**
+ * 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.jaxws.interceptors;
+
+import javax.xml.ws.WebFault;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+
+public class OutFaultConverterInterceptor extends
AbstractPhaseInterceptor<Message> {
+
+ public void handleMessage(Message message) throws Fault {
+ Fault f = (Fault)message.getContent(Exception.class);
+
+ Throwable cause = f.getCause();
+ if (cause instanceof Exception &&
cause.getClass().isAnnotationPresent(WebFault.class)) {
+ // serialize to details
+ }
+ }
+
+}
Propchange:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/OutFaultConverterInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/OutFaultConverterInterceptor.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/OutFaultConverterInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java?view=diff&rev=446583&r1=446582&r2=446583
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
Fri Sep 15 04:51:40 2006
@@ -36,7 +36,7 @@
import org.apache.cxf.message.Message;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.factory.ServiceConstructionException;
-import org.apache.cxf.service.invoker.SimpleMethodInvoker;
+import org.apache.cxf.service.invoker.BeanInvoker;
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.test.AbstractCXFTest;
@@ -108,7 +108,7 @@
bean.setBus(bus);
bean.setServiceClass(GreeterImpl.class);
GreeterImpl greeter = new GreeterImpl();
- SimpleMethodInvoker invoker = new SimpleMethodInvoker(greeter);
+ BeanInvoker invoker = new BeanInvoker(greeter);
bean.setInvoker(invoker);
Service service = bean.create();
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java?view=diff&rev=446583&r1=446582&r2=446583
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
Fri Sep 15 04:51:40 2006
@@ -31,7 +31,7 @@
import org.apache.cxf.binding.BindingFactoryManagerImpl;
import org.apache.cxf.binding.soap.SoapBindingFactory;
import org.apache.cxf.service.Service;
-import org.apache.cxf.service.invoker.SimpleMethodInvoker;
+import org.apache.cxf.service.invoker.BeanInvoker;
import org.apache.cxf.service.model.InterfaceInfo;
import org.apache.cxf.service.model.OperationInfo;
import org.apache.cxf.wsdl.WSDLManager;
@@ -53,7 +53,7 @@
bean.setBus(bus);
bean.setServiceClass(GreeterImpl.class);
- SimpleMethodInvoker invoker = new SimpleMethodInvoker(new
GreeterImpl());
+ BeanInvoker invoker = new BeanInvoker(new GreeterImpl());
bean.setInvoker(invoker);
Service service = bean.create();
Added:
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPSession.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPSession.java?view=auto&rev=446583
==============================================================================
---
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPSession.java
(added)
+++
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPSession.java
Fri Sep 15 04:51:40 2006
@@ -0,0 +1,56 @@
+/**
+ * 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 javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.cxf.transport.Session;
+
+/**
+ * A session implementation bound to HTTP.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Dan Diephouse</a>
+ */
+public class HTTPSession implements Session {
+ private HttpServletRequest request;
+
+ private HttpSession session;
+
+ public HTTPSession(HttpServletRequest request) {
+ this.request = request;
+ }
+
+ public Object get(Object key) {
+ return getSession().getAttribute((String)key);
+ }
+
+ public void put(Object key, Object value) {
+ getSession().setAttribute((String)key, value);
+ }
+
+ public HttpSession getSession() {
+ if (session == null) {
+ session = request.getSession();
+ }
+
+ return session;
+ }
+}
Propchange:
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPSession.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPSession.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPSession.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterGetFaultMessage.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterGetFaultMessage.xml?view=auto&rev=446583
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterGetFaultMessage.xml
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterGetFaultMessage.xml
Fri Sep 15 04:51:40 2006
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
+ <env:Body>
+ <m:testDocLitFault xmlns:m="http://apache.org/hello_world_soap_http/types">
+ <m:faultType>BadRecordLitFault</m:faultType>
+ </m:testDocLitFault>
+ </env:Body>
+</env:Envelope>
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterGetFaultMessage.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterGetFaultMessage.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterGetFaultMessage.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterTest.java?view=diff&rev=446583&r1=446582&r2=446583
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterTest.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterTest.java
Fri Sep 15 04:51:40 2006
@@ -29,7 +29,7 @@
import org.apache.cxf.binding.soap.SoapDestinationFactory;
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
import org.apache.cxf.service.Service;
-import org.apache.cxf.service.invoker.SimpleMethodInvoker;
+import org.apache.cxf.service.invoker.BeanInvoker;
import org.apache.cxf.test.AbstractCXFTest;
import org.apache.cxf.transport.ConduitInitiatorManager;
import org.apache.cxf.transport.DestinationFactoryManager;
@@ -70,7 +70,7 @@
bean.setBus(bus);
bean.setServiceClass(GreeterImpl.class);
GreeterImpl greeter = new GreeterImpl();
- SimpleMethodInvoker invoker = new SimpleMethodInvoker(greeter);
+ BeanInvoker invoker = new BeanInvoker(greeter);
bean.setInvoker(invoker);
Service service = bean.create();
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/SoapFaultTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/SoapFaultTest.java?view=auto&rev=446583
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/SoapFaultTest.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/SoapFaultTest.java
Fri Sep 15 04:51:40 2006
@@ -0,0 +1,121 @@
+/**
+ * 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.systest.jaxws;
+
+import java.net.URL;
+
+import org.w3c.dom.Node;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.soap.SoapBindingFactory;
+import org.apache.cxf.binding.soap.SoapDestinationFactory;
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.invoker.BeanInvoker;
+import org.apache.cxf.test.AbstractCXFTest;
+import org.apache.cxf.transport.ConduitInitiatorManager;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.apache.hello_world_soap_http.GreeterImpl;
+
+public class SoapFaultTest extends AbstractCXFTest {
+
+ private Bus bus;
+ private Service service;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ bus = getBus();
+
+ SoapBindingFactory bindingFactory = new SoapBindingFactory();
+
+ bus.getExtension(BindingFactoryManager.class)
+ .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/",
bindingFactory);
+
+ DestinationFactoryManager dfm =
bus.getExtension(DestinationFactoryManager.class);
+ SoapDestinationFactory soapDF = new SoapDestinationFactory(dfm);
+
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
+
+ LocalTransportFactory localTransport = new LocalTransportFactory();
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http",
localTransport);
+
+ ConduitInitiatorManager extension =
bus.getExtension(ConduitInitiatorManager.class);
+ extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID,
localTransport);
+
+ JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
+ URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
+ assertNotNull(resource);
+ bean.setWsdlURL(resource);
+ bean.setBus(bus);
+ bean.setServiceClass(GreeterImpl.class);
+
+ GreeterImpl greeter = new GreeterImpl();
+ BeanInvoker invoker = new BeanInvoker(greeter);
+ bean.setInvoker(invoker);
+
+ service = bean.create();
+
+ bean.activateEndpoints();
+ }
+
+ public void testInterceptorThrowingSoapFault() throws Exception {
+ service.getInInterceptors().add(new FaultThrowingInterceptor());
+
+ Node response = invoke("http://localhost:9000/SoapContext/SoapPort",
+ LocalTransportFactory.TRANSPORT_ID,
"GreeterMessage.xml");
+
+ assertNotNull(response);
+
+ assertValid("/s:Envelope/s:Body/s:Fault/faultstring[text()='I blame
Hadrian.']", response);
+ }
+
+
+ /**
+ * We need to get the jaxws fault -> soap fault conversion working for this
+ * @throws Exception
+ */
+ public void xtestWebServiceException() throws Exception {
+ Node response = invoke("http://localhost:9000/SoapContext/SoapPort",
+ LocalTransportFactory.TRANSPORT_ID,
"GreeterGetFaultMessage.xml");
+
+ assertNotNull(response);
+
+ assertValid("/s:Envelope/s:Body/s:Fault/faultstring[text()='I blame
Hadrian.']", response);
+ }
+
+ public class FaultThrowingInterceptor extends AbstractSoapInterceptor {
+ public FaultThrowingInterceptor() {
+ setPhase(Phase.USER_LOGICAL);
+ }
+
+ public void handleMessage(SoapMessage message) throws Fault {
+ throw new SoapFault("I blame Hadrian.", SoapFault.SENDER);
+ }
+
+ }
+}
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/SoapFaultTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/SoapFaultTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date