### Question:
RMEndpoint { void createEndpoint(org.apache.cxf.transport.Destination d, ProtocolVariation protocol) { final QName bindingQName = new QName(protocol.getWSRMNamespace(), BINDING_NAME); WrappedService service = services.get(protocol); ServiceInfo si = service.getServiceInfo(); buildBindingInfo(si, protocol); EndpointInfo aei = applicationEndpoint.getEndpointInfo(); String transportId = aei.getTransportId(); EndpointInfo ei = new EndpointInfo(si, transportId); if (d != null) { ei.setProperty(MAPAggregator.DECOUPLED_DESTINATION, d); } ei.setAddress(aei.getAddress()); ei.setName(RMUtils.getConstants(protocol.getWSRMNamespace()).getPortName()); ei.setBinding(si.getBinding(bindingQName)); Object ua = getUsingAddressing(aei); if (null != ua) { ei.addExtensor(ua); } si.addEndpoint(ei); ei.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore); Endpoint endpoint = new WrappedEndpoint(applicationEndpoint, ei, service); if (applicationEndpoint.getEndpointInfo() != null && applicationEndpoint.getEndpointInfo().getProperties() != null) { for (String key : applicationEndpoint.getEndpointInfo().getProperties().keySet()) { endpoint.getEndpointInfo() .setProperty(key, applicationEndpoint.getEndpointInfo().getProperty(key)); } } service.setEndpoint(endpoint); endpoints.put(protocol, endpoint); } RMEndpoint(RMManager m, Endpoint ae); RMManager getManager(); Endpoint getApplicationEndpoint(); Endpoint getEndpoint(ProtocolVariation protocol); Service getService(ProtocolVariation protocol); BindingInfo getBindingInfo(ProtocolVariation protocol); Proxy getProxy(); Servant getServant(); Destination getDestination(); void setDestination(Destination destination); Source getSource(); void setSource(Source source); long getLastApplicationMessage(); int getApplicationMessageCount(); void receivedApplicationMessage(); long getLastControlMessage(); int getControlMessageCount(); void receivedControlMessage(); Conduit getConduit(); RMConfiguration getConfiguration(); void handleAccept(String ssid, long number, Message msg); void handleAcknowledgment(String ssid, long number, Message msg);  }### Answer:
@Test public void testCreateEndpoint() throws NoSuchMethodException, EndpointException { Method m = RMEndpoint.class.getDeclaredMethod("getUsingAddressing", new Class[] {EndpointInfo.class}); Service as = control.createMock(Service.class); EndpointInfo aei = new EndpointInfo(); ae = new EndpointImpl(null, as, aei); rme = EasyMock.createMockBuilder(RMEndpoint.class).withConstructor(manager, ae) .addMockedMethod(m).createMock(control); rme.setAplicationEndpoint(ae); rme.setManager(manager); SoapBindingInfo bi = control.createMock(SoapBindingInfo.class); aei.setBinding(bi); SoapVersion sv = Soap11.getInstance(); EasyMock.expect(bi.getSoapVersion()).andReturn(sv); String ns = "http: EasyMock.expect(bi.getBindingId()).andReturn(ns); aei.setTransportId(ns); String addr = "addr"; aei.setAddress(addr); Object ua = new Object(); EasyMock.expect(rme.getUsingAddressing(aei)).andReturn(ua); control.replay(); rme.createServices(); rme.createEndpoints(null); Endpoint e = rme.getEndpoint(ProtocolVariation.RM10WSA200408); WrappedEndpoint we = (WrappedEndpoint)e; assertSame(ae, we.getWrappedEndpoint()); Service s = rme.getService(ProtocolVariation.RM10WSA200408); assertEquals(1, s.getEndpoints().size()); assertSame(e, s.getEndpoints().get(RM10Constants.PORT_NAME)); }