cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1543519 - in /cxf/trunk: rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/ rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/ rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/resources/ systests/databinding/src/test/jav...
Date Tue, 19 Nov 2013 17:48:30 GMT
Author: dkulp
Date: Tue Nov 19 17:48:29 2013
New Revision: 1543519

URL: http://svn.apache.org/r1543519
Log:
[CXF-5392] Ability to set validation handlers on the writers
Modified patch from Joe Wertz applied

Added:
    cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/MyCustomHandler.java
  (with props)
    cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/resources/SetPropertyValidationFailureReq.xml
  (with props)
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/CustomValidatorJAXBTest.java
  (with props)
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorld.java
  (with props)
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorldImpl.java
  (with props)
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/MyCustomHandler.java
  (with props)
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/PassedObject.java
  (with props)
    cxf/trunk/systests/databinding/src/test/resources/jaxbCustomValidators.xml   (with props)
Modified:
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
    cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataReaderTest.java
    cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataWriterTest.java

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java?rev=1543519&r1=1543518&r2=1543519&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
Tue Nov 19 17:48:29 2013
@@ -85,7 +85,10 @@ public class DataReaderImpl<T> extends J
             unwrapJAXBElement = Boolean.TRUE.equals(value);
         } else if (prop.equals(org.apache.cxf.message.Message.class.getName())) {
             org.apache.cxf.message.Message m = (org.apache.cxf.message.Message)value;
-            veventHandler = (ValidationEventHandler)m.getContextualProperty("jaxb-validation-event-handler");
+            veventHandler = (ValidationEventHandler)m.getContextualProperty("jaxb-reader-validation-event-handler");
+            if (veventHandler == null) {
+                veventHandler = (ValidationEventHandler)m.getContextualProperty("jaxb-validation-event-handler");
+            }
             if (veventHandler == null) {
                 veventHandler = databinding.getValidationEventHandler();
             }

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java?rev=1543519&r1=1543518&r2=1543519&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
Tue Nov 19 17:48:29 2013
@@ -46,12 +46,15 @@ import org.apache.cxf.jaxb.JAXBDataBase;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxb.JAXBEncoderDecoder;
 import org.apache.cxf.jaxb.attachment.JAXBAttachmentMarshaller;
+import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 
 public class DataWriterImpl<T> extends JAXBDataBase implements DataWriter<T>
{
     private static final Logger LOG = LogUtils.getLogger(JAXBDataBinding.class);
 
+    ValidationEventHandler veventHandler;
+    boolean setEventHandler = true;
     private JAXBDataBinding databinding;
     
     public DataWriterImpl(JAXBDataBinding binding) {
@@ -62,6 +65,23 @@ public class DataWriterImpl<T> extends J
     public void write(Object obj, T output) {
         write(obj, null, output);
     }
+    
+    public void setProperty(String prop, Object value) {
+        if (prop.equals(org.apache.cxf.message.Message.class.getName())) {
+            org.apache.cxf.message.Message m = (org.apache.cxf.message.Message)value;
+            veventHandler = (ValidationEventHandler)m.getContextualProperty(
+                    "jaxb-writer-validation-event-handler");
+            if (veventHandler == null) {
+                veventHandler = (ValidationEventHandler)m.getContextualProperty(
+                    "jaxb-validation-event-handler");
+            }
+            if (veventHandler == null) {
+                veventHandler = databinding.getValidationEventHandler();
+            }      
+            setEventHandler = MessageUtils.getContextualBoolean(m, "set-jaxb-validation-event-handler",
true);
+        }
+    }
+    
     private static class MtomValidationHandler implements ValidationEventHandler {
         ValidationEventHandler origHandler;
         JAXBAttachmentMarshaller marshaller;
@@ -106,8 +126,8 @@ public class DataWriterImpl<T> extends J
             marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
             marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);
             marshaller.setListener(databinding.getMarshallerListener());
-            if (databinding.getValidationEventHandler() != null) {
-                marshaller.setEventHandler(databinding.getValidationEventHandler());
+            if (setEventHandler) {
+                marshaller.setEventHandler(veventHandler);
             }
             
             final Map<String, String> nspref = databinding.getDeclaredNamespaceMappings();

Added: cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/MyCustomHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/MyCustomHandler.java?rev=1543519&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/MyCustomHandler.java
(added)
+++ cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/MyCustomHandler.java
Tue Nov 19 17:48:29 2013
@@ -0,0 +1,37 @@
+/**
+ * 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.jaxb.io;
+
+import javax.xml.bind.ValidationEvent;
+import javax.xml.bind.ValidationEventHandler;
+
+public class MyCustomHandler implements ValidationEventHandler {
+
+    private boolean used;
+    public boolean getUsed() {
+        return used;
+    }
+    
+    public boolean handleEvent(ValidationEvent event) {
+        used = true;
+        return true;
+    }
+
+}
\ No newline at end of file

Propchange: cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/MyCustomHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataReaderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataReaderTest.java?rev=1543519&r1=1543518&r2=1543519&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataReaderTest.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataReaderTest.java
Tue Nov 19 17:48:29 2013
@@ -57,6 +57,32 @@ public class XMLStreamDataReaderTest ext
     }
 
     @Test
+    public void testSetProperty() throws Exception {
+        JAXBDataBinding db = getDataBinding(GreetMe.class);
+    
+        reader = getTestReader("../resources/SetPropertyValidationFailureReq.xml");
+        assertNotNull(reader);
+        
+        DataReaderImpl<XMLStreamReader> dr = (DataReaderImpl)db.createReader(XMLStreamReader.class);
+        assertNotNull(dr);
+        
+        // Build message to set custom event handler
+        org.apache.cxf.message.Message message = new org.apache.cxf.message.MessageImpl();
+        message.put("jaxb-validation-event-handler", new MyCustomHandler());
+        message.put("unwrap.jaxb.element", true);
+    
+        dr.setProperty("org.apache.cxf.message.Message", message);        
+        
+        // Should fail if custom handler doesn't skip formatting error
+        Object val = dr.read(reader);
+        assertTrue(val instanceof GreetMe);
+        assertEquals("TestSOAPInputPMessage", ((GreetMe)val).getRequestType());
+        
+        // Check handler used
+        assertTrue(((MyCustomHandler)dr.veventHandler).getUsed());
+    }
+    
+    @Test
     public void testReadWrapper() throws Exception {
         JAXBDataBinding db = getDataBinding(GreetMe.class);
         

Modified: cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataWriterTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataWriterTest.java?rev=1543519&r1=1543518&r2=1543519&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataWriterTest.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataWriterTest.java
Tue Nov 19 17:48:29 2013
@@ -66,6 +66,35 @@ public class XMLStreamDataWriterTest ext
     public void tearDown() throws Exception {
         baos.close();
     }
+    
+    @Test
+    public void testSetProperty() throws Exception {
+        JAXBDataBinding db = getTestWriterFactory();
+               
+        DataWriterImpl<XMLStreamWriter> dw = (DataWriterImpl)db.createWriter(XMLStreamWriter.class);
+        assertNotNull(dw);
+        
+        // Build message to set custom event handler
+        org.apache.cxf.message.Message message = new org.apache.cxf.message.MessageImpl();
+        message.put("jaxb-writer-validation-event-handler", new MyCustomHandler());
+    
+        dw.setProperty("org.apache.cxf.message.Message", message);     
+        
+        // Write Stuff
+        TradePriceData val = new TradePriceData();
+        val.setTickerSymbol("This is a symbol");
+        val.setTickerPrice(1.0f);
+        
+        QName elName = new QName("http://apache.org/hello_world_doc_lit_bare/types", "inout");
+        MessagePartInfo part = new MessagePartInfo(elName, null);
+        part.setElement(true);
+        part.setElementQName(elName);
+        dw.write(val, part, streamWriter);
+        streamWriter.flush();
+        
+        // Test MyCustomHandler
+        assertTrue(((MyCustomHandler)dw.veventHandler).getUsed());       
+    }
 
     @Test
     public void testWriteRPCLit1() throws Exception {

Added: cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/resources/SetPropertyValidationFailureReq.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/resources/SetPropertyValidationFailureReq.xml?rev=1543519&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/resources/SetPropertyValidationFailureReq.xml
(added)
+++ cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/resources/SetPropertyValidationFailureReq.xml
Tue Nov 19 17:48:29 2013
@@ -0,0 +1,22 @@
+<!--
+  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.
+-->
+<ns4:greetMe xmlns:ns4="http://apache.org/hello_world_soap_http/types">
+    <ns4:requestType>TestSOAPInputPMessage</ns4:requestType>
+    <ns4:somethingElse>bla bla bla</ns4:somethingElse>
+</ns4:greetMe>

Propchange: cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/resources/SetPropertyValidationFailureReq.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/resources/SetPropertyValidationFailureReq.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/CustomValidatorJAXBTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/CustomValidatorJAXBTest.java?rev=1543519&view=auto
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/CustomValidatorJAXBTest.java
(added)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/CustomValidatorJAXBTest.java
Tue Nov 19 17:48:29 2013
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxb.validators;
+
+import org.apache.cxf.testutil.common.TestUtil;
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+/**
+ * 
+ */
+@ContextConfiguration(locations = { "classpath:jaxbCustomValidators.xml" })
+public class CustomValidatorJAXBTest extends AbstractJUnit4SpringContextTests {
+    static final String PORT = TestUtil.getPortNumber(CustomValidatorJAXBTest.class);
+   
+    @Test
+    public void cleanTest() {
+        HelloWorld client = (HelloWorld)applicationContext
+                .getBean("testClient", HelloWorld.class);
+        
+        PassedObject hi = client.sayHi(new PassedObject("John", "Doe"));
+        Assert.assertTrue("Expected: 'Hello John Doe' Actual: " + hi.getName(),
+                "Hello John Doe".equals(hi.getName()));
+        
+    }
+    
+    @Test
+    public void sendNullTest() {
+        HelloWorld client = (HelloWorld)applicationContext
+                .getBean("testClient", HelloWorld.class);
+        
+        PassedObject hi = client.sayHi(new PassedObject());
+        Assert.assertTrue("Expected: 'Hello null null' Actual: '" + hi.getName() + "'",
+                "Hello null null".equals(hi.getName()));
+        
+    }
+    
+    @Test
+    public void returnNullTest() {
+        HelloWorld client = (HelloWorld)applicationContext
+                .getBean("testClient", HelloWorld.class);
+        
+        PassedObject hi = client.returnNull(new PassedObject("John", "Doe"));
+        Assert.assertTrue("Expected: 'Hello null' Actual: '" + hi.getName() + "'",
+                "Hello null".equals(hi.getName()));
+        
+    }
+}

Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/CustomValidatorJAXBTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorld.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorld.java?rev=1543519&view=auto
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorld.java
(added)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorld.java
Tue Nov 19 17:48:29 2013
@@ -0,0 +1,33 @@
+/**
+ * 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.jaxb.validators;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+
+@javax.jws.WebService(targetNamespace = "aNamespace")
+public interface HelloWorld {
+    
+    @WebMethod(operationName = "sayHi")
+    PassedObject sayHi(@WebParam(name = "text") PassedObject name);
+
+    @WebMethod(operationName = "returnNull")
+    PassedObject returnNull(@WebParam(name = "text") PassedObject name);
+}
+

Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorld.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorldImpl.java?rev=1543519&view=auto
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorldImpl.java
(added)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorldImpl.java
Tue Nov 19 17:48:29 2013
@@ -0,0 +1,33 @@
+/**
+ * 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.jaxb.validators;
+
+@javax.jws.WebService(endpointInterface = "org.apache.cxf.systest.jaxb.validators.HelloWorld")
+public class HelloWorldImpl implements HelloWorld {
+
+    public PassedObject sayHi(PassedObject name) {
+        return new PassedObject("Hello", name.getName());
+    }
+    
+    public PassedObject returnNull(PassedObject name) {
+        return new PassedObject("Hello", null);
+    }
+    
+}
+

Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/MyCustomHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/MyCustomHandler.java?rev=1543519&view=auto
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/MyCustomHandler.java
(added)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/MyCustomHandler.java
Tue Nov 19 17:48:29 2013
@@ -0,0 +1,37 @@
+/**
+ * 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.jaxb.validators;
+
+import javax.xml.bind.ValidationEvent;
+import javax.xml.bind.ValidationEventHandler;
+
+public class MyCustomHandler implements ValidationEventHandler {
+
+    private boolean used;
+    public boolean getUsed() {
+        return used;
+    }
+    
+    public boolean handleEvent(ValidationEvent event) {
+        used = true;
+        return true;
+    }
+
+}
\ No newline at end of file

Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/MyCustomHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/PassedObject.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/PassedObject.java?rev=1543519&view=auto
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/PassedObject.java
(added)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/PassedObject.java
Tue Nov 19 17:48:29 2013
@@ -0,0 +1,55 @@
+/**
+ * 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.jaxb.validators;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType(name = "UserType", propOrder = { "firstName", "lastName" })
+@XmlAccessorType(XmlAccessType.FIELD)
+public class PassedObject {
+
+    @XmlElement(required = true, nillable = false)
+    private String firstName;
+
+    @XmlElement(required = true, nillable = false)
+    private String lastName;
+
+    public PassedObject() { }
+
+    public PassedObject(String firstName, String lastName) {
+        this.firstName = firstName;
+        this.lastName = lastName;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public String getName() {
+        return firstName + " " + lastName;
+    }
+
+}

Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/validators/PassedObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cxf/trunk/systests/databinding/src/test/resources/jaxbCustomValidators.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/resources/jaxbCustomValidators.xml?rev=1543519&view=auto
==============================================================================
--- cxf/trunk/systests/databinding/src/test/resources/jaxbCustomValidators.xml (added)
+++ cxf/trunk/systests/databinding/src/test/resources/jaxbCustomValidators.xml Tue Nov 19
17:48:29 2013
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+						http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+						http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd">
+
+	<!-- Services -->
+	<jaxws:server 
+		id="testServer" 
+		serviceClass="org.apache.cxf.systest.jaxb.validators.HelloWorld"
+		address="http://localhost:9000/Hello">
+		<jaxws:serviceBean>
+			<bean class="org.apache.cxf.systest.jaxb.validators.HelloWorldImpl"/>
+		</jaxws:serviceBean>
+		<jaxws:properties>
+            <entry key="schema-validation-enabled" value="true" />
+            <entry key="jaxb-validation-event-handler">
+                <bean class="org.apache.cxf.systest.jaxb.validators.MyCustomHandler"></bean>
+            </entry>
+            <entry key="jaxb-writer-validation-event-handler">
+                <bean class="org.apache.cxf.systest.jaxb.validators.MyCustomHandler"></bean>
+            </entry>
+        </jaxws:properties>
+	</jaxws:server>
+	
+	<!-- Client Proxy -->
+	<jaxws:client 
+		id="testClient" 
+		serviceClass="org.apache.cxf.systest.jaxb.validators.HelloWorld"
+		address="http://localhost:9000/Hello">
+	</jaxws:client>
+	
+				
+</beans>

Propchange: cxf/trunk/systests/databinding/src/test/resources/jaxbCustomValidators.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/databinding/src/test/resources/jaxbCustomValidators.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message