From jbossws-commits at lists.jboss.org Fri Feb 9 17:16:27 2007 Content-Type: multipart/mixed; boundary="===============6728422296633165185==" MIME-Version: 1.0 From: jbossws-commits at lists.jboss.org To: jbossws-commits at lists.jboss.org Subject: [jbossws-commits] JBossWS SVN: r2326 - trunk/jbossws-tests/src/main/java/org/jboss/test/ws/tools/jaxws. Date: Fri, 09 Feb 2007 17:16:25 -0500 Message-ID: --===============6728422296633165185== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2007-02-09 17:16:24 -0500 (Fri, 09 Feb 2007) New Revision: 2326 Added: trunk/jbossws-tests/src/main/java/org/jboss/test/ws/tools/jaxws/WSContra= ctProviderTestCase.java Log: Rename test Copied: trunk/jbossws-tests/src/main/java/org/jboss/test/ws/tools/jaxws/WSC= ontractProviderTestCase.java (from rev 2325, trunk/jbossws-tests/src/main/j= ava/org/jboss/test/ws/tools/jaxws/WebServiceGeneratorTestCase.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jbossws-tests/src/main/java/org/jboss/test/ws/tools/jaxws/WSContr= actProviderTestCase.java (rev 0) +++ trunk/jbossws-tests/src/main/java/org/jboss/test/ws/tools/jaxws/WSContr= actProviderTestCase.java 2007-02-09 22:16:24 UTC (rev 2326) @@ -0,0 +1,156 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt 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.tools.jaxws; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; + +import org.jboss.test.ws.JBossWSTest; +import org.jboss.test.ws.jaxws.samples.soapbinding.DocWrappedServiceImpl; +import org.jboss.test.ws.jaxws.samples.soapbinding.PurchaseOrder; +import org.jboss.test.ws.jaxws.samples.soapbinding.PurchaseOrderAck; +import org.jboss.ws.core.utils.JavaUtils; +import org.jboss.ws.tools.jaxws.api.WSContractProvider; +import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory; + +/** + * Tests the WSContractProvider API. + * = + * @author Jason T. Greene + * @version $Revision$ + */ +public class WSContractProviderTestCase extends JBossWSTest +{ + public void testBasic() throws Exception + { + WSContractProvider gen =3D getGenerator(); + File outputDir =3D new File("tools/wsprovide/basic/out"); + gen.setOutputDirectory(outputDir); + gen.provide(DocWrappedServiceImpl.class); + = + checkWrapperClasses(outputDir); + = + // There should be no source code + checkWrapperSource(outputDir, false); + } + + private WSContractProvider getGenerator() + { + return WSContractProvider.newInstance(); + } + + private void checkWrapperSource(File outputDir, boolean shouldExist) + { + File file1 =3D new File(outputDir, "org/jboss/test/ws/jaxws/samples/= soapbinding/jaxws/SubmitPO.java"); + File file2 =3D new File(outputDir, "org/jboss/test/ws/jaxws/samples/= soapbinding/jaxws/SubmitPOResponse.java"); + assertEquals(shouldExist, file1.exists()); + assertEquals(shouldExist, file2.exists()); + } + + private void checkWrapperClasses(File outputDir) throws MalformedURLExc= eption, ClassNotFoundException, NoSuchMethodException + { + // Use a different loader each time to make sure the files exist + URLClassLoader classLoader =3D new URLClassLoader(new URL[]{outputDi= r.toURL()}, Thread.currentThread().getContextClassLoader()); + = + // Check request wrapper + Class wrapper =3D JavaUtils.loadJavaType("org.jboss.test.ws.jaxws.sa= mples.soapbinding.jaxws.SubmitPO", classLoader); = + wrapper.getMethod("setPurchaseOrder", PurchaseOrder.class); + assertEquals(PurchaseOrder.class.getName(), wrapper.getMethod("getPu= rchaseOrder").getReturnType().getName()); + = + // Check response wrapper + wrapper =3D JavaUtils.loadJavaType("org.jboss.test.ws.jaxws.samples.= soapbinding.jaxws.SubmitPOResponse", classLoader); + wrapper.getMethod("setPurchaseOrderAck", PurchaseOrderAck.class); + assertEquals(PurchaseOrderAck.class.getName(), wrapper.getMethod("ge= tPurchaseOrderAck").getReturnType().getName()); + } + = + public void testSource() throws Exception + { + WSContractProvider gen =3D getGenerator(); + File outputDir =3D new File("tools/wsprovide/source/out"); + gen.setOutputDirectory(outputDir); + gen.setGenerateSource(true); + gen.provide(DocWrappedServiceImpl.class); + = + checkWrapperClasses(outputDir); + checkWrapperSource(outputDir, true); + } + = + public void testSourceDir() throws Exception + { + WSContractProvider gen =3D getGenerator(); + File outputDir =3D new File("tools/wsprovide/sourcedir/out"); + File sourceDir =3D new File("tools/wsprovide/sourcedir/source"); + = + gen.setOutputDirectory(outputDir); + gen.setSourceDirectory(sourceDir); + gen.setGenerateSource(true); + gen.provide(DocWrappedServiceImpl.class); + = + checkWrapperClasses(outputDir); + checkWrapperSource(outputDir, false); + checkWrapperSource(sourceDir, true); + } + = + public void testWsdl() throws Exception + { + WSContractProvider gen =3D getGenerator(); + File outputDir =3D new File("tools/wsprovide/wsdl/out"); + gen.setOutputDirectory(outputDir); + gen.setGenerateWsdl(true); + gen.provide(DocWrappedServiceImpl.class); + = + checkWrapperClasses(outputDir); + = + // There should be no source code + checkWrapperSource(outputDir, false); + = + File wsdlFile =3D new File(outputDir, "DocWrappedService.wsdl"); + WSDLDefinitionsFactory wsdlFactory =3D WSDLDefinitionsFactory.newIns= tance(); + wsdlFactory.parse(wsdlFile.toURL()); + } + = + public void testResourceDir() throws Exception + { + WSContractProvider gen =3D getGenerator(); + File outputDir =3D new File("tools/wsprovide/resourcedir/out"); + File wsdlDir =3D new File("tools/wsprovide/resourcedir/wsdl"); + gen.setOutputDirectory(outputDir); + gen.setResourceDirectory(wsdlDir); + gen.setGenerateWsdl(true); + gen.provide(DocWrappedServiceImpl.class); + = + checkWrapperClasses(outputDir); + = + // There should be no source code + checkWrapperSource(outputDir, false); + = + String wsdlName =3D "DocWrappedService.wsdl"; + File wsdlFile =3D new File(outputDir, wsdlName); + assertFalse(wsdlFile.exists()); + = + wsdlFile =3D new File(wsdlDir, wsdlName); + WSDLDefinitionsFactory wsdlFactory =3D WSDLDefinitionsFactory.newIns= tance(); + wsdlFactory.parse(wsdlFile.toURL()); + } +} \ No newline at end of file --===============6728422296633165185==--