Пример #1
0
  @Test
  public void testServerFactoryBean() throws Exception {
    ServerFactoryBean svrBean = new ServerFactoryBean();
    svrBean.setAddress("http://localhost/Hello");
    svrBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
    svrBean.setServiceBean(new HelloServiceImpl());
    svrBean.setServiceClass(HelloService.class);
    svrBean.setBus(getBus());

    svrBean.create();

    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress("http://localhost/Hello");
    clientBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(getBus());
    clientBean.getInInterceptors().add(new LoggingInInterceptor());

    HelloService client = (HelloService) proxyFactory.create();

    ClientImpl c = (ClientImpl) ClientProxy.getClient(client);
    c.getOutInterceptors().add(new LoggingOutInterceptor());
    c.getInInterceptors().add(new LoggingInInterceptor());

    assertEquals("hello", client.sayHello());
    assertEquals("hello", client.echo("hello"));
  }
  @Test
  public void testClient() throws Exception {
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setAddress("local://IInterfaceService");
    proxyFac.setServiceClass(IInterfaceService.class);
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());

    IInterfaceService client = (IInterfaceService) proxyFac.create();

    IChild child = client.getChild();
    assertNotNull(child);
    assertEquals("child", child.getChildName());
    assertEquals("parent", child.getParentName());

    IParent parent = client.getChildViaParent();
    assertEquals("parent", parent.getParentName());
    assertFalse(parent instanceof IChild);

    IGrandChild grandChild = client.getGrandChild();
    assertEquals("parent", grandChild.getParentName());

    Document wsdl = getWSDLDocument("IInterfaceService");
    assertValid("//xsd:complexType[@name='IGrandChild']", wsdl);
    assertValid(
        "//xsd:complexType[@name='IGrandChild']//xsd:element[@name='grandChildName']", wsdl);
    assertValid("//xsd:complexType[@name='IGrandChild']//xsd:element[@name='childName'][1]", wsdl);
    assertInvalid(
        "//xsd:complexType[@name='IGrandChild']//xsd:element[@name='childName'][2]", wsdl);
    assertValid("//xsd:complexType[@name='IChild']", wsdl);
    assertValid("//xsd:complexType[@name='IParent']", wsdl);
    assertInvalid("//xsd:complexType[@name='IChild'][@abstract='true']", wsdl);
  }
Пример #3
0
  @Test(expected = HelloException.class)
  @Ignore("Not working yet due to namespace things")
  public void testJaxwsServerSimpleClient() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    sfbean.setDataBinding(new AegisDatabinding());
    sfbean.setAddress("local://ExceptionServiceJaxWs1");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));

    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionServiceJaxWs1");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());

    ExceptionService clientInterface = proxyFac.create(ExceptionService.class);

    clientInterface.sayHiWithException();
  }
Пример #4
0
  @Test
  public void testInvokingServiceFromCXFClient() throws Exception {
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(simpleEndpointAddress);
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(BusFactory.getDefaultBus());

    HelloService client = (HelloService) proxyFactory.create();
    assertNotNull(client);

    String result = client.echo(TEST_MESSAGE);
    assertEquals(
        "We should get the echo string result from router", result, "echo " + TEST_MESSAGE);

    Boolean bool = client.echoBoolean(Boolean.TRUE);
    assertNotNull("The result should not be null", bool);
    assertEquals("We should get the echo boolean result from router ", bool.toString(), "true");

    int beforeCallingPing = pingCounter;
    client.ping();
    int afterCallingPing = pingCounter;
    assertTrue("The ping operation doesn't be called", afterCallingPing - beforeCallingPing == 1);
  }
Пример #5
0
  @Test
  public void testHeaders() throws Exception {
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionService");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());

    ExceptionService client = proxyFac.create(ExceptionService.class);

    try {
      client.sayHiWithException();
      fail("Must throw exception!");
    } catch (HelloException e) {
      // nothing
    }

    // check to make sure the fault is an element
    Document wsdl = getWSDLDocument("ExceptionService");
    addNamespace("tns", "http://exception.aegis.cxf.apache.org");
    assertValid(
        "//wsdl:message[@name='HelloException']/wsdl:part[@name='HelloException']"
            + "[@element='tns:String']",
        wsdl);
  }