### Question:
WSDLHelper { public static org.w3c.dom.Node unwrapMessagePart(org.w3c.dom.Element content) { org.w3c.dom.NodeList nl=content.getChildNodes(); for (int i=0; i < nl.getLength(); i++) { if (nl.item(i) instanceof org.w3c.dom.Element) { org.w3c.dom.NodeList nl2=((org.w3c.dom.Element)nl.item(i)).getChildNodes(); for (int j=0; j < nl2.getLength(); j++) { if (nl2.item(j) instanceof org.w3c.dom.Element) { return ((org.w3c.dom.Node)nl2.item(j)); } } if (nl2.getLength() > 0) { return (nl2.item(0)); } return (null); } } return (null); } private  WSDLHelper(); static javax.wsdl.Definition getWSDLDefinition(String location); static javax.wsdl.PortType getPortType(String location, javax.wsdl.Definition wsdl); static javax.wsdl.Service getServiceForPortType(javax.wsdl.PortType portType,
                                javax.wsdl.Definition wsdl); static org.w3c.dom.Node unwrapMessagePart(org.w3c.dom.Element content); static org.w3c.dom.Element wrapRequestMessagePart(org.w3c.dom.Element content,
                        javax.wsdl.Operation operation); static org.w3c.dom.Element wrapResponseMessagePart(org.w3c.dom.Element content,
                        javax.wsdl.Operation operation); static org.w3c.dom.Element wrapFaultMessagePart(org.w3c.dom.Element content,
                        javax.wsdl.Operation operation, String faultName);  }### Answer:
@Test public void testUnwrapMessagePart() { String content="content"; String xml="<message><partName><"+content+"/></partName></message>"; try { org.w3c.dom.Element elem=DOMUtils.stringToDOM(xml); org.w3c.dom.Node unwrapped=WSDLHelper.unwrapMessagePart(elem); if (unwrapped == null) { fail("Result is null"); } if (unwrapped.getNodeName().equals(content) == false) { fail("Unexpected unwrapped content: "+unwrapped.getNodeName()); } } catch(Exception e) { fail("Failed: "+e); } }
@Test public void testUnwrapMessagePartText() { String content="content"; String xml="<message><partName>"+content+"</partName></message>"; try { org.w3c.dom.Element elem=DOMUtils.stringToDOM(xml); org.w3c.dom.Node unwrapped=WSDLHelper.unwrapMessagePart(elem); if (unwrapped == null) { fail("Result is null"); } if (!(unwrapped instanceof Text)) { fail("Context was not Text"); } if (((Text)unwrapped).getTextContent().equals(content) == false) { fail("Unexpected unwrapped content: "+((Text)unwrapped).getTextContent()); } } catch(Exception e) { fail("Failed: "+e); } }
@Test public void testUnwrapMessagePartWhitespace() { String content="content"; String xml="<message><partName>\r\n <"+content+"/>\r\n</partName></message>"; try { org.w3c.dom.Element elem=DOMUtils.stringToDOM(xml); org.w3c.dom.Node unwrapped=WSDLHelper.unwrapMessagePart(elem); if (unwrapped == null) { fail("Result is null"); } if (unwrapped.getNodeName().equals(content) == false) { fail("Unexpected unwrapped content: "+unwrapped.getNodeName()); } } catch(Exception e) { fail("Failed: "+e); } }