### Question:
NMRDestination extends AbstractDestination implements Endpoint { public void activate() { nmr.getEndpointRegistry().register(this, properties); } NMRDestination(EndpointInfo info, NMR nmr); void setChannel(Channel dc); Channel getChannel(); void shutdown(); void deactivate(); void activate(); void process(Exchange exchange);  }### Answer:
@Test public void testNMRDestinationRunAsSubjct() throws Exception { ServiceMix smx = new ServiceMix(); smx.init(); nmr = smx; EndpointInfo ei = new EndpointInfo(); ei.setAddress("nmr:dumy?RUN_AS_SUBJECT=true"); ei.setName(new QName("http: ServiceInfo si = new ServiceInfo(); si.setName(new QName("http: InterfaceInfo interInfo = new InterfaceInfo(si, new QName("http: si.setInterface(interInfo); ei.setService(si); nmrTransportFactory.setNmr(nmr); NMRDestination destination = (NMRDestination) nmrTransportFactory.getDestination(ei); destination.activate(); assertNotNull(destination); Subject subject = new Subject(); subject.getPrincipals().add(new UserPrincipal("ffang")); Channel channel = nmr.createChannel(); org.apache.servicemix.nmr.api.Exchange exchange = channel.createExchange(Pattern.InOut); exchange.setTarget( nmr.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME, "dumy"))); exchange.getIn().setSecuritySubject(subject); Source source = new StreamSource(new ByteArrayInputStream( "<message>TestHelloWorld</message>".getBytes())); exchange.getIn().setBody(source); observer = new MessageObserver() { public void onMessage(Message m) { inMessage = m; Subject receivedSubject = (Subject)inMessage.get(NMRTransportFactory.NMR_SECURITY_SUBJECT); assertNotNull(receivedSubject); assertEquals(receivedSubject.getPrincipals().size(), 1); assertEquals(receivedSubject.getPrincipals().iterator().next().getName(), "ffang"); Subject onBefalfsubject = Subject.getSubject(AccessController.getContext()); assertNotNull(onBefalfsubject); assertEquals(onBefalfsubject, receivedSubject); } }; destination.setMessageObserver(observer); channel.send(exchange); Thread.sleep(2000); assertNotNull(inMessage); }