JaVa
   

Package org.apache. cactus.util

Both of the classes in the util package have been deprecated in Cactus 1.2. ClientCookie has been improved to become org.apache.cactus.Cookie and the functionality of AssertUtils has been rolled into WebResponse.

Class AssertUtils Deprecated

public class AssertUtils


Inheritance Information

Extends: Object

Description

The functionality of this class has been incorporated into WebResponse as of Cactus 1.2. AssertUtils is a class of static utility functions that simplify the extraction of information from HttpUrlConnections. Such information can then be used in assertions:

/*this is the Cactus 1.1 endXXX() method signature.*/
public void endSomeTestMethod(java.net.HttpURLConnection conn) {
 /*cookie assertions*/
 Hashtable allCookies = AssertUtils.getCookies(conn);

 List chocolateChipCookies = (List)allCookies.get("C_CHIP");
 assertEquals("only one chocolate chip cookie set",
 1, chocolateChipCookies.size());
 ClientCookie cookie = (ClientCookie)chocolateChipCookies.get(0);
 assertTrue(cookie.getMaxAge() < this.FRESHNESS_DATE);
 /*response assertions*/
 String allResponseText = AssertUtils.getResponseAsString(conn);
 assertTrue("contains descriptive text",
 allResponseText.indexOf("Cookies 4 U") > -1);
 String[] allTextArray = AssertUtils.getResponseAsStringArray(conn);
 int last = allTextArray.length;
 assertTrue("html tag closed",
 allTextArray[last].endsWith("</html>"));
 }


Methods

getCookies(HttpURLConnection theConnection)
public static Hashtable getCookies(HttpURLConnection theConnection)


This method returns a Hashtable containing cookie names as keys. The associated values are Lists (Vectors) of ClientCookie objects that can be inspected.

getResponseAsString(HttpURLConnection theConnection)
public static String getResponseAsString(HttpURLConnection
 theConnection) throws IOException


This method returns the output stream contained in the connection as a String.

getResponseAsStringArray(HttpURLConnection theConnection)
public static String[] getResponseAsStringArray(HttpURLConnection
 theConnection) throws IOException


This method returns the output stream contained in the connection as an array of Strings, where each String corresponds to a line in the output stream.

Class ClientCookie Deprecated

public class ClientCookie


Inheritance Information

Extends: Object


Description

The functionality of this class has been expanded and included in the Cookie class of Cactus.

ClientCookie is a simple class for storing the information about a cookie contained in a set-cookie header. It is usually instantiated by AssertUtils.getCookies(HttpUrlConnection connection).

Constructor

public ClientCookie(...)
public ClientCookie(String theName, String theValue, String theComment,
 String theDomain, long theMaxAge, String thePath,
 boolean isSecure, float theVersion)


Methods

The following methods are accessors for all the properties specified in the constructor; they correspond to the different parts of the set-cookie response header.

getComment()
public String getComment()
getDomain()
public String getDomain()
getMaxAge()
public long getMaxAge()
getName()
public String getName()
getPath()
public String getPath()
getValue()
public String getValue()
getVersion()
public float getVersion()
isSecure()
public boolean isSecure()


JaVa
   
Comments