cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r629686 - in /incubator/cxf/trunk: rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ systests/src/test/java/org/apache/cxf/systest/ws/rm/
Date Thu, 21 Feb 2008 03:59:43 GMT
Author: dkulp
Date: Wed Feb 20 19:59:43 2008
New Revision: 629686

URL: http://svn.apache.org/viewvc?rev=629686&view=rev
Log:
[CXF-905] If schema validation is turned on, also validate the RM messages against the RM
schema

Modified:
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ClientPersistenceTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledBareTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java?rev=629686&r1=629685&r2=629686&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java Wed Feb
20 19:59:43 2008
@@ -25,8 +25,12 @@
 import java.util.logging.Logger;
 
 import javax.wsdl.extensions.ExtensibilityElement;
+import javax.xml.XMLConstants;
 import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
 
 import org.apache.cxf.binding.soap.SoapVersion;
 import org.apache.cxf.binding.soap.model.SoapBindingInfo;
@@ -72,6 +76,8 @@
     private static final QName CREATE_RESPONSE_PART_NAME = new QName(RMConstants.getWsdlNamespace(),
                                                                      "createResponse");
     private static final QName TERMINATE_PART_NAME = new QName(RMConstants.getWsdlNamespace(),
"terminate");
+    
+    private static Schema rmSchema;
 
     private RMManager manager;
     private Endpoint applicationEndpoint;
@@ -228,7 +234,10 @@
 
     void createService() {
         ServiceInfo si = new ServiceInfo();
+        si.setProperty(Schema.class.getName(), getSchema());
+        
         si.setName(SERVICE_NAME);
+        
         buildInterfaceInfo(si);
 
         service = new WrappedService(applicationEndpoint.getService(), SERVICE_NAME, si);
@@ -242,6 +251,27 @@
         }
         service.setDataBinding(dataBinding);
         service.setInvoker(servant);
+    }
+
+    private static synchronized Schema getSchema() {
+        if (rmSchema == null) {
+            try {
+                SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+                javax.xml.transform.Source ad = new StreamSource(RMEndpoint.class
+                                             .getResource("/schemas/wsdl/addressing.xsd")
+                                             .openStream(),
+                                             "http://schemas.xmlsoap.org/ws/2004/08/addressing");
+                javax.xml.transform.Source rm = new StreamSource(RMEndpoint.class
+                                                                 .getResource("/schemas/wsdl/wsrm.xsd")
+                                                                 .openStream());
+                
+                javax.xml.transform.Source schemas[] = new javax.xml.transform.Source[] {ad,
rm};
+                rmSchema = factory.newSchema(schemas);
+            } catch (Exception ex) {
+                //ignore
+            }
+        }
+        return rmSchema;
     }
 
     void createEndpoint() {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ClientPersistenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ClientPersistenceTest.java?rev=629686&r1=629685&r2=629686&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ClientPersistenceTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ClientPersistenceTest.java
Wed Feb 20 19:59:43 2008
@@ -21,8 +21,11 @@
 
 import java.math.BigInteger;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.logging.Logger;
 
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Endpoint;
 
 import org.apache.cxf.Bus;
@@ -88,7 +91,11 @@
             
             GreeterImpl implementor = new GreeterImpl();
             String address = "http://localhost:9020/SoapContext/GreeterPort";
-            Endpoint.publish(address, implementor);
+            Endpoint ep = Endpoint.create(implementor);
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put("schema-validation-enabled", Boolean.TRUE);
+            ep.setProperties(properties);
+            ep.publish(address);
             LOG.info("Published greeter endpoint.");
         }
 
@@ -108,6 +115,7 @@
 
     @BeforeClass
     public static void startServers() throws Exception {        
+        RMTxStore.deleteDatabaseFiles(RMTxStore.DEFAULT_DATABASE_NAME, false);
         String derbyHome = System.getProperty("derby.system.home");
         try {
             if (derbyHome == null) {
@@ -150,6 +158,7 @@
 
         GreeterService gs = new GreeterService();
         greeter = gs.getGreeterPort();
+        ((BindingProvider)greeter).getRequestContext().put("schema-validation-enabled", Boolean.TRUE);
 
         out = new OutMessageRecorder();
         in = new InMessageRecorder();

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledBareTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledBareTest.java?rev=629686&r1=629685&r2=629686&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledBareTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledBareTest.java
Wed Feb 20 19:59:43 2008
@@ -19,8 +19,11 @@
 
 package org.apache.cxf.systest.ws.rm;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.logging.Logger;
 
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Endpoint;
 
 
@@ -56,7 +59,11 @@
             
             Object implementor = new DocLitBareGreeterImpl();
             String address = "http://localhost:7600/SoapContext/SoapPort";
-            Endpoint.publish(address, implementor);
+            Endpoint ep = Endpoint.create(implementor);
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put("schema-validation-enabled", Boolean.TRUE);
+            ep.setProperties(properties);
+            ep.publish(address);
             LOG.info("Published server endpoint.");
         }
         
@@ -89,6 +96,7 @@
         assertNotNull(service);
 
         DocLitBare greeter = service.getSoapPort();
+        ((BindingProvider)greeter).getRequestContext().put("schema-validation-enabled", Boolean.TRUE);
 
         ConnectionHelper.setKeepAliveConnection(greeter, true);
        

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java?rev=629686&r1=629685&r2=629686&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/DecoupledClientServerTest.java
Wed Feb 20 19:59:43 2008
@@ -19,8 +19,11 @@
 
 package org.apache.cxf.systest.ws.rm;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.logging.Logger;
 
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Endpoint;
 
 import org.apache.cxf.Bus;
@@ -64,7 +67,13 @@
             implementor.useLastOnewayArg(true);
             implementor.setDelay(5000);
             String address = "http://localhost:9020/SoapContext/GreeterPort";
-            Endpoint.publish(address, implementor);
+            
+            Endpoint ep = Endpoint.create(implementor);
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put("schema-validation-enabled", Boolean.TRUE);
+            ep.setProperties(properties);
+            ep.publish(address);
+
             LOG.info("Published greeter endpoint.");
         }
         
@@ -101,6 +110,7 @@
         
         GreeterService gs = new GreeterService();
         final Greeter greeter = gs.getGreeterPort();
+        ((BindingProvider)greeter).getRequestContext().put("schema-validation-enabled", Boolean.TRUE);
         LOG.fine("Created greeter client.");
        
         ConnectionHelper.setKeepAliveConnection(greeter, true);



Mime
View raw message