Return-Path: Delivered-To: apmail-incubator-beehive-dev-archive@www.apache.org Received: (qmail 23381 invoked from network); 16 Jun 2005 13:58:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Jun 2005 13:58:17 -0000 Received: (qmail 77664 invoked by uid 500); 16 Jun 2005 13:58:16 -0000 Delivered-To: apmail-incubator-beehive-dev-archive@incubator.apache.org Received: (qmail 77610 invoked by uid 500); 16 Jun 2005 13:58:16 -0000 Mailing-List: contact beehive-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Beehive Developers" Delivered-To: mailing list beehive-dev@incubator.apache.org Received: (qmail 77578 invoked by uid 99); 16 Jun 2005 13:58:15 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of ekoneil@gmail.com designates 64.233.184.196 as permitted sender) Received: from wproxy.gmail.com (HELO wproxy.gmail.com) (64.233.184.196) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 16 Jun 2005 06:58:14 -0700 Received: by wproxy.gmail.com with SMTP id 37so411619wra for ; Thu, 16 Jun 2005 06:57:51 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=dS20kDPsPzc8CSgO2LpcDHh5E1Nh3ThmjMhtnaaoBCFwdhnj1rAhO1KFgJykadrS3pNKlVdSSkhkikEcePckZu7mZom1CBrXQ7kXGHiKRQv4mXWm807EzFjnk+OU1KpyUvx51WEMavA77MZRPzsQNX4+ACOmGITfiW7QtZ7CTRM= Received: by 10.54.49.26 with SMTP id w26mr472954wrw; Thu, 16 Jun 2005 06:51:11 -0700 (PDT) Received: by 10.54.48.10 with HTTP; Thu, 16 Jun 2005 06:51:10 -0700 (PDT) Message-ID: Date: Thu, 16 Jun 2005 07:51:10 -0600 From: Eddie ONeil Reply-To: Eddie ONeil To: Beehive Developers Subject: Re: possible WSM tests In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Jeremiah-- Yeah -- it'd be great to have request / response tests for WSM.=20 Both the framework and WSDL test cases seem like a great way to get started with this. Definitely the right thing to do. :) To ease the process of making a patch, a couple of comments: - tests should go in the "org.apache.beehive.wsm.tests" package. In the cases above, something like "org.apache.beehive.wsm.tests.axis" would be good. - for the sake of playing nicely with Ant, how about using a .properties file for defining the server / port information rather than a system property? - is the "do.start.appserver" property used anywhere? Would be great if it was, but if not we probably don't need it. If you want to open a JIRA issue and attach a patch, I can get started integrating this in. Thanks! Eddie On 6/16/05, Jeremiah Johnson wrote: > I have some tests that I wrote to check the WSDL produced after a JWS has= been compiled and deployed. I wrote these tests because I was interested = in checking some pieces of the WSDL based on the annotations in the JSR 181= spec. In some cases (i.e. namespace issues), they can serve as regression= tests, but in others (i.e. @Oneway) they don't have much value. A major p= roblem with these tests is that they currently require a Web container. >=20 > I can create a Jira issue and attach my full diff - just wanted to bring = up the type of test to see if you see value in it. Please take a look at t= he info below and let me know if you have questions or doubts. >=20 > Since the WSM tests don't currently have any tests (that I know of) that = require a Web container, I modified the build scripts in WSM a little. Her= e is an overview of what I did: >=20 > Added some main properties: > > > >=20 > Increased the work of build.webapp: > > > > destdir=3D"${webapp.dir}/WEB-INF/classes" > tempdir=3D"${webapp.dir}/WEB-INF/temp" > classpathref=3D"drt.classpath"/> > > > > > > > > >=20 > Added the in-container section to drt: > > > > > > tempdir=3D"${build.dir}" fork=3D"yes"> > > > > > > value=3D"${server.root.url}/${wsm.test.webapp.nam= e}"/> > > todir=3D"${drt.logs}"/> > > > > > > >=20 > Here is an example case that I think adds value: > /* > * Copyright 2005 The Apache Software Foundation. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > * You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie= d. > * See the License for the specific language governing permissions and > * limitations under the License. > */ > package org.apache.beehive.wsm.jsr181.wsdl; >=20 > import javax.wsdl.Definition; > import javax.wsdl.factory.WSDLFactory; > import javax.wsdl.xml.WSDLReader; > import javax.xml.namespace.QName; >=20 > import junit.framework.TestCase; >=20 > /** > * Unit tests around the WebService targetNamespace attribute. > *

> * This test currently requires a running instance of a Web container. T= he > * root URL of the server is determined by the value of BASE_URL. > *

> */ > public class WebServiceTargetNamespace extends TestCase { >=20 > /** > * The root URL of the server to hit for the Web service; defaults to > * http://localhsot:8080/wsmTest but can be overridden by setting the > * base.url system property. > */ > private static final String BASE_URL =3D > System.getProperty( "base.url", "http://localhost:8080/wsmTest" )= ; >=20 > /** > * Instance of the WSDL Reader used in the test methods; this is (re)= set > * in the set up method. > */ > private WSDLReader reader; >=20 > /** > * Prepare for testing by creating a new reader instance. > */ > public void setUp() { > try { > reader =3D WSDLFactory.newInstance().newWSDLReader(); > } catch( Exception e ) { > e.printStackTrace(); > fail( "failed to prepare WSDL reader for tests: " + e ); > } > } >=20 > /** > * When the targetNamespace attribute is used but empty, the > * targetNamespace in the WSDL should default to http://{package}; > * in this case it should be http://webservice. > */ > public void testEmpty() throws Exception { > Definition wsdl =3D reader.readWSDL( null, > BASE_URL + "/webservice/TargetNamespaceEmpty.jws?wsdl" ); > assertEquals( "http://webservice", wsdl.getTargetNamespace() ); > } >=20 > /** > * When the targetNamespace attribute is used but empty, the > * targetNamespace in the WSDL should default to the http://{package}= . > *

> * If there is no package, then it defaults to http://{classname}; in > * this case, it should be http://TargetNamespaceEmpty. > *

> */ > public void testEmptyNoPackage() throws Exception { > Definition wsdl =3D reader.readWSDL( null, > BASE_URL + "/WebServiceTargetNamespaceEmpty.jws?wsdl" ); > assertEquals( "http://WebServiceTargetNamespaceEmpty", > wsdl.getTargetNamespace() ); > } >=20 > /** > * When the targetNamespace attribute is not used, the targetNamespac= e in > * the WSDL should default to http://{package}; in this case it shoul= d be > * http://webservice. > */ > public void testNotUsed() throws Exception { > Definition wsdl =3D reader.readWSDL( null, > BASE_URL + "/webservice/TargetNamespaceNotUsed.jws?wsdl" ); > assertEquals( "http://webservice", wsdl.getTargetNamespace() ); > } >=20 > /** > * When the targetNamespace attribute is not used, the targetNamespac= e in > * the WSDL should default to the package name of the Web service. > *

> * If there is no package, then the targetNamespace defaults to > * http://{classname}; in this case it would be > * http://WebServiceTargetNamespaceNotUsed. > *

> */ > public void testNotUsedNoPackage() throws Exception { > Definition wsdl =3D reader.readWSDL( null, > BASE_URL + "/WebServiceTargetNamespaceNotUsed.jws?wsdl" ); > assertEquals( "http://WebServiceTargetNamespaceNotUsed", > wsdl.getTargetNamespace() ); > } >=20 > /** > * When the name attribute is used, the portType should be the name s= et > * in the attribute; in this case, the targetNamespace should be > * urn:jsr181-webservice. > */ > public void testUsed() throws Exception { > Definition wsdl =3D reader.readWSDL( null, > BASE_URL + "/webservice/TargetNamespaceUsed.jws?wsdl" ); > assertEquals( "urn:jsr181-webservice", wsdl.getTargetNamespace() = ); > } >=20 > } >=20 > Here is the example case that I don't think adds much value: > /* > * Copyright 2005 The Apache Software Foundation. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > * You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie= d. > * See the License for the specific language governing permissions and > * limitations under the License. > */ > package org.apache.beehive.wsm.jsr181.wsdl; >=20 > import java.util.List; > import java.util.Map; > import javax.wsdl.Definition; > import javax.wsdl.Operation; > import javax.wsdl.Port; > import javax.wsdl.PortType; > import javax.wsdl.Service; > import javax.wsdl.factory.WSDLFactory; > import javax.wsdl.xml.WSDLReader; > import javax.xml.namespace.QName; >=20 > import junit.framework.TestCase; >=20 > /** > * Unit tests around the Oneway annotation. > */ > public class Oneway extends TestCase { >=20 > /** > * The root URL of the server to hit for the Web service; defaults to > * http://localhsot:8080/wsmTest but can be overridden by setting the > * base.url system property. > */ > private static final String BASE_URL =3D > System.getProperty( "base.url", "http://localhost:8080/wsmTest" )= ; >=20 > /** > * Instance of the WSDL Reader used in the test methods; this is (re)= set > * in the set up method. > */ > private WSDLReader reader; >=20 > /** > * Prepare for testing by creating a new reader instance. > */ > public void setUp() { > try { > reader =3D WSDLFactory.newInstance().newWSDLReader(); > } catch( Exception e ) { > e.printStackTrace(); > fail( "failed to prepare WSDL reader for tests: " + e ); > } > } >=20 > /** > * When the Oneway annotation is not used, the operation will have an > * output element even if the return on the actual method signature i= s > * void. > */ > public void testNotUsed() throws Exception { > Definition wsdl =3D > reader.readWSDL( null, BASE_URL + "OnewayNotUsed.jws?wsdl" ); > assertOperationOutput( wsdl, true ); > } >=20 > /** > * When the Oneway annotation is used, the operation will not have an > * output element. > */ > public void testUsed() throws Exception { > Definition wsdl =3D > reader.readWSDL( null, BASE_URL + "OnewayUsed.jws?wsdl" ); > assertOperationOutput( wsdl, false ); > } >=20 > /** > * Assuming one service, port, and operation for the given WSDL, this > * verifies that the operation does or doesn't have an output element= . > */ > private static void assertOperationOutput( Definition wsdl, > boolean output ) { > Map services =3D wsdl.getServices(); > assertNotNull( "services", services ); > assertEquals( 1, services.size() ); > Service service =3D (Service) services.values().toArray()[0]; >=20 > Map ports =3D service.getPorts(); > assertNotNull( "ports", ports ); > assertEquals( 1, ports.size() ); > PortType portType =3D > ((Port) ports.values().toArray()[0]).getBinding().getPortType= (); >=20 > List operations =3D portType.getOperations(); > assertNotNull( "operations", operations ); > assertEquals( 1, operations.size() ); >=20 > assertNotNull( "input", operations.get(0).getInput() ); > if( output ) { > assertNotNull( "output expected", operations.get(0).getOutput= () ); > } else { > assertNull( "output not expected", operations.get(0).getOutpu= t() ); > } > } >=20 > } >=20 > Here is the full diff of the wsm build.xml, in case you are interested: > Index: wsm/drt/build.xml > =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 > --- wsm/drt/build.xml (revision 190820) > +++ wsm/drt/build.xml (working copy) > @@ -5,6 +5,10 @@ > > >=20 > + > + > + bapp.name}"/> > + > > > > @@ -43,6 +47,12 @@ > > >=20 > + > + > + > + > + > + > > > > @@ -111,11 +121,24 @@ > > > > + + destdir=3D"${webapp.dir}/WEB-INF/classes" > + tempdir=3D"${webapp.dir}/WEB-INF/temp" > + classpathref=3D"drt.classpath"/> > + > + > + > + > + > + > + > >=20 > > > > + > + > >=20 > > @@ -148,7 +171,8 @@ >=20 > > > - d.dir}" fork=3D"yes"> > + + tempdir=3D"${build.dir}" fork=3D"yes"> > > > > @@ -162,7 +186,110 @@ > > > > - d."/> > + > + > + > + > + > + > + + tempdir=3D"${build.dir}" fork=3D"yes"> > + > + > + > + > + > + + value=3D"${server.root.url}/${wsm.test.webapp.na= me}"/> > + > + + todir=3D"${drt.logs}"/> > + > + > + > + > + > + > + > + >=20 > >=20 > + > + > + > + > + > + > + .name}"/> > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + abled for org.apache.beehive.netui"> > + ."/> > + > + > + rts enabled for org.apache.beehive.wsm"> > + > > + > + > + > + > + > + > + > + Ensuring that the webapp ${wsm.test.webapp.name} is deploy= ed on a > running server at the url ${webapp.waitfor.url} > + > + > > + > + > + > + > + webapp.waitfor.url}"/> > + > + > + > + Webapp is not deployed; deploying > + > + > + ...deploy complete > + > + ailable"> > + > + > + > + > + > + Webapp is deployed; undeploy and redeploy > + > + > + ...undeploy complete > + > + > + ...deploy complete > + > + ailable"> > + > + > + > + > >=20 > I wanted this email to be a little longer, but that is all I have to say = :) >=20 > - jeremiah >=20 >