Search in sources :

Example 1 with CalculatorPortType

use of org.apache.cxf.calculator.CalculatorPortType in project cxf by apache.

the class SOAPBindingTest method testRoles.

@Test
public void testRoles() throws Exception {
    URL wsdl1 = getClass().getResource("/wsdl/calculator.wsdl");
    assertNotNull(wsdl1);
    ServiceImpl service = new ServiceImpl(getBus(), wsdl1, SERVICE_1, ServiceImpl.class);
    CalculatorPortType cal = service.getPort(PORT_1, CalculatorPortType.class);
    BindingProvider bindingProvider = (BindingProvider) cal;
    assertTrue(bindingProvider.getBinding() instanceof SOAPBinding);
    SOAPBinding binding = (SOAPBinding) bindingProvider.getBinding();
    assertNotNull(binding.getRoles());
    assertEquals(2, binding.getRoles().size());
    assertTrue(binding.getRoles().contains(Soap12.getInstance().getNextRole()));
    assertTrue(binding.getRoles().contains(Soap12.getInstance().getUltimateReceiverRole()));
    String myrole = "http://myrole";
    Set<String> roles = new HashSet<>();
    roles.add(myrole);
    binding.setRoles(roles);
    assertNotNull(binding.getRoles());
    assertEquals(3, binding.getRoles().size());
    assertTrue(binding.getRoles().contains(myrole));
    assertTrue(binding.getRoles().contains(Soap12.getInstance().getNextRole()));
    assertTrue(binding.getRoles().contains(Soap12.getInstance().getUltimateReceiverRole()));
    roles.add(Soap12.getInstance().getNoneRole());
    try {
        binding.setRoles(roles);
        fail("did not throw exception");
    } catch (WebServiceException e) {
    // that's expected with none role
    }
}
Also used : CalculatorPortType(org.apache.cxf.calculator.CalculatorPortType) WebServiceException(javax.xml.ws.WebServiceException) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with CalculatorPortType

use of org.apache.cxf.calculator.CalculatorPortType in project cxf by apache.

the class SOAPBindingTest method testSAAJ.

@Test
public void testSAAJ() throws Exception {
    URL wsdl1 = getClass().getResource("/wsdl/calculator.wsdl");
    assertNotNull(wsdl1);
    ServiceImpl service = new ServiceImpl(getBus(), wsdl1, SERVICE_1, ServiceImpl.class);
    CalculatorPortType cal = service.getPort(PORT_1, CalculatorPortType.class);
    BindingProvider bindingProvider = (BindingProvider) cal;
    assertTrue(bindingProvider.getBinding() instanceof SOAPBinding);
    SOAPBinding binding = (SOAPBinding) bindingProvider.getBinding();
    assertNotNull(binding.getMessageFactory());
    assertNotNull(binding.getSOAPFactory());
}
Also used : CalculatorPortType(org.apache.cxf.calculator.CalculatorPortType) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Test(org.junit.Test)

Example 3 with CalculatorPortType

use of org.apache.cxf.calculator.CalculatorPortType in project cxf by apache.

the class ServiceImplTest method testJAXBCachedOnRepeatGetPort.

@Test
public void testJAXBCachedOnRepeatGetPort() {
    System.gc();
    System.gc();
    URL wsdl1 = getClass().getResource("/wsdl/calculator.wsdl");
    assertNotNull(wsdl1);
    ServiceImpl service = new ServiceImpl(getBus(), wsdl1, SERVICE_1, ServiceImpl.class);
    CalculatorPortType cal1 = service.getPort(PORT_1, CalculatorPortType.class);
    assertNotNull(cal1);
    ClientProxy cp = (ClientProxy) Proxy.getInvocationHandler(cal1);
    JAXBDataBinding db1 = (JAXBDataBinding) cp.getClient().getEndpoint().getService().getDataBinding();
    assertNotNull(db1);
    System.gc();
    System.gc();
    System.gc();
    System.gc();
    CalculatorPortType cal2 = service.getPort(PORT_1, CalculatorPortType.class);
    assertNotNull(cal2);
    cp = (ClientProxy) Proxy.getInvocationHandler(cal2);
    JAXBDataBinding db2 = (JAXBDataBinding) cp.getClient().getEndpoint().getService().getDataBinding();
    assertNotNull(db2);
    assertEquals("got cached JAXBContext", db1.getContext(), db2.getContext());
}
Also used : CalculatorPortType(org.apache.cxf.calculator.CalculatorPortType) ClientProxy(org.apache.cxf.frontend.ClientProxy) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) URL(java.net.URL) Test(org.junit.Test)

Example 4 with CalculatorPortType

use of org.apache.cxf.calculator.CalculatorPortType in project cxf by apache.

the class ServiceImplTest method testHandlerResolver.

@Test
public void testHandlerResolver() {
    URL wsdl1 = getClass().getResource("/wsdl/calculator.wsdl");
    assertNotNull(wsdl1);
    ServiceImpl service = new ServiceImpl(getBus(), wsdl1, SERVICE_1, ServiceImpl.class);
    TestHandlerResolver resolver = new TestHandlerResolver();
    assertNull(resolver.getPortInfo());
    service.setHandlerResolver(resolver);
    CalculatorPortType cal = service.getPort(PORT_1, CalculatorPortType.class);
    assertNotNull(cal);
    PortInfo info = resolver.getPortInfo();
    assertNotNull(info);
    assertEquals(SERVICE_1, info.getServiceName());
    assertEquals(PORT_1, info.getPortName());
    assertEquals(SOAPBinding.SOAP12HTTP_BINDING, info.getBindingID());
}
Also used : PortInfo(javax.xml.ws.handler.PortInfo) CalculatorPortType(org.apache.cxf.calculator.CalculatorPortType) URL(java.net.URL) Test(org.junit.Test)

Example 5 with CalculatorPortType

use of org.apache.cxf.calculator.CalculatorPortType in project cxf by apache.

the class ServiceImplTest method testGetGoodPort.

@Test
public void testGetGoodPort() {
    URL wsdl1 = getClass().getResource("/wsdl/calculator.wsdl");
    assertNotNull(wsdl1);
    ServiceImpl service = new ServiceImpl(getBus(), wsdl1, SERVICE_1, ServiceImpl.class);
    CalculatorPortType cal = service.getPort(PORT_1, CalculatorPortType.class);
    assertNotNull(cal);
}
Also used : CalculatorPortType(org.apache.cxf.calculator.CalculatorPortType) URL(java.net.URL) Test(org.junit.Test)

Aggregations

URL (java.net.URL)5 CalculatorPortType (org.apache.cxf.calculator.CalculatorPortType)5 Test (org.junit.Test)5 BindingProvider (javax.xml.ws.BindingProvider)2 SOAPBinding (javax.xml.ws.soap.SOAPBinding)2 HashSet (java.util.HashSet)1 WebServiceException (javax.xml.ws.WebServiceException)1 PortInfo (javax.xml.ws.handler.PortInfo)1 ClientProxy (org.apache.cxf.frontend.ClientProxy)1 JAXBDataBinding (org.apache.cxf.jaxb.JAXBDataBinding)1