axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r676623 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/datasource/jaxb/JAXBDataSource.java test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java
Date Mon, 14 Jul 2008 15:24:01 GMT
Author: scheu
Date: Mon Jul 14 08:24:00 2008
New Revision: 676623

URL: http://svn.apache.org/viewvc?rev=676623&view=rev
Log:
WSCOMMONS-360

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDataSource.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDataSource.java?rev=676623&r1=676622&r2=676623&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDataSource.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDataSource.java
Mon Jul 14 08:24:00 2008
@@ -55,6 +55,10 @@
         super();
         this.jaxb = jaxb;
         this.context = context;
+        
+        // Currently we cannot control how the unmarshaller will emit the prefix
+        // So if the value of the prefix is needed, full expansion is necessary.
+        setProperty(OMDataSourceExt.LOSSY_PREFIX, Boolean.TRUE);
     }
 
     public void close() {

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java?rev=676623&r1=676622&r2=676623&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java
Mon Jul 14 08:24:00 2008
@@ -22,6 +22,7 @@
 import junit.framework.TestCase;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axis2.datasource.jaxb.JAXBCustomBuilder;
@@ -62,14 +63,15 @@
     
     public void test() throws Exception {
 
+        TreeSet<String> contextPackages = new TreeSet<String>();
+        contextPackages.add(EchoString.class.getPackage().getName());
+        /**
         // Setup: Create a jaxb object
         ObjectFactory factory = new ObjectFactory();
         EchoString jaxb = factory.createEchoString(); 
         jaxb.setInput("Hello World");
         
-        // Now create a Context for this object
-        TreeSet<String> contextPackages = new TreeSet<String>();
-        contextPackages.add(EchoString.class.getPackage().getName());
+        
         JAXBContext context = JAXBUtils.getJAXBContext(contextPackages);
            
         // Write out the xml
@@ -80,7 +82,13 @@
         JAXBUtils.releaseJAXBMarshaller(context, marshaller);
         writer.flush();
         sw.flush();
-        StringReader sr = new StringReader(sw.toString());
+        String outtext = sw.toString();
+        System.out.println("OUT=" + outtext);
+        StringReader sr = new StringReader(outtext);
+        **/
+        
+        String inText = "<pre:echoString xmlns:pre=\"http://test\"><pre:input>Hello
World</pre:input></pre:echoString>";
+        StringReader sr = new StringReader(inText);
         
         // Read the sample text using OM backed by StAX.
         XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
@@ -106,6 +114,30 @@
         assertTrue(jaxbObject instanceof EchoString);
         EchoString result = (EchoString) jaxbObject;
         assertTrue(result.getInput().equals("Hello World"));
+        
+        // Make sure that the local name can be obtained without expansion
+        String localName = om.getLocalName();
+        assertTrue("echoString".equals(localName));
+        ds = ((OMSourcedElement) om).getDataSource();
+        assertTrue(ds != null);
+        
+        // Make sure that the namespace uri can be obtained without expansion
+        OMNamespace omNS = om.getNamespace();
+        String uri = omNS.getNamespaceURI();
+        assertTrue("http://test".equals (uri));
+        ds = ((OMSourcedElement) om).getDataSource();
+        assertTrue(ds != null);
+        
+        // Make sure the prefix is consistent with the output
+        String prefix = omNS.getPrefix();
+        System.out.println(prefix);
+        String text = om.toString();
+        System.out.println(text);
+        String searchString = (prefix == null || prefix.length() == 0) ? 
+                    "</echoString>" :
+                    "</" + prefix + ":echoString>";
+        assertTrue(text.indexOf(searchString) > 0);
+            
     }
     
 }



Mime
View raw message