XPathPayloadMappingKeyExtractor extends AbstractMappingKeyExtractor { public void setXpathExpression(String xpathExpression) { this.xpathExpression = xpathExpression; }  @Override String getMappingKey(Message request); void setXpathExpression(String xpathExpression); void setNamespaceContextBuilder(NamespaceContextBuilder namespaceContextBuilder);  }
@Test public void testExtractMappingKey() throws Exception { XPathPayloadMappingKeyExtractor extractor = new XPathPayloadMappingKeyExtractor(); extractor.setXpathExpression("local-name( Assert.assertEquals(extractor.extractMappingKey(new DefaultMessage( "<MessageBody><Foo>foo</Foo></MessageBody>")), "Foo"); Assert.assertEquals(extractor.extractMappingKey(new DefaultMessage( "<MessageBody><Bar>bar</Bar></MessageBody>")), "Bar"); }
@Test public void testRouteMessageWithBadXpathExpression() throws Exception { XPathPayloadMappingKeyExtractor extractor = new XPathPayloadMappingKeyExtractor(); extractor.setXpathExpression(" try { extractor.extractMappingKey(new DefaultMessage( "<MessageBody><Foo>foo</Foo></MessageBody>")); Assert.fail("Missing exception due to bad XPath expression"); } catch (CitrusRuntimeException e) { Assert.assertEquals(e.getMessage(), "No result for XPath expression: ' } }