Search in sources :

Example 1 with Number

use of org.apache.cxf.factory_pattern.Number in project cxf by apache.

the class ManualHttpMulitplexClientServerTest method testWithManualMultiplexEprCreation.

@Test
public void testWithManualMultiplexEprCreation() throws Exception {
    NumberFactoryService service = new NumberFactoryService();
    NumberFactory nfact = service.getNumberFactoryPort();
    updateAddressPort(nfact, PORT);
    W3CEndpointReference w3cEpr = nfact.create("2");
    assertNotNull("reference", w3cEpr);
    // use the epr info only
    // no wsdl so default generated soap/http binding will be used
    // address url must come from the calling context
    EndpointReferenceType epr = ProviderImpl.convertToInternal(w3cEpr);
    QName serviceName = EndpointReferenceUtils.getServiceName(epr, bus);
    Service numService = Service.create(serviceName);
    String portString = EndpointReferenceUtils.getPortName(epr);
    QName portName = new QName(serviceName.getNamespaceURI(), portString);
    numService.addPort(portName, SoapBindingFactory.SOAP_11_BINDING, "http://foo");
    Number num = numService.getPort(portName, Number.class);
    setupContextWithEprAddress(epr, num);
    IsEvenResponse numResp = num.isEven();
    assertTrue("2 is even", Boolean.TRUE.equals(numResp.isEven()));
    // try again with the address from another epr
    w3cEpr = nfact.create("3");
    epr = ProviderImpl.convertToInternal(w3cEpr);
    setupContextWithEprAddress(epr, num);
    numResp = num.isEven();
    assertTrue("3 is not even", Boolean.FALSE.equals(numResp.isEven()));
    // try again with the address from another epr
    w3cEpr = nfact.create("6");
    epr = ProviderImpl.convertToInternal(w3cEpr);
    setupContextWithEprAddress(epr, num);
    numResp = num.isEven();
    assertTrue("6 is even", Boolean.TRUE.equals(numResp.isEven()));
}
Also used : NumberFactory(org.apache.cxf.factory_pattern.NumberFactory) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Number(org.apache.cxf.factory_pattern.Number) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) NumberService(org.apache.cxf.factory_pattern.NumberService) NumberFactoryService(org.apache.cxf.factory_pattern.NumberFactoryService) NumberFactoryService(org.apache.cxf.factory_pattern.NumberFactoryService) IsEvenResponse(org.apache.cxf.factory_pattern.IsEvenResponse) Test(org.junit.Test)

Example 2 with Number

use of org.apache.cxf.factory_pattern.Number in project cxf by apache.

the class MultiplexClientServerTest method testWithGetPortExtensionOverJMS.

@Test
public void testWithGetPortExtensionOverJMS() throws Exception {
    NumberFactoryService service = new NumberFactoryService();
    NumberFactory factory = service.getNumberFactoryPort();
    updateAddressPort(factory, PORT);
    // use values >= 30 to create JMS eprs - see NumberFactoryImpl.create
    // verify it is JMS, 999 for JMS will throw a fault
    W3CEndpointReference ref = factory.create("999");
    String s = NumberService.WSDL_LOCATION.toString();
    EmbeddedJMSBrokerLauncher.updateWsdlExtensors(BusFactory.getDefaultBus(), s);
    NumberService numService = new NumberService();
    assertNotNull("reference", ref);
    ServiceImpl serviceImpl = ServiceDelegateAccessor.get(numService);
    Number num = serviceImpl.getPort(ref, Number.class);
    try {
        num.isEven().isEven();
        fail("there should be a fault on val 999");
    } catch (Exception expected) {
        assertTrue("match on exception message " + expected.getMessage(), expected.getMessage().indexOf("999") != -1);
    }
    ClientProxy.getClient(num).getConduit().close();
    ref = factory.create("37");
    assertNotNull("reference", ref);
    num = serviceImpl.getPort(ref, Number.class);
    assertTrue("37 is not even", !num.isEven().isEven());
    ClientProxy.getClient(num).getConduit().close();
    ClientProxy.getClient(factory).getConduit().close();
}
Also used : NumberService(org.apache.cxf.factory_pattern.NumberService) NumberFactory(org.apache.cxf.factory_pattern.NumberFactory) Number(org.apache.cxf.factory_pattern.Number) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) NumberFactoryService(org.apache.cxf.factory_pattern.NumberFactoryService) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with Number

use of org.apache.cxf.factory_pattern.Number in project cxf by apache.

the class MultiplexHttpAddressClientServerTest method testWithManualMultiplexEprCreation.

@Test
public void testWithManualMultiplexEprCreation() throws Exception {
    Service numService = Service.create(NumberFactoryImpl.NUMBER_SERVICE_QNAME);
    Number num = numService.getPort(Number.class);
    InvocationHandler handler = Proxy.getInvocationHandler(num);
    BindingProvider bp = (BindingProvider) handler;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, NUMBER_SERVANT_ADDRESS_ROOT + "103");
    IsEvenResponse numResp = num.isEven();
    assertTrue("103 is not even", Boolean.FALSE.equals(numResp.isEven()));
}
Also used : Number(org.apache.cxf.factory_pattern.Number) Service(javax.xml.ws.Service) NumberService(org.apache.cxf.factory_pattern.NumberService) NumberFactoryService(org.apache.cxf.factory_pattern.NumberFactoryService) BindingProvider(javax.xml.ws.BindingProvider) IsEvenResponse(org.apache.cxf.factory_pattern.IsEvenResponse) InvocationHandler(java.lang.reflect.InvocationHandler) Test(org.junit.Test)

Example 4 with Number

use of org.apache.cxf.factory_pattern.Number in project cxf by apache.

the class ManualHttpMulitplexClientServerTest method testWithGetPortExtensionHttp.

@Test
public void testWithGetPortExtensionHttp() throws Exception {
    NumberFactoryService service = new NumberFactoryService();
    NumberFactory factory = service.getNumberFactoryPort();
    updateAddressPort(factory, PORT);
    W3CEndpointReference w3cEpr = factory.create("20");
    EndpointReferenceType numberTwoRef = ProviderImpl.convertToInternal(w3cEpr);
    assertNotNull("reference", numberTwoRef);
    // use getPort with epr api on service
    NumberService numService = new NumberService();
    ServiceImpl serviceImpl = ServiceDelegateAccessor.get(numService);
    Number num = serviceImpl.getPort(numberTwoRef, Number.class);
    assertTrue("20 is even", num.isEven().isEven());
    w3cEpr = factory.create("23");
    EndpointReferenceType numberTwentyThreeRef = ProviderImpl.convertToInternal(w3cEpr);
    num = serviceImpl.getPort(numberTwentyThreeRef, Number.class);
    assertTrue("23 is not even", !num.isEven().isEven());
}
Also used : NumberService(org.apache.cxf.factory_pattern.NumberService) NumberFactory(org.apache.cxf.factory_pattern.NumberFactory) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Number(org.apache.cxf.factory_pattern.Number) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) NumberFactoryService(org.apache.cxf.factory_pattern.NumberFactoryService) Test(org.junit.Test)

Example 5 with Number

use of org.apache.cxf.factory_pattern.Number in project cxf by apache.

the class MultiplexClientServerTest method testWithGetPortExtensionHttp.

@Test
public void testWithGetPortExtensionHttp() throws Exception {
    NumberFactoryService service = new NumberFactoryService();
    NumberFactory factory = service.getNumberFactoryPort();
    updateAddressPort(factory, PORT);
    NumberService numService = new NumberService();
    ServiceImpl serviceImpl = ServiceDelegateAccessor.get(numService);
    W3CEndpointReference numberTwoRef = factory.create("20");
    assertNotNull("reference", numberTwoRef);
    Number num = serviceImpl.getPort(numberTwoRef, Number.class);
    assertTrue("20 is even", num.isEven().isEven());
    close(num);
    W3CEndpointReference numberTwentyThreeRef = factory.create("23");
    num = serviceImpl.getPort(numberTwentyThreeRef, Number.class);
    assertTrue("23 is not even", !num.isEven().isEven());
    close(num);
    close(factory);
}
Also used : NumberService(org.apache.cxf.factory_pattern.NumberService) NumberFactory(org.apache.cxf.factory_pattern.NumberFactory) Number(org.apache.cxf.factory_pattern.Number) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) NumberFactoryService(org.apache.cxf.factory_pattern.NumberFactoryService) Test(org.junit.Test)

Aggregations

Number (org.apache.cxf.factory_pattern.Number)6 NumberFactoryService (org.apache.cxf.factory_pattern.NumberFactoryService)6 NumberService (org.apache.cxf.factory_pattern.NumberService)6 Test (org.junit.Test)6 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)5 NumberFactory (org.apache.cxf.factory_pattern.NumberFactory)5 ServiceImpl (org.apache.cxf.jaxws.ServiceImpl)4 Service (javax.xml.ws.Service)2 IsEvenResponse (org.apache.cxf.factory_pattern.IsEvenResponse)2 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)2 IOException (java.io.IOException)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 QName (javax.xml.namespace.QName)1 BindingProvider (javax.xml.ws.BindingProvider)1