Example usage for javax.xml.namespace NamespaceContext getPrefixes

List of usage examples for javax.xml.namespace NamespaceContext getPrefixes

Introduction

In this page you can find the example usage for javax.xml.namespace NamespaceContext getPrefixes.

Prototype

Iterator<String> getPrefixes(String namespaceURI);

Source Link

Document

Get all prefixes bound to a Namespace URI in the current scope.

Usage

From source file:gov.nij.bundles.intermediaries.ers.EntityResolutionServiceIntermediaryTest.java

@Before
public void setUp() throws Exception {

    final NamespaceContext baseEntityResolutionNamespaceContext = new EntityResolutionNamespaceContext();
    testNamespaceContext = new NamespaceContext() {

        @Override//from   www.  j  a va  2  s . c  o  m
        public String getNamespaceURI(String prefix) {
            if ("ext".equals(prefix)) {
                return "http://local.org/IEPD/Extensions/PersonSearchResults/1.0";
            }
            return baseEntityResolutionNamespaceContext.getNamespaceURI(prefix);
        }

        @Override
        public String getPrefix(String arg0) {
            return baseEntityResolutionNamespaceContext.getPrefix(arg0);
        }

        @SuppressWarnings("rawtypes")
        @Override
        public Iterator getPrefixes(String arg0) {
            return baseEntityResolutionNamespaceContext.getPrefixes(arg0);
        }

    };

    // Advise the person search results endpoint and replace it with a mock endpoint.
    // We then will test this mock endpoint to see if it gets the proper payload.
    context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            // weave the vehicle search results in the route
            // and replace it with the following mock route path
            weaveByToString("To[EntityResolutionResponseEndpoint]").replace()
                    .to("mock:EntityResolutionResponseEndpoint");
            replaceFromWith("direct:entityResolutionRequestServiceEndpoint");
        }
    });

    context.start();

    // We should get one message
    entityResolutionResponseMock.expectedMessageCount(1);

    // Create a new exchange
    senderExchange = new DefaultExchange(context);

    Document doc = createDocument();
    List<SoapHeader> soapHeaders = new ArrayList<SoapHeader>();
    soapHeaders.add(makeSoapHeader(doc, "http://www.w3.org/2005/08/addressing", "MessageID", "12345"));
    soapHeaders.add(makeSoapHeader(doc, "http://www.w3.org/2005/08/addressing", "ReplyTo", "https://reply.to"));
    senderExchange.getIn().setHeader(Header.HEADER_LIST, soapHeaders);

    senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, CXF_OPERATION_NAME);
    senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAMESPACE, CXF_OPERATION_NAMESPACE);
}

From source file:gov.nij.bundles.intermediaries.ers.EntityResolutionMessageHandlerTest.java

@Before
public void setUp() throws Exception {
    final NamespaceContext baseEntityResolutionNamespaceContext = new EntityResolutionNamespaceContext();
    testNamespaceContext = new NamespaceContext() {

        @Override//from  w ww. j a  v a  2s .  co m
        public String getNamespaceURI(String prefix) {
            if ("ext".equals(prefix)) {
                return "http://local.org/IEPD/Extensions/PersonSearchResults/1.0";
            }
            return baseEntityResolutionNamespaceContext.getNamespaceURI(prefix);
        }

        @Override
        public String getPrefix(String arg0) {
            return baseEntityResolutionNamespaceContext.getPrefix(arg0);
        }

        @SuppressWarnings("rawtypes")
        @Override
        public Iterator getPrefixes(String arg0) {
            return baseEntityResolutionNamespaceContext.getPrefixes(arg0);
        }

    };
    entityResolutionMessageHandler = new EntityResolutionMessageHandler();
    testAttributeParametersMessageInputStream = getClass()
            .getResourceAsStream("/xml/TestAttributeParameters.xml");
    assertNotNull(testAttributeParametersMessageInputStream);
    entityResolutionMessageHandler.setAttributeParametersStream(testAttributeParametersMessageInputStream);
    testRequestMessageInputStream = getClass().getResourceAsStream("/xml/EntityMergeRequestMessage.xml");
    assertNotNull(testRequestMessageInputStream);
}