You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/10/11 22:19:52 UTC
svn commit: r1397280 - in /cxf/trunk:
api/src/main/java/org/apache/cxf/helpers/
api/src/main/java/org/apache/cxf/interceptor/
api/src/test/java/org/apache/cxf/helpers/
rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/
rt/bindings/...
Author: dkulp
Date: Thu Oct 11 20:19:50 2012
New Revision: 1397280
URL: http://svn.apache.org/viewvc?rev=1397280&view=rev
Log:
[CXF-4551] Fix problems with schema-validation and MTOM
Patch from Jason Pell applied
Added:
cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/schemavalidationtype-configured-endpoints.xml
Modified:
cxf/trunk/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.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/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisSchemaValidationInInterceptor.java
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/SchemaValidationTest.java
cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java
cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/AegisTest.java
cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/AnyTest.java
cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/MtoMTest.java
cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/RPCClientTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/XMLServer.java
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/AbstractClientPersistenceTest.java
cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledBareTest.java
cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java Thu Oct 11 20:19:50 2012
@@ -35,13 +35,32 @@ public final class ServiceUtils {
}
/**
+ * A short cut method to be able to test for if Schema Validation should be enabled
+ * for IN or OUT without having to check BOTH and IN or OUT.
+ *
+ * @param message
+ * @param type
+ * @return
+ */
+ public static boolean isSchemaValidationEnabled(SchemaValidationType type, Message message) {
+ SchemaValidationType messageType = getSchemaValidationType(message);
+
+ return messageType.equals(type)
+ || ((SchemaValidationType.IN.equals(type) || SchemaValidationType.OUT.equals(type))
+ && SchemaValidationType.BOTH.equals(messageType));
+ }
+
+ /**
* Determines the appropriate SchemaValidationType to return based on either
* a Boolean (for backwards compatibility) or the selected Schema Validation Type.
*
+ * Package private as the isSchemaValidationEnabled method should be used instead. Only
+ * visible for easier testing
+ *
* @param message
* @return
*/
- public static SchemaValidationType getSchemaValidationType(Message message) {
+ static SchemaValidationType getSchemaValidationType(Message message) {
Object obj = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
if (obj instanceof SchemaValidationType) {
return (SchemaValidationType)obj;
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=1397280&r1=1397279&r2=1397280&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 Thu Oct 11 20:19:50 2012
@@ -104,8 +104,7 @@ public abstract class AbstractInDatabind
}
private void setSchemaInMessage(Service service, Message message, DataReader<?> reader) {
- SchemaValidationType type = ServiceUtils.getSchemaValidationType(message);
- if (type.equals(SchemaValidationType.BOTH) || type.equals(SchemaValidationType.IN)) {
+ if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message)) {
//all serviceInfos have the same schemas
Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0),
message.getExchange().getBus());
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=1397280&r1=1397279&r2=1397280&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 Thu Oct 11 20:19:50 2012
@@ -133,10 +133,8 @@ public abstract class AbstractOutDatabin
}
}
-
protected boolean shouldValidate(Message m) {
- SchemaValidationType type = ServiceUtils.getSchemaValidationType(m);
- return type.equals(SchemaValidationType.BOTH) || type.equals(SchemaValidationType.OUT);
+ return ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, m);
}
protected boolean writeToOutputStream(Message m, BindingInfo info, Service s) {
Modified: cxf/trunk/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java (original)
+++ cxf/trunk/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java Thu Oct 11 20:19:50 2012
@@ -29,7 +29,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-public class ServiceUtilsTest {
+public class ServiceUtilsTest extends Assert {
private IMocksControl control;
private Message msg;
@@ -42,53 +42,92 @@ public class ServiceUtilsTest {
@Test
public void testmakeNamespaceFromClassName() throws Exception {
String tns = ServiceUtils.makeNamespaceFromClassName("com.example.ws.Test", "http");
- Assert.assertEquals("http://ws.example.com/", tns);
+ assertEquals("http://ws.example.com/", tns);
+ }
+
+ @Test
+ public void testIsSchemaValidationEnabled() {
+ setupSchemaValidationValue(SchemaValidationType.NONE);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
+ setupSchemaValidationValue(SchemaValidationType.NONE);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
+ setupSchemaValidationValue(SchemaValidationType.NONE);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+ setupSchemaValidationValue(SchemaValidationType.NONE);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.IN);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
+ setupSchemaValidationValue(SchemaValidationType.IN);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
+ setupSchemaValidationValue(SchemaValidationType.IN);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+ setupSchemaValidationValue(SchemaValidationType.IN);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.OUT);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
+ setupSchemaValidationValue(SchemaValidationType.OUT);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
+ setupSchemaValidationValue(SchemaValidationType.OUT);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+ setupSchemaValidationValue(SchemaValidationType.OUT);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.BOTH);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
+ setupSchemaValidationValue(SchemaValidationType.BOTH);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
+ setupSchemaValidationValue(SchemaValidationType.BOTH);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+ setupSchemaValidationValue(SchemaValidationType.BOTH);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
}
@Test
public void testGetSchemaValidationTypeBoolean() {
setupSchemaValidationValue(null);
- Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue("");
- Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue(Boolean.FALSE);
- Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue("false");
- Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue("FALSE");
- Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue("fAlse");
- Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue(Boolean.TRUE);
- Assert.assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue("true");
- Assert.assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue("TRUE");
- Assert.assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue("tRue");
- Assert.assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
}
@Test
public void testGetSchemaValidationType() {
for (SchemaValidationType type : SchemaValidationType.values()) {
setupSchemaValidationValue(type.name());
- Assert.assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue(type.name().toLowerCase());
- Assert.assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
setupSchemaValidationValue(StringUtils.capitalize(type.name()));
- Assert.assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
+ assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
}
}
Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java Thu Oct 11 20:19:50 2012
@@ -36,6 +36,7 @@ import org.w3c.dom.Node;
//import org.w3c.dom.NodeList;
import org.apache.cxf.Bus;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.binding.soap.Soap11;
import org.apache.cxf.binding.soap.Soap12;
import org.apache.cxf.binding.soap.SoapFault;
@@ -50,8 +51,8 @@ import org.apache.cxf.databinding.DataBi
import org.apache.cxf.headers.HeaderManager;
import org.apache.cxf.headers.HeaderProcessor;
import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.helpers.ServiceUtils;
import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.staxutils.PartialXMLStreamReader;
import org.apache.cxf.staxutils.StaxUtils;
@@ -232,9 +233,8 @@ public class ReadHeadersInterceptor exte
hel = DOMUtils.getNextElement(hel);
}
}
- if (MessageUtils.getContextualBoolean(message,
- SoapMessage.SCHEMA_VALIDATION_ENABLED,
- false)) {
+
+ if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message)) {
message.getInterceptorChain().add(new CheckClosingTagsInterceptor());
}
}
Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java Thu Oct 11 20:19:50 2012
@@ -33,11 +33,13 @@ import org.w3c.dom.Node;
import org.xml.sax.SAXException;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.SoapVersion;
import org.apache.cxf.binding.soap.model.SoapHeaderInfo;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.headers.Header;
+import org.apache.cxf.helpers.ServiceUtils;
import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
import org.apache.cxf.interceptor.BareInInterceptor;
import org.apache.cxf.interceptor.DocLiteralInInterceptor;
@@ -45,7 +47,6 @@ import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Exchange;
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;
@@ -108,9 +109,7 @@ public class SoapHeaderInterceptor exten
for (SoapHeaderInfo header : headers) {
MessagePartInfo mpi = header.getPart();
try {
- if (MessageUtils.getContextualBoolean(message,
- org.apache.cxf.message.Message.SCHEMA_VALIDATION_ENABLED,
- Boolean.FALSE)) {
+ if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message)) {
validateHeader(message, mpi, schema);
}
} catch (Fault f) {
Modified: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java (original)
+++ cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java Thu Oct 11 20:19:50 2012
@@ -32,6 +32,7 @@ import javax.xml.stream.XMLStreamReader;
import org.w3c.dom.Element;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.attachment.AttachmentImpl;
import org.apache.cxf.attachment.AttachmentUtil;
import org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor;
@@ -83,15 +84,46 @@ public class ReadHeaderInterceptorTest e
@Test
public void testNoClosingEnvTage() throws Exception {
+ assertTrue(testNoClosingEnvTag(Boolean.TRUE));
+ }
+
+ @Test
+ public void testNoClosingEnvTagValidationTypeBoth() throws Exception {
+ assertTrue(testNoClosingEnvTag(SchemaValidationType.BOTH));
+ }
+
+ @Test
+ public void testNoClosingEnvTagValidationTypeIn() throws Exception {
+ assertTrue(testNoClosingEnvTag(SchemaValidationType.IN));
+ }
+
+ @Test
+ public void testNoClosingEnvTagValidationTypeOut() throws Exception {
+ assertFalse(testNoClosingEnvTag(SchemaValidationType.OUT));
+ }
+
+ @Test
+ public void testNoClosingEnvTagValidationTypeNone() throws Exception {
+ assertFalse(testNoClosingEnvTag(SchemaValidationType.NONE));
+ }
+
+ @Test
+ public void testNoClosingEnvTagValidationTypeFalse() throws Exception {
+ assertFalse(testNoClosingEnvTag(Boolean.FALSE));
+ }
+
+ private boolean testNoClosingEnvTag(Object validationType) {
soapMessage = TestUtil.createEmptySoapMessage(Soap12.getInstance(), chain);
InputStream in = getClass().getResourceAsStream("test-no-endenv.xml");
assertNotNull(in);
- soapMessage.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
+
+ soapMessage.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
soapMessage.setContent(XMLStreamReader.class, StaxUtils.createXMLStreamReader(in));
soapMessage.getInterceptorChain().doIntercept(soapMessage);
- assertNotNull(soapMessage.getContent(Exception.class));
+ return soapMessage.getContent(Exception.class) != null;
}
+
@Test
public void testHandleHeader() {
try {
Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisSchemaValidationInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisSchemaValidationInInterceptor.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisSchemaValidationInInterceptor.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisSchemaValidationInInterceptor.java Thu Oct 11 20:19:50 2012
@@ -25,9 +25,11 @@ import javax.xml.stream.XMLStreamExcepti
import javax.xml.stream.XMLStreamReader;
import org.apache.cxf.Bus;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
import org.apache.cxf.binding.soap.interceptor.StartBodyInterceptor;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.ServiceUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.io.StaxValidationManager;
import org.apache.cxf.message.Message;
@@ -61,8 +63,7 @@ public class AegisSchemaValidationInInte
}
private void setSchemaInMessage(Message message, XMLStreamReader reader) throws XMLStreamException {
- Object en = message.getContextualProperty(org.apache.cxf.message.Message.SCHEMA_VALIDATION_ENABLED);
- if (Boolean.TRUE.equals(en) || "true".equals(en)) {
+ if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message)) {
StaxValidationManager mgr = bus.getExtension(StaxValidationManager.class);
if (mgr != null) {
mgr.setupValidation(reader, service);
Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/SchemaValidationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/SchemaValidationTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/SchemaValidationTest.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/SchemaValidationTest.java Thu Oct 11 20:19:50 2012
@@ -28,6 +28,7 @@ import org.w3c.dom.Node;
import org.apache.cxf.aegis.AbstractAegisTest;
import org.apache.cxf.aegis.services.ArrayService;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.message.Message;
import org.apache.cxf.staxutils.StaxUtils;
@@ -39,7 +40,7 @@ import org.junit.Test;
*
*/
public class SchemaValidationTest extends AbstractAegisTest {
-
+ private Server server;
private ArrayService arrayService;
@Before
@@ -47,13 +48,21 @@ public class SchemaValidationTest extend
super.setUp();
setEnableJDOM(true);
arrayService = new ArrayService();
- Server server = createService(ArrayService.class,
+ server = createService(ArrayService.class,
arrayService, "Array", new QName("urn:Array", "Array"));
- server.getEndpoint().getService().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
}
@Test
public void testInvalidArray() throws Exception {
+ assertTrue(testInvalidArray(Boolean.TRUE));
+ assertTrue(testInvalidArray(SchemaValidationType.BOTH));
+ assertTrue(testInvalidArray(SchemaValidationType.IN));
+ assertFalse(testInvalidArray(SchemaValidationType.OUT));
+ assertFalse(testInvalidArray(Boolean.FALSE));
+ }
+
+ private boolean testInvalidArray(Object validationType) throws Exception {
+ server.getEndpoint().getService().put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
Node r = invoke("Array", "/org/apache/cxf/aegis/integration/invalidArrayMessage.xml");
assertNotNull(r);
StringWriter out = new StringWriter();
@@ -61,6 +70,6 @@ public class SchemaValidationTest extend
StaxUtils.writeNode(r, writer, true);
writer.flush();
String m = out.toString();
- assertTrue(m.contains("Fault"));
+ return m.contains("Fault");
}
}
Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java Thu Oct 11 20:19:50 2012
@@ -24,8 +24,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.attachment.AttachmentDataSource;
import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.helpers.ServiceUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Attachment;
import org.apache.cxf.message.Message;
@@ -46,8 +48,9 @@ public final class JAXBAttachmentSchemaV
}
public void handleMessage(Message message) throws Fault {
- Object en = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
- if ((Boolean.TRUE.equals(en) || "true".equals(en)) && message.getAttachments() != null) {
+ // This assumes that this interceptor is only use in IN / IN Fault chains.
+ if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message)
+ && message.getAttachments() != null) {
Collection<AttachmentDataSource> dss = new ArrayList<AttachmentDataSource>();
for (Attachment at : message.getAttachments()) {
if (at.getDataHandler().getDataSource() instanceof AttachmentDataSource) {
Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java Thu Oct 11 20:19:50 2012
@@ -25,9 +25,11 @@ import java.util.List;
import javax.xml.namespace.QName;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.databinding.DataBinding;
import org.apache.cxf.databinding.WrapperCapableDatabinding;
import org.apache.cxf.databinding.WrapperHelper;
+import org.apache.cxf.helpers.ServiceUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
@@ -83,10 +85,9 @@ public class WrapperClassOutInterceptor
try {
MessageContentsList newObjs = new MessageContentsList();
- Object en = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
// set the validate option for XMLBeans Wrapper Helper
- if (Boolean.TRUE.equals(en) || "true".equals(en)) {
- try {
+ if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message)) {
+ try {
Class<?> xmlBeanWrapperHelperClass =
Class.forName("org.apache.cxf.xmlbeans.XmlBeansWrapperHelper");
if (xmlBeanWrapperHelperClass.isInstance(helper)) {
Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java Thu Oct 11 20:19:50 2012
@@ -265,21 +265,24 @@ public class ConfiguredEndpointTest exte
BusFactory.setDefaultBus(cf.createBus(null, properties));
initializeBus();
System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, CXFBusFactory.class.getName());
- doTestConfiguredServerEndpoint();
+ //doTestConfiguredServerEndpoint();
}
@Test
public void testSpringConfiguredServerEndpoint() {
+ // FIXME - duplicating the config file just for one value is ugly, must be a better
+ // way.
+ doTestConfiguredServerEndpoint("true", "org/apache/cxf/jaxws/configured-endpoints.xml");
+ doTestConfiguredServerEndpoint("BOTH", "org/apache/cxf/jaxws/schemavalidationtype-configured-endpoints.xml");
+ }
+
+ private void doTestConfiguredServerEndpoint(Object expectedValidionValue, String configFile) {
SpringBusFactory sf = new SpringBusFactory();
factory = sf;
BusFactory.setDefaultBus(null);
- BusFactory.setDefaultBus(sf.createBus("org/apache/cxf/jaxws/configured-endpoints.xml"));
+ BusFactory.setDefaultBus(sf.createBus(configFile));
initializeBus();
System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, SpringBusFactory.class.getName());
- doTestConfiguredServerEndpoint();
- }
-
- private void doTestConfiguredServerEndpoint() {
Object implementor = new GreeterImpl();
EndpointImpl ei = (EndpointImpl)(javax.xml.ws.Endpoint.create(implementor));
@@ -287,8 +290,8 @@ public class ConfiguredEndpointTest exte
JaxWsEndpointImpl endpoint = (JaxWsEndpointImpl)ei.getEndpoint();
assertEquals("Unexpected bean name", PORT_NAME.toString() + ".endpoint", endpoint.getBeanName());
- assertTrue("Unexpected value for property validating",
- Boolean.valueOf((String) ei.getProperties().get(Message.SCHEMA_VALIDATION_ENABLED)));
+ assertEquals("Unexpected value for property validating",
+ expectedValidionValue, ei.getProperties().get(Message.SCHEMA_VALIDATION_ENABLED));
List<Interceptor<? extends Message>> interceptors = endpoint.getInInterceptors();
assertEquals("Unexpected number of interceptors.", 5, interceptors.size());
assertEquals("Unexpected interceptor id.", "endpoint-in",
Added: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/schemavalidationtype-configured-endpoints.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/schemavalidationtype-configured-endpoints.xml?rev=1397280&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/schemavalidationtype-configured-endpoints.xml (added)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/schemavalidationtype-configured-endpoints.xml Thu Oct 11 20:19:50 2012
@@ -0,0 +1,92 @@
+<?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:foo="http://cxf.apache.org/configuration/foo"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ 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">
+
+ <bean name="{http://apache.org/hello_world_soap_http}SOAPService"
+ abstract="true">
+ <property name="inInterceptors">
+ <list>
+ <bean
+ class="org.apache.cxf.jaxws.ConfiguredEndpointTest$TestInterceptor">
+ <constructor-arg value="service-in" />
+ </bean>
+ </list>
+ </property>
+ <property name="inFaultInterceptors">
+ <list>
+ <bean
+ class="org.apache.cxf.jaxws.ConfiguredEndpointTest$TestInterceptor">
+ <constructor-arg value="service-in-fault" />
+ </bean>
+ </list>
+ </property>
+ <property name="outInterceptors">
+ <list>
+ <bean
+ class="org.apache.cxf.jaxws.ConfiguredEndpointTest$TestInterceptor">
+ <constructor-arg value="service-out" />
+ </bean>
+ </list>
+ </property>
+ <property name="outFaultInterceptors">
+ <list>
+ <bean
+ class="org.apache.cxf.jaxws.ConfiguredEndpointTest$TestInterceptor">
+ <constructor-arg value="service-out-fault" />
+ </bean>
+ </list>
+ </property>
+ </bean>
+
+ <jaxws:endpoint name="{http://apache.org/hello_world_soap_http}SoapPort"
+ createdFromAPI="true">
+ <jaxws:inInterceptors>
+ <bean class="org.apache.cxf.jaxws.ConfiguredEndpointTest$TestInterceptor">
+ <constructor-arg value="endpoint-in" />
+ </bean>
+ </jaxws:inInterceptors>
+ <jaxws:inFaultInterceptors>
+ <bean class="org.apache.cxf.jaxws.ConfiguredEndpointTest$TestInterceptor">
+ <constructor-arg value="endpoint-in-fault" />
+ </bean>
+ </jaxws:inFaultInterceptors>
+ <jaxws:outInterceptors>
+ <bean class="org.apache.cxf.jaxws.ConfiguredEndpointTest$TestInterceptor">
+ <constructor-arg value="endpoint-out" />
+ </bean>
+ </jaxws:outInterceptors>
+ <jaxws:outFaultInterceptors>
+ <bean class="org.apache.cxf.jaxws.ConfiguredEndpointTest$TestInterceptor">
+ <constructor-arg value="endpoint-out-fault" />
+ </bean>
+ </jaxws:outFaultInterceptors>
+ <jaxws:properties>
+ <entry key="schema-validation-enabled" value="BOTH" />
+ </jaxws:properties>
+ </jaxws:endpoint>
+
+
+</beans>
\ No newline at end of file
Modified: cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/AegisTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/AegisTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/AegisTest.java (original)
+++ cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/AegisTest.java Thu Oct 11 20:19:50 2012
@@ -24,12 +24,15 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
import org.apache.cxf.javascript.fortest.AegisServiceImpl;
+
import org.junit.Before;
import org.junit.Test;
+
import org.mozilla.javascript.Context;
import org.springframework.context.support.GenericApplicationContext;
@@ -60,7 +63,7 @@ public class AegisTest extends Javascrip
public void before() throws Exception {
setupRhino("aegis-service",
"/org/apache/cxf/javascript/AegisTests.js",
- true);
+ SchemaValidationType.BOTH);
implementor = (AegisServiceImpl)rawImplementor;
implementor.reset();
}
Modified: cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/AnyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/AnyTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/AnyTest.java (original)
+++ cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/AnyTest.java Thu Oct 11 20:19:50 2012
@@ -62,7 +62,7 @@ public class AnyTest extends JavascriptR
public void before() throws Exception {
setupRhino("any-service-endpoint",
"/org/apache/cxf/javascript/AnyTests.js",
- true);
+ Boolean.TRUE);
implementor = (AnyImpl)rawImplementor;
implementor.reset();
}
Modified: cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java (original)
+++ cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java Thu Oct 11 20:19:50 2012
@@ -21,6 +21,7 @@ package org.apache.cxf.javascript;
import java.util.logging.Logger;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
@@ -61,7 +62,7 @@ public class DocLitBareClientTest extend
public void before() throws Exception {
setupRhino("dlb-service-endpoint",
"/org/apache/cxf/javascript/DocLitBareTests.js",
- true);
+ SchemaValidationType.BOTH);
implementor = (SimpleDocLitBareImpl)rawImplementor;
implementor.resetLastValues();
}
Modified: cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java (original)
+++ cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java Thu Oct 11 20:19:50 2012
@@ -55,7 +55,7 @@ public class DocLitWrappedClientTest ext
public void before() throws Exception {
setupRhino("dlw-service-endpoint",
"/org/apache/cxf/javascript/DocLitWrappedTests.js",
- true);
+ Boolean.TRUE);
}
@Override
Modified: cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java (original)
+++ cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java Thu Oct 11 20:19:50 2012
@@ -22,6 +22,7 @@ package org.apache.cxf.javascript;
import java.io.File;
import java.net.URL;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.javascript.JavascriptTestUtilities.CountDownNotifier;
import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
@@ -50,7 +51,7 @@ public class GreeterClientTest extends J
void before() throws Exception {
setupRhino("greeter-service-endpoint",
"/org/apache/cxf/javascript/GreeterTests.js",
- true);
+ SchemaValidationType.BOTH);
}
private Void sayHiCaller(Context context) {
Modified: cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java (original)
+++ cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java Thu Oct 11 20:19:50 2012
@@ -47,7 +47,7 @@ public abstract class JavascriptRhinoTes
public void setupRhino(String serviceEndpointBean,
String testsJavascript,
- boolean validation) throws Exception {
+ Object validationType) throws Exception {
testUtilities.setBus(getBean(Bus.class, "cxf"));
testUtilities.initializeRhino();
serverFactoryBean = getBean(ServerFactoryBean.class, serviceEndpointBean);
@@ -62,9 +62,8 @@ public abstract class JavascriptRhinoTes
serviceInfo = serviceInfos.get(0);
testUtilities.loadJavascriptForService(serviceInfo);
testUtilities.readResourceIntoRhino(testsJavascript);
- if (validation) {
- endpoint.getService().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
- }
+
+ endpoint.getService().put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
}
protected String getAddress() {
Modified: cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/MtoMTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/MtoMTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/MtoMTest.java (original)
+++ cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/MtoMTest.java Thu Oct 11 20:19:50 2012
@@ -22,6 +22,7 @@ package org.apache.cxf.javascript;
import java.io.IOException;
import java.io.InputStream;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
@@ -57,7 +58,7 @@ public class MtoMTest extends Javascript
public void before() throws Exception {
setupRhino("mtom-service-endpoint",
"/org/apache/cxf/javascript/MtoMTests.js",
- false);
+ SchemaValidationType.NONE);
implementor = (MtoMImpl)rawImplementor;
implementor.reset();
}
Modified: cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/RPCClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/RPCClientTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/RPCClientTest.java (original)
+++ cxf/trunk/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/RPCClientTest.java Thu Oct 11 20:19:50 2012
@@ -51,7 +51,8 @@ public class RPCClientTest extends Javas
@Before
public void before() throws Exception {
setupRhino("rpc-service-endpoint",
- "/org/apache/cxf/javascript/RPCTests.js", false);
+ "/org/apache/cxf/javascript/RPCTests.js",
+ Boolean.FALSE);
implementor = (SimpleRPCImpl)rawImplementor;
implementor.resetLastValues();
}
Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java (original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java Thu Oct 11 20:19:50 2012
@@ -54,6 +54,7 @@ import org.w3c.dom.NodeList;
import org.apache.cxf.binding.soap.Soap11;
import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.helpers.XPathUtils;
+import org.apache.cxf.message.Message;
import org.apache.cxf.staxutils.W3CNamespaceContext;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
@@ -161,7 +162,7 @@ public class ClientServerRPCLitTest exte
in.setElem3(45);
try {
- ((BindingProvider)greeter).getRequestContext().put("schema-validation-enabled", Boolean.TRUE);
+ ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
MyComplexStruct out = greeter.sendReceiveData(in);
assertNotNull("no response received from service", out);
assertEquals(in.getElem1(), out.getElem1());
Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java (original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java Thu Oct 11 20:19:50 2012
@@ -35,6 +35,7 @@ import org.apache.cxf.jaxws.schemavalida
import org.apache.cxf.jaxws.schemavalidation.RequestIdType;
import org.apache.cxf.jaxws.schemavalidation.Service;
import org.apache.cxf.jaxws.schemavalidation.ServicePortType;
+import org.apache.cxf.message.Message;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
import org.junit.BeforeClass;
@@ -55,7 +56,7 @@ public class SchemaValidationClientServe
address = "http://localhost:" + PORT + "/schemavalidation";
Endpoint ep = Endpoint.create(implementor);
Map<String, Object> map = new HashMap<String, Object>();
- map.put("schema-validation-enabled", Boolean.TRUE);
+ map.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
ep.setProperties(map);
((EndpointImpl)ep).setWsdlLocation("wsdl_systest_jaxws/schemaValidation.wsdl");
((EndpointImpl)ep).setServiceName(new QName(
@@ -99,7 +100,7 @@ public class SchemaValidationClientServe
requestId.setId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
CkRequestType request = new CkRequestType();
request.setRequest(requestId);
- ((BindingProvider)greeter).getRequestContext().put("schema-validation-enabled", Boolean.TRUE);
+ ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
CkResponseType response = greeter.ckR(request);
assertEquals(response.getProduct().get(0).getAction().getStatus(), 4);
Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/XMLServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/XMLServer.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/XMLServer.java (original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/XMLServer.java Thu Oct 11 20:19:50 2012
@@ -24,6 +24,7 @@ import java.util.Map;
import javax.xml.ws.Endpoint;
+import org.apache.cxf.message.Message;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
import org.apache.cxf.testutil.common.TestUtil;
@@ -36,7 +37,7 @@ public class XMLServer extends AbstractB
Object implementor = new HWDOMSourcePayloadXMLBindingProvider();
Endpoint ep = Endpoint.create(implementor);
Map<String, Object> map = new HashMap<String, Object>();
- map.put("schema-validation-enabled", Boolean.TRUE);
+ map.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
ep.setProperties(map);
ep.publish(ADDRESS);
}
Modified: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java (original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java Thu Oct 11 20:19:50 2012
@@ -32,6 +32,7 @@ import javax.xml.ws.Holder;
import javax.xml.ws.soap.SOAPBinding;
import org.apache.cxf.Bus;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
import org.apache.cxf.endpoint.Client;
@@ -46,6 +47,7 @@ import org.apache.cxf.jaxws.JaxWsClientP
import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.message.Message;
import org.apache.cxf.mime.TestMtom;
import org.apache.cxf.mime.types.XopStringType;
import org.apache.cxf.mtom_xop.TestMtomImpl;
@@ -94,7 +96,6 @@ public class ClientMtomXopTest extends A
assertTrue("server did not launch correctly", launchServer(Server.class, true));
}
-
@Test
public void testMtomXop() throws Exception {
TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class, true, true);
@@ -118,59 +119,69 @@ public class ClientMtomXopTest extends A
fileSize);
}
- ((BindingProvider)mtomPort).getRequestContext().put("schema-validation-enabled",
- Boolean.TRUE);
- param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
- name = new Holder<String>("call detail");
- mtomPort.testXop(name, param);
- assertEquals("name unchanged", "return detail + call detail", name.value);
- assertNotNull(param.value);
-
- in = param.value.getInputStream();
- bytes = IOUtils.readBytesFromStream(in);
- assertEquals(data.length, bytes.length);
- in.close();
-
- param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
- name = new Holder<String>("call detail");
- mtomPort.testXop(name, param);
- assertEquals("name unchanged", "return detail + call detail", name.value);
- assertNotNull(param.value);
-
- in = param.value.getInputStream();
- bytes = IOUtils.readBytesFromStream(in);
- assertEquals(data.length, bytes.length);
- in.close();
- ((BindingProvider)mtomPort).getRequestContext().put("schema-validation-enabled",
- Boolean.FALSE);
- SAAJOutInterceptor saajOut = new SAAJOutInterceptor();
- SAAJInInterceptor saajIn = new SAAJInInterceptor();
- param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
- name = new Holder<String>("call detail");
- mtomPort.testXop(name, param);
- assertEquals("name unchanged", "return detail + call detail", name.value);
- assertNotNull(param.value);
-
- in = param.value.getInputStream();
- bytes = IOUtils.readBytesFromStream(in);
- assertEquals(data.length, bytes.length);
- in.close();
-
- ClientProxy.getClient(mtomPort).getInInterceptors().add(saajIn);
- ClientProxy.getClient(mtomPort).getInInterceptors().add(saajOut);
- param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
- name = new Holder<String>("call detail");
- mtomPort.testXop(name, param);
- assertEquals("name unchanged", "return detail + call detail", name.value);
- assertNotNull(param.value);
-
- in = param.value.getInputStream();
- bytes = IOUtils.readBytesFromStream(in);
- assertEquals(data.length, bytes.length);
- in.close();
+ Object[] validationTypes = new Object[]{Boolean.TRUE, SchemaValidationType.IN, SchemaValidationType.BOTH};
+
+ for (Object validationType : validationTypes) {
+ ((BindingProvider)mtomPort).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,
+ validationType);
+
+ param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
+ name = new Holder<String>("call detail");
+ mtomPort.testXop(name, param);
+ assertEquals("name unchanged", "return detail + call detail", name.value);
+ assertNotNull(param.value);
+
+ in = param.value.getInputStream();
+ bytes = IOUtils.readBytesFromStream(in);
+ assertEquals(data.length, bytes.length);
+ in.close();
+
+ param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
+ name = new Holder<String>("call detail");
+ mtomPort.testXop(name, param);
+ assertEquals("name unchanged", "return detail + call detail", name.value);
+ assertNotNull(param.value);
+
+ in = param.value.getInputStream();
+ bytes = IOUtils.readBytesFromStream(in);
+ assertEquals(data.length, bytes.length);
+ in.close();
+ }
+
+ validationTypes = new Object[]{Boolean.FALSE, SchemaValidationType.OUT, SchemaValidationType.NONE};
+ for (Object validationType : validationTypes) {
+ ((BindingProvider)mtomPort).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,
+ validationType);
+ SAAJOutInterceptor saajOut = new SAAJOutInterceptor();
+ SAAJInInterceptor saajIn = new SAAJInInterceptor();
- ClientProxy.getClient(mtomPort).getInInterceptors().remove(saajIn);
- ClientProxy.getClient(mtomPort).getInInterceptors().remove(saajOut);
+ param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
+ name = new Holder<String>("call detail");
+ mtomPort.testXop(name, param);
+ assertEquals("name unchanged", "return detail + call detail", name.value);
+ assertNotNull(param.value);
+
+ in = param.value.getInputStream();
+ bytes = IOUtils.readBytesFromStream(in);
+ assertEquals(data.length, bytes.length);
+ in.close();
+
+ ClientProxy.getClient(mtomPort).getInInterceptors().add(saajIn);
+ ClientProxy.getClient(mtomPort).getInInterceptors().add(saajOut);
+ param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
+ name = new Holder<String>("call detail");
+ mtomPort.testXop(name, param);
+ assertEquals("name unchanged", "return detail + call detail", name.value);
+ assertNotNull(param.value);
+
+ in = param.value.getInputStream();
+ bytes = IOUtils.readBytesFromStream(in);
+ assertEquals(data.length, bytes.length);
+ in.close();
+
+ ClientProxy.getClient(mtomPort).getInInterceptors().remove(saajIn);
+ ClientProxy.getClient(mtomPort).getInInterceptors().remove(saajOut);
+ }
} catch (UndeclaredThrowableException ex) {
throw (Exception)ex.getCause();
} catch (Exception ex) {
@@ -186,7 +197,7 @@ public class ClientMtomXopTest extends A
throw ex;
}
}
-
+
@Test
public void testMtomWithFileName() throws Exception {
TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class, true, true);
@@ -196,15 +207,16 @@ public class ClientMtomXopTest extends A
URL fileURL = getClass().getClassLoader().getResource("me.bmp");
- ((BindingProvider)mtomPort).getRequestContext().put("schema-validation-enabled",
- Boolean.TRUE);
- param.value = new DataHandler(fileURL);
- name = new Holder<String>("have name");
- mtomPort.testXop(name, param);
- assertEquals("can't get file name", "return detail + me.bmp", name.value);
- assertNotNull(param.value);
-
-
+ Object[] validationTypes = new Object[]{Boolean.TRUE, SchemaValidationType.IN, SchemaValidationType.BOTH};
+ for (Object validationType : validationTypes) {
+ ((BindingProvider)mtomPort).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,
+ validationType);
+ param.value = new DataHandler(fileURL);
+ name = new Holder<String>("have name");
+ mtomPort.testXop(name, param);
+ assertEquals("can't get file name", "return detail + me.bmp", name.value);
+ assertNotNull(param.value);
+ }
} catch (UndeclaredThrowableException ex) {
throw (Exception)ex.getCause();
} catch (Exception ex) {
Modified: cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/AbstractClientPersistenceTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/AbstractClientPersistenceTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/AbstractClientPersistenceTest.java (original)
+++ cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/AbstractClientPersistenceTest.java Thu Oct 11 20:19:50 2012
@@ -39,6 +39,7 @@ import org.apache.cxf.greeter_control.Gr
import org.apache.cxf.greeter_control.GreeterService;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.message.Message;
import org.apache.cxf.systest.ws.util.MessageFlow;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
@@ -103,7 +104,7 @@ public abstract class AbstractClientPers
String address = "http://localhost:" + port + "/SoapContext/GreeterPort";
ep = Endpoint.create(implementor);
Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("schema-validation-enabled", Boolean.TRUE);
+ properties.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
ep.setProperties(properties);
ep.publish(address);
LOG.info("Published greeter endpoint.");
@@ -152,7 +153,7 @@ public abstract class AbstractClientPers
GreeterService gs = new GreeterService();
greeter = gs.getGreeterPort();
updateAddressPort(greeter, getPort());
- ((BindingProvider)greeter).getRequestContext().put("schema-validation-enabled", Boolean.TRUE);
+ ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
out = new OutMessageRecorder();
in = new InMessageRecorder();
Modified: cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledBareTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledBareTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledBareTest.java (original)
+++ cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledBareTest.java Thu Oct 11 20:19:50 2012
@@ -31,6 +31,7 @@ import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.message.Message;
import org.apache.cxf.systest.ws.util.ConnectionHelper;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
@@ -65,7 +66,7 @@ public class DecoupledBareTest extends A
String address = "http://localhost:" + PORT + "/SoapContext/SoapPort";
ep = Endpoint.create(implementor);
Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("schema-validation-enabled", Boolean.TRUE);
+ properties.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
ep.setProperties(properties);
ep.publish(address);
LOG.info("Published server endpoint.");
@@ -92,7 +93,7 @@ public class DecoupledBareTest extends A
DocLitBare greeter = service.getSoapPort();
updateAddressPort(greeter, PORT);
- ((BindingProvider)greeter).getRequestContext().put("schema-validation-enabled", Boolean.TRUE);
+ ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
ConnectionHelper.setKeepAliveConnection(greeter, true);
Modified: cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java?rev=1397280&r1=1397279&r2=1397280&view=diff
==============================================================================
--- cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java (original)
+++ cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java Thu Oct 11 20:19:50 2012
@@ -34,6 +34,7 @@ import org.apache.cxf.greeter_control.Gr
import org.apache.cxf.greeter_control.GreeterService;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.message.Message;
import org.apache.cxf.systest.ws.util.ConnectionHelper;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
@@ -72,7 +73,7 @@ public class DecoupledClientServerTest e
ep = Endpoint.create(implementor);
Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("schema-validation-enabled",
+ properties.put(Message.SCHEMA_VALIDATION_ENABLED,
shouldValidate());
ep.setProperties(properties);
ep.publish(address);
@@ -116,7 +117,7 @@ public class DecoupledClientServerTest e
GreeterService gs = new GreeterService();
final Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
- ((BindingProvider)greeter).getRequestContext().put("schema-validation-enabled",
+ ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,
shouldValidate());
LOG.fine("Created greeter client.");