private WebResource getResource( PseudoServlet servlet, HttpRequest request ) throws IOException { servlet.init( request ); return servlet.getResponse( request.getCommand() ); }
protected void assertEqualQueries( String query1, String query2 ) { assertEquals( new QuerySpec( query1 ), new QuerySpec( query2 ) ); }
ReceivedHttpMessage( InputStream inputStream ) throws IOException { interpretMessageHeader( readHeaderLine( inputStream ) ); readHeaders( inputStream ); readMessageBody( inputStream ); }
/** * Defines the contents of an expected resource. **/ public void setResource( String name, String value, String contentType ) { _resources.put( asResourceName( name ), new WebResource( value, contentType ) ); }
protected void assertImplement( String comment, Object[] objects, Class expectedClass ) { if (objects.length == 0) fail( "No " + comment + " found." ); for (int i = 0; i < objects.length; i++) { assertImplements( comment, objects[i], expectedClass ); } }
/** * Returns a resource object as a result of a get request. **/ public WebResource getGetResponse() throws IOException { throw new UnknownMethodException( "GET" ); }
private ServerSocket getServerSocket() throws IOException { synchronized (this) { if (_serverSocket == null) _serverSocket = ServerSocketFactory.newServerSocket(); } return _serverSocket; }
/** * Returns the values for the parameter with the specified name. If no values exist * will return null. **/ protected String[] getParameter( String name ) { return _request.getParameter( name ); }
/** * Defines the contents of an expected resource. **/ public void setResource( String name, String value ) { setResource( name, value, "text/html" ); }
/** * define a Web Page with the given page name and boy adding the html and body tags with pageName as the title of the page * @param pageName * @param body */ protected void defineWebPage( String pageName, String body ) { defineWebPage(null,pageName,body); }
public WebResource( InputStream stream, String contentType, int responseCode ) { _stream = stream; _contentType = contentType; _responseCode = responseCode; addHeader( "Connection: close" ); }
/** * Returns a reader for the body of the request. **/ protected Reader getReader() { return _request.getReader(); }
/** * Returns the header with the specified name. If no such header exists, will return null. **/ protected String getHeader( String name ) { return _request.getHeader( name ); }
private WebResource getResource( PseudoServlet servlet, HttpRequest request ) throws IOException { servlet.init( request ); return servlet.getResponse( request.getCommand() ); }
/** * Defines a resource which will result in an error message. **/ public void setErrorResource( String name, int errorCode, String errorMessage ) { _resources.put( asResourceName( name ), new WebResource( errorMessage, errorCode ) ); }
/** * Returns a resource object as a result of a get request. **/ public WebResource getGetResponse() throws IOException { throw new UnknownMethodException( "GET" ); }
private ServerSocket getServerSocket() throws IOException { synchronized (this) { if (_serverSocket == null) _serverSocket = ServerSocketFactory.newServerSocket(); } return _serverSocket; }
private WebResource getResource( PseudoServlet servlet, HttpRequest request ) throws IOException { servlet.init( request ); return servlet.getResponse( request.getCommand() ); }