Author: slaws
Date: Thu Jun 23 16:20:49 2011
New Revision: 1138966

URL: http://svn.apache.org/viewvc?rev=1138966&view=rev
Log:
Take a look at the sequence of interceptors that gets called when an exception 
is thrown. Seems to be OK at first view when we depend on InterceptorAsyncImpl. 

Added:
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldException.java
Modified:
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorld.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java

Modified: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorld.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorld.java?rev=1138966&r1=1138965&r2=1138966&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorld.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorld.java
 Thu Jun 23 16:20:49 2011
@@ -25,5 +25,7 @@ import org.oasisopen.sca.annotation.Remo
 public interface HelloWorld {
     
     String getGreetings(String s);
+    
+    String getGreetingsException(String s) throws HelloWorldException;
 
 }

Modified: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java?rev=1138966&r1=1138965&r2=1138966&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java
 Thu Jun 23 16:20:49 2011
@@ -29,9 +29,21 @@ public class HelloWorldClient implements
     public HelloWorld helloWorldWS;
     
     public String getGreetings(String s) {
+        StatusImpl.appendStatus("At client.getGreetings() pre-invoke", s);
         String response = helloWorldWS.getGreetings(s);
-        StatusImpl.appendStatus("At client", response);
+        StatusImpl.appendStatus("At client.getGreetings() post-invoke", 
response);
         return response;
     }
-
+    
+    public String getGreetingsException(String s) throws HelloWorldException {
+        StatusImpl.appendStatus("At client.getGreetingsException() 
pre-invoke", s);
+        try {
+            String response = helloWorldWS.getGreetingsException(s);
+            StatusImpl.appendStatus("At client.getGreetingsException() 
post-invoke", response);
+            return response;    
+        } catch (HelloWorldException ex){
+            StatusImpl.appendStatus("At client.getGreetingsException() 
post-exception", ex.getMessage());
+            throw ex;
+        }
+    }
 }

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldException.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldException.java?rev=1138966&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldException.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldException.java
 Thu Jun 23 16:20:49 2011
@@ -0,0 +1,34 @@
+/*
+ * 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 helloworld;
+
+
+public class HelloWorldException extends Exception {
+
+    private static final long serialVersionUID = 4608283774062947117L;
+    
+    public HelloWorldException(){
+    }
+
+    public HelloWorldException(String message){
+        super(message);
+    }
+
+}

Modified: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java?rev=1138966&r1=1138965&r2=1138966&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java
 Thu Jun 23 16:20:49 2011
@@ -29,10 +29,16 @@ public class HelloWorldService implement
     @Context
     protected RequestContext requestContext;
     
-    public String getGreetings(String name) {
-        Subject subject = requestContext.getSecuritySubject();
-        String response = "Hello " + name;       
-        StatusImpl.appendStatus("At service", response);
+    public String getGreetings(String s) {
+        //Subject subject = requestContext.getSecuritySubject();
+        String response = "Hello " + s;       
+        StatusImpl.appendStatus("At service.getGreetings()", response);
         return response;
     }
+    
+    public String getGreetingsException(String s) throws HelloWorldException {
+        String response = "Hello " + s;  
+        StatusImpl.appendStatus("At service.getGreetingsException()", 
response);
+        throw new HelloWorldException(response);
+    }
 }

Modified: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java?rev=1138966&r1=1138965&r2=1138966&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java
 Thu Jun 23 16:20:49 2011
@@ -51,7 +51,9 @@ public class TestBindingWSPolicyProvider
         List<org.apache.axis2.engine.Phase> outPhases = 
axisConfiguration.getOutFlowPhases();
         outPhases.get(0).addHandler(new TestBindingWSAxisHandler("Reference 
OutFlow Handler"));
         List<org.apache.axis2.engine.Phase> inPhases = 
axisConfiguration.getInFlowPhases();
-        inPhases.get(0).addHandler(new TestBindingWSAxisHandler("Reference 
InFlow Handler"));         
+        inPhases.get(0).addHandler(new TestBindingWSAxisHandler("Reference 
InFlow Handler"));  
+        List<org.apache.axis2.engine.Phase> inFaultPhases = 
axisConfiguration.getInFaultFlowPhases();
+        inFaultPhases.get(0).addHandler(new 
TestBindingWSAxisHandler("Reference InFaultFlow Handler"));
     }
 
     public PhasedInterceptor createBindingInterceptor() {

Modified: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java?rev=1138966&r1=1138965&r2=1138966&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java
 Thu Jun 23 16:20:49 2011
@@ -52,6 +52,8 @@ public class TestBindingWSPolicyProvider
         inPhases.get(0).addHandler(new TestBindingWSAxisHandler("Service 
InFlow Handler"));              
         List<org.apache.axis2.engine.Phase> outPhases = 
axisConfiguration.getOutFlowPhases();
         outPhases.get(0).addHandler(new TestBindingWSAxisHandler("Service 
OutFlow Handler"));
+        List<org.apache.axis2.engine.Phase> outFaultPhases = 
axisConfiguration.getOutFaultFlowPhases();
+        outFaultPhases.get(0).addHandler(new TestBindingWSAxisHandler("Service 
OutFaultFlow Handler"));
     }
 
     public PhasedInterceptor createBindingInterceptor() {

Modified: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java?rev=1138966&r1=1138965&r2=1138966&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java
 Thu Jun 23 16:20:49 2011
@@ -25,6 +25,7 @@ import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import helloworld.HelloWorld;
+import helloworld.HelloWorldException;
 import helloworld.StatusImpl;
 
 import org.apache.tuscany.sca.assembly.Component;
@@ -50,7 +51,7 @@ public class HelloworldTestCase extends 
         helloWorld = node.getService(HelloWorld.class, 
"HelloWorldClient/HelloWorld");
     }
     
-    public void testCalculator() throws Exception {
+    public void testHelloWorld() throws Exception {
         // check response from application
         assertEquals("Hello fred", helloWorld.getGreetings("fred"));
         
@@ -61,6 +62,7 @@ public class HelloworldTestCase extends 
                      "TestPolicyInterceptor.processRequest() - 
HelloWorldClient#reference-binding($self$.HelloWorld/HelloWorld) @ 
reference.policy\n" +
                      "TestPolicyInterceptor.processRequest() - 
HelloWorldClient#service-binding(HelloWorld/HelloWorld) @ service.policy\n" +
                      "TestPolicyInterceptor.processRequest() - null @ 
implementation.policy\n" +
+                     "At client.getGreetings() pre-invoke - fred\n" +
                      "TestBindingWSPolicyProviderReference.configureBinding() 
- 
org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ReferenceBindingProvider\n"
 +
                      "TestPolicyInterceptor.processRequest() - 
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @ 
reference.policy\n" +
                      "TestBindingWSPolicyInterceptor.processRequest() - 
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @ 
reference.binding.policy\n" +
@@ -69,7 +71,7 @@ public class HelloworldTestCase extends 
                      "TestBindingWSPolicyInterceptor.processRequest() - 
HelloWorldService2#service-binding(HelloWorld/BindingWS) @ 
service.binding.policy\n" +
                      "TestPolicyInterceptor.processRequest() - 
HelloWorldService2#service-binding(HelloWorld/BindingWS) @ service.policy\n" +
                      "TestPolicyInterceptor.processRequest() - null @ 
implementation.policy\n" +
-                     "At service - Hello fred\n" +
+                     "At service.getGreetings() - Hello fred\n" +
                      "TestPolicyInterceptor.processResponse() - null @ 
implementation.policy\n" +
                      "TestPolicyInterceptor.processResponse() - 
HelloWorldService2#service-binding(HelloWorld/BindingWS) @ service.policy\n" +
                      "TestBindingWSPolicyInterceptor.processResponse() - 
HelloWorldService2#service-binding(HelloWorld/BindingWS) @ 
service.binding.policy\n" +
@@ -77,7 +79,7 @@ public class HelloworldTestCase extends 
                      "TestAxisHandler.invoke() - Reference InFlow Handler\n" +
                      "TestBindingWSPolicyInterceptor.processResponse() - 
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @ 
reference.binding.policy\n" +
                      "TestPolicyInterceptor.processResponse() - 
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @ 
reference.policy\n" +
-                     "At client - Hello fred\n" +
+                     "At client.getGreetings() post-invoke - Hello fred\n" +
                      "TestPolicyInterceptor.processResponse() - null @ 
implementation.policy\n" +
                      "TestPolicyInterceptor.processResponse() - 
HelloWorldClient#service-binding(HelloWorld/HelloWorld) @ service.policy\n" +
                      "TestPolicyInterceptor.processResponse() - 
HelloWorldClient#reference-binding($self$.HelloWorld/HelloWorld) @ 
reference.policy\n", 
@@ -94,6 +96,57 @@ public class HelloworldTestCase extends 
         
     }    
     
+    public void testHelloWorldException() throws Exception {
+        
+        // check response from application
+        try {
+            helloWorld.getGreetingsException("fred");
+            Assert.fail();
+        } catch (HelloWorldException ex){
+            assertEquals("Hello fred", ex.getMessage());
+        }
+        
+        // check sequences of interceptors
+        System.out.println(StatusImpl.statusString);
+        assertEquals("TestBindingWSPolicyProviderService.configureBinding() - 
org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ServiceBindingProvider\n" 
+
+                     "TestBindingWSPolicyProviderService.configureBinding() - 
org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ServiceBindingProvider\n" 
+
+                     "TestPolicyInterceptor.processRequest() - 
HelloWorldClient#reference-binding($self$.HelloWorld/HelloWorld) @ 
reference.policy\n" +
+                     "TestPolicyInterceptor.processRequest() - 
HelloWorldClient#service-binding(HelloWorld/HelloWorld) @ service.policy\n" +
+                     "TestPolicyInterceptor.processRequest() - null @ 
implementation.policy\n" +
+                     "At client.getGreetingsException() pre-invoke - fred\n" +
+                     "TestBindingWSPolicyProviderReference.configureBinding() 
- 
org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ReferenceBindingProvider\n"
 +
+                     "TestPolicyInterceptor.processRequest() - 
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @ 
reference.policy\n" +
+                     "TestBindingWSPolicyInterceptor.processRequest() - 
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @ 
reference.binding.policy\n" +
+                     "TestAxisHandler.invoke() - Reference OutFlow Handler\n" +
+                     "TestAxisHandler.invoke() - Service InFlow Handler\n" +
+                     "TestBindingWSPolicyInterceptor.processRequest() - 
HelloWorldService2#service-binding(HelloWorld/BindingWS) @ 
service.binding.policy\n" +
+                     "TestPolicyInterceptor.processRequest() - 
HelloWorldService2#service-binding(HelloWorld/BindingWS) @ service.policy\n" +
+                     "TestPolicyInterceptor.processRequest() - null @ 
implementation.policy\n" +
+                     "At service.getGreetingsException() - Hello fred\n" +
+                     "TestPolicyInterceptor.processResponse() - null @ 
implementation.policy\n" +
+                     "TestPolicyInterceptor.processResponse() - 
HelloWorldService2#service-binding(HelloWorld/BindingWS) @ service.policy\n" +
+                     "TestBindingWSPolicyInterceptor.processResponse() - 
HelloWorldService2#service-binding(HelloWorld/BindingWS) @ 
service.binding.policy\n" +
+                     "TestAxisHandler.invoke() - Service OutFaultFlow 
Handler\n" +
+                     "TestAxisHandler.invoke() - Reference InFaultFlow 
Handler\n" +
+                     "TestBindingWSPolicyInterceptor.processResponse() - 
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @ 
reference.binding.policy\n" +
+                     "TestPolicyInterceptor.processResponse() - 
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @ 
reference.policy\n" +
+                     "At client.getGreetingsException() post-exception - Hello 
fred\n" +
+                     "TestPolicyInterceptor.processResponse() - null @ 
implementation.policy\n" +
+                     "TestPolicyInterceptor.processResponse() - 
HelloWorldClient#service-binding(HelloWorld/HelloWorld) @ service.policy\n" +
+                     "TestPolicyInterceptor.processResponse() - 
HelloWorldClient#reference-binding($self$.HelloWorld/HelloWorld) @ 
reference.policy\n", 
+                     StatusImpl.statusString);
+        
+        // check final intents on endpoint reference to see if the matching 
process
+        // results on the right set
+        Composite domainComposite = ((NodeImpl)node).getDomainComposite();
+        List<PolicySet> policySets = 
domainComposite.getComponents().get(0).getReferences().get(0).getEndpointReferences().get(0).getPolicySets();
+        
+        assertEquals(2, policySets.size());
+        assertEquals("TestInteractonPolicySet2", 
policySets.get(0).getName().getLocalPart());
+        assertEquals("TestInteractonPolicySet1", 
policySets.get(1).getName().getLocalPart());
+        
+    }       
+    
     @Override
     protected void tearDown() throws Exception {
         node.stop();


Reply via email to