FileDocCategorySizeDatePackage
TestBasicProvider.javaAPI DocApache Axis 1.44693Sat Apr 22 18:57:28 BST 2006test.providers

TestBasicProvider

public class TestBasicProvider extends TestCase
Test if BasicProvider can generate WSDL out of metainformation provided in the WSDD descriptor.
author
Thomas Bayer (bayer@oio.de)

Fields Summary
static final QName
PROVIDERQNAME
static final String
TNS
static final String
SERVICE_NAME
static final String
PORTTYPE
static final QName
PORTTYPEQNAME
private static org.apache.axis.server.AxisServer
server
static final String
wsdd
Constructors Summary
public TestBasicProvider()


      
        super("test");
    
public TestBasicProvider(String s)

        super(s);
    
Methods Summary
public static voidmain(java.lang.String[] args)

        TestBasicProvider tester = new TestBasicProvider();
        tester.setUp();
        tester.testGenerateWSDL();
    
protected voidsetUp()


        server = new AxisServer(new XMLStringProvider(wsdd));

        LocalTransport transport;

        transport = new LocalTransport(server);
        transport.setRemoteService(SERVICE_NAME);
        
        WSDDProvider.registerProvider( PROVIDERQNAME, new WSDDDummyProvider());
    
public voidtestGenerateWSDL()

        
        SOAPService soapService = server.getService(SERVICE_NAME);    

        BasicProvider provider = (BasicProvider) soapService.getPivotHandler();

        MessageContext mc = new MessageContext(server);
        mc.setService(soapService);
        mc.setProperty(MessageContext.TRANS_URL, "local");

        provider.generateWSDL(mc);

        Document wsdl = (Document) mc.getProperty("WSDL");
        assertNotNull( "cannot create WSDL", wsdl);
        
        Definition def = WSDLFactory.newInstance().newWSDLReader().readWSDL( null, wsdl);
        
        PortType portType = def.getPortType( PORTTYPEQNAME);    
        assertNotNull( "cannot find porttype " + PORTTYPEQNAME, portType);
        
        Operation operation = portType.getOperation( "method1", null, null);        
        assertNotNull( "cannot find operation ", operation);
        
        Input input = operation.getInput();
        
        javax.wsdl.Message message = def.getMessage( new QName( TNS, input.getName()));        
        assertNotNull( "cannot find message " + input.getName(), message);
        
        Part part = message.getPart("param1");        
        assertEquals( "wrong type for part", part.getTypeName().getLocalPart(), "string");