private String decode( String string ) { return HttpUnitUtils.decode( string, _baseResponse.getCharacterSet() ).trim(); }
private String decode( String string ) { return HttpUnitUtils.decode( string, _baseResponse.getCharacterSet() ).trim(); }
private String decode( String string ) { return HttpUnitUtils.decode( string, _baseResponse.getCharacterSet() ).trim(); }
protected void loadResponseText() throws IOException { if (_responseText != null) throw new IllegalStateException( "May only invoke loadResponseText once" ); _responseText = ""; InputStream inputStream = getInputStream(); try { final int contentLength = this.encodedUsingGZIP() ? -1 : getContentLength(); int bytesRemaining = contentLength < 0 ? Integer.MAX_VALUE : contentLength; byte[] bytes = readFromStream( inputStream, bytesRemaining ); readTags( bytes ); _responseText = new String( bytes, getCharacterSet() ); _inputStream = new ByteArrayInputStream( bytes ); if (HttpUnitOptions.isCheckContentLength() && contentLength >= 0 && bytes.length != contentLength) { throw new IOException("Truncated message. Expected length: " + contentLength + ", Actual length: " + bytes.length); } } finally { inputStream.close(); } }
protected void loadResponseText() throws IOException { if (_responseText != null) throw new IllegalStateException( "May only invoke loadResponseText once" ); _responseText = ""; InputStream inputStream = getInputStream(); try { final int contentLength = this.encodedUsingGZIP() ? -1 : getContentLength(); int bytesRemaining = contentLength < 0 ? Integer.MAX_VALUE : contentLength; byte[] bytes = readFromStream( inputStream, bytesRemaining ); readTags( bytes ); _responseText = new String( bytes, getCharacterSet() ); _inputStream = new ByteArrayInputStream( bytes ); if (HttpUnitOptions.isCheckContentLength() && contentLength >= 0 && bytes.length != contentLength) { throw new IOException("Truncated message. Expected length: " + contentLength + ", Actual length: " + bytes.length); } } finally { inputStream.close(); } }
protected void loadResponseText() throws IOException { if (_responseText != null) throw new IllegalStateException( "May only invoke loadResponseText once" ); _responseText = ""; InputStream inputStream = getInputStream(); try { final int contentLength = this.encodedUsingGZIP() ? -1 : getContentLength(); int bytesRemaining = contentLength < 0 ? Integer.MAX_VALUE : contentLength; byte[] bytes = readFromStream( inputStream, bytesRemaining ); readTags( bytes ); _responseText = new String( bytes, getCharacterSet() ); _inputStream = new ByteArrayInputStream( bytes ); if (HttpUnitOptions.isCheckContentLength() && contentLength >= 0 && bytes.length != contentLength) { throw new IOException("Truncated message. Expected length: " + contentLength + ", Actual length: " + bytes.length); } } finally { inputStream.close(); } }
/** * get the received Page * @return the received page * @throws SAXException */ HTMLPage getReceivedPage() throws SAXException { if (_page == null) { try { _parsingPage = true; if (!isHTML()) throw new NotHTMLException( getContentType() ); _page = new HTMLPage( this, _frame, _baseURL, _baseTarget, getCharacterSet() ); _page.parse( getText(), _pageURL ); if (_page == null) throw new IllegalStateException( "replaceText called in the middle of getReceivedPage()" ); ((HTMLDocumentImpl) _page.getRootNode()).getWindow().setProxy( this ); } catch (IOException e) { HttpUnitUtils.handleException(e); throw new RuntimeException( e.toString() ); } finally { _parsingPage = false; } } return _page; }
/** * get the received Page * @return the received page * @throws SAXException */ HTMLPage getReceivedPage() throws SAXException { if (_page == null) { try { _parsingPage = true; if (!isHTML()) throw new NotHTMLException( getContentType() ); _page = new HTMLPage( this, _frame, _baseURL, _baseTarget, getCharacterSet() ); _page.parse( getText(), _pageURL ); if (_page == null) throw new IllegalStateException( "replaceText called in the middle of getReceivedPage()" ); ((HTMLDocumentImpl) _page.getRootNode()).getWindow().setProxy( this ); } catch (IOException e) { HttpUnitUtils.handleException(e); throw new RuntimeException( e.toString() ); } finally { _parsingPage = false; } } return _page; }
/** * get the received Page * @return the received page * @throws SAXException */ HTMLPage getReceivedPage() throws SAXException { if (_page == null) { try { _parsingPage = true; if (!isHTML()) throw new NotHTMLException( getContentType() ); _page = new HTMLPage( this, _frame, _baseURL, _baseTarget, getCharacterSet() ); _page.parse( getText(), _pageURL ); if (_page == null) throw new IllegalStateException( "replaceText called in the middle of getReceivedPage()" ); ((HTMLDocumentImpl) _page.getRootNode()).getWindow().setProxy( this ); } catch (IOException e) { HttpUnitUtils.handleException(e); throw new RuntimeException( e.toString() ); } finally { _parsingPage = false; } } return _page; }
private void invoke(String encoding) throws Exception { WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/greeter", getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=" + encoding); ServletUnitClient client = newClient(); WebResponse response = client.getResponse(req); client.setExceptionsThrownOnErrorStatus(false); assertEquals("text/xml", response.getContentType()); assertTrue(encoding.equalsIgnoreCase(response.getCharacterSet())); Document doc = StaxUtils.read(response.getInputStream()); assertNotNull(doc); addNamespace("h", "http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body", doc); assertValid("//h:sayHiResponse", doc); }
@Test public void testPostInvokeServices() throws Exception { newClient(); WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter", getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=UTF-8"); WebResponse response = newClient().getResponse(req); assertEquals("text/xml", response.getContentType()); assertEquals(StandardCharsets.UTF_8.name(), response.getCharacterSet()); Document doc = StaxUtils.read(response.getInputStream()); assertNotNull(doc); addNamespace("h", "http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body", doc); assertValid("//h:sayHiResponse", doc); } }
@Test public void testPostInvokeServices() throws Exception { newClient(); WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/greeter", getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=UTF-8"); WebResponse response = newClient().getResponse(req); assertEquals("text/xml", response.getContentType()); assertEquals(StandardCharsets.UTF_8.name(), response.getCharacterSet()); Document doc = StaxUtils.read(response.getInputStream()); assertNotNull(doc); addNamespace("h", "http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body", doc); assertValid("//h:sayHiResponse", doc); } }
public void invokingEndpoint(WebRequest req) throws Exception { WebResponse response = newClient().getResponse(req); assertEquals("text/xml", response.getContentType()); assertTrue("utf-8".equalsIgnoreCase(response.getCharacterSet())); Document doc = StaxUtils.read(response.getInputStream()); assertNotNull(doc); addNamespace("h", "http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body", doc); assertValid("//h:sayHiResponse", doc); }
public void invokingEndpoint(WebRequest req) throws Exception { WebResponse response = newClient().getResponse(req); assertEquals("text/xml", response.getContentType()); assertTrue("utf-8".equalsIgnoreCase(response.getCharacterSet())); Document doc = StaxUtils.read(response.getInputStream()); assertNotNull(doc); addNamespace("h", "http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body", doc); assertValid("//h:sayHiResponse", doc); }