### Question:
JettyHTTPDestination extends ServletDestination { protected String getAddress(EndpointInfo endpointInfo) { return endpointInfo.getAddress(); } JettyHTTPDestination(
            Bus bus,
            DestinationRegistry registry,
            EndpointInfo ei,
            JettyHTTPServerEngineFactory serverEngineFactory
    ); protected  JettyHTTPDestination(Bus bus,
                                   DestinationRegistry registry,
                                   EndpointInfo ei,
                                   URL nurl,
                                   JettyHTTPServerEngineFactory serverEngineFactory); void setServletContext(ServletContext sc); void finalizeConfig(); ServerEngine getEngine();  }### Answer:
@Test public void testGetAddress() throws Exception { destination = setUpDestination(); EndpointReferenceType ref = destination.getAddress(); assertNotNull("unexpected null address", ref); assertEquals("unexpected address", EndpointReferenceUtils.getAddress(ref), StringUtils.addDefaultPortIfMissing(EndpointReferenceUtils.getAddress(address))); assertEquals("unexpected service name local part", EndpointReferenceUtils.getServiceName(ref, bus).getLocalPart(), "Service"); assertEquals("unexpected portName", EndpointReferenceUtils.getPortName(ref), "Port"); }
@Test public void testRandomPortAllocation() throws Exception { bus = BusFactory.getDefaultBus(true); transportFactory = new HTTPTransportFactory(); ServiceInfo serviceInfo = new ServiceInfo(); serviceInfo.setName(new QName("bla", "Service")); EndpointInfo ei = new EndpointInfo(serviceInfo, ""); ei.setName(new QName("bla", "Port")); Destination d1 = transportFactory.getDestination(ei, bus); URL url = new URL(d1.getAddress().getAddress().getValue()); assertTrue("No random port has been allocated", url.getPort() > 0); }
@Test public void testMultiplexGetAddressWithIdForAddress() throws Exception { destination = setUpDestination(); destination.setMultiplexWithAddress(true); final String id = "ID3"; EndpointReferenceType refWithId = destination.getAddressWithId(id); assertNotNull(refWithId); assertNull(refWithId.getReferenceParameters()); assertTrue("match our id", EndpointReferenceUtils.getAddress(refWithId).indexOf(id) != -1); }
@Test public void testMultiplexGetIdForAddress() throws Exception { destination = setUpDestination(); destination.setMultiplexWithAddress(true); final String id = "ID3"; EndpointReferenceType refWithId = destination.getAddressWithId(id); String pathInfo = EndpointReferenceUtils.getAddress(refWithId); Map<String, Object> context = new HashMap<>(); assertNull("fails with no context", destination.getId(context)); context.put(Message.PATH_INFO, pathInfo); String result = destination.getId(context); assertNotNull(result); assertEquals("match our id", result, id); }