[jbossws-commits] JBossWS SVN: r10863 - in framework/trunk/testsuite/test: java/org/jboss/test/ws/jaxws and 6 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Oct 8 06:39:04 EDT 2009


Author: alessio.soldano at jboss.com
Date: 2009-10-08 06:39:04 -0400 (Thu, 08 Oct 2009)
New Revision: 10863

Added:
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jaxbcust/
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jaxbcust/BindingCustomizationTestCase.java
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotatedUserEndpoint.java
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotatedUserType.java
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotationReaderTestCase.java
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/Endpoint.java
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/EndpointBean.java
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/JAXBIntroTestCase.java
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/UserType.java
   framework/trunk/testsuite/test/resources/jaxws/samples/jaxbintros/
   framework/trunk/testsuite/test/resources/jaxws/samples/jaxbintros/META-INF/
   framework/trunk/testsuite/test/resources/jaxws/samples/jaxbintros/META-INF/jaxb-intros.xml
Modified:
   framework/trunk/testsuite/test/ant-import/build-samples-jaxws.xml
Log:
[JBWS-2714] Adding common test to jbossws-framework


Modified: framework/trunk/testsuite/test/ant-import/build-samples-jaxws.xml
===================================================================
--- framework/trunk/testsuite/test/ant-import/build-samples-jaxws.xml	2009-10-08 09:28:27 UTC (rev 10862)
+++ framework/trunk/testsuite/test/ant-import/build-samples-jaxws.xml	2009-10-08 10:39:04 UTC (rev 10863)
@@ -137,6 +137,18 @@
         <include name="wsdl/HttpBinding.wsdl"/>
       </webinf>
     </war>
+  	
+  	<!-- jaxws-samples-jaxbintros -->
+    <jar destfile="${tests.output.dir}/test-libs/jaxws-samples-jaxbintros.jar">
+      <fileset dir="${tests.output.dir}/test-classes">
+        <include name="org/jboss/test/ws/jaxws/samples/jaxbintros/Endpoint.class"/>
+        <include name="org/jboss/test/ws/jaxws/samples/jaxbintros/EndpointBean.class"/>
+        <include name="org/jboss/test/ws/jaxws/samples/jaxbintros/UserType.class"/>
+      </fileset>
+      <metainf dir="${tests.output.dir}/test-resources/jaxws/samples/jaxbintros/META-INF">
+        <include name="**/*" />
+      </metainf>
+    </jar>
 
     <!-- jaxws-samples-logicalhandler -->
     <war warfile="${tests.output.dir}/test-libs/jaxws-samples-logicalhandler-source.war"

Added: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jaxbcust/BindingCustomizationTestCase.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jaxbcust/BindingCustomizationTestCase.java	                        (rev 0)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jaxbcust/BindingCustomizationTestCase.java	2009-10-08 10:39:04 UTC (rev 10863)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jaxbcust;
+
+import junit.framework.TestCase;
+
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.binding.BindingCustomization;
+import org.jboss.wsf.spi.binding.JAXBBindingCustomization;
+import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.Endpoint.EndpointState;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @author alessio.soldano at jboss.com
+ * 
+ * @since 28-Jun-2007
+ */
+public class BindingCustomizationTestCase extends TestCase {
+
+   DeploymentModelFactory deploymentModelFactory;
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      deploymentModelFactory = spiProvider.getSPI(DeploymentModelFactory.class);
+   }
+
+   public void testCustomizationWriteAccess() throws Exception
+   {
+      Endpoint endpoint = deploymentModelFactory.newEndpoint(null);
+      BindingCustomization jaxbCustomization = new JAXBBindingCustomization();
+      jaxbCustomization.put("com.sun.xml.bind.defaultNamespaceRemap", "http://org.jboss.bindingCustomization");
+      endpoint.addAttachment(BindingCustomization.class, jaxbCustomization);
+
+      // a started endpoint should deny customizations
+      try
+      {
+         endpoint.setState(EndpointState.STARTED);
+         endpoint.addAttachment(BindingCustomization.class, jaxbCustomization);
+
+         fail("It should not be possible to change bindinig customizations on a started endpoint");
+      }
+      catch (Exception e)
+      {
+         // all fine, this should happen
+      }
+   }
+
+   public void testCustomizationReadAccess() throws Exception
+   {
+      Endpoint endpoint = deploymentModelFactory.newEndpoint(null);
+      BindingCustomization jaxbCustomization = new JAXBBindingCustomization();
+      jaxbCustomization.put("com.sun.xml.bind.defaultNamespaceRemap", "http://org.jboss.bindingCustomization");
+      endpoint.addAttachment(BindingCustomization.class, jaxbCustomization);
+      endpoint.setState(EndpointState.STARTED);
+
+      // read a single customization
+      BindingCustomization knownCustomization = endpoint.getAttachment(BindingCustomization.class);
+      assertNotNull(knownCustomization);
+
+      // however the iteratoion should be unmodifiable
+      try
+      {
+         endpoint.addAttachment(BindingCustomization.class, jaxbCustomization);
+         fail("Started Endpoints should only axpose read acccess to their binding customizations");
+      }
+      catch (Exception e)
+      {
+         // all fine, we'd expect this
+      }
+
+
+   }
+}


Property changes on: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jaxbcust/BindingCustomizationTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotatedUserEndpoint.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotatedUserEndpoint.java	                        (rev 0)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotatedUserEndpoint.java	2009-10-08 10:39:04 UTC (rev 10863)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.jaxbintros;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+ at WebService(name = "EndpointService", targetNamespace = "http://org.jboss.ws/samples/jaxbintros")
+ at SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
+public interface AnnotatedUserEndpoint
+{
+   public AnnotatedUserType echo(AnnotatedUserType foo);
+}


Property changes on: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotatedUserEndpoint.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotatedUserType.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotatedUserType.java	                        (rev 0)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotatedUserType.java	2009-10-08 10:39:04 UTC (rev 10863)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.jaxbintros;
+       
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.namespace.QName;
+
+/**
+ * <p>Java class for UserType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="UserType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="string" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         &lt;element name="qname" type="{http://www.w3.org/2001/XMLSchema}QName"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ at XmlRootElement(namespace = "http://org.jboss.ws/provider", name = "user")
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "UserType", propOrder = { "string", "qname" })
+public class AnnotatedUserType
+{
+
+   @XmlAttribute(required = true)
+   protected String string;
+   @XmlElement(required = true)
+   protected QName qname;
+
+   /**
+    * Gets the value of the string property.
+    *
+    * @return
+    *     possible object is
+    *     {@link String }
+    *
+    */
+   public String getString()
+   {
+      return string;
+   }
+
+   /**
+    * Sets the value of the string property.
+    *
+    * @param value
+    *     allowed object is
+    *     {@link String }
+    *
+    */
+   public void setString(String value)
+   {
+      this.string = value;
+   }
+
+   /**
+    * Gets the value of the qname property.
+    *
+    * @return
+    *     possible object is
+    *     {@link javax.xml.namespace.QName }
+    *
+    */
+   public QName getQname()
+   {
+      return qname;
+   }
+
+   /**
+    * Sets the value of the qname property.
+    *
+    * @param value
+    *     allowed object is
+    *     {@link javax.xml.namespace.QName }
+    *
+    */
+   public void setQname(QName value)
+   {
+      this.qname = value;
+   }
+
+}
+


Property changes on: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotatedUserType.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotationReaderTestCase.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotationReaderTestCase.java	                        (rev 0)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotationReaderTestCase.java	2009-10-08 10:39:04 UTC (rev 10863)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.jaxbintros;
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+
+import org.jboss.jaxb.intros.BindingCustomizationFactory;
+import org.jboss.wsf.test.JBossWSTest;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @author alessio.soldano at jboss.com
+ */
+public class AnnotationReaderTestCase extends JBossWSTest
+{
+   public void testUnmarshal() throws Exception
+   {
+      String reqString = 
+         "   <ns1:user xmlns:ns1='http://org.jboss.ws/provider' string='Kermit'>" + 
+         "      <qname>The Frog</qname>" + 
+         "    </ns1:user>";
+
+      Map<String, Object> jaxbConfig = BindingCustomizationFactory.getBindingCustomization(new FileInputStream(getResourceFile(
+            "jaxws/samples/jaxbintros/META-INF/jaxb-intros.xml").getPath()), "http://org.jboss.ws/provider");
+      
+      JAXBContext jaxbContext = JAXBContext.newInstance(new Class[] { UserType.class }, jaxbConfig);
+      Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+
+      JAXBElement jbe = unmarshaller.unmarshal(new StreamSource(new ByteArrayInputStream(reqString.getBytes())
+
+      ), UserType.class);
+
+      UserType ut = (UserType)jbe.getValue();
+      assertEquals("Kermit", ut.getString());
+      assertEquals("The Frog", ut.getQname().getLocalPart());
+
+   }
+}


Property changes on: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/AnnotationReaderTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/Endpoint.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/Endpoint.java	                        (rev 0)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/Endpoint.java	2009-10-08 10:39:04 UTC (rev 10863)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.jaxbintros;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+ at WebService(name = "EndpointService", targetNamespace = "http://org.jboss.ws/samples/jaxbintros")
+ at SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
+public interface Endpoint
+{
+   public UserType echo(UserType user);
+}


Property changes on: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/Endpoint.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/EndpointBean.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/EndpointBean.java	                        (rev 0)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/EndpointBean.java	2009-10-08 10:39:04 UTC (rev 10863)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.jaxbintros;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+ at WebService(name = "EndpointService", targetNamespace = "http://org.jboss.ws/samples/jaxbintros")
+ at SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
+ at Stateless
+public class EndpointBean implements Endpoint
+{
+   public UserType echo(UserType user)
+   {
+      System.out.println("user: " + user);
+      return user;
+   }
+}


Property changes on: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/EndpointBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/JAXBIntroTestCase.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/JAXBIntroTestCase.java	                        (rev 0)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/JAXBIntroTestCase.java	2009-10-08 10:39:04 UTC (rev 10863)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.jaxbintros;
+
+import java.net.URL;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+import org.w3c.dom.Element;
+
+/**
+ * Test the JAXBIntroduction features.
+ * 
+ * jaxb-intros.xml can reside under META-INF or WEB-INF and should be
+ * picked up by JAXBIntroduction deployment aspect on server side.
+ *
+ * @author alessio.soldano at jboss.com
+ */
+public class JAXBIntroTestCase extends JBossWSTest
+{
+   private String endpointAddress = "http://" + getServerHost() + ":8080/jaxws-samples-jaxbintros/EndpointBean";
+   
+   public static Test suite()
+   {
+      return new JBossWSTestSetup(JAXBIntroTestCase.class, "jaxws-samples-jaxbintros.jar");
+   }
+                                     
+   @SuppressWarnings("unchecked")
+   public void testWSDLAccess() throws Exception
+   {
+      URL wsdlURL = new URL(endpointAddress + "?wsdl");
+      Element wsdl = DOMUtils.parse(wsdlURL.openStream());
+      assertNotNull(wsdl);
+      Iterator<Element> it = DOMUtils.getChildElements(wsdl, new QName("http://www.w3.org/2001/XMLSchema","attribute"), true);
+      boolean attributeFound = false;
+      while (it.hasNext())
+      {
+         Element el = it.next();
+         if ("string".equals(el.getAttribute("name")))
+         {
+            attributeFound = true;
+         }
+      }
+      assertTrue("<xs:attribute name=\"string\" ..> not found in wsdl", attributeFound);
+   }
+   
+   /**
+    * Client side uses the annotated user type class, server side uses the plain one but has jaxbintros in place
+    * 
+    * @throws Exception
+    */
+   public void testAnnotatedUserEndpoint() throws Exception
+   {
+      URL wsdlURL = new URL(endpointAddress + "?wsdl");
+      QName serviceName = new QName("http://org.jboss.ws/samples/jaxbintros", "EndpointBeanService");
+
+      Service service = Service.create(wsdlURL, serviceName);
+      AnnotatedUserEndpoint port = service.getPort(AnnotatedUserEndpoint.class);
+      AnnotatedUserType user = new AnnotatedUserType();
+      QName qname = new QName("ns", "local", "prefix");
+      user.setQname(qname);
+      user.setString("Foo");
+      AnnotatedUserType result = port.echo(user);
+      assertEquals("Foo", result.getString());
+      assertEquals(qname, result.getQname());
+   }   
+}


Property changes on: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/JAXBIntroTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/UserType.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/UserType.java	                        (rev 0)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/UserType.java	2009-10-08 10:39:04 UTC (rev 10863)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.jaxbintros;
+
+import javax.xml.namespace.QName;
+
+/**
+ * <p>Java class for UserType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="UserType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="string" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         &lt;element name="qname" type="{http://www.w3.org/2001/XMLSchema}QName"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+public class UserType
+{  
+   protected String string;
+
+   protected QName qname;
+
+   /**
+    * Gets the value of the string property.
+    *
+    * @return
+    *     possible object is
+    *     {@link String }
+    *
+    */
+   public String getString()
+   {
+      return string;
+   }
+
+   /**
+    * Sets the value of the string property.
+    *
+    * @param value
+    *     allowed object is
+    *     {@link String }
+    *
+    */
+   public void setString(String value)
+   {
+      this.string = value;
+   }
+
+   /**
+    * Gets the value of the qname property.
+    *
+    * @return
+    *     possible object is
+    *     {@link javax.xml.namespace.QName }
+    *
+    */
+   public QName getQname()
+   {
+      return qname;
+   }
+
+   /**
+    * Sets the value of the qname property.
+    *
+    * @param value
+    *     allowed object is
+    *     {@link javax.xml.namespace.QName }
+    *
+    */
+   public void setQname(QName value)
+   {
+      this.qname = value;
+   }
+
+}


Property changes on: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/jaxbintros/UserType.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: framework/trunk/testsuite/test/resources/jaxws/samples/jaxbintros/META-INF/jaxb-intros.xml
===================================================================
--- framework/trunk/testsuite/test/resources/jaxws/samples/jaxbintros/META-INF/jaxb-intros.xml	                        (rev 0)
+++ framework/trunk/testsuite/test/resources/jaxws/samples/jaxbintros/META-INF/jaxb-intros.xml	2009-10-08 10:39:04 UTC (rev 10863)
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jaxb-intros xmlns="http://www.jboss.org/xsd/jaxb/intros" default-namespace="http://org.jboss.ws/provider">
+
+  <!--
+  Note: how the "name" attributes on class, field and method configs can be regular expressions.
+  -->
+
+  <!--
+ at XmlRootElement(namespace = "http://org.jboss.ws/provider", name = "user")
+ at XmlAccessorType(XmlAccessType.FIELD)
+ at XmlType(name = "UserType", propOrder = { "string", "qname" })
+public class UserType {}
+  -->
+
+  <!--
+  The type namespaces on the customerOrder are different from the rest of the message...
+  -->
+  <Class name="org.jboss.test.ws.jaxws.samples.jaxbintros.UserType">
+    <XmlAccessorType value="FIELD"/>   
+    <XmlRootElement name="user" namespace="http://org.jboss.ws/provider"/>
+
+    <Field name="string">
+      <XmlAttribute />
+    </Field>    
+  </Class>
+
+</jaxb-intros>
\ No newline at end of file


Property changes on: framework/trunk/testsuite/test/resources/jaxws/samples/jaxbintros/META-INF/jaxb-intros.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF



More information about the jbossws-commits mailing list