FileDocCategorySizeDatePackage
PipelineAssemblerFactoryImplTest.javaAPI DocExample8620Fri Jun 15 07:04:58 BST 2007com.sun.xml.ws.assembler

PipelineAssemblerFactoryImplTest

public class PipelineAssemblerFactoryImplTest extends TestCase
author
Fabian Ritzmann

Fields Summary
private static final String
NAMESPACE
private static final URI
ADDRESS_URL
Constructors Summary
public PipelineAssemblerFactoryImplTest(String testName)

     
        try {
            ADDRESS_URL = new URI("http://localhost:8080/dispatch/Service1Service");
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Failed to initialize address URI", e);
        }
    
        super(testName);
    
Methods Summary
private com.sun.xml.ws.api.model.wsdl.WSDLModelparseConfigFile(java.lang.String configFile)

        URL url = PolicyUtils.ConfigFile.loadFromClasspath("assembler/" + configFile);
        return PolicyConfigParser.parseModel(url, true);
    
public voidtestCreateClientNull()

        try {
            final BindingID bindingId = BindingID.SOAP11_HTTP;
            final PipelineAssemblerFactoryImpl factory = new PipelineAssemblerFactoryImpl();
            final PipelineAssembler assembler = factory.doCreate(bindingId);
            final Pipe pipe = assembler.createClient(null);
            fail("Expected NullPointerException");
        } catch (NullPointerException e) {
        }
    
public voidtestCreateDispatchClientAllFeaturesConfig()
Test client creation with parameters that correspond to a dispatch client with wsit-client.xml.

        Pipe pipe = testDispatch("allfeatures.xml");
        assertNotNull(pipe);
    
public voidtestCreateDispatchClientNoConfig()
Test client creation with parameters that correspond to a dispatch client with no wsit-client.xml.

        final BindingID bindingId = BindingID.SOAP11_HTTP;
        final WSBinding binding = bindingId.createBinding();
        final EndpointAddress address = new EndpointAddress(ADDRESS_URL);
        final WSDLPort port = null;
        final WSService service = null;
        final Container container = Container.NONE;
        final ClientPipeAssemblerContext context = new ClientPipeAssemblerContext(
                address, port, service, binding, container);
        final PipelineAssemblerFactoryImpl factory = new PipelineAssemblerFactoryImpl();
        final PipelineAssembler assembler = factory.doCreate(bindingId);
        final Pipe pipe = assembler.createClient(context);
        assertNotNull(pipe);
    
public voidtestCreateDispatchClientNoPoliciesConfig()
Test client creation with parameters that correspond to a dispatch client with wsit-client.xml.

        Pipe pipe = testDispatch("nopolicies.xml");
        assertNotNull(pipe);
    
public voidtestCreateDispatchClientNoServiceMatchConfig()
Test client creation with parameters that correspond to a dispatch client with wsit-client.xml.

        Pipe pipe = testDispatch("noservicematch.xml");
        assertNotNull(pipe);
    
public voidtestCreateServerNull()

        try {
            final BindingID bindingId = BindingID.SOAP11_HTTP;
            final PipelineAssemblerFactoryImpl factory = new PipelineAssemblerFactoryImpl();
            final PipelineAssembler assembler = factory.doCreate(bindingId);
            final Pipe pipe = assembler.createServer(null);
            fail("Expected NullPointerException");
        } catch (NullPointerException e) {
        }
    
private com.sun.xml.ws.api.pipe.PipetestDispatch(java.lang.String configFileName)
Execute a sequence that corresponds to:
Service.createService(null, serviceName);
Service.addPort(portName, bindingId, address);

        final URL wsdlLocation = null;
        final QName serviceName = new QName(NAMESPACE, "Service1Service");
        // Corresponds to Service.createService(wsdlLocation, serviceName)
        final WSServiceDelegate serviceDelegate = new WSServiceDelegate(wsdlLocation, serviceName, Service.class);
        
        final QName portName = new QName(NAMESPACE, "Service1Port");
        final BindingID bindingId = BindingID.SOAP11_HTTP;
        // Corresponds to Service.addPort(portName, bindingId, address)
        serviceDelegate.addPort(portName, bindingId.toString(), ADDRESS_URL.toString());

        final EndpointAddress address = new EndpointAddress(ADDRESS_URL);
        final WSDLPort port = null;
        final WSDLModel clientModel = parseConfigFile(configFileName);
        final WSDLPolicyMapWrapper mapWrapper = clientModel.getExtension(WSDLPolicyMapWrapper.class);
        final PolicyMap map = mapWrapper.getPolicyMap();
        final WSPortInfo portInfo  = serviceDelegate.safeGetPort(portName);
        final PolicyFeature feature = new PolicyFeature(map, clientModel, portInfo);
        final WSBinding binding = bindingId.createBinding(feature);
        final Container container = Container.NONE;
        final ClientPipeAssemblerContext context = new ClientPipeAssemblerContext(
                address, port, serviceDelegate, binding, container);

        final PipelineAssemblerFactoryImpl factory = new PipelineAssemblerFactoryImpl();
        final PipelineAssembler assembler = factory.doCreate(bindingId);
        return assembler.createClient(context);