cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jp...@apache.org
Subject cxf git commit: CXF-6118 remove the client mappings for IN / OUT. Replaced with new REQUEST / RESPONSE validation types which are client / server sensitive
Date Sun, 30 Nov 2014 22:03:23 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 9df5ed744 -> ee8dc35aa


CXF-6118 remove the client mappings for IN / OUT.  Replaced with new REQUEST / RESPONSE validation
types which are client / server sensitive


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ee8dc35a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ee8dc35a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ee8dc35a

Branch: refs/heads/2.7.x-fixes
Commit: ee8dc35aaa3ba91f41f948cc586818af6da4c425
Parents: 9df5ed7
Author: Jason Pell <jpell@apache.org>
Authored: Sun Nov 30 11:31:27 2014 +1100
Committer: Jason Pell <jpell@apache.org>
Committed: Mon Dec 1 09:03:16 2014 +1100

----------------------------------------------------------------------
 .../cxf/annotations/SchemaValidation.java       |   2 +-
 .../org/apache/cxf/helpers/ServiceUtils.java    |  37 ++--
 .../AbstractInDatabindingInterceptor.java       |   5 +-
 .../AbstractOutDatabindingInterceptor.java      |   4 +-
 .../apache/cxf/helpers/ServiceUtilsTest.java    |  93 +++++---
 .../JavaFirstSchemaValidationTest.java          | 213 ++++++++-----------
 .../PersonServiceWithRequestResponseAnns.java   |  52 +++++
 ...ersonServiceWithRequestResponseAnnsImpl.java |  50 +++++
 8 files changed, 286 insertions(+), 170 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ee8dc35a/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java b/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
index d0d6e72..c04e04f 100644
--- a/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
+++ b/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
@@ -33,7 +33,7 @@ import java.lang.annotation.Target;
 @Target({ ElementType.TYPE, ElementType.METHOD })
 public @interface SchemaValidation {
     public enum SchemaValidationType {
-        IN, OUT, BOTH, NONE
+        IN, REQUEST, OUT, RESPONSE, BOTH, NONE
     }
     
     @Deprecated

http://git-wip-us.apache.org/repos/asf/cxf/blob/ee8dc35a/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java b/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
index 28c7ba2..0be09b9 100644
--- a/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
+++ b/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
@@ -49,6 +49,21 @@ public final class ServiceUtils {
      */
     public static boolean isSchemaValidationEnabled(SchemaValidationType type, Message message)
{
         SchemaValidationType validationType = getSchemaValidationType(message);
+
+        boolean isRequestor = MessageUtils.isRequestor(message);
+        if (SchemaValidationType.REQUEST.equals(validationType)) {
+            if (isRequestor) {
+                validationType = SchemaValidationType.OUT;
+            } else {
+                validationType = SchemaValidationType.IN;
+            }
+        } else if (SchemaValidationType.RESPONSE.equals(validationType)) {
+            if (isRequestor) {
+                validationType = SchemaValidationType.IN;
+            } else {
+                validationType = SchemaValidationType.OUT;
+            }
+        }
         
         return validationType.equals(type) 
             || ((SchemaValidationType.IN.equals(type) || SchemaValidationType.OUT.equals(type))
@@ -71,7 +86,7 @@ public final class ServiceUtils {
         if (validationType == null) {
             validationType = SchemaValidationType.NONE;
         }
-        
+     
         return validationType;
     }
     
@@ -86,7 +101,6 @@ public final class ServiceUtils {
     }
     
     private static SchemaValidationType getSchemaValidationTypeFromModel(Message message)
{
-        boolean isRequestor = MessageUtils.isRequestor(message);
         Exchange exchange = message.getExchange();
         
         if (exchange != null) {
@@ -99,10 +113,10 @@ public final class ServiceUtils {
                 EndpointInfo ep = endpoint.getEndpointInfo();
                 
                 if (validationType == null && opInfo != null) {
-                    validationType = getSchemaValidationTypeFromModel(message, opInfo, isRequestor);
+                    validationType = getSchemaValidationTypeFromModel(message, opInfo);
                     
                     if (validationType == null && ep != null) {
-                        validationType = getSchemaValidationTypeFromModel(message, ep, isRequestor);
+                        validationType = getSchemaValidationTypeFromModel(message, ep);
                     }
                 }
                 
@@ -115,21 +129,10 @@ public final class ServiceUtils {
     }
     
     private static SchemaValidationType getSchemaValidationTypeFromModel(
-            Message message, AbstractPropertiesHolder properties, boolean isRequestor) {
+            Message message, AbstractPropertiesHolder properties) {
         Object obj = properties.getProperty(Message.SCHEMA_VALIDATION_TYPE);
         if (obj != null) {
-            SchemaValidationType validationType = getSchemaValidationType(obj);
-            
-            // Reverse the direction of any IN / OUT for requestor (client)
-            if (isRequestor) {
-                if (SchemaValidationType.IN.equals(validationType)) {
-                    return SchemaValidationType.OUT;
-                } else if (SchemaValidationType.OUT.equals(validationType)) {
-                    return SchemaValidationType.IN;
-                }
-            }
-
-            return validationType;
+            return getSchemaValidationType(obj);
         } else {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ee8dc35a/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
b/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
index ec8cf71..5810edc 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
+++ b/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
@@ -30,7 +30,6 @@ import javax.xml.stream.XMLStreamReader;
 import javax.xml.validation.Schema;
 
 import org.w3c.dom.Node;
-
 import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.databinding.DataReader;
@@ -38,6 +37,7 @@ import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.ServiceUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingMessageInfo;
@@ -67,8 +67,9 @@ public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInte
         super(i, phase);
     }
     
+    @Deprecated
     protected boolean isRequestor(Message message) {
-        return Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE));
+        return MessageUtils.isRequestor(message);
     }
  
     protected boolean supportsDataReader(Message message, Class<?> input) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/ee8dc35a/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
b/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
index 52d1cb1..1dd720a 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
+++ b/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
@@ -59,9 +59,11 @@ public abstract class AbstractOutDatabindingInterceptor extends AbstractPhaseInt
         super(id, phase);
     }
     
+    @Deprecated
     protected boolean isRequestor(Message message) {
-        return Boolean.TRUE.equals(message.containsKey(Message.REQUESTOR_ROLE));
+        return MessageUtils.isRequestor(message);
     }
+    
     protected boolean shouldBuffer(Message message) {
         Object en = message.getContextualProperty(OUT_BUFFERING);
         boolean allowBuffer = true;

http://git-wip-us.apache.org/repos/asf/cxf/blob/ee8dc35a/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java b/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
index b790880..32a5820 100644
--- a/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
+++ b/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
@@ -46,95 +46,128 @@ public class ServiceUtilsTest extends Assert {
     }
     
     @Test
+    public void testRequestResponseTypes() {
+        // lets do server side first
+        setupSchemaValidationValue(SchemaValidationType.REQUEST, false);
+        assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+        
+        setupSchemaValidationValue(SchemaValidationType.REQUEST, false);
+        assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+        
+        setupSchemaValidationValue(SchemaValidationType.RESPONSE, false);
+        assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+        
+        setupSchemaValidationValue(SchemaValidationType.RESPONSE, false);
+        assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+        
+        // now client side
+        setupSchemaValidationValue(SchemaValidationType.REQUEST, true);
+        assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+        
+        setupSchemaValidationValue(SchemaValidationType.REQUEST, true);
+        assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+        
+        setupSchemaValidationValue(SchemaValidationType.RESPONSE, true);
+        assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+        
+        setupSchemaValidationValue(SchemaValidationType.RESPONSE, true);
+        assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+    }
+    
+    @Test
     public void testIsSchemaValidationEnabled() {
-        setupSchemaValidationValue(SchemaValidationType.NONE);
+        setupSchemaValidationValue(SchemaValidationType.NONE, false);
         assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
-        setupSchemaValidationValue(SchemaValidationType.NONE);
+        setupSchemaValidationValue(SchemaValidationType.NONE, false);
         assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
-        setupSchemaValidationValue(SchemaValidationType.NONE);
+        setupSchemaValidationValue(SchemaValidationType.NONE, false);
         assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
-        setupSchemaValidationValue(SchemaValidationType.NONE);
+        setupSchemaValidationValue(SchemaValidationType.NONE, false);
         assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
         
-        setupSchemaValidationValue(SchemaValidationType.IN);
+        setupSchemaValidationValue(SchemaValidationType.IN, false);
         assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
-        setupSchemaValidationValue(SchemaValidationType.IN);
+        setupSchemaValidationValue(SchemaValidationType.IN, false);
         assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
-        setupSchemaValidationValue(SchemaValidationType.IN);
+        setupSchemaValidationValue(SchemaValidationType.IN, false);
         assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
-        setupSchemaValidationValue(SchemaValidationType.IN);
+        setupSchemaValidationValue(SchemaValidationType.IN, false);
         assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
         
-        setupSchemaValidationValue(SchemaValidationType.OUT);
+        setupSchemaValidationValue(SchemaValidationType.OUT, false);
         assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
-        setupSchemaValidationValue(SchemaValidationType.OUT);
+        setupSchemaValidationValue(SchemaValidationType.OUT, false);
         assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
-        setupSchemaValidationValue(SchemaValidationType.OUT);
+        setupSchemaValidationValue(SchemaValidationType.OUT, false);
         assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
-        setupSchemaValidationValue(SchemaValidationType.OUT);
+        setupSchemaValidationValue(SchemaValidationType.OUT, false);
         assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
         
-        setupSchemaValidationValue(SchemaValidationType.BOTH);
+        setupSchemaValidationValue(SchemaValidationType.BOTH, false);
         assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
-        setupSchemaValidationValue(SchemaValidationType.BOTH);
+        setupSchemaValidationValue(SchemaValidationType.BOTH, false);
         assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
-        setupSchemaValidationValue(SchemaValidationType.BOTH);
+        setupSchemaValidationValue(SchemaValidationType.BOTH, false);
         assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
-        setupSchemaValidationValue(SchemaValidationType.BOTH);
+        setupSchemaValidationValue(SchemaValidationType.BOTH, false);
         assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
     }
     
     @Test
     public void testGetSchemaValidationTypeBoolean() {
-        setupSchemaValidationValue(null);
+        setupSchemaValidationValue(null, false);
         assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
         
-        setupSchemaValidationValue("");
+        setupSchemaValidationValue("", false);
         assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
         
-        setupSchemaValidationValue(Boolean.FALSE);
+        setupSchemaValidationValue(Boolean.FALSE, false);
         assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
         
-        setupSchemaValidationValue("false");
+        setupSchemaValidationValue("false", false);
         assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
         
-        setupSchemaValidationValue("FALSE");
+        setupSchemaValidationValue("FALSE", false);
         assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
         
-        setupSchemaValidationValue("fAlse");
+        setupSchemaValidationValue("fAlse", false);
         assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
         
-        setupSchemaValidationValue(Boolean.TRUE);
+        setupSchemaValidationValue(Boolean.TRUE, false);
         assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
         
-        setupSchemaValidationValue("true");
+        setupSchemaValidationValue("true", false);
         assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
         
-        setupSchemaValidationValue("TRUE");
+        setupSchemaValidationValue("TRUE", false);
         assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
         
-        setupSchemaValidationValue("tRue");
+        setupSchemaValidationValue("tRue", false);
         assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
     }
     
     @Test
     public void testGetSchemaValidationType() {
         for (SchemaValidationType type : SchemaValidationType.values()) {
-            setupSchemaValidationValue(type.name());
+            setupSchemaValidationValue(type.name(), false);
             assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
             
-            setupSchemaValidationValue(type.name().toLowerCase());
+            setupSchemaValidationValue(type.name().toLowerCase(), false);
             assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
             
-            setupSchemaValidationValue(StringUtils.capitalize(type.name()));
+            setupSchemaValidationValue(StringUtils.capitalize(type.name()), false);
             assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
         }
     }
     
-    private void setupSchemaValidationValue(Object value) {
+    private void setupSchemaValidationValue(Object value, boolean isRequestor) {
         control.reset();
         msg.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
         EasyMock.expectLastCall().andReturn(value);
+        
+        msg.get(Message.REQUESTOR_ROLE);
+        EasyMock.expectLastCall().andReturn(isRequestor);
+        
         control.replay();
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ee8dc35a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
index 9f08839..64863e9 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
@@ -20,8 +20,6 @@
 package org.apache.cxf.systest.jaxws.schemavalidation;
 
 import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -35,7 +33,6 @@ import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.Feature;
-import org.apache.cxf.feature.LoggingFeature;
 import org.apache.cxf.feature.validation.DefaultSchemaValidationTypeProvider;
 import org.apache.cxf.feature.validation.SchemaValidationFeature;
 import org.apache.cxf.frontend.ClientProxy;
@@ -52,40 +49,52 @@ import org.junit.Test;
 
 public class JavaFirstSchemaValidationTest extends Assert {
     static final String PORT = TestUtil.getNewPortNumber(JavaFirstSchemaValidationTest.class);
+    static final String PORT2 = TestUtil.getNewPortNumber(JavaFirstSchemaValidationTest.class);
     static final String PORT_UNUSED = TestUtil.getNewPortNumber(JavaFirstSchemaValidationTest.class);
 
     private static List<Server> serverList = new ArrayList<Server>();
     private static PersonServiceAnnotated annotatedClient;
-    private static PersonServiceAnnotated annotatedValidatingClient;
     private static PersonService client;
     private static PersonServiceRPC rpcClient;
     
-    private static PersonService disconnectedClient;
+    private static PersonServiceWithRequestResponseAnns annotatedNonValidatingClient;
+    private static PersonServiceWithRequestResponseAnns disconnectedClient;
+    private static PersonServiceWithRequestResponseAnns noValidationServerClient;
 
     @BeforeClass
     public static void startServers() throws Exception {
+        createServer(PORT, PersonService.class, new PersonServiceImpl(), null, createSchemaValidationFeature());
+        
+        createServer(PORT2, PersonServiceWithRequestResponseAnns.class, 
+                new PersonServiceWithRequestResponseAnnsImpl(), SchemaValidationType.NONE);
+        
+        createServer(PORT, PersonServiceAnnotated.class, new PersonServiceAnnotatedImpl(),
null);
+        
+        createServer(PORT, PersonServiceRPC.class, new PersonServiceRPCImpl(), null, 
+                createSchemaValidationFeature());
+        
+        createServer(PORT, PersonServiceWithRequestResponseAnns.class, 
+                new PersonServiceWithRequestResponseAnnsImpl(), null);
+
+        annotatedClient = createClient(PORT, PersonServiceAnnotated.class, SchemaValidationType.NONE);
+        annotatedNonValidatingClient = createClient(PORT, PersonServiceWithRequestResponseAnns.class,

+                SchemaValidationType.NONE);
+        client = createClient(PORT, PersonService.class, SchemaValidationType.NONE);
+        disconnectedClient = createClient(PORT_UNUSED, PersonServiceWithRequestResponseAnns.class,
null);
+        rpcClient = createClient(PORT, PersonServiceRPC.class, SchemaValidationType.NONE);
+        noValidationServerClient = createClient(PORT2, PersonServiceWithRequestResponseAnns.class,
null);
+    }
+
+    private static SchemaValidationFeature createSchemaValidationFeature() {
         Map<String, SchemaValidationType> operationMap = new HashMap<String, SchemaValidationType>();
         operationMap.put("saveInheritEndpoint", SchemaValidationType.BOTH);
         operationMap.put("saveNoValidation", SchemaValidationType.NONE);
         operationMap.put("saveValidateIn", SchemaValidationType.IN);
         operationMap.put("saveValidateOut", SchemaValidationType.OUT);
         DefaultSchemaValidationTypeProvider provider = new DefaultSchemaValidationTypeProvider(operationMap);
-
-        SchemaValidationFeature feature = new SchemaValidationFeature(provider);
-
-        createServer(PersonService.class, new PersonServiceImpl(), feature);
-
-        createServer(PersonServiceAnnotated.class, new PersonServiceAnnotatedImpl());
-
-        createServer(PersonServiceRPC.class, new PersonServiceRPCImpl(), feature, new LoggingFeature());
-
-        annotatedClient = createClient(PORT, PersonServiceAnnotated.class, SchemaValidationType.NONE);
-        annotatedValidatingClient = createClient(PORT, PersonServiceAnnotated.class, null);
-        client = createClient(PORT, PersonService.class, SchemaValidationType.NONE);
-        disconnectedClient = createClient(PORT_UNUSED, PersonService.class, SchemaValidationType.OUT);
-        rpcClient = createClient(PORT, PersonServiceRPC.class, SchemaValidationType.NONE);
+        return new SchemaValidationFeature(provider);
     }
-
+    
     @AfterClass
     public static void cleanup() throws Exception {
         for (Server server : serverList) {
@@ -126,9 +135,7 @@ public class JavaFirstSchemaValidationTest extends Assert {
             annotatedClient.saveInheritEndpoint(person);
             fail("Expected exception");
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Unmarshalling Error"));
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
         }
 
         try {
@@ -136,9 +143,7 @@ public class JavaFirstSchemaValidationTest extends Assert {
             annotatedClient.saveInheritEndpoint(person);
             fail("Expected exception");
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Unmarshalling Error"));
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
         }
 
         person.setLastName(""); // empty string is valid
@@ -153,9 +158,7 @@ public class JavaFirstSchemaValidationTest extends Assert {
             annotatedClient.saveValidateIn(person);
             fail("Expected exception");
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Unmarshalling Error"));
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
         }
 
         try {
@@ -163,9 +166,7 @@ public class JavaFirstSchemaValidationTest extends Assert {
             annotatedClient.saveValidateIn(person);
             fail("Expected exception");
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Unmarshalling Error"));
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
         }
 
         person.setLastName(""); // empty string is valid
@@ -186,78 +187,42 @@ public class JavaFirstSchemaValidationTest extends Assert {
     }
 
     @Test
-    public void testSaveValidationOutAnnotatedWithClientValidationDisabled() {
-        Person person = new Person();
-
-        try {
-            annotatedClient.saveValidateOut(person);
-        } catch (SOAPFaultException sfe) {
-            // verify its server side and a schema validation
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Marshalling Error"));
-            
-            // it's still a server side fault, because server side validation coming in failed
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
-        }
-        
-        person.setFirstName(""); // empty string is valid
-        try {
-            annotatedClient.saveValidateOut(person);
-        } catch (SOAPFaultException sfe) {
-            // verify its server side and a schema validation
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Marshalling Error"));
-            
-            // it's still a server side fault, because server side validation coming in failed
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
-        }
-
-        person.setLastName(""); // empty string is valid
-        annotatedClient.saveValidateIn(person);
-    }
-    
-    // this will still all be server side, as the OUT validation is turned into an IN validation
for
-    // the client, but by then the server has already thrown the exception for the OUT
-    @Test
-    public void testSaveValidationOutAnnotatedWithClientValidationEnabled() {
+    public void testRequestValidationWithClientValidationDisabled() {
         Person person = new Person();
 
         try {
-            annotatedValidatingClient.saveValidateIn(person);
+            annotatedNonValidatingClient.saveValidateIn(person);
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Marshalling Error"));
-            assertFalse(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            // has to be server side exception, as all validation is disabled on client
+            assertTrue(sfe.getMessage().contains("Marshalling Error"));
         }
         
         person.setFirstName(""); // empty string is valid
         try {
-            annotatedValidatingClient.saveValidateIn(person);
+            annotatedNonValidatingClient.saveValidateIn(person);
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Marshalling Error"));
-            assertFalse(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            // has to be server side exception, as all validation is disabled on client
+            assertTrue(sfe.getMessage().contains("Marshalling Error"));
         }
 
         person.setLastName(""); // empty string is valid
-        annotatedValidatingClient.saveValidateIn(person);
+        annotatedNonValidatingClient.saveValidateIn(person);
     }
     
     @Test
-    public void testSaveValidationInAnnotatedWithClientValidationEnabled() {
+    public void testResponseValidationWithClientValidationDisabled() {
         Person person = new Person();
 
         try {
             person.setFirstName("InvalidResponse");
             person.setLastName("WhoCares");
-            annotatedValidatingClient.saveValidateOut(person);
+            annotatedNonValidatingClient.saveValidateOut(person);
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Marshalling Error"));
-            assertFalse(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            // has to be server side exception, as all validation is disabled on client
+            assertTrue(sfe.getMessage().contains("Marshalling Error"));
         }
     }
-
+    
     @Test
     public void testEndpointSchemaValidationProvider() {
         Person person = new Person();
@@ -266,9 +231,7 @@ public class JavaFirstSchemaValidationTest extends Assert {
             client.saveInheritEndpoint(person);
             fail("Expected exception");
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Unmarshalling Error"));
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
         }
        
         try {
@@ -276,9 +239,7 @@ public class JavaFirstSchemaValidationTest extends Assert {
             client.saveInheritEndpoint(person);
             fail("Expected exception");
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Unmarshalling Error"));
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
         }
 
         person.setLastName(""); // empty string is valid
@@ -293,9 +254,7 @@ public class JavaFirstSchemaValidationTest extends Assert {
             client.saveValidateIn(person);
             fail("Expected exception");
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Unmarshalling Error"));
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
         }
 
         try {
@@ -303,9 +262,7 @@ public class JavaFirstSchemaValidationTest extends Assert {
             client.saveValidateIn(person);
             fail("Expected exception");
         } catch (SOAPFaultException sfe) {
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Unmarshalling Error"));
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
         }
 
         person.setLastName(""); // empty string is valid
@@ -325,17 +282,14 @@ public class JavaFirstSchemaValidationTest extends Assert {
     }
 
     @Test
-    public void testSaveValidationOutProviderClientOnly() {
+    public void testRequestClientValidation() {
         Person person = new Person();
 
         try {
             disconnectedClient.saveValidateOut(person);
             fail("Expected exception");
         } catch (SOAPFaultException sfe) {
-            // verify its client side outgoing
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Marshalling Error"));
-            assertFalse(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Marshalling Error"));
         }
         
         person.setFirstName(""); // empty string is valid
@@ -343,10 +297,7 @@ public class JavaFirstSchemaValidationTest extends Assert {
             disconnectedClient.saveValidateOut(person);
             fail("Expected exception");
         } catch (SOAPFaultException sfe) {
-            // verify its client side outgoing
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Marshalling Error"));
-            assertFalse(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Marshalling Error"));
         }
 
         person.setLastName(""); // empty string is valid
@@ -359,7 +310,30 @@ public class JavaFirstSchemaValidationTest extends Assert {
             assertTrue(e.getMessage().contains("Could not send Message"));
         }
     }
+    
+    @Test
+    public void testResponseClientValidation() {
+        Person person = new Person();
 
+        try {
+            noValidationServerClient.saveValidateIn(person);
+            fail("Expected exception");
+        } catch (SOAPFaultException e) {
+            assertTrue(e.getMessage().contains("Unmarshalling Error"));
+        }
+        
+        person.setFirstName(""); // empty string is valid
+        try {
+            noValidationServerClient.saveValidateIn(person);
+            fail("Expected exception");
+        } catch (SOAPFaultException sfe) {
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
+        }
+
+        person.setLastName(""); // empty string is valid
+        
+        noValidationServerClient.saveValidateIn(person);        
+    }
     
     @Test
     public void testSaveValidationOutProvider() {
@@ -369,32 +343,31 @@ public class JavaFirstSchemaValidationTest extends Assert {
             client.saveValidateOut(person);
         } catch (SOAPFaultException sfe) {
             // verify its server side outgoing
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Marshalling Error"));
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Marshalling Error"));
         }
         
         person.setFirstName(""); // empty string is valid
         try {
             client.saveValidateOut(person);
         } catch (SOAPFaultException sfe) {
-            // verify its server side outgoing
-            String stackTrace = getStackTrace(sfe);
-            assertTrue(stackTrace.contains("Marshalling Error"));
-            assertTrue(stackTrace.contains("org.apache.cxf.binding.soap.SoapFault"));
+            assertTrue(sfe.getMessage().contains("Marshalling Error"));
         }
 
         person.setLastName(""); // empty string is valid
         client.saveValidateOut(person);
     }
 
-    private static <T> T createClient(String port, Class<T> serviceClass, SchemaValidationType
type) {
+    private static <T> T createClient(String port, Class<T> serviceClass, SchemaValidationType
type, 
+            Feature ... features) {
         JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
         clientFactory.setServiceClass(serviceClass);
         
         
         clientFactory.setAddress(getAddress(port, serviceClass));
         
+        if (features != null) {
+            clientFactory.getFeatures().addAll(Arrays.asList(features));
+        }
         
         @SuppressWarnings("unchecked")
         T newClient = (T)clientFactory.create();
@@ -415,24 +388,26 @@ public class JavaFirstSchemaValidationTest extends Assert {
         return newClient;
     }
 
-    public static Server createServer(Class<?> serviceInterface, Object serviceImpl,
Feature ... features)
+    public static Server createServer(String port, Class<?> serviceInterface, Object
serviceImpl, 
+            SchemaValidationType type, Feature ... features)
         throws IOException {
         JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
         svrFactory.setServiceClass(serviceImpl.getClass());
+        
         if (features != null) {
             svrFactory.getFeatures().addAll(Arrays.asList(features));
         }
-        svrFactory.setAddress(getAddress(PORT, serviceInterface));
+        
+        if (type != null) {
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put(Message.SCHEMA_VALIDATION_ENABLED, type);
+            svrFactory.setProperties(properties);
+        }
+        
+        svrFactory.setAddress(getAddress(port, serviceInterface));
         svrFactory.setServiceBean(serviceImpl);
         Server server = svrFactory.create();
         serverList.add(server);
         return server;
     }
-    
-    private String getStackTrace(Exception e) {
-        StringWriter sWriter = new StringWriter();
-        PrintWriter writer = new PrintWriter(sWriter, true);
-        e.printStackTrace(writer);
-        return sWriter.toString();
-    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ee8dc35a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnns.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnns.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnns.java
new file mode 100644
index 0000000..a1f4fe0
--- /dev/null
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnns.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxws.schemavalidation;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+
+import org.apache.cxf.annotations.SchemaValidation;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+
+@WebService(name = "PersonServiceWithRequestResponseAnns", 
+    targetNamespace = "http://org.apache.cxf/service/PersonServiceWithRequestResponseAnns")
+@SchemaValidation(type = SchemaValidationType.BOTH)
+public interface PersonServiceWithRequestResponseAnns {
+    @WebMethod(operationName = "saveInheritEndpoint")
+    @WebResult(name = "Person")
+    Person saveInheritEndpoint(@WebParam(name = "Person") Person data);
+
+    @SchemaValidation(type = SchemaValidationType.NONE)
+    @WebMethod(operationName = "saveNoValidation")
+    @WebResult(name = "Person")
+    Person saveNoValidation(@WebParam(name = "Person") Person data);
+
+    @SchemaValidation(type = SchemaValidationType.RESPONSE)
+    @WebMethod(operationName = "saveValidateIn")
+    @WebResult(name = "Person")
+    Person saveValidateIn(@WebParam(name = "Person") Person data);
+
+    @SchemaValidation(type = SchemaValidationType.REQUEST)
+    @WebMethod(operationName = "saveValidateOut")
+    @WebResult(name = "Person")
+    Person saveValidateOut(@WebParam(name = "Person") Person data);
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/ee8dc35a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnnsImpl.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnnsImpl.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnnsImpl.java
new file mode 100644
index 0000000..f64014f
--- /dev/null
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnnsImpl.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxws.schemavalidation;
+
+import javax.jws.WebService;
+
+@WebService(endpointInterface = "org.apache.cxf.systest.jaxws.schemavalidation.PersonServiceWithRequestResponseAnns",

+    serviceName = "PersonServiceWithRequestResponseAnns", 
+    targetNamespace = "http://org.apache.cxf/service/PersonServiceWithRequestResponseAnns")
+public class PersonServiceWithRequestResponseAnnsImpl implements PersonServiceWithRequestResponseAnns
{
+    @Override
+    public Person saveNoValidation(Person data) {
+        return data;
+    }
+
+    @Override
+    public Person saveInheritEndpoint(Person data) {
+        return data;
+    }
+
+    @Override
+    public Person saveValidateIn(Person data) {
+        if ("InvalidResponse".equals(data.getFirstName())) {
+            return new Person();
+        }
+        return data;
+    }
+
+    @Override
+    public Person saveValidateOut(Person data) {
+        return data;
+    }
+}


Mime
View raw message