cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaypai...@apache.org
Subject svn commit: r528035 [1/3] - in /incubator/cxf/trunk: rt/bindings/coloc/ rt/bindings/coloc/src/ rt/bindings/coloc/src/main/ rt/bindings/coloc/src/main/java/ rt/bindings/coloc/src/main/java/org/ rt/bindings/coloc/src/main/java/org/apache/ rt/bindings/col...
Date Thu, 12 Apr 2007 17:00:14 GMT
Author: ajaypaibir
Date: Thu Apr 12 10:00:11 2007
New Revision: 528035

URL: http://svn.apache.org/viewvc?view=rev&rev=528035
Log:
Adding a Colocated binding. The coloc interceptor infers if a service exist on the bus and does a local invocation bypassing the binding, protocol, stream interceptors that exist after POST_LOGICAL Phase. The Note: There will be a unification process to merge the Colocated and ObjectBinding approach. A proposal for this unification will be made shortly.
Added a system test for the colocated approach that tests operations with in, inout, out and fault parts with a verfication the invocation is not going remote.

Added:
    incubator/cxf/trunk/rt/bindings/coloc/
    incubator/cxf/trunk/rt/bindings/coloc/pom.xml   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/
    incubator/cxf/trunk/rt/bindings/coloc/src/main/
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/Messages.properties   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/test/
    incubator/cxf/trunk/rt/bindings/coloc/src/test/java/
    incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/
    incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/
    incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/
    incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/
    incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/
    incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocMessageObserverTest.java   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocOutInterceptorTest.java   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java   (with props)
    incubator/cxf/trunk/rt/bindings/coloc/src/test/resources/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/AbstractColocTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/AbstractHeaderServiceDocLitTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/AbstractHeaderServiceRpcLitTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/BaseHeaderTesterDocLitImpl.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/BaseHeaderTesterRpcLitImpl.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/ColocHeaderDocLitTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/ColocHeaderRpcLitTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/HeaderTesterUtil.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/ThrowFaultInterceptor.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/cxf.xml   (with props)
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/header.xsd   (with props)
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/header_doc_lit.wsdl   (with props)
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/header_rpc_lit.wsdl   (with props)
Removed:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainSetupInterceptor.java
Modified:
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/interceptor/OutgoingChainInterceptorTest.java
    incubator/cxf/trunk/systests/pom.xml
    incubator/cxf/trunk/testutils/pom.xml

Added: incubator/cxf/trunk/rt/bindings/coloc/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/pom.xml?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/pom.xml (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/pom.xml Thu Apr 12 10:00:11 2007
@@ -0,0 +1,67 @@
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.cxf</groupId>
+    <artifactId>cxf-rt-bindings-coloc</artifactId>
+    <packaging>jar</packaging>
+    <name>Apache CXF Colocated Binding</name>
+    <url>http://cwiki.apache.org/CXF</url>
+
+    <parent>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-parent</artifactId>
+        <version>2.0-incubator-RC-SNAPSHOT</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.xml.ws</groupId>
+            <artifactId>jaxws-api</artifactId>
+            <version>${jaxws.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-testutils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymockclassextension</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

Propchange: incubator/cxf/trunk/rt/bindings/coloc/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/bindings/coloc/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,48 @@
+/**
+ * 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.binding.coloc;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.InFaultChainInitiatorObserver;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.phase.PhaseManager;
+
+public class ColocInFaultObserver extends InFaultChainInitiatorObserver {
+
+    private List<Phase> list;
+    public ColocInFaultObserver(Bus bus) {
+        super(bus);
+        list = new ArrayList<Phase>(bus.getExtension(PhaseManager.class).getInPhases());
+        ColocUtil.setPhases(list, Phase.PRE_LOGICAL, Phase.PRE_INVOKE);
+    }
+
+    protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) {
+        super.initializeInterceptors(ex, chain);
+        chain.add(new WebFaultInInterceptor());
+    }
+
+    protected List<Phase> getPhases() {
+        return list;
+    }
+}

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInFaultObserver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,72 @@
+/**
+ * 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.binding.coloc;
+
+import java.util.ArrayList;
+import java.util.List;
+//import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.Bus;
+//import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.interceptor.ServiceInvokerInterceptor;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseManager;
+
+public class ColocInInterceptor extends AbstractPhaseInterceptor<Message> {
+//    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ColocInInterceptor.class);
+    private static final Logger LOG = Logger.getLogger(ColocInInterceptor.class.getName());
+
+    
+    public ColocInInterceptor() {
+        super();
+        setPhase(Phase.INVOKE);
+        addAfter(ServiceInvokerInterceptor.class.getName());
+    }
+
+    public void handleMessage(Message msg) throws Fault {
+        Exchange ex = msg.getExchange();
+        if (ex.isOneWay()) {
+            return;
+        }
+       
+        Bus bus = ex.get(Bus.class);
+        List<Phase> phases = new ArrayList<Phase>(bus.getExtension(PhaseManager.class).getOutPhases());
+
+        //TODO Set Coloc FaultObserver chain
+        ColocUtil.setPhases(phases, Phase.SETUP, Phase.USER_LOGICAL);
+        InterceptorChain chain = ColocUtil.getOutInterceptorChain(ex, phases);
+
+        if (LOG.isLoggable(Level.FINER)) {
+            LOG.finer("Processing Message at collocated endpoint.  Response message: " + msg);
+        }
+
+        //Initiate OutBound Processing
+        Message outBound = ex.getOutMessage();
+        outBound.put(Message.INBOUND_MESSAGE, Boolean.FALSE);        
+        outBound.setInterceptorChain(chain);
+        chain.doIntercept(outBound);
+    }
+}

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocInInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,107 @@
+/**
+ * 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.binding.coloc;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.Binding;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.transport.ChainInitiationObserver;
+
+public class ColocMessageObserver extends ChainInitiationObserver {
+    private static final Logger LOG = Logger.getLogger(ColocMessageObserver.class.getName());
+    private static final String COLOCATED = Message.class.getName() + ".COLOCATED";
+    
+    public ColocMessageObserver(Endpoint endpoint, Bus bus) {
+        super(endpoint, bus);
+    }
+
+    public void onMessage(Message m) {
+        if (LOG.isLoggable(Level.FINER)) {
+            LOG.finer("Processing Message at collocated endpoint.  Request message: " + m);
+        }
+        Exchange ex = new ExchangeImpl();
+        setExchangeProperties(ex, m);
+        
+        Message inMsg = endpoint.getBinding().createMessage();
+        MessageImpl.copyContent(m, inMsg);
+        
+        inMsg.put(COLOCATED, Boolean.TRUE);
+        inMsg.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
+        inMsg.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
+        ex.setInMessage(inMsg);
+        inMsg.setExchange(ex);
+        
+        if (LOG.isLoggable(Level.FINEST)) {
+            LOG.finest("Build inbound interceptor chain.");
+        }
+
+        //Add all interceptors between USER_LOGICAL and INVOKE.
+        List<Phase> phases = new ArrayList<Phase>(bus.getExtension(PhaseManager.class).getInPhases());
+        ColocUtil.setPhases(phases, Phase.USER_LOGICAL, Phase.INVOKE);
+        InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, phases);
+        inMsg.setInterceptorChain(chain);
+
+        chain.doIntercept(inMsg);
+        
+        //Set Server OutBound Message onto InBound Exchange.
+        setOutBoundMessage(ex, m.getExchange());
+    }
+    
+    protected void setOutBoundMessage(Exchange from, Exchange to) {
+        if (from.getOutFaultMessage() != null) {
+            to.setInFaultMessage(from.getOutFaultMessage());
+        } else {
+            to.setInMessage(from.getOutMessage());
+        }
+    }
+    
+    protected void setExchangeProperties(Exchange exchange, Message m) {
+        exchange.put(Bus.class, bus);
+        exchange.put(Endpoint.class, endpoint);
+        exchange.put(Service.class, endpoint.getService());
+        exchange.put(Binding.class, endpoint.getBinding());
+
+        //Setup the BindingOperationInfo
+        QName opName = (QName) m.get(Message.WSDL_OPERATION);
+        BindingInfo bi = endpoint.getEndpointInfo().getBinding();
+        BindingOperationInfo boi = bi.getOperation(opName);
+        exchange.put(BindingInfo.class, bi);
+        exchange.put(BindingOperationInfo.class, boi);
+        exchange.put(OperationInfo.class, boi.getOperationInfo());
+    }
+    
+}

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,41 @@
+/**
+ * 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.binding.coloc;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.OutFaultChainInitiatorObserver;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseManager;
+
+public class ColocOutFaultObserver extends OutFaultChainInitiatorObserver {
+
+    List<Phase> list;
+    public ColocOutFaultObserver(Bus bus) {
+        super(bus);
+        list = new ArrayList<Phase>(bus.getExtension(PhaseManager.class).getOutPhases());
+        ColocUtil.setPhases(list, Phase.SETUP, Phase.USER_LOGICAL);        
+    }
+
+    protected List<Phase> getPhases() {
+        return list;
+    }
+}

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutFaultObserver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,183 @@
+/**
+ * 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.binding.coloc;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.binding.Binding;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+//import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.MessageObserver;
+
+public class ColocOutInterceptor extends AbstractPhaseInterceptor<Message> {
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ColocOutInterceptor.class);
+    private static final Logger LOG = LogUtils.getL7dLogger(ClientImpl.class);
+    private static final String COLOCATED = Message.class.getName() + ".COLOCATED";
+    private MessageObserver colocObserver;
+    
+    public ColocOutInterceptor() {
+        super();
+        setPhase(Phase.POST_LOGICAL);
+    }
+
+    public void handleMessage(Message message) throws Fault {
+        Bus bus = BusFactory.getDefaultBus(false);
+        if (bus == null) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message("BUS_NOT_FOUND", BUNDLE));
+        }
+        
+        ServerRegistry registry = bus.getExtension(ServerRegistry.class);
+        
+        if (registry == null) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message("SERVER_REGISTRY_NOT_FOUND", BUNDLE));
+        }
+        
+        Exchange exchange = message.getExchange();
+        Endpoint senderEndpoint = exchange.get(Endpoint.class);
+
+        if (senderEndpoint == null) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message("ENDPOINT_NOT_FOUND", 
+                                                                   BUNDLE));
+        }
+
+        BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
+        
+        if (boi == null) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message("OPERATIONINFO_NOT_FOUND", 
+                                                                   BUNDLE));
+        }
+
+        Server srv = isColocated(registry.getServers(), senderEndpoint, boi);
+        
+        if (srv != null) {
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Operation:" + boi.getName() + " dispatched as colocated call.");
+            }
+
+            InterceptorChain outChain = message.getInterceptorChain();
+            outChain.abort();
+            exchange.put(Bus.class, bus);
+            message.put(COLOCATED, Boolean.TRUE);
+            message.put(Message.WSDL_OPERATION, boi.getName());
+            message.put(Message.WSDL_INTERFACE, boi.getBinding().getInterface().getName());
+            invokeColocObserver(message, srv.getEndpoint(), bus);
+            invokeInboundChain(exchange, senderEndpoint);
+        } else {
+            message.put(COLOCATED, Boolean.FALSE);
+        }
+    }
+    
+    protected void invokeColocObserver(Message outMsg, Endpoint inboundEndpoint, Bus bus) {
+        if (colocObserver == null) {
+            colocObserver = new ColocMessageObserver(inboundEndpoint, bus);
+        }
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.finest("Invoke on Coloc Observer.");
+        }
+
+        colocObserver.onMessage(outMsg);
+    }
+
+    protected void invokeInboundChain(Exchange ex, Endpoint ep) {
+        Message m = getInBoundMessage(ex);
+        Message inMsg = ep.getBinding().createMessage();
+        MessageImpl.copyContent(m, inMsg);
+        inMsg.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
+        inMsg.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
+        inMsg.setExchange(ex);
+        
+        Bus bus = ex.get(Bus.class);        
+        Exception exc = inMsg.getContent(Exception.class);
+        if (exc != null) {
+            ex.setInFaultMessage(inMsg);
+            ColocInFaultObserver observer = new ColocInFaultObserver(bus);
+            observer.onMessage(inMsg);            
+        } else {
+            //Handle Response
+            ex.setInMessage(inMsg);
+            PhaseManager pm = bus.getExtension(PhaseManager.class);
+            List<Phase> phases = new ArrayList<Phase>(pm.getInPhases());
+            ColocUtil.setPhases(phases, Phase.USER_LOGICAL, Phase.PRE_INVOKE);
+            
+            InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, phases);        
+            inMsg.setInterceptorChain(chain);        
+            chain.doIntercept(inMsg);
+        }
+        ex.put(ClientImpl.FINISHED, Boolean.TRUE);
+    }
+    
+    protected Message getInBoundMessage(Exchange ex) {
+        return  (ex.getInFaultMessage() != null)
+                   ? ex.getInFaultMessage()
+                   : ex.getInMessage();
+    }
+    
+    protected void setMessageObserver(MessageObserver observer) {
+        colocObserver = observer;
+    }
+    
+    protected Server isColocated(List<Server> servers, Endpoint endpoint, BindingOperationInfo boi) {
+        if (servers != null) {
+            Service senderService = endpoint.getService();
+            EndpointInfo senderEI = endpoint.getEndpointInfo();
+            for (Server s : servers) {
+                Endpoint receiverEndpoint = s.getEndpoint();
+                Service receiverService = receiverEndpoint.getService();
+                EndpointInfo receiverEI = receiverEndpoint.getEndpointInfo();
+                if (receiverService.getName().equals(senderService.getName())
+                    && receiverEI.getName().equals(senderEI.getName())
+                    && receiverEI.getBinding().getOperation(boi.getName()) != null) {
+                    return s;
+                    //TODO Do a Strict check on the SEI Method from the implementor. 
+                }
+            }
+        }
+        
+        return null;
+    }
+    
+    public void setExchangeProperties(Exchange exchange, Endpoint ep) {
+        exchange.put(Endpoint.class, ep);
+        exchange.put(Service.class, ep.getService());
+        exchange.put(Binding.class, ep.getBinding());
+        exchange.put(Bus.class, BusFactory.getDefaultBus(false));
+    }
+}

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocOutInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,109 @@
+/**
+ * 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.binding.coloc;
+
+import java.util.List;
+import java.util.ListIterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+
+public final class ColocUtil {
+    //private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ColocInInterceptor.class);
+    private static final Logger LOG = Logger.getLogger(ColocUtil.class.getName());
+
+    private ColocUtil() {
+        //Completge
+    }
+
+    public static void setPhases(List<Phase> list, String start, String end) {
+        Phase startPhase = new Phase(start, 1);
+        Phase endPhase = new Phase(end, 2);
+        ListIterator<Phase> iter = list.listIterator();
+        boolean remove = true;
+        while (iter.hasNext()) {
+            Phase p = iter.next();
+            if (remove 
+                && p.getName().equals(startPhase.getName())) {
+                remove = false;
+            } else if (p.getName().equals(endPhase.getName())) {
+                remove = true;
+            } else if (remove) {
+                iter.remove();
+            }
+        }
+    }
+    
+    public static InterceptorChain getOutInterceptorChain(Exchange ex, List<Phase> phases) {
+        Bus bus = ex.get(Bus.class);
+        PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
+        
+        Endpoint ep = ex.get(Endpoint.class);
+        List<Interceptor> il = ep.getOutInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by endpoint: " + il);
+        }
+        chain.add(il);
+        il = ep.getService().getOutInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by service: " + il);
+        }
+        chain.add(il);
+        il = bus.getOutInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by bus: " + il);
+        }
+        chain.add(il);
+
+        return chain;
+    }
+    
+    public static InterceptorChain getInInterceptorChain(Exchange ex, List<Phase> phases) {
+        Bus bus = ex.get(Bus.class);
+        PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
+        
+        Endpoint ep = ex.get(Endpoint.class);
+        List<Interceptor> il = ep.getInInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by endpoint: " + il);
+        }
+        chain.add(il);
+        il = ep.getService().getInInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by service: " + il);
+        }
+        chain.add(il);
+        il = bus.getInInterceptors();
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Interceptors contributed by bus: " + il);
+        }
+        chain.add(il);
+        chain.setFaultObserver(new ColocOutFaultObserver(bus));
+
+        return chain;
+    }    
+    
+}

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/Messages.properties?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/Messages.properties (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/Messages.properties Thu Apr 12 10:00:11 2007
@@ -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.
+#
+#
+
+BUS_NOT_FOUND = Bus not created or not set as default bus.
+SERVER_REGISTRY_NOT_FOUND = Server Registry not registered with bus.
+ENDPOINT_NOT_FOUND =  Consumer Endpoint not found in exchange.
+OPERATIONINFO_NOT_FOUND = Operation not found in exchange.
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/Messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/Messages.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/Messages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,97 @@
+/**
+ * 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.binding.coloc;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebFault;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.FaultInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.UnwrappedOperationInfo;
+
+public class WebFaultInInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    public WebFaultInInterceptor() {
+        super();
+        setPhase(Phase.PRE_LOGICAL);
+    }
+
+    public void handleMessage(Message message) throws Fault {
+        Exception ex = message.getContent(Exception.class);
+        if (ex != null) {
+            message.put(Message.RESPONSE_CODE, new Integer(500));
+        }
+        
+        if (ex instanceof Fault) {
+            Fault f = (Fault) ex;
+            ex = (Exception) f.getCause();
+        }
+        
+        QName faultName = this.getFaultName(ex);
+        if (faultName == null) {
+            return;
+        }
+
+        BindingOperationInfo boi = message.getExchange().get(BindingOperationInfo.class);
+        MessagePartInfo part = getFaultMessagePart(faultName, boi.getOperationInfo());
+
+        if (part != null) {
+            message.setContent(Exception.class, ex);
+        }
+    }
+
+    private QName getFaultName(Exception webFault) {
+        QName faultName = null;
+        WebFault wf = webFault.getClass().getAnnotation(WebFault.class);
+        if (wf != null) {
+            faultName = new QName(wf.targetNamespace(), wf.name());
+        }
+            
+        return faultName;
+    }
+    
+    private MessagePartInfo getFaultMessagePart(QName qname, OperationInfo op) {
+        if (op.isUnwrapped()) {
+            op = ((UnwrappedOperationInfo)op).getWrappedOperation();
+        }
+        
+        for (FaultInfo faultInfo : op.getFaults()) {
+            for (MessagePartInfo mpi : faultInfo.getMessageParts()) {
+                String ns = null;
+                if (mpi.isElement()) {
+                    ns = mpi.getElementQName().getNamespaceURI();
+                } else {
+                    ns = mpi.getTypeQName().getNamespaceURI();
+                }
+                if (qname.getLocalPart().equals(mpi.getConcreteName().getLocalPart()) 
+                        && qname.getNamespaceURI().equals(ns)) {
+                    return mpi;
+                }
+            }
+            
+        }
+        return null;
+    }    
+}

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/WebFaultInInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocMessageObserverTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocMessageObserverTest.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocMessageObserverTest.java (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocMessageObserverTest.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,146 @@
+/**
+ * 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.binding.coloc;
+
+import java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.binding.Binding;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.phase.PhaseManagerImpl;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ColocMessageObserverTest extends Assert {
+    private IMocksControl control = EasyMock.createNiceControl();
+    private ColocMessageObserver observer;
+    private Message msg;
+    private Exchange ex;
+    private Service srv;
+    private Endpoint ep;
+    private Bus bus;
+
+    @Before
+    public void setUp() throws Exception {
+        ep = control.createMock(Endpoint.class);
+        bus = control.createMock(Bus.class);
+        srv = control.createMock(Service.class);        
+        BusFactory.setDefaultBus(bus);        
+        msg = new MessageImpl();
+        ex = new ExchangeImpl();
+        //msg.setExchange(ex);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        BusFactory.setDefaultBus(null);
+    }
+
+    @Test
+    public void testSetExchangeProperties() throws Exception {
+        observer = new ColocMessageObserver(ep, bus);
+        QName opName = new QName("A", "B");
+        msg.put(Message.WSDL_OPERATION, opName);
+
+        EasyMock.expect(ep.getService()).andReturn(srv);
+        Binding binding = control.createMock(Binding.class);
+        EasyMock.expect(ep.getBinding()).andReturn(binding);
+        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EasyMock.expect(ep.getEndpointInfo()).andReturn(ei);
+        BindingInfo bi = control.createMock(BindingInfo.class);
+        EasyMock.expect(ei.getBinding()).andReturn(bi);
+        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
+        EasyMock.expect(bi.getOperation(opName)).andReturn(boi);
+
+        control.replay();
+        observer.setExchangeProperties(ex, msg);
+        control.verify();
+
+        assertNotNull("Binding should be set",
+                      ex.get(Binding.class));
+        assertNotNull("Service should be set",
+                      ex.get(Service.class));
+    }
+
+    @Test
+    public void testObserverOnMessage() throws Exception {
+        observer = new TestColocMessageObserver(ep, bus);
+        msg.setExchange(ex);
+        
+        Binding binding = control.createMock(Binding.class);
+        EasyMock.expect(ep.getBinding()).andReturn(binding);
+        
+        Message inMsg = new MessageImpl();
+        EasyMock.expect(binding.createMessage()).andReturn(inMsg);
+        
+        EasyMock.expect(ep.getService()).andReturn(srv).anyTimes();
+        EasyMock.expect(
+            bus.getExtension(PhaseManager.class)).andReturn(
+                                      new PhaseManagerImpl()).times(2);
+        EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList<Interceptor>());
+        EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList<Interceptor>());
+        EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList<Interceptor>());
+
+        control.replay();
+        observer.onMessage(msg);
+        control.verify();
+
+        Exchange inEx = inMsg.getExchange();
+        assertNotNull("Should Have a valid Exchange", inEx);
+        assertEquals("Message.REQUESTOR_ROLE should be false",
+                     Boolean.FALSE,
+                     inMsg.get(Message.REQUESTOR_ROLE));
+        assertEquals("Message.INBOUND_MESSAGE should be true",
+                     Boolean.TRUE,
+                     inMsg.get(Message.INBOUND_MESSAGE));
+        assertNotNull("Chain should be set", inMsg.getInterceptorChain());
+        Exchange ex1 = msg.getExchange();
+        assertNotNull("Exchange should be set", ex1);
+    }
+    
+    class TestColocMessageObserver extends ColocMessageObserver {
+        public TestColocMessageObserver(Endpoint endpoint, Bus bus) {
+            super(endpoint, bus);
+        }
+        
+        public void setExchangeProperties(Exchange exchange, Message m) {
+            exchange.put(Bus.class, bus);
+            exchange.put(Endpoint.class, ep);
+            exchange.put(Service.class, srv);
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocMessageObserverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocMessageObserverTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocOutInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocOutInterceptorTest.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocOutInterceptorTest.java (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocOutInterceptorTest.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,426 @@
+/**
+ * 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.binding.coloc;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.binding.Binding;
+import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.phase.PhaseManagerImpl;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ColocOutInterceptorTest extends Assert {
+    private static final String COLOCATED = Message.class.getName() + ".COLOCATED";
+    private IMocksControl control = EasyMock.createNiceControl();
+    private ColocOutInterceptor colocOut;
+    private Message msg;
+    private Exchange ex;
+
+    @Before
+    public void setUp() throws Exception {
+        colocOut = new ColocOutInterceptor();
+        msg = new MessageImpl();
+        ex = new ExchangeImpl();
+        msg.setExchange(ex);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        BusFactory.setDefaultBus(null);
+    }
+
+    @Test
+    public void testColocOutPhase() throws Exception {
+        assertEquals(Phase.POST_LOGICAL, colocOut.getPhase());
+    }
+
+    @Test
+    public void testColocOutInvalidBus() throws Exception {
+        try {
+            colocOut.handleMessage(msg);
+            fail("Should have thrown a fault");
+        } catch (Fault f) {
+            assertEquals("Bus not created or not set as default bus.",
+                         f.getMessage());
+        }
+    }
+
+    @Test
+    public void testColocOutInvalidServiceRegistry() throws Exception {
+
+        setupBus();
+        try {
+            colocOut.handleMessage(msg);
+            fail("Should have thrown a fault");
+        } catch (Fault f) {
+            assertEquals("Server Registry not registered with bus.",
+                         f.getMessage());
+        }
+    }
+
+    @Test
+    public void testColocOutInvalidEndpoint() throws Exception {
+
+        Bus bus = setupBus();
+        ServerRegistry sr = control.createMock(ServerRegistry.class);
+        EasyMock.expect(bus.getExtension(ServerRegistry.class)).andReturn(sr);
+
+        control.replay();
+        try {
+            colocOut.handleMessage(msg);
+            fail("Should have thrown a fault");
+        } catch (Fault f) {
+            assertEquals("Consumer Endpoint not found in exchange.",
+                         f.getMessage());
+        }
+    }
+
+    @Test
+    public void testColocOutInvalidOperation() throws Exception {
+
+        Bus bus = setupBus();
+        ServerRegistry sr = control.createMock(ServerRegistry.class);
+        EasyMock.expect(bus.getExtension(ServerRegistry.class)).andReturn(sr);
+
+        Endpoint ep = control.createMock(Endpoint.class);
+        ex.put(Endpoint.class, ep);
+
+        control.replay();
+        try {
+            colocOut.handleMessage(msg);
+            fail("Should have thrown a fault");
+        } catch (Fault f) {
+            assertEquals("Operation not found in exchange.",
+                         f.getMessage());
+        }
+    }
+
+    @Test
+    public void testColocOutIsColocated() throws Exception {
+        verifyIsColocatedWithNullList();
+        verifyIsColocatedWithEmptyList();
+        verifyIsColocatedWithDifferentService();
+        verifyIsColocatedWithDifferentEndpoint();
+        verifyIsColocatedWithDifferentOperation();
+        verifyIsColocatedWithSameOperation();
+    }
+
+    @Test
+    public void testColocOutIsColocatedPropertySet() throws Exception {
+        colocOut = new TestColocOutInterceptor1();
+        
+        Bus bus = setupBus();
+        ServerRegistry sr = control.createMock(ServerRegistry.class);
+        EasyMock.expect(bus.getExtension(ServerRegistry.class)).andReturn(sr);
+
+        //Funtion Param
+        Server s1 = control.createMock(Server.class);
+        List<Server> list = new ArrayList<Server>();
+        list.add(s1);        
+        Endpoint sep = control.createMock(Endpoint.class);
+        ex.put(Endpoint.class, sep);
+        BindingInfo sbi = control.createMock(BindingInfo.class);
+        InterfaceInfo sii = control.createMock(InterfaceInfo.class);
+        BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
+        
+        ex.put(BindingOperationInfo.class, sboi);
+        //Local var
+        Service ses = control.createMock(Service.class);
+        EndpointInfo sei = control.createMock(EndpointInfo.class);
+
+        Endpoint rep = control.createMock(Endpoint.class);
+        Service res = control.createMock(Service.class);
+        BindingInfo rbi = control.createMock(BindingInfo.class);
+        EndpointInfo rei = control.createMock(EndpointInfo.class);
+
+        EasyMock.expect(sr.getServers()).andReturn(list);
+        EasyMock.expect(sep.getService()).andReturn(ses);
+        EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
+        EasyMock.expect(s1.getEndpoint()).andReturn(rep);
+        EasyMock.expect(rep.getService()).andReturn(res);
+        EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
+        EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
+        EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
+        EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
+        EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
+        EasyMock.expect(rei.getBinding()).andReturn(rbi);
+
+        QName intf = new QName("G", "H");
+        QName op = new QName("E", "F");
+        EasyMock.expect(sboi.getName()).andReturn(op).anyTimes();
+        EasyMock.expect(rbi.getOperation(op)).andReturn(sboi);
+        
+        InterceptorChain chain = control.createMock(InterceptorChain.class);
+        msg.setInterceptorChain(chain);
+        EasyMock.expect(sboi.getBinding()).andReturn(sbi);
+        EasyMock.expect(sbi.getInterface()).andReturn(sii);
+        EasyMock.expect(sii.getName()).andReturn(intf);
+        
+        control.replay();
+        colocOut.handleMessage(msg);
+        assertEquals("COLOCATED property should be set",
+                     Boolean.TRUE, msg.get(COLOCATED));
+        assertEquals("Message.WSDL_OPERATION property should be set",
+                     op, msg.get(Message.WSDL_OPERATION));
+        assertEquals("Message.WSDL_INTERFACE property should be set",
+                     intf, msg.get(Message.WSDL_INTERFACE));
+        
+        control.verify();        
+    }
+    
+    @Test
+    public void testInvokeInboundChain() {
+        //Reset Exchange on msg
+        msg.setExchange(null);
+        Bus bus = setupBus();
+        PhaseManager pm = new PhaseManagerImpl();
+        EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm).times(2);
+
+        Endpoint ep = control.createMock(Endpoint.class);
+        Binding  bd = control.createMock(Binding.class);
+        Service srv = control.createMock(Service.class);
+        ex.setInMessage(msg);
+        ex.put(Bus.class, bus);
+        ex.put(Endpoint.class, ep);
+        ex.put(Service.class, srv);
+        
+        EasyMock.expect(ep.getBinding()).andReturn(bd);
+        EasyMock.expect(bd.createMessage()).andReturn(new MessageImpl());
+        EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList<Interceptor>()).atLeastOnce();
+        EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce();
+        EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList<Interceptor>()).atLeastOnce();
+        EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList<Interceptor>()).atLeastOnce();
+        
+        control.replay();
+        colocOut.invokeInboundChain(ex, ep);
+        Message inMsg = ex.getInMessage();
+        assertNotSame(msg, inMsg);
+        assertEquals("Requestor role should be set to true.",
+                     Boolean.TRUE, inMsg.get(Message.REQUESTOR_ROLE));
+        assertEquals("Inbound Message should be set to true.",
+                     Boolean.TRUE, inMsg.get(Message.INBOUND_MESSAGE));
+        assertNotNull("Inbound Message should have interceptor chain set.",
+                      inMsg.getInterceptorChain());
+        assertEquals("Client Invoke state should be FINISHED",
+                      Boolean.TRUE, ex.get(ClientImpl.FINISHED));
+        control.verify();
+    }
+    
+    private void verifyIsColocatedWithNullList() {
+        Server val = colocOut.isColocated(null, null, null);
+        assertEquals("Is not a colocated call",
+                     null,
+                     val);
+        control.reset();
+    }
+
+    private void verifyIsColocatedWithEmptyList() {
+        List<Server> list = new ArrayList<Server>();
+        //Local var
+        Endpoint sep = control.createMock(Endpoint.class);
+        Service ses = control.createMock(Service.class);
+        EndpointInfo sei = control.createMock(EndpointInfo.class);
+
+        EasyMock.expect(sep.getService()).andReturn(ses);
+        EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
+        
+        control.replay();
+        Server val = colocOut.isColocated(list, sep, null);
+        assertEquals("Is not a colocated call",
+                     null,
+                     val);
+        control.reset();
+    }
+
+    private void verifyIsColocatedWithDifferentService() {
+        //Funtion Param
+        Server s1 = control.createMock(Server.class);
+        List<Server> list = new ArrayList<Server>();
+        list.add(s1);        
+        Endpoint sep = control.createMock(Endpoint.class);
+        //Local var
+        Service ses = control.createMock(Service.class);
+
+        Endpoint rep = control.createMock(Endpoint.class);
+        Service res = control.createMock(Service.class);
+
+        EasyMock.expect(sep.getService()).andReturn(ses);
+        EasyMock.expect(s1.getEndpoint()).andReturn(rep);
+        EasyMock.expect(rep.getService()).andReturn(res);
+        EasyMock.expect(ses.getName()).andReturn(new QName("A", "C"));
+        EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
+        
+        control.replay();
+        Server val = colocOut.isColocated(list, sep, null);
+        assertEquals("Is not a colocated call",
+                     null,
+                     val);
+        control.reset();
+    }
+
+    private void verifyIsColocatedWithDifferentEndpoint() {
+        //Funtion Param
+        Server s1 = control.createMock(Server.class);
+        List<Server> list = new ArrayList<Server>();
+        list.add(s1);        
+        Endpoint sep = control.createMock(Endpoint.class);
+        BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
+        //Local var
+        Service ses = control.createMock(Service.class);
+        EndpointInfo sei = control.createMock(EndpointInfo.class);
+
+        Endpoint rep = control.createMock(Endpoint.class);
+        Service res = control.createMock(Service.class);
+        EndpointInfo rei = control.createMock(EndpointInfo.class);
+
+        EasyMock.expect(sep.getService()).andReturn(ses);
+        EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
+        EasyMock.expect(s1.getEndpoint()).andReturn(rep);
+        EasyMock.expect(rep.getService()).andReturn(res);
+        EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
+        EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
+        EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
+        EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
+        EasyMock.expect(sei.getName()).andReturn(new QName("C", "E"));
+        
+        control.replay();
+        Server val = colocOut.isColocated(list, sep, sboi);
+        assertEquals("Is not a colocated call",
+                     null,
+                     val);
+        control.reset();
+    }
+
+    private void verifyIsColocatedWithDifferentOperation() {
+        //Funtion Param
+        Server s1 = control.createMock(Server.class);
+        List<Server> list = new ArrayList<Server>();
+        list.add(s1);        
+        Endpoint sep = control.createMock(Endpoint.class);
+        BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
+        //Local var
+        Service ses = control.createMock(Service.class);
+        EndpointInfo sei = control.createMock(EndpointInfo.class);
+        BindingInfo rbi = control.createMock(BindingInfo.class);
+        Endpoint rep = control.createMock(Endpoint.class);
+        Service res = control.createMock(Service.class);
+        EndpointInfo rei = control.createMock(EndpointInfo.class);
+
+        EasyMock.expect(sep.getService()).andReturn(ses);
+        EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
+        EasyMock.expect(s1.getEndpoint()).andReturn(rep);
+        EasyMock.expect(rep.getService()).andReturn(res);
+        EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
+        EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
+        EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
+        EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
+        EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
+        EasyMock.expect(rei.getBinding()).andReturn(rbi);
+        QName op = new QName("E", "F");
+        EasyMock.expect(rbi.getOperation(op)).andReturn(null);
+        
+        control.replay();
+        Server val = colocOut.isColocated(list, sep, sboi);
+        assertEquals("Is not a colocated call",
+                     null,
+                     val);
+        control.reset();
+    }
+
+    private void verifyIsColocatedWithSameOperation() {
+        //Funtion Param
+        Server s1 = control.createMock(Server.class);
+        List<Server> list = new ArrayList<Server>();
+        list.add(s1);        
+        Endpoint sep = control.createMock(Endpoint.class);
+        BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
+        //Local var
+        Service ses = control.createMock(Service.class);
+        EndpointInfo sei = control.createMock(EndpointInfo.class);
+        BindingInfo rbi = control.createMock(BindingInfo.class);
+        Endpoint rep = control.createMock(Endpoint.class);
+        Service res = control.createMock(Service.class);
+        EndpointInfo rei = control.createMock(EndpointInfo.class);
+
+        EasyMock.expect(sep.getService()).andReturn(ses);
+        EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
+        EasyMock.expect(s1.getEndpoint()).andReturn(rep);
+        EasyMock.expect(rep.getService()).andReturn(res);
+        EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
+        EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
+        EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
+        EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
+        EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
+        EasyMock.expect(rei.getBinding()).andReturn(rbi);
+        QName op = new QName("E", "F");
+        EasyMock.expect(sboi.getName()).andReturn(op);
+        EasyMock.expect(rbi.getOperation(op)).andReturn(sboi);
+        
+        control.replay();
+        Server val = colocOut.isColocated(list, sep, sboi);
+        assertEquals("Expecting a colocated call",
+                     s1,
+                     val);
+        control.reset();
+    }
+    
+    private Bus setupBus() {
+        Bus bus = control.createMock(Bus.class);
+        BusFactory.setDefaultBus(bus);
+        return bus;
+    }
+    
+    class TestColocOutInterceptor1 extends ColocOutInterceptor {
+        public void invokeColocObserver(Message outMsg, Endpoint inboundEndpoint, Bus bus) {
+            //No Op
+        }
+        
+        public void invokeInboundChain(Exchange exchange, Endpoint ep) {
+            //No Op
+        }        
+    }
+}

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocOutInterceptorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocOutInterceptorTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java (added)
+++ incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,156 @@
+/**
+ * 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.binding.coloc;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.phase.PhaseManagerImpl;
+import org.apache.cxf.service.Service;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ColocUtilTest extends Assert {
+    private IMocksControl control = EasyMock.createNiceControl();
+    private Bus bus;
+
+    @Before
+    public void setUp() throws Exception {
+        bus = control.createMock(Bus.class);
+        BusFactory.setDefaultBus(bus);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        BusFactory.setDefaultBus(null);
+    }
+
+    @Test
+    public void testSetColocInPhases() throws Exception {
+        PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
+        List<Phase> list = phaseMgr.getInPhases();
+        int size1 = list.size();
+        ColocUtil.setPhases(list, Phase.USER_LOGICAL, Phase.INVOKE);
+
+        assertNotSame("The list size should not be same",
+                      size1, list.size());
+        assertEquals("Expecting Phase.USER_LOGICAL",
+                     list.get(0).getName(),
+                     Phase.USER_LOGICAL);
+        assertEquals("Expecting Phase.POST_INVOKE",
+                     list.get(list.size() - 1).getName(),
+                     Phase.INVOKE);
+    }
+
+    @Test
+    public void testSetColocOutPhases() throws Exception {
+        PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
+
+        List<Phase> list = phaseMgr.getOutPhases();
+        int size1 = list.size();
+        ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL);
+
+        assertNotSame("The list size should not be same",
+                      size1, list.size());
+        assertEquals("Expecting Phase.SETUP",
+                     list.get(0).getName(),
+                     Phase.SETUP);
+        assertEquals("Expecting Phase.POST_LOGICAL",
+                     list.get(list.size() - 1).getName(),
+                     Phase.POST_LOGICAL);
+
+    }
+    
+    @Test
+    public void testGetOutInterceptorChain() throws Exception {
+        PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
+        List<Phase> list = phaseMgr.getInPhases();
+        ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL);
+        
+        Endpoint ep = control.createMock(Endpoint.class);
+        Service srv = control.createMock(Service.class);
+        Exchange ex = new ExchangeImpl();
+        
+        ex.put(Bus.class, bus);
+        ex.put(Endpoint.class, ep);
+        ex.put(Service.class, srv);
+        
+        EasyMock.expect(ep.getOutInterceptors()).andReturn(new ArrayList<Interceptor>()).atLeastOnce();
+        EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce();
+        EasyMock.expect(srv.getOutInterceptors()).andReturn(new ArrayList<Interceptor>()).atLeastOnce();
+        EasyMock.expect(bus.getOutInterceptors()).andReturn(new ArrayList<Interceptor>()).atLeastOnce();
+        
+        control.replay();
+        InterceptorChain chain = ColocUtil.getOutInterceptorChain(ex, list);
+        control.verify();
+        assertNotNull("Should have chain instance", chain);
+        Iterator<Interceptor<? extends Message>> iter = chain.iterator();
+        assertEquals("Should not have interceptors in chain",
+                     false,
+                     iter.hasNext());
+    }
+
+    @Test
+    public void testGetInInterceptorChain() throws Exception {
+        PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
+        List<Phase> list = phaseMgr.getInPhases();
+        ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL);
+        
+        Endpoint ep = control.createMock(Endpoint.class);
+        Service srv = control.createMock(Service.class);
+        Exchange ex = new ExchangeImpl();
+        
+        ex.put(Bus.class, bus);
+        ex.put(Endpoint.class, ep);
+        ex.put(Service.class, srv);
+        
+        EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(phaseMgr);
+        EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList<Interceptor>()).atLeastOnce();
+        EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce();
+        EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList<Interceptor>()).atLeastOnce();
+        EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList<Interceptor>()).atLeastOnce();
+        
+        control.replay();
+        InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, list);
+        control.verify();
+        assertNotNull("Should have chain instance", chain);
+        Iterator<Interceptor<? extends Message>> iter = chain.iterator();
+        assertEquals("Should not have interceptors in chain",
+                     false,
+                     iter.hasNext());
+        assertNotNull("OutFaultObserver should be set", chain.getFaultObserver());
+    }
+    
+}

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/coloc/src/test/java/org/apache/cxf/binding/coloc/ColocUtilTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=528035&r1=528034&r2=528035
==============================================================================
--- 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 Thu Apr 12 10:00:11 2007
@@ -74,7 +74,7 @@
         EasyMock.expect(endpoint.getBinding()).andStubReturn(binding);
         MessageImpl m = new MessageImpl();
         EasyMock.expect(binding.createMessage()).andStubReturn(m);
-        
+
         EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
         EasyMock.expect(endpoint.getOutInterceptors()).andReturn(empty);
         EasyMock.expect(service.getOutInterceptors()).andReturn(empty);
@@ -98,7 +98,6 @@
     }
 
     public void testInterceptor() throws Exception {
-        OutgoingChainSetupInterceptor setupIntc = new OutgoingChainSetupInterceptor();
         OutgoingChainInterceptor intc = new OutgoingChainInterceptor();
 
         MessageImpl m = new MessageImpl();
@@ -109,7 +108,6 @@
         exchange.put(Binding.class, binding);
         exchange.put(BindingOperationInfo.class, bopInfo);
         exchange.setOutMessage(m);
-        setupIntc.handleMessage(m);
         intc.handleMessage(m);
     }
 

Modified: incubator/cxf/trunk/systests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/pom.xml?view=diff&rev=528035&r1=528034&r2=528035
==============================================================================
--- incubator/cxf/trunk/systests/pom.xml (original)
+++ incubator/cxf/trunk/systests/pom.xml Thu Apr 12 10:00:11 2007
@@ -6,9 +6,9 @@
   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
@@ -145,7 +145,11 @@
             <artifactId>cxf-integration-jca</artifactId>
             <version>${project.version}</version>
         </dependency>
-
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-bindings-coloc</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-testutils</artifactId>

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/AbstractColocTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/AbstractColocTest.java?view=auto&rev=528035
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/AbstractColocTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/AbstractColocTest.java Thu Apr 12 10:00:11 2007
@@ -0,0 +1,124 @@
+/**
+ * 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.coloc;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+
+import org.apache.commons.logging.Log;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+
+public abstract class AbstractColocTest extends Assert {
+    /**
+     * Cxf Bus
+     */
+    protected Bus bus;
+
+    /**
+     * WS endpoint object
+     */
+    protected Endpoint endpoint;
+
+    /**
+     * Setup this test case
+     */
+    @Before
+    public void setUp() throws Exception {
+        // initialize Mule Manager
+        URL cxfConfig = null;
+        if (getCxfConfig() != null) {
+            cxfConfig = ClassLoaderUtils.getResource(getCxfConfig(), AbstractColocTest.class);
+            if (cxfConfig == null) {
+                throw new Exception("Make sure " + getCxfConfig() + " is in the CLASSPATH");
+            }
+            assertTrue(cxfConfig.toExternalForm() != null);
+        }
+
+        //Bus is shared by client, router and server.
+        SpringBusFactory bf = new SpringBusFactory();
+        bus = bf.createBus(cxfConfig);
+        BusFactory.setDefaultBus(bus);
+
+        //Start the Remote Server
+        // the endpoint of the "real" cxf server
+        endpoint = Endpoint.publish(getTransportURI(), getServiceImpl());
+    }
+
+    /**
+     * Tear down this test case
+     */
+    @After
+    public void tearDown() throws Exception {
+
+        getLogger().debug("tearDown ...");
+
+        if (endpoint != null) {
+            endpoint.stop();
+        }
+
+        if (bus != null) {
+            bus.shutdown(true);
+        }
+    }
+    /**
+     * @return cxf configuration file name
+     */
+    protected String getCxfConfig() {
+        return "org/apache/cxf/systest/coloc/cxf.xml";
+    }
+
+    /**
+     * Create client and return the port
+     * @return port for a interface represented by cls.
+     */
+    protected <T> T getPort(QName serviceName, QName portName,
+                                  String wsdlLocation, Class<T> cls) {
+        Service srv = Service.create(
+                         AbstractColocTest.class.getResource(wsdlLocation),
+                         serviceName);
+        return srv.getPort(portName, cls);
+    }
+    /**
+     * @return the greeter impl object
+     */
+    protected abstract Object getServiceImpl();
+
+    /**
+     * @return logger object
+     */
+    protected abstract Log getLogger();
+
+    /**
+     * @return transport URI for the WS Endpoint
+     */
+    protected abstract String getTransportURI();
+
+
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/AbstractColocTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/coloc/AbstractColocTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message