SoapFinder { public String findSoapTag(String string) { String result = null; for (Pattern pattern : patterns) { Matcher m = pattern.matcher(string); boolean found = m.find(); if (found) { result = m.group(1); break; } } return result; }  String findSoapTag(String string); SortedSet<SubText> findSoaps(String text);  }
@Test public void testFindSoapTag() throws Exception { ClassLoader classLoader = this.getClass().getClassLoader(); String soap1Formatted = IOUtils.toString(classLoader.getResourceAsStream("soap/1-soapMessageFormmated.txt")); String soap1UnFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/1-soapMessage.txt")); String soap2Formatted = IOUtils.toString(classLoader.getResourceAsStream("soap/2-soapMessageFormmated.txt")); String soap2UnFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/2-soapMessage.txt")); String soap1xRequestUnFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.1.request.xml")); String soap2xRequestUnFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.2.request.xml")); String soap3xRequestUnFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.3.request.xml")); String soap4xRequestUnFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.4.request.xml")); String soap1xRequestFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.1.request.formatted.xml")); String soap2xRequestFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.2.request.formatted.xml")); String soap3xRequestFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.3.request.formatted.xml")); String soap4xRequestFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.4.request.formatted.xml")); String soap1xResponseUnFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.1.response.xml")); String soap2xResponseUnFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.2.response.xml")); String soap3xResponseUnFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.3.response.xml")); String soap4xResponseUnFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.4.response.xml")); String soap1xResponseFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.1.response.formatted.xml")); String soap2xResponseFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.2.response.formatted.xml")); String soap3xResponseFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.3.response.formatted.xml")); String soap4xResponseFormatted = IOUtils.toString(classLoader.getResourceAsStream("soap/soap.4.response.formatted.xml")); SoapFinder soapFinder = new SoapFinder(); AssertJUnit.assertEquals("SoAp", soapFinder.findSoapTag(soap1Formatted)); AssertJUnit.assertEquals("SoAp", soapFinder.findSoapTag(soap1UnFormatted)); AssertJUnit.assertEquals("soap", soapFinder.findSoapTag(soap2Formatted)); AssertJUnit.assertEquals("soap", soapFinder.findSoapTag(soap2UnFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap1xRequestFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap2xRequestFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap3xRequestFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap4xRequestFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap1xRequestUnFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap2xRequestUnFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap3xRequestUnFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap4xRequestUnFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap1xResponseFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap2xResponseFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap3xResponseFormatted)); AssertJUnit.assertEquals("SOAP-ENV", soapFinder.findSoapTag(soap4xResponseFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap1xResponseUnFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap2xResponseUnFormatted)); AssertJUnit.assertEquals("env", soapFinder.findSoapTag(soap3xResponseUnFormatted)); AssertJUnit.assertEquals("SOAP-ENV", soapFinder.findSoapTag(soap4xResponseUnFormatted)); }