[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit ClientProperties.java,1.4,1.5 HttpUnitOpt
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2003-03-16 17:22:43
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv18420/src/com/meterware/httpunit
Modified Files:
ClientProperties.java HttpUnitOptions.java WebClient.java
WebWindow.java
Log Message:
Moved properties from HttpUnitOptions to ClientProperties
Index: ClientProperties.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ClientProperties.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ClientProperties.java 4 Feb 2003 05:32:03 -0000 1.4
+++ ClientProperties.java 16 Mar 2003 17:22:38 -0000 1.5
@@ -129,6 +129,77 @@
}
+ /**
+ * Returns true if the client should accept and transmit cookies. The default is to accept them.
+ */
+ public boolean isAcceptCookies() {
+ return _acceptCookies;
+ }
+
+
+ /**
+ * Specifies whether the client should accept and send cookies.
+ */
+ public void setAcceptCookies( boolean acceptCookies ) {
+ _acceptCookies = acceptCookies;
+ }
+
+
+ /**
+ * Returns true if the client will accept GZIP encoding of responses. The default is to accept GZIP encoding.
+ **/
+ public boolean isAcceptGzip() {
+ return _acceptGzip;
+ }
+
+
+ /**
+ * Specifies whether the client will accept GZIP encoded responses. The default is true.
+ */
+ public void setAcceptGzip( boolean acceptGzip ) {
+ _acceptGzip = acceptGzip;
+ }
+
+
+ /**
+ * Returns true if the client should automatically follow page redirect requests (status 3xx).
+ * By default, this is true.
+ **/
+ public boolean isAutoRedirect() {
+ return _autoRedirect;
+ }
+
+
+ /**
+ * Determines whether the client should automatically follow page redirect requests (status 3xx).
+ * By default, this is true in order to simulate normal browser operation.
+ **/
+ public void setAutoRedirect( boolean autoRedirect ) {
+ _autoRedirect = autoRedirect;
+ }
+
+
+ /**
+ * Returns true if the client should automatically follow page refresh requests.
+ * By default, this is false, so that programs can verify the redirect page presented
+ * to users before the browser switches to the new page.
+ **/
+ public boolean isAutoRefresh() {
+ return _autoRefresh;
+ }
+
+
+ /**
+ * Specifies whether the client should automatically follow page refresh requests.
+ * By default, this is false, so that programs can verify the redirect page presented
+ * to users before the browser switches to the new page. Setting this to true can
+ * cause an infinite loop on pages that refresh themselves.
+ **/
+ public void setAutoRefresh( boolean autoRefresh ) {
+ _autoRefresh = autoRefresh;
+ }
+
+
public boolean isIframeSupported() {
return _iframeSupported;
}
@@ -146,13 +217,17 @@
private String _applicationCodeName = "httpunit";
private String _applicationName = "HttpUnit";
- private String _applicationVersion = "1.4";
+ private String _applicationVersion = "1.5";
private String _userAgent;
private String _platform = "Java";
private int _availWidth = 800;
private int _availHeight = 600;
private boolean _iframeSupported = true;
+ private boolean _acceptCookies = true;
+ private boolean _acceptGzip = true;
+ private boolean _autoRedirect = true;
+ private boolean _autoRefresh = false;
private static ClientProperties _defaultProperties = new ClientProperties();
@@ -168,5 +243,9 @@
_userAgent = source._userAgent;
_platform = source._platform;
_iframeSupported = source._iframeSupported;
+ _acceptCookies = source._acceptCookies;
+ _acceptGzip = source._acceptGzip;
+ _autoRedirect = source._autoRedirect;
+ _autoRefresh = source._autoRefresh;
}
}
Index: HttpUnitOptions.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- HttpUnitOptions.java 28 Feb 2003 17:30:26 -0000 1.37
+++ HttpUnitOptions.java 16 Mar 2003 17:22:38 -0000 1.38
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000-2002, Russell Gold
+* Copyright (c) 2000-2003, Russell Gold
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
@@ -47,15 +47,11 @@
_imagesTreatedAsAltText = false;
_loggingHttpHeaders = false;
_matchesIgnoreCase = true;
- _autoRefresh = false;
- _autoRedirect = true;
_checkContentLength = false;
_redirectDelay = 0;
_characterSet = HttpUnitUtils.DEFAULT_CHARACTER_SET;
_contentType = DEFAULT_CONTENT_TYPE;
_postIncludesCharset = false;
- _acceptGzip = true;
- _acceptCookies = true;
setScriptEngineClassName( DEFAULT_SCRIPT_ENGINE_FACTORY );
setScriptingEnabled( true );
setExceptionsThrownOnScriptError( true );
@@ -64,33 +60,37 @@
/**
* Returns true if HttpUnit is accepting and saving cookies. The default is to accept them.
+ * @deprecated as of 1.5.3, use ClientProperties#isAcceptCookies();
*/
public static boolean isAcceptCookies() {
- return _acceptCookies;
+ return ClientProperties.getDefaultProperties().isAcceptCookies();
}
/**
* Specifies whether HttpUnit should accept and send cookies.
+ * @deprecated as of 1.5.3, use ClientProperties#setAcceptCookies();
*/
public static void setAcceptCookies( boolean acceptCookies ) {
- _acceptCookies = acceptCookies;
+ ClientProperties.getDefaultProperties().setAcceptCookies( acceptCookies );
}
/**
* Returns true if any WebClient created will accept GZIP encoding of responses. The default is to accept GZIP encoding.
+ * @deprecated as of 1.5.3, use ClientProperties#isAcceptGzip();
**/
public static boolean isAcceptGzip() {
- return _acceptGzip;
+ return ClientProperties.getDefaultProperties().isAcceptGzip();
}
/**
* Specifies whether a WebClient will be initialized to accept GZIP encoded responses. The default is true.
+ * @deprecated as of 1.5.3, use ClientProperties#setAcceptGzip();
*/
public static void setAcceptGzip( boolean acceptGzip ) {
- _acceptGzip = acceptGzip;
+ ClientProperties.getDefaultProperties().setAcceptGzip( acceptGzip );
}
@@ -290,18 +290,20 @@
/**
* Returns true if HttpUnit should automatically follow page redirect requests (status 3xx).
* By default, this is true.
+ * @deprecated as of 1.5.3, use ClientProperties#isAutoRedirect();
**/
public static boolean getAutoRedirect() {
- return _autoRedirect;
+ return ClientProperties.getDefaultProperties().isAutoRedirect();
}
/**
* Determines whether HttpUnit should automatically follow page redirect requests (status 3xx).
* By default, this is true in order to simulate normal browser operation.
+ * @deprecated as of 1.5.3, use ClientProperties#setAutoRedirect();
**/
public static void setAutoRedirect( boolean autoRedirect ) {
- _autoRedirect = autoRedirect;
+ ClientProperties.getDefaultProperties().setAutoRedirect( autoRedirect );
}
@@ -328,9 +330,10 @@
* Returns true if HttpUnit should automatically follow page refresh requests.
* By default, this is false, so that programs can verify the redirect page presented
* to users before the browser switches to the new page.
+ * @deprecated as of 1.5.3, use ClientProperties#isAutoRefresh();
**/
public static boolean getAutoRefresh() {
- return _autoRefresh;
+ return ClientProperties.getDefaultProperties().isAutoRefresh();
}
@@ -339,9 +342,10 @@
* By default, this is false, so that programs can verify the redirect page presented
* to users before the browser switches to the new page. Setting this to true can
* cause an infinite loop on pages that refresh themselves.
+ * @deprecated as of 1.5.3, use ClientProperties#setAutoRefresh();
**/
public static void setAutoRefresh( boolean autoRefresh ) {
- _autoRefresh = autoRefresh;
+ ClientProperties.getDefaultProperties().setAutoRefresh( autoRefresh );
}
@@ -473,10 +477,6 @@
};
- private static boolean _acceptGzip = true;
-
- private static boolean _acceptCookies = true;
-
private static boolean _exceptionsOnErrorStatus = true;
private static boolean _parameterValuesValidated = true;
@@ -486,10 +486,6 @@
private static boolean _loggingHttpHeaders;
private static boolean _matchesIgnoreCase = true;
-
- private static boolean _autoRefresh;
-
- private static boolean _autoRedirect = true;
private static boolean _postIncludesCharset = false;
Index: WebClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- WebClient.java 27 Feb 2003 23:35:58 -0000 1.49
+++ WebClient.java 16 Mar 2003 17:22:38 -0000 1.50
@@ -345,9 +345,6 @@
protected WebClient() {
- if (HttpUnitOptions.isAcceptGzip()) {
- setHeaderField( "Accept-Encoding", "gzip" );
- }
_openWindows.add( _mainWindow );
}
@@ -373,6 +370,7 @@
protected Dictionary getHeaderFields( URL targetURL ) {
Hashtable result = (Hashtable) _headers.clone();
result.put( "User-Agent", getClientProperties().getUserAgent() );
+ if (getClientProperties().isAcceptGzip()) result.put( "Accept-Encoding", "gzip" );
AddHeaderIfNotNull( result, "Cookie", _cookieJar.getCookieHeaderField( targetURL ) );
AddHeaderIfNotNull( result, getAuthorizationHeaderName(), _authorizationString );
return result;
@@ -435,7 +433,7 @@
void updateClient( WebResponse response ) throws IOException {
- if (HttpUnitOptions.isAcceptCookies()) _cookieJar.updateCookies( response.getCookieJar() );
+ if (getClientProperties().isAcceptCookies()) _cookieJar.updateCookies( response.getCookieJar() );
validateHeaders( response );
}
Index: WebWindow.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- WebWindow.java 14 Mar 2003 17:41:30 -0000 1.10
+++ WebWindow.java 16 Mar 2003 17:22:38 -0000 1.11
@@ -126,7 +126,7 @@
**/
WebResponse updateWindow( String requestTarget, WebResponse response, RequestContext requestContext ) throws MalformedURLException, IOException, SAXException {
_client.updateClient( response );
- if (HttpUnitOptions.getAutoRefresh() && response.getRefreshRequest() != null) {
+ if (getClient().getClientProperties().isAutoRefresh() && response.getRefreshRequest() != null) {
return getResponse( response.getRefreshRequest() );
} else if (shouldFollowRedirect( response )) {
delay( HttpUnitOptions.getRedirectDelay() );
@@ -234,7 +234,7 @@
private boolean shouldFollowRedirect( WebResponse response ) {
- return HttpUnitOptions.getAutoRedirect()
+ return getClient().getClientProperties().isAutoRedirect()
&& response.getResponseCode() >= HttpURLConnection.HTTP_MOVED_PERM
&& response.getResponseCode() <= HttpURLConnection.HTTP_MOVED_TEMP
&& response.getHeaderField( "Location" ) != null;
|