Example usage for javax.xml.ws Endpoint publish

List of usage examples for javax.xml.ws Endpoint publish

Introduction

In this page you can find the example usage for javax.xml.ws Endpoint publish.

Prototype

public void publish(HttpContext serverContext) 

Source Link

Document

Publishes this endpoint at the provided server context.

Usage

From source file:test.unit.be.fedict.trust.xkms2.XKMSPortImplTest.java

@Test
public void test() throws Exception {
    int port = getFreePort();
    String address = "http://localhost:" + port + "/xkms2";
    HttpServer server = HttpServer.create(new InetSocketAddress("localhost", port), 5);
    ExecutorService threads = Executors.newFixedThreadPool(5);
    server.setExecutor(threads);/* w ww  .  j a v a 2 s .  co  m*/
    server.start();

    XKMSPortType xkmsPort = new XKMSPortImpl();
    Endpoint endpoint = Endpoint.create(xkmsPort);

    HttpContext httpContext = server.createContext("/xkms2");
    LOG.debug("http context attributes: " + httpContext.getAttributes());
    endpoint.publish(httpContext);

    assertTrue(endpoint.isPublished());

    HttpClient httpClient = new HttpClient();
    GetMethod getMethod = new GetMethod(address + "?wsdl");
    int statusCode = httpClient.executeMethod(getMethod);
    LOG.debug("status code: " + statusCode);
    assertEquals(HttpServletResponse.SC_OK, statusCode);
    LOG.debug("runtime WSDL: " + getMethod.getResponseBodyAsString());

    getMethod = new GetMethod(address + "?wsdl=1");
    statusCode = httpClient.executeMethod(getMethod);
    LOG.debug("status code: " + statusCode);
    assertEquals(HttpServletResponse.SC_OK, statusCode);
    LOG.debug("runtime WSDL: " + getMethod.getResponseBodyAsString());

    XKMSService xkmsService = XKMSServiceFactory.getInstance();
    XKMSPortType xkmsPortClient = xkmsService.getXKMSPort();
    BindingProvider bindingProviderClient = (BindingProvider) xkmsPortClient;
    bindingProviderClient.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);

    // EasyMock.replay(mockServletContext);
    // ValidateResultType validateResult = xkmsPortClient.validate(null);
    // EasyMock.verify(mockServletContext);
}