in black and white
Main menu
Share a book About us Home
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics

Java Tools for Extreme programming mastering open source tools including - Hightower R.

Hightower R. Java Tools for Extreme programming mastering open source tools including - Wiley publishing , 2002. - 417 p.
ISBN: 0-471-20708
Download (direct link): javatoolsforextremeprog2002.pdf
Previous << 1 .. 145 146 147 148 149 150 < 151 > 152 153 154 155 156 157 .. 159 >> Next

getResponse(java.lang.String urlString)
public WebResponse getResponse(java.lang.String urlString) throws,
This method returns a WebResponse containing the result of a GET method request to the specified URL. It's essentially a convenience method for getResponse(new GetMethodWebRequest(urlString)) (see that method for details).
getResponse(WebRequest request)
public WebResponse getResponse(WebRequest request) throws,, org.xml.sax.SAXException
One of the key methods in the HttpUnit API, getResponse() embodies a Webbrowser request and server response. Functionally, it sends the specified WebRequest to the server using all the state information (cookies, headers, and so on) stored in the WebClient.
The list of exceptions is large but manageable. In most test methods, you'll want to declare that the test method throws Exception and allow JUnit to treat these occurrences as test failures. The java exceptions are simply passed on from classes in the package (representing an illegal URL and IO problem during network connection respectively). The SAXException occurs when an error occurs while parsing the received page as XML.
public String getUserAgent()
This method gets the User-Agent header (the type of browser this WebClient is emulating) that is sent to the server.
newResponse(WebRequest request)
protected abstract WebResponse newResponse(WebRequest request) throws,
This method is used internally to talk to the server and create a new WebResponse from the results.
setAuthorization(String userName, String password)
public void setAuthorization(String userName, String password)
This method sets the Authorization header using the basic authorization scheme. (See the "Description" section of this class for an example.)
setHeaderField(String fieldName, String fieldValue)
public void setHeaderField(String fieldName, String fieldValue)
This method sets a header that will be sent to the server with every request. If a header is set to null, that header is removed from future requests:
conversation.setHeaderField("Cache-Control", "Cache-Control :
setUserAgent(String userAgent)
public void setUserAgent(String userAgent)
This method sets the User-Agent header (used to emulate a type of browser). updateClient(WebResponse response) protected final void updateClient(WebResponse response) throws,, org.xml.sax.SAXException
This method is used internally to update the state of the WebClient to reflect the results of the latest transaction.
Class WebConversation
public class WebConversation
Inheritance Information
Extends: WebClient
WebConversation is the concrete implementation of WebClient; it provides no new external behavior. See the section on WebClient for details and examples.
public WebConversation()
newResponse(WebRequest request)
protected WebResponse newResponse(WebRequest request) throws,
Class WebForm
public class WebForm
Inheritance Information
Extends: ObjectDescription
This class represents an HTML form present in a Web page. It provides a variety of shortcut methods that make examining the form and writing assertions against it easier. It also provides the facility to create a WebRequest that simulates the submission of this form. (See the section on WebRequest for more details.) Note A common problem that occurs when working with WebForm relates to poorly
structured HTML. HttpUnit uses an HTML parser (JTidy) that parses strictly according to the HTML specification. Any improperly nested tags are ignored. For instance, JTidy would not recognize the form tags in the following lines:
<td>form body</td>
This behavior can cause inconsistent results in HttpUnit even though the (more forgiving) standard browsers will have no problems with the form. To check if your HTML is improperly formatted, call HttpUnitOptions.setParserWarningsEnabled(true) (see the section on HttpUnitOptions for details) before retrieving the page in question. Doing so will cause any warnings generated by JTidy during parsing to be printed to System.out. Listing 16.2 (in the section on WebRequest) contains an example of using WebForm and WebRequest to access a form, verify it, and simulate a user's submission to that form.
public String getCharacterSet()
This method gets the character set encoding for this form. This information is contained in the Content-type header for the parent page.
public org.w3c.dom.Node getDOMSubtree()
This method returns a copy of the DOM Node representing this form in the underlying page. getID()
public String getID()
Previous << 1 .. 145 146 147 148 149 150 < 151 > 152 153 154 155 156 157 .. 159 >> Next