CVS: ivory/src/test/org/codehaus/ivory/axis DefaultAxisServiceTest.java,1.3,1.4 DefaultAxisServiceTest.xml,1.2,1.3 plexus.xml,1.1,NONE server-config.wsdd,1.1,NONE web.xml,1.2,NONE
[email protected] Sun, 4 May 2003 15:25:58 -0500
| Newsgroups | gmane.comp.java.plexus.devel |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/plexus/ivory/src/test/org/codehaus/ivory/axis In directory eng.werken.com:/tmp/cvs-serv24814/src/test/org/codehaus/ivory/axis Modified Files: DefaultAxisServiceTest.java DefaultAxisServiceTest.xml Removed Files: plexus.xml server-config.wsdd web.xml Log Message: - Documentation corrections - move the servlets to the plexus package. - IvoryTestCase which should make testing services a little easier. See the unit tests if you're interested. More testing utilities coming soon! - You do not need to call AxisServer.start() as it turns out, the AxisServer constructor already does that. - AxisService will not expose methods that return a List or take it as a parameter. Axis does not know how to hanlde this yet. Index: DefaultAxisServiceTest.java =================================================================== RCS file: /cvsroot/plexus/ivory/src/test/org/codehaus/ivory/axis/DefaultAxisServiceTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- DefaultAxisServiceTest.java 2 May 2003 15:17:20 -0000 1.3 +++ DefaultAxisServiceTest.java 4 May 2003 20:25:56 -0000 1.4 @@ -1,21 +1,8 @@ package org.codehaus.ivory.axis; -import java.io.PrintWriter; - -import javax.servlet.ServletContext; - -import org.apache.axis.MessageContext; -import org.apache.axis.server.AxisServer; -import org.apache.axis.soap.SOAPConstants; -import org.apache.axis.transport.local.LocalTransport; -import org.apache.axis.utils.XMLUtils; -import org.apache.plexus.PlexusTestCase; -import org.apache.plexus.servlet.PlexusServlet; -import org.w3c.dom.Document; +import org.codehaus.ivory.axis.plexus.IvoryTestCase; import com.meterware.httpunit.WebResponse; -import com.meterware.servletunit.InvocationContext; -import com.meterware.servletunit.ServletRunner; import com.meterware.servletunit.ServletUnitClient; /** @@ -24,134 +11,55 @@ * @author <a href="mailto:[email protected]">Dan Diephouse</a> * @since Mar 9, 2003 */ -public class DefaultAxisServiceTest extends PlexusTestCase +public class DefaultAxisServiceTest + extends IvoryTestCase { - - public DefaultAxisServiceTest(String name) { super(name); } - public void setUp() throws Exception - { - super.setUp(); - - - } - public void testAxisService() throws Exception { AxisService service = ( AxisService ) getComponent( AxisService.ROLE ); + + assertNotNull( service.getAxisServer() ); } - /** - * Start up the axis servlet and make sure it is working. - * - * @throws Exception - */ - public void testAxisServlet() throws Exception { - ServletUnitClient client = newClient(); - - client.getResponse( "http://localhost/servlet/AxisServlet" ); - - System.out.println( "Testing Version:" ); - WebResponse response = - client.getResponse( "http://localhost/services/Version" ); - System.out.println( response.getText() ); - - System.out.println( "Testing Version getVersion:" ); - response = client.getResponse( - "http://localhost/services/Version?method=getVersion" ); - System.out.println( response.getText() ); - } - /* - public void testExposeClass() throws Exception + public void testWSDLGeneration() throws Exception + { + assertValidWSDL( "Version", "getVersion" ); + assertValidWSDL( "SparePartInfo", "getPartInfo" ); + } + + public void testVersionMethod() throws Exception { - ServletUnitClient client = newClient(); + WebResponse response = newClient().getResponse("http://localhost/services/Version?method=getVersion"); - AxisService service = ( AxisService ) getComponent( AxisService.ROLE ); - service.exposeClass( "SparePartInfoClass", - DefaultSparePartInfo.class.getName() ); + String body = response.getText(); + assertIsXml( body ); + assertTrue( body.indexOf( "<getVersionReturn") > 0 ); + } - System.out.println( "Testing AxisServlet listing:" ); - WebResponse response = client.getResponse( - "http://localhost/servlet/AxisServlet?list" ); - System.out.println( response.getText() ); - - System.out.println( "Testing soap client:" ); - response = client.getResponse( - "http://localhost/services/SparePartInfoClass?method=getPartInfo&PartSKU=test" ); - System.out.println( response.getText() ); - } - */ public void testExposeService() throws Exception { ServletUnitClient client = newClient(); - - System.out.println( "Testing AxisServlet listing:" ); - WebResponse response = client.getResponse( - "http://localhost/servlet/AxisServlet?list" ); - System.out.println( response.getText() ); - - System.out.println( "Testing soap client:" ); - response = client.getResponse( - "http://localhost/services/SparePartInfo?method=getPartInfo&PartSKU=test" ); - System.out.println( response.getText() ); - } - - public void testWSDLGeneration() throws Exception - { - AxisService service = ( AxisService ) getComponent( AxisService.ROLE ); - AxisServer server = service.getAxisServer(); - String SERVICE_NAME = "SparePartInfo"; - LocalTransport transport = new LocalTransport(server); - - MessageContext msgContext = new MessageContext(server); - msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS); - msgContext.setEncodingStyle(SOAPConstants.SOAP12_CONSTANTS.getEncodingURI()); + WebResponse response = client.getResponse("http://localhost/services/SparePartInfo?method=getPartInfo&PartSKU=test"); - msgContext.setTargetService( SERVICE_NAME ); - - // During a real invocation this is set by the handler, however we - // need to set it hear to get the wsdl generation working. - msgContext.setProperty( MessageContext.TRANS_URL, - "http://localhost/services/SparePartInfo" ); - server.generateWSDL( msgContext ); - - // another one of those undocumented "features" - Document doc = (Document) msgContext.getProperty( "WSDL" ); - - PrintWriter writer = new PrintWriter( System.out ); - XMLUtils.DocumentToWriter(doc, writer); + assertIsXml( response.getText() ); + assertStringInBody( response, "<getPartInfoReturn" ); + assertStringInBody( response, "test - Part Info" ); } public void testComplexSerialization() throws Exception { ServletUnitClient client = newClient(); - - System.out.println( "Testing complex serialization:" ); - WebResponse response = client.getResponse( - "http://localhost/services/SparePartInfo?method=getSparePart" ); - System.out.println( response.getText() ); - } - - protected ServletUnitClient newClient() throws Exception - { - ServletRunner sr = new ServletRunner( - "src/test/org/codehaus/ivory/axis/web.xml" ); - - ServletUnitClient client = sr.newClient(); - InvocationContext ic = client.newInvocation( "http://localhost/servlet/AxisServlet" ); - ServletContext context = - ic.getServlet().getServletConfig().getServletContext(); - context.setAttribute( PlexusServlet.SERVICE_MANAGER_KEY , - this.getContainer().getComponentRepository() ); - - return client; + WebResponse response = client.getResponse("http://localhost/services/SparePartInfo?method=getSparePart"); + + assertIsXml( response.getText() ); + assertStringInBody( response, "<SKU" ); } - } Index: DefaultAxisServiceTest.xml =================================================================== RCS file: /cvsroot/plexus/ivory/src/test/org/codehaus/ivory/axis/DefaultAxisServiceTest.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- DefaultAxisServiceTest.xml 29 Mar 2003 22:12:55 -0000 1.2 +++ DefaultAxisServiceTest.xml 4 May 2003 20:25:56 -0000 1.3 @@ -4,8 +4,7 @@ <component> <role>org.codehaus.ivory.axis.AxisService</role> <implementation>org.codehaus.ivory.axis.DefaultAxisService</implementation> - <configuration - server-config="src/test/org/codehaus/ivory/axis/server-config.wsdd"> + <configuration> <services> <avalonService role="org.codehaus.ivory.axis.SparePartInfo" name="SparePartInfo"/> --- plexus.xml DELETED --- --- server-config.wsdd DELETED --- --- web.xml DELETED ---