cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r586781 - in /incubator/cxf/branches/2.0.x-fixes: ./ buildtools/src/main/resources/ rt/core/src/main/java/org/apache/cxf/test/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ systests/ systests/src/test/generated/ systests/src/test/g...
Date Sat, 20 Oct 2007 19:18:54 GMT
Author: dkulp
Date: Sat Oct 20 12:18:51 2007
New Revision: 586781

URL: http://svn.apache.org/viewvc?rev=586781&view=rev
Log:
Merged revisions 586116 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r586116 | bimargulies | 2007-10-18 16:14:46 -0400 (Thu, 18 Oct 2007) | 7 lines
  
  1) Refactor the AbstractCXFTest to move common utilities to a
  new class where they can be used by tests that can't inherit from
  AbstractCXFTest, like tests that use the Spring structure.
  
  2) fix CXF-1118 by filtering the Exception object fields to only 
  marshall public, non-static fields.
........

Added:
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java
      - copied unchanged from r586116, incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/generated/
      - copied from r586116, incubator/cxf/trunk/systests/src/test/generated/
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/generated/org/
      - copied from r586116, incubator/cxf/trunk/systests/src/test/generated/org/
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/generated/org/apache/
      - copied from r586116, incubator/cxf/trunk/systests/src/test/generated/org/apache/
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/generated/org/apache/cxf/
      - copied from r586116, incubator/cxf/trunk/systests/src/test/generated/org/apache/cxf/
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/generated/org/apache/cxf/systest/
      - copied from r586116, incubator/cxf/trunk/systests/src/test/generated/org/apache/cxf/systest/
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/generated/org/apache/cxf/systest/jaxb/
      - copied from r586116, incubator/cxf/trunk/systests/src/test/generated/org/apache/cxf/systest/jaxb/
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/generated/org/apache/cxf/systest/jaxb/service/
      - copied from r586116, incubator/cxf/trunk/systests/src/test/generated/org/apache/cxf/systest/jaxb/service/
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/generated/org/apache/cxf/systest/jaxb/service/TestServiceException.java
      - copied unchanged from r586116, incubator/cxf/trunk/systests/src/test/generated/org/apache/cxf/systest/jaxb/service/TestServiceException.java
Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/buildtools/src/main/resources/cxf-checkstyle.xml
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
    incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
    incubator/cxf/branches/2.0.x-fixes/systests/pom.xml
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/TestServiceTest.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/service/TestService.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/service/TestServiceImpl.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/buildtools/src/main/resources/cxf-checkstyle.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/buildtools/src/main/resources/cxf-checkstyle.xml?rev=586781&r1=586780&r2=586781&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/buildtools/src/main/resources/cxf-checkstyle.xml (original)
+++ incubator/cxf/branches/2.0.x-fixes/buildtools/src/main/resources/cxf-checkstyle.xml Sat
Oct 20 12:18:51 2007
@@ -44,7 +44,8 @@
     <!--<module name="StrictDuplicateCode"/>-->
 
     <module name="TreeWalker">
-
+ 	    <!-- Enable FileContentsHolder to allow us to in turn turn on suppression comments
-->
+        <module name="FileContentsHolder"/>
         <!-- Checks for Javadoc comments.                     -->
         <!-- See http://checkstyle.sf.net/config_javadoc.html -->
         <!--
@@ -283,5 +284,5 @@
         </module>
         <!--<module name="RequiredRegexp">-->
     </module>
-
+    <module name="SuppressionCommentFilter"/>
 </module>

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java?rev=586781&r1=586780&r2=586781&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
Sat Oct 20 12:18:51 2007
@@ -19,73 +19,45 @@
 
 package org.apache.cxf.test;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
 import java.io.Reader;
-import java.util.HashMap;
 import java.util.Map;
 
-import javax.wsdl.Definition;
 import javax.wsdl.WSDLException;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLWriter;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.xml.sax.SAXParseException;
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
-import org.apache.cxf.service.Service;
-import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.Conduit;
-import org.apache.cxf.transport.ConduitInitiator;
-import org.apache.cxf.transport.ConduitInitiatorManager;
-import org.apache.cxf.transport.MessageObserver;
-import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
+
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 
+
 /**
  * A basic test case meant for helping users unit test their services.
  */
 public class AbstractCXFTest extends Assert {
     
-    private static String basedirPath;
-    
+    protected TestUtilities testUtilities;
     protected Bus bus;
-    /**
-     * Namespaces for the XPath expressions.
-     */
-    private Map<String, String> namespaces = new HashMap<String, String>();
-
+    
+    protected AbstractCXFTest() {
+        testUtilities = new TestUtilities(getClass());
+        testUtilities.addDefaultNamespaces();
+    }
     
     @Before
     public void setUpBus() throws Exception {
         if (bus == null) {
             bus = createBus();
-            
-            addNamespace("s", "http://schemas.xmlsoap.org/soap/envelope/");
-            addNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
-            addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
-            addNamespace("wsdlsoap", "http://schemas.xmlsoap.org/wsdl/soap/");
-            addNamespace("soap", "http://schemas.xmlsoap.org/soap/");
-            addNamespace("soap12env", "http://www.w3.org/2003/05/soap-envelope");       

-            addNamespace("xml", "http://www.w3.org/XML/1998/namespace");
+            testUtilities.setBus(bus);
         }
     }
     
@@ -110,50 +82,13 @@
     protected byte[] invokeBytes(String address, 
                                  String transport,
                                  String message) throws Exception {
-        EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
-        ei.setAddress(address);
-
-        ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class);
-        ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport);
-        Conduit conduit = conduitInit.getConduit(ei);
-
-        TestMessageObserver obs = new TestMessageObserver();
-        conduit.setMessageObserver(obs);
-        
-        Message m = new MessageImpl();
-        conduit.prepare(m);
-
-        OutputStream os = m.getContent(OutputStream.class);
-        InputStream is = getResourceAsStream(message);
-        if (is == null) {
-            throw new RuntimeException("Could not find resource " + message);
-        }
-        
-        IOUtils.copy(is, os);
-
-        // TODO: shouldn't have to do this. IO caching needs cleaning
-        // up or possibly removal...
-        os.flush();
-        is.close();
-        os.close();
-        
-        byte[] bs = obs.getResponseStream().toByteArray();
-        
-        return bs;
+        return testUtilities.invokeBytes(address, transport, message);
     }
     
     protected Node invoke(String address, 
                           String transport,
                           String message) throws Exception {
-        byte[] bs = invokeBytes(address, transport, message);
-        
-        ByteArrayInputStream input = new ByteArrayInputStream(bs);
-        try {
-            return DOMUtils.readXml(input);
-        } catch (SAXParseException e) {
-            throw new IllegalStateException("Could not parse message:\n" 
-                                            + new String(bs));
-        }
+        return testUtilities.invoke(address, transport, message);
     }
 
     /**
@@ -163,7 +98,7 @@
      * @throws Exception 
      */
     public NodeList assertValid(String xpath, Node node) throws Exception {
-        return XPathAssert.assertValid(xpath, node, namespaces);
+        return testUtilities.assertValid(xpath, node);
     }
 
     /**
@@ -172,11 +107,11 @@
      * @param xpath
      */
     public NodeList assertInvalid(String xpath, Node node) throws Exception {
-        return XPathAssert.assertInvalid(xpath, node, namespaces);
+        return testUtilities.assertInvalid(xpath, node);
     }
 
     /**
-     * Asser that the text of the xpath node retrieved is equal to the value
+     * Assert that the text of the xpath node retrieved is equal to the value
      * specified.
      * 
      * @param xpath
@@ -184,11 +119,16 @@
      * @param node
      */
     public void assertXPathEquals(String xpath, String value, Node node) throws Exception
{
-        XPathAssert.assertXPathEquals(xpath, value, node, namespaces);
+        testUtilities.assertXPathEquals(xpath, value, node);
     }
 
+    /**
+     * Assert that this node is not a SOAP fault part.
+     * @param node
+     * @throws Exception
+     */
     public void assertNoFault(Node node) throws Exception {
-        XPathAssert.assertNoFault(node);
+        testUtilities.assertNoFault(node);
     }
     
     /**
@@ -198,86 +138,37 @@
      * @param uri The namespace uri.
      */
     public void addNamespace(String ns, String uri) {
-        namespaces.put(ns, uri);
+        testUtilities.addNamespace(ns, uri);
     }
 
     public Map<String, String> getNamespaces() {
-        return namespaces;
+        return testUtilities.getNamespaces();
     }
 
     protected InputStream getResourceAsStream(String resource) {
-        return getClass().getResourceAsStream(resource);
+        return testUtilities.getResourceAsStream(resource);
     }
 
     protected Reader getResourceAsReader(String resource) {
-        return new InputStreamReader(getResourceAsStream(resource));
+        return testUtilities.getResourceAsReader(resource);
     }
 
     public File getTestFile(String relativePath) {
-        return new File(getBasedir(), relativePath);
+        return testUtilities.getTestFile(relativePath);
     }
 
     public static String getBasedir() {
-        if (basedirPath != null) {
-            return basedirPath;
-        }
-
-        basedirPath = System.getProperty("basedir");
-
-        if (basedirPath == null) {
-            basedirPath = new File("").getAbsolutePath();
-        }
-
-        return basedirPath;
+        return TestUtilities.getBasedir();
     }
 
     protected Document getWSDLDocument(Server server) throws WSDLException {
-        Service service = server.getEndpoint().getService();
-        
-        ServiceWSDLBuilder wsdlBuilder = 
-            new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0));
-        wsdlBuilder.setUseSchemaImports(false);
-        Definition definition = wsdlBuilder.build();
-        WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
-        
-        return writer.getDocument(definition);
+        return testUtilities.getWSDLDocument(server);
     }
     
-    public static class TestMessageObserver implements MessageObserver {
-        ByteArrayOutputStream response = new ByteArrayOutputStream();
-        boolean written;
-        String contentType;
-        
-        public ByteArrayOutputStream getResponseStream() throws Exception {
-            synchronized (this) {
-                if (!written) {
-                    wait(1000000000);
-                }
-            }
-            return response;
-        }
-        
-        public String getResponseContentType() {
-            return contentType;
-        }
+    public static class TestMessageObserver extends TestUtilities.TestMessageObserver {
 
-        public void onMessage(Message message) {
-            try {
-                contentType = (String) message.get(Message.CONTENT_TYPE);
-                InputStream is = message.getContent(InputStream.class);
-                IOUtils.copy(is, response);
-                
-                is.close();
-                response.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-                fail();
-            } finally {
-                synchronized (this) {
-                    written = true;
-                    notifyAll();
-                }
-            }
+        public TestMessageObserver() {
+            super();
         }
     }
 }

Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=586781&r1=586780&r2=586781&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Sat Oct 20 12:18:51 2007
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxb;
 
 import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.util.Iterator;
 import java.util.logging.Logger;
 
@@ -281,6 +282,14 @@
         ct.setParticle(seq);
         String namespace = part.getElementQName().getNamespaceURI();
         for (Field f : cls.getDeclaredFields()) {
+            // This code takes all the fields that are public and not static.
+            // It is arguable that it should be looking at get/is properties and all those
+            // bean-like things.
+            int modifiers = f.getModifiers();
+            if (!Modifier.isPublic(modifiers) || Modifier.isStatic(modifiers)) {
+                continue;
+            }
+        
             JaxBeanInfo<?> beanInfo = context.getBeanInfo(f.getType());
             if (beanInfo != null) {
                 el = new XmlSchemaElement();

Modified: incubator/cxf/branches/2.0.x-fixes/systests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/pom.xml?rev=586781&r1=586780&r2=586781&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/pom.xml (original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/pom.xml Sat Oct 20 12:18:51 2007
@@ -37,6 +37,25 @@
     <build>
         <plugins>
             <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.0</version>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${basedir}/src/test/generated</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.cxf</groupId>
                 <artifactId>cxf-codegen-plugin</artifactId>
                 <version>${project.version}</version>

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/TestServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/TestServiceTest.java?rev=586781&r1=586780&r2=586781&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/TestServiceTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/TestServiceTest.java
Sat Oct 20 12:18:51 2007
@@ -21,10 +21,17 @@
 
 import java.net.URL;
 
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.systest.jaxb.model.ExtendedWidget;
 import org.apache.cxf.systest.jaxb.model.Widget;
 import org.apache.cxf.systest.jaxb.service.TestService;
+import org.apache.cxf.test.TestUtilities;
 import org.junit.Test;
 import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
 
@@ -32,12 +39,13 @@
 public class TestServiceTest extends AbstractDependencyInjectionSpringContextTests {
 
     private TestService testClient;
+    private TestUtilities testUtilities;
 
     public TestServiceTest() {
         setAutowireMode(AbstractDependencyInjectionSpringContextTests.AUTOWIRE_BY_NAME);
+        testUtilities = new TestUtilities(getClass());
     }
 
-
     @Test
     public void testExtraSubClassWithJaxb() throws Throwable {
         Widget expected = new ExtendedWidget(42, "blah", "blah", true, true);
@@ -53,6 +61,22 @@
         String s = IOUtils.toString(url.openStream());
         assertTrue(s, s.contains("application/octet-stream"));
     }
+    
+    @Test
+    public void testAutoFaultBeanProperties() throws Exception {
+        testUtilities.setBus((Bus)applicationContext.getBean("cxf"));
+        testUtilities.addDefaultNamespaces();
+        testUtilities.addNamespace("ts", "http://cxf.org.apache/service");
+        Server s = testUtilities.getServerForService(new QName("http://cxf.org.apache/service",

+                                                               "TestServiceService"));
+        Document wsdl = testUtilities.getWSDLDocument(s);
+        testUtilities.assertInvalid("//xsd:complexType[@name='TestServiceException']"
+                                    + "/xsd:sequence/xsd:element[@name='serialVersionUID']",
wsdl);
+        testUtilities.assertInvalid("//xsd:complexType[@name='TestServiceException']"
+                                    + "/xsd:sequence/xsd:element[@name='privateInt']", wsdl);
+        testUtilities.assertValid("//xsd:complexType[@name='TestServiceException']"
+                                    + "/xsd:sequence/xsd:element[@name='publicString']",
wsdl);
+    }
 
     /*
      * (non-Javadoc)
@@ -77,5 +101,4 @@
     public void setTestClient(TestService testClient) {
         this.testClient = testClient;
     }
-
 }

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/service/TestService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/service/TestService.java?rev=586781&r1=586780&r2=586781&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/service/TestService.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/service/TestService.java
Sat Oct 20 12:18:51 2007
@@ -31,5 +31,8 @@
     @WebMethod(operationName = "getWidgetById")
     Widget getWidgetById(@WebParam(name = "id")
                          long id);
+    
+    @WebMethod
+    void testExceptionMarshalling() throws TestServiceException;
 
 }

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/service/TestServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/service/TestServiceImpl.java?rev=586781&r1=586780&r2=586781&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/service/TestServiceImpl.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxb/service/TestServiceImpl.java
Sat Oct 20 12:18:51 2007
@@ -33,6 +33,10 @@
         return new ExtendedWidget(id, "blah", "blah", true, true);
     }
 
+    public void testExceptionMarshalling() throws TestServiceException {
+        throw new TestServiceException("Your hovercraft is full of eels.");
+    }
+
     
 
 }



Mime
View raw message