Example usage for javax.xml.ws Endpoint create

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

Introduction

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

Prototype

public static Endpoint create(Object implementor) 

Source Link

Document

Creates an endpoint with the specified implementor object.

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 av a 2 s .com*/
    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);
}