cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jp...@apache.org
Subject svn commit: r1413572 - in /cxf/trunk: api/src/main/java/org/apache/cxf/annotations/ api/src/main/java/org/apache/cxf/feature/validation/ api/src/main/java/org/apache/cxf/interceptor/ rt/core/src/main/java/org/apache/cxf/feature/validation/ rt/core/src/...
Date Mon, 26 Nov 2012 12:21:24 GMT
Author: jpell
Date: Mon Nov 26 12:21:22 2012
New Revision: 1413572

URL: http://svn.apache.org/viewvc?rev=1413572&view=rev
Log:
CXF-4610 add support for controlling schema validation at the operation level.  Currently
only fully supported for JAX-WS.  Additional work required to support other binding types.

Added:
    cxf/trunk/api/src/main/java/org/apache/cxf/feature/validation/
    cxf/trunk/api/src/main/java/org/apache/cxf/feature/validation/SchemaValidationTypeProvider.java
  (with props)
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java
  (with props)
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
  (with props)
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
  (with props)
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/Person.java
  (with props)
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java
  (with props)
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java
  (with props)
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java
  (with props)
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java
  (with props)
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
    cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
    cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
    cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java?rev=1413572&r1=1413571&r2=1413572&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java Mon Nov 26
12:21:22 2012
@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
  */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.TYPE })
+@Target({ ElementType.TYPE, ElementType.METHOD })
 public @interface SchemaValidation {
     public enum SchemaValidationType {
         IN, OUT, BOTH, NONE

Added: cxf/trunk/api/src/main/java/org/apache/cxf/feature/validation/SchemaValidationTypeProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/feature/validation/SchemaValidationTypeProvider.java?rev=1413572&view=auto
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/feature/validation/SchemaValidationTypeProvider.java
(added)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/feature/validation/SchemaValidationTypeProvider.java
Mon Nov 26 12:21:22 2012
@@ -0,0 +1,31 @@
+/**
+ * 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.feature.validation;
+
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+import org.apache.cxf.service.model.OperationInfo;
+
+/**
+ * Returning null from the getSchemaValidationType will be ignored.  This generally
+ * will mean, it falls back to the service endpoint default, whether configured 
+ * by @SchemaValidation or a endpoint property.
+ */
+public interface SchemaValidationTypeProvider {
+    SchemaValidationType getSchemaValidationType(OperationInfo info);
+}

Propchange: cxf/trunk/api/src/main/java/org/apache/cxf/feature/validation/SchemaValidationTypeProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java?rev=1413572&r1=1413571&r2=1413572&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
(original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
Mon Nov 26 12:21:22 2012
@@ -91,7 +91,7 @@ public abstract class AbstractInDatabind
         dataReader.setAttachments(message.getAttachments());
         dataReader.setProperty(DataReader.ENDPOINT, message.getExchange().getEndpoint());
         dataReader.setProperty(Message.class.getName(), message);
-        setSchemaInMessage(service, message, dataReader);   
+        setDataReaderValidation(service, message, dataReader);
         return dataReader;
     }
     
@@ -103,15 +103,48 @@ public abstract class AbstractInDatabind
         return getDataReader(message, Node.class);
     }
 
-    private void setSchemaInMessage(Service service, Message message, DataReader<?>
reader) {
-        if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message)) {
+    protected boolean shouldValidate(Message message) {
+        return ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message);
+    }
+    
+    /**
+     * Based on the Schema Validation configuration, will initialise the
+     * DataReader with or without the schema set.
+     * 
+     * Can also be called to override schema validation at operation level, thus the reader.setSchema(null)
+     * to remove schema validation
+     */
+    protected void setDataReaderValidation(Service service, Message message, DataReader<?>
reader) {
+        if (shouldValidate(message)) {
             //all serviceInfos have the same schemas
             Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0),
                                                              message.getExchange().getBus());
             reader.setSchema(schema);
+        } else {
+            reader.setSchema(null); // if this is being called for an operation, then override
the service level
         }
     }
-
+    
+    /**
+     * Where an operation level validation type has been set, copy it to the message, so
it can be interrogated
+     * by all downstream interceptors.  It is expected that sub classes will call setDataReaderValidation
subsequent
+     * to this to ensure the DataReader schema reference is updated as appropriate.
+     * 
+     * @param bop
+     * @param message
+     * @param reader
+     * @see #setDataReaderValidation(Service, Message, DataReader)
+     */
+    private void setOperationSchemaValidation(OperationInfo opInfo, Message message) {
+        if (opInfo != null) {
+            SchemaValidationType validationType = 
+                (SchemaValidationType) opInfo.getProperty(Message.SCHEMA_VALIDATION_ENABLED);
+            if (validationType != null) {
+                message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
+            }
+        }
+    }
+    
     protected DepthXMLStreamReader getXMLStreamReader(Message message) {
         XMLStreamReader xr = message.getContent(XMLStreamReader.class);
         if (xr == null) {
@@ -194,7 +227,8 @@ public abstract class AbstractInDatabind
                        lastMsgInfo.getMessageInfo());
         }
         return lastChoice;
-    }    
+    }
+    
     protected MessageInfo setMessage(Message message, BindingOperationInfo operation,
                                    boolean requestor, ServiceInfo si,
                                    MessageInfo msgInfo) {
@@ -212,6 +246,9 @@ public abstract class AbstractInDatabind
             message.put(Message.WSDL_OPERATION, operation.getName());
         }
 
+        // configure endpoint and operation level schema validation based on annotations
+        setOperationSchemaValidation(operation.getOperationInfo(), message);
+        
         QName serviceQName = si.getName();
         message.put(Message.WSDL_SERVICE, serviceQName);
 
@@ -237,6 +274,9 @@ public abstract class AbstractInDatabind
 
         return msgInfo;
     }
+    
+    
+    
     /**
      * Returns a BindingOperationInfo if the operation is indentified as 
      * a wrapped method,  return null if it is not a wrapped method 

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java?rev=1413572&r1=1413571&r2=1413572&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
(original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
Mon Nov 26 12:21:22 2012
@@ -42,6 +42,7 @@ 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.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.staxutils.CachingXmlEventWriter;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
@@ -62,8 +63,6 @@ public abstract class AbstractOutDatabin
         return Boolean.TRUE.equals(message.containsKey(Message.REQUESTOR_ROLE));
     }
     
-
-       
     protected void writeParts(Message message, Exchange exchange, 
                               BindingOperationInfo operation, MessageContentsList objs, 
                               List<MessagePartInfo> parts) {
@@ -73,6 +72,10 @@ public abstract class AbstractOutDatabin
         XMLStreamWriter xmlWriter = origXmlWriter;
         CachingXmlEventWriter cache = null;
         
+        // configure endpoint and operation level schema validation based on
+        // annotations
+        setOperationSchemaValidation(operation.getOperationInfo(), message);
+        
         Object en = message.getContextualProperty(OUT_BUFFERING);
         boolean allowBuffer = true;
         boolean buffer = false;
@@ -133,6 +136,24 @@ public abstract class AbstractOutDatabin
         }
     }
     
+    /**
+     * Where an operation level validation type has been set, copy it to the message, so
it can be interrogated
+     * by all downstream interceptors and update the DataReader with the schema.
+     * 
+     * @param bop
+     * @param message
+     * @param reader
+     */
+    private void setOperationSchemaValidation(OperationInfo opInfo, Message message) {
+        if (opInfo != null) {
+            SchemaValidationType validationType = 
+                (SchemaValidationType) opInfo.getProperty(Message.SCHEMA_VALIDATION_ENABLED);
+            if (validationType != null) {
+                message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
+            }
+        }
+    }
+    
     protected boolean shouldValidate(Message m) {
         return ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, m);
     }
@@ -169,11 +190,20 @@ public abstract class AbstractOutDatabin
         writer.setProperty(DataWriter.ENDPOINT, message.getExchange().getEndpoint());
         writer.setProperty(Message.class.getName(), message);
         
-        setSchemaOutMessage(service, message, writer);
+        setDataWriterValidation(service, message, writer);
         return writer;
     }
 
-    private void setSchemaOutMessage(Service service, Message message, DataWriter<?>
writer) {
+    /**
+     * Based on the Schema Validation configuration, will initialise the DataWriter with
or without the schema set.
+     * 
+     * Can also be called to override schema validation at operation level, thus the writer.setSchema(null)
+     * to remove schema validation
+     * 
+     * Note this is different to the reader side, as we know the binding operation info up
front, so won't
+     * need to overwrite the service level schema validation.
+     */
+    private void setDataWriterValidation(Service service, Message message, DataWriter<?>
writer) {
         if (shouldValidate(message)) {
             Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0),
                                                              message.getExchange().getBus());

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java?rev=1413572&r1=1413571&r2=1413572&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java Mon
Nov 26 12:21:22 2012
@@ -37,6 +37,7 @@ import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessageInfo;
@@ -81,24 +82,16 @@ public class DocLiteralInInterceptor ext
             return;
         }
 
-        //bop might be a unwrapped, wrap it back so that we can get correct info 
-        if (bop != null && bop.isUnwrapped()) {
-            bop = bop.getWrappedOperation();
-        }
-
-        if (bop == null) {
-            QName startQName = xmlReader == null 
-                ? new QName("http://cxf.apache.org/jaxws/provider", "invoke")
-                : xmlReader.getName();
-            bop = getBindingOperationInfo(exchange, startQName, client);
-        }
+        Service service = ServiceModelUtil.getService(message.getExchange());
+        bop = getBindingOperationInfo(xmlReader, exchange, bop, client);
 
         try {
             if (bop != null && bop.isUnwrappedCapable()) {
                 ServiceInfo si = bop.getBinding().getService();
                 // Wrapped case
                 MessageInfo msgInfo = setMessage(message, bop, client, si);
-    
+                setDataReaderValidation(service, message, dr);
+                
                 // Determine if we should keep the parameters wrapper
                 if (shouldWrapParameters(msgInfo, message)) {
                     QName startQName = xmlReader.getName();
@@ -168,7 +161,9 @@ public class DocLiteralInInterceptor ext
                     }
                     return;
                 }
-    
+
+                setDataReaderValidation(service, message, dr);
+                
                 int paramNum = 0;
     
                 do {
@@ -224,6 +219,22 @@ public class DocLiteralInInterceptor ext
             throw f;
         }
     }
+
+    private BindingOperationInfo getBindingOperationInfo(DepthXMLStreamReader xmlReader,
Exchange exchange,
+                                                         BindingOperationInfo bop, boolean
client) {
+        //bop might be a unwrapped, wrap it back so that we can get correct info 
+        if (bop != null && bop.isUnwrapped()) {
+            bop = bop.getWrappedOperation();
+        }
+
+        if (bop == null) {
+            QName startQName = xmlReader == null 
+                ? new QName("http://cxf.apache.org/jaxws/provider", "invoke")
+                : xmlReader.getName();
+            bop = getBindingOperationInfo(exchange, startQName, client);
+        }
+        return bop;
+    }
     
     private void validatePart(MessagePartInfo p, QName elName, Message m) {
         if (p == null) {

Added: cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java?rev=1413572&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java
(added)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java
Mon Nov 26 12:21:22 2012
@@ -0,0 +1,44 @@
+/**
+ * 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.feature.validation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+import org.apache.cxf.service.model.OperationInfo;
+
+/**
+ * Default provider which accepts a map of operation names to schema validation types.  The
+ * names ignore any namespaces
+ */
+public class DefaultSchemaValidationTypeProvider implements SchemaValidationTypeProvider
{
+    private final Map<String, SchemaValidationType> operationMap = 
+        new HashMap<String, SchemaValidationType>();
+    
+    public DefaultSchemaValidationTypeProvider(Map<String, SchemaValidationType> operationMap)
{
+        this.operationMap.putAll(operationMap);
+    }
+
+    @Override
+    public SchemaValidationType getSchemaValidationType(OperationInfo info) {
+        return operationMap.get(info.getName().getLocalPart());
+    }
+}

Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java?rev=1413572&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
(added)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
Mon Nov 26 12:21:22 2012
@@ -0,0 +1,58 @@
+/**
+ * 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.feature.validation;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.BindingOperationInfo;
+
+/**
+ * A feature to configure schema validation at the operation level, as an alternative to
+ * using the @SchemaValidation annotation.
+ */
+public class SchemaValidationFeature extends AbstractFeature {
+    private final SchemaValidationTypeProvider provider;
+    
+    public SchemaValidationFeature(final SchemaValidationTypeProvider provider) {
+        this.provider = provider;
+    }
+    
+    public void initialize(Server server, Bus bus) {
+        initialise(server.getEndpoint());
+    }
+    
+    public void initialize(Client client, Bus bus) {
+        initialise(client.getEndpoint());
+    }
+    
+    private void initialise(Endpoint endpoint) {
+        for (BindingOperationInfo bop : endpoint.getEndpointInfo().getBinding().getOperations())
{
+            SchemaValidationType type = provider.getSchemaValidationType(bop.getOperationInfo());
+            if (type != null) {
+                bop.getOperationInfo().setProperty(Message.SCHEMA_VALIDATION_ENABLED, type);
+            }
+        }
+    }
+}

Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java?rev=1413572&r1=1413571&r2=1413572&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
Mon Nov 26 12:21:22 2012
@@ -157,6 +157,11 @@ public class AnnotationsFactoryBeanListe
             if (col != null) {
                 addDocumentation(inf, WSDLDocumentation.Placement.PORT_TYPE_OPERATION, col.value());
             }
+            
+            SchemaValidation methodValidation = m.getAnnotation(SchemaValidation.class);
+            if (methodValidation != null) {
+                addSchemaValidationSupport(inf, methodValidation);
+            }
             break;
         }
         default:
@@ -318,6 +323,15 @@ public class AnnotationsFactoryBeanListe
         }
     }
 
+    private void addSchemaValidationSupport(OperationInfo inf, SchemaValidation annotation)
{
+        // Notice no support for deprecated enabled property here!
+        // TODO - should we check for the use of this property and at least log the fact
we are
+        // ignoring it
+        if (annotation != null) {
+            inf.setProperty(Message.SCHEMA_VALIDATION_ENABLED, annotation.type());
+        }
+    }
+    
     private void addDocumentation(OperationInfo inf, Placement defPlace, WSDLDocumentation
... values) {
         List<WSDLDocumentation> later = new ArrayList<WSDLDocumentation>();
         for (WSDLDocumentation doc : values) {

Added: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java?rev=1413572&view=auto
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
(added)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
Mon Nov 26 12:21:22 2012
@@ -0,0 +1,277 @@
+/**
+ * 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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.ws.soap.SOAPFaultException;
+
+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.validation.DefaultSchemaValidationTypeProvider;
+import org.apache.cxf.feature.validation.SchemaValidationFeature;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.testutil.common.TestUtil;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * TODO - test where the default is NONE at the service level test where the default is IN
or OUT, and then
+ * override at operation levels
+ */
+public class JavaFirstSchemaValidationTest extends Assert {
+    static final String PORT = TestUtil.getPortNumber(JavaFirstSchemaValidationTest.class);
+
+    private static List<Server> serverList = new ArrayList<Server>();
+    private static PersonServiceAnnotated annotatedClient;
+    private static PersonService client;
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        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(), null);
+
+        annotatedClient = createClient(PersonServiceAnnotated.class);
+        client = createClient(PersonService.class);
+    }
+
+    @AfterClass
+    public static void cleanup() throws Exception {
+        for (Server server : serverList) {
+            server.stop();
+        }
+    }
+
+    static String getAddress(Class<?> sei) {
+        return "http://localhost:" + PORT + "/" + sei.getSimpleName();
+    }
+
+    // so this is the default, we are inheriting from the service level SchemaValidation
annotation
+    // which is set to BOTH
+    @Test
+    public void testEndpointSchemaValidationAnnotated() {
+        Person person = new Person();
+
+        try {
+            annotatedClient.saveInheritEndpoint(person);
+        } catch (SOAPFaultException sfe) {
+            // verify its server side and a schema validation
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
+        }
+
+        try {
+            person.setFirstName(""); // empty string is valid
+            annotatedClient.saveInheritEndpoint(person);
+        } catch (SOAPFaultException sfe) {
+            // verify its server side and a schema validation
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
+        }
+
+        person.setLastName(""); // empty string is valid
+        annotatedClient.saveInheritEndpoint(person);
+    }
+
+    @Test
+    public void testSaveValidateInAnnotated() {
+        Person person = new Person();
+
+        try {
+            annotatedClient.saveValidateIn(person);
+        } catch (SOAPFaultException sfe) {
+            // verify its server side and a schema validation
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
+        }
+
+        try {
+            person.setFirstName(""); // empty string is valid
+            annotatedClient.saveValidateIn(person);
+        } catch (SOAPFaultException sfe) {
+            // verify its server side and a schema validation
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
+        }
+
+        person.setLastName(""); // empty string is valid
+        annotatedClient.saveValidateIn(person);
+    }
+
+    // no validation at all is required
+    @Test
+    public void testSaveNoValidationAnnotated() {
+        Person person = new Person();
+        annotatedClient.saveNoValidation(person);
+
+        person.setFirstName(""); // empty string is valid
+        annotatedClient.saveNoValidation(person);
+
+        person.setLastName(""); // empty string is valid
+        annotatedClient.saveNoValidation(person);
+    }
+
+    // no validation is required for incoming
+    @Test
+    public void testSaveValidationOutAnnotated() {
+        Person person = new Person();
+
+        annotatedClient.saveValidateOut(person);
+
+        person.setFirstName(""); // empty string is valid
+        annotatedClient.saveValidateOut(person);
+
+        person.setLastName(""); // empty string is valid
+        annotatedClient.saveValidateOut(person);
+    }
+
+    // so this is the default, we are inheriting from the service level SchemaValidation
annotation
+    // which is set to BOTH
+    @Test
+    public void testEndpointSchemaValidationProvider() {
+        Person person = new Person();
+
+        try {
+            client.saveInheritEndpoint(person);
+        } catch (SOAPFaultException sfe) {
+            // verify its server side and a schema validation
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
+        }
+
+        try {
+            person.setFirstName(""); // empty string is valid
+            client.saveInheritEndpoint(person);
+        } catch (SOAPFaultException sfe) {
+            // verify its server side and a schema validation
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
+        }
+
+        person.setLastName(""); // empty string is valid
+        client.saveInheritEndpoint(person);
+    }
+
+    @Test
+    public void testSaveValidateInProvider() {
+        Person person = new Person();
+
+        try {
+            client.saveValidateIn(person);
+        } catch (SOAPFaultException sfe) {
+            // verify its server side and a schema validation
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
+        }
+
+        try {
+            person.setFirstName(""); // empty string is valid
+            client.saveValidateIn(person);
+        } catch (SOAPFaultException sfe) {
+            // verify its server side and a schema validation
+            assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
+        }
+
+        person.setLastName(""); // empty string is valid
+        client.saveValidateIn(person);
+    }
+
+    // no validation at all is required
+    @Test
+    public void testSaveNoValidationProvider() {
+        Person person = new Person();
+        client.saveNoValidation(person);
+
+        person.setFirstName(""); // empty string is valid
+        client.saveNoValidation(person);
+
+        person.setLastName(""); // empty string is valid
+        client.saveNoValidation(person);
+    }
+
+    // no validation is required for incoming
+    @Test
+    public void testSaveValidationOutProvider() {
+        Person person = new Person();
+
+        client.saveValidateOut(person);
+
+        person.setFirstName(""); // empty string is valid
+        client.saveValidateOut(person);
+
+        person.setLastName(""); // empty string is valid
+        client.saveValidateOut(person);
+    }
+
+    private static <T> T createClient(Class<T> serviceClass) {
+        JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
+        clientFactory.setServiceClass(serviceClass);
+
+        // ensure all client schema validation is disabled
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(Message.SCHEMA_VALIDATION_ENABLED, SchemaValidationType.NONE);
+        clientFactory.setProperties(properties);
+
+        clientFactory.setAddress(getAddress(serviceClass));
+
+        @SuppressWarnings("unchecked")
+        T newClient = (T)clientFactory.create();
+
+        Client clientProxy = ClientProxy.getClient(newClient);
+
+        // ensure all client schema validation is disabled
+        for (BindingOperationInfo bop : clientProxy.getEndpoint().getEndpointInfo().getBinding()
+            .getOperations()) {
+            bop.getOperationInfo().setProperty(Message.SCHEMA_VALIDATION_ENABLED, SchemaValidationType.NONE);
+        }
+
+        return newClient;
+    }
+
+    public static Server createServer(Class<?> serviceInterface, Object serviceImpl,
Feature feature)
+        throws IOException {
+        JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
+        svrFactory.setServiceClass(serviceImpl.getClass());
+        if (feature != null) {
+            svrFactory.getFeatures().add(feature);
+        }
+        svrFactory.setAddress(getAddress(serviceInterface));
+        svrFactory.setServiceBean(serviceImpl);
+        Server server = svrFactory.create();
+        serverList.add(server);
+        return server;
+    }
+}

Propchange: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/Person.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/Person.java?rev=1413572&view=auto
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/Person.java
(added)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/Person.java
Mon Nov 26 12:21:22 2012
@@ -0,0 +1,54 @@
+/**
+ * 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.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "Person")
+public class Person {
+    @XmlElement(required = true, name = "firstName")
+    private String firstName;
+
+    @XmlElement(required = true, name = "lastName")
+    private String lastName;
+
+    public Person() {
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+}

Propchange: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/Person.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java?rev=1413572&view=auto
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java
(added)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java
Mon Nov 26 12:21:22 2012
@@ -0,0 +1,43 @@
+/**
+ * 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.WebService;
+
+import org.apache.cxf.annotations.SchemaValidation;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+
+@WebService(name = "PersonService", targetNamespace = "http://org.apache.cxf/service/PersonService")
+@SchemaValidation(type = SchemaValidationType.BOTH)
+public interface PersonService {
+    @WebMethod(operationName = "saveInheritEndpoint")
+    void saveInheritEndpoint(@WebParam(name = "Person") Person data);
+
+    @WebMethod(operationName = "saveNoValidation")
+    void saveNoValidation(@WebParam(name = "Person") Person data);
+
+    @WebMethod(operationName = "saveValidateIn")
+    void saveValidateIn(@WebParam(name = "Person") Person data);
+
+    @WebMethod(operationName = "saveValidateOut")
+    void saveValidateOut(@WebParam(name = "Person") Person data);
+}

Propchange: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java?rev=1413572&view=auto
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java
(added)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java
Mon Nov 26 12:21:22 2012
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxws.schemavalidation;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+
+import org.apache.cxf.annotations.SchemaValidation;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+
+@WebService(name = "PersonServiceAnnotated", targetNamespace = "http://org.apache.cxf/service/PersonServiceAnnotated")
+@SchemaValidation(type = SchemaValidationType.BOTH)
+public interface PersonServiceAnnotated {
+    @WebMethod(operationName = "saveInheritEndpoint")
+    void saveInheritEndpoint(@WebParam(name = "Person") Person data);
+
+    @SchemaValidation(type = SchemaValidationType.NONE)
+    @WebMethod(operationName = "saveNoValidation")
+    void saveNoValidation(@WebParam(name = "Person") Person data);
+
+    @SchemaValidation(type = SchemaValidationType.IN)
+    @WebMethod(operationName = "saveValidateIn")
+    void saveValidateIn(@WebParam(name = "Person") Person data);
+
+    @SchemaValidation(type = SchemaValidationType.OUT)
+    @WebMethod(operationName = "saveValidateOut")
+    void saveValidateOut(@WebParam(name = "Person") Person data);
+}

Propchange: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java?rev=1413572&view=auto
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java
(added)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java
Mon Nov 26 12:21:22 2012
@@ -0,0 +1,43 @@
+/**
+ * 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.PersonServiceAnnotated",

+    serviceName = "PersonServiceAnnotated", 
+    targetNamespace = "http://org.apache.cxf/service/PersonServiceAnnotated")
+public class PersonServiceAnnotatedImpl implements PersonServiceAnnotated {
+    @Override
+    public void saveNoValidation(Person data) {
+    }
+
+    @Override
+    public void saveInheritEndpoint(Person data) {
+    }
+
+    @Override
+    public void saveValidateIn(Person data) {
+    }
+
+    @Override
+    public void saveValidateOut(Person data) {
+    }
+}

Propchange: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java?rev=1413572&view=auto
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java
(added)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java
Mon Nov 26 12:21:22 2012
@@ -0,0 +1,43 @@
+/**
+ * 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.PersonService",

+    serviceName = "PersonService", 
+    targetNamespace = "http://org.apache.cxf/service/PersonService")
+public class PersonServiceImpl implements PersonService {
+    @Override
+    public void saveNoValidation(Person data) {
+    }
+
+    @Override
+    public void saveInheritEndpoint(Person data) {
+    }
+
+    @Override
+    public void saveValidateIn(Person data) {
+    }
+
+    @Override
+    public void saveValidateOut(Person data) {
+    }
+}

Propchange: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message