Hi guys,
I wanted to move my Xpath/JDOM codes out of my endpoint and to unit test them.
Code:private XPathExpression<Element> cusIdExpression;Code:Namespace namespace = Namespace.getNamespace("etc", NAMESPACE_URI); XPathFactory xPathFactory = XPathFactory.instance(); cusIdExpression = xPathFactory.compile("//etc:cusId", Filters.element(), null, namespace);However I am having difficulty to understand how I should be constructing the @RequestPayload Element customerSearchOptions to input to the unit test.Code:@PayloadRoot(namespace = NAMESPACE_URI, localPart = "method1Request") @ResponsePayload @Transactional(readOnly=true) public SearchCustomerResponse method1(@RequestPayload Element customerSearchOptions) Long cusId = Long.parseLong(cusIdExpression.evaluateFirst(customerSearchOptions).getText());
When I logged the to customerSearchOptions the console, I only found the line below logged
and the input XML which I was expecting was not there (i.e, the one being sent from SOAP UI)[Element: <ns:method1Request [Namespace: http://www.etc.com/etc/schemas/1/00]/>]
Code:<soapenv:Body> <ns:method1> <ns:cusId>?</ns:cusId> <ns:locationCriteria> <ns:addressLine1>flacq</ns:addressLine1> <ns:city>?</ns:city> <ns:postCode>?</ns:postCode> <ns:isoCountryCode>Mauritius</ns:isoCountryCode>
If anyone knows how to actually contruct an input which could be used to unit test the XPath Expressions, I would appreciate if you could share it.
Also, if there is also a document which is published. Thanks for sharing that as well.Code:public void testCustomerId() { Element customerSearchOptions = new Element(""); customerSearchServicePathExpressionParser.getCusId(customerSearchOptions); }
Regards
Kris


Reply With Quote