[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit AuthorizationRequiredException.java,1.3,1
Brought to you by:
russgold
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv30213/src/com/meterware/httpunit
Modified Files:
AuthorizationRequiredException.java GetMethodWebRequest.java
HTMLSegment.java HttpException.java HttpUnitOptions.java
HttpWebResponse.java IllegalRequestParameterException.java
MimeEncodedMessageBody.java NodeUtils.java
PostMethodWebRequest.java ReceivedPage.java SubmitButton.java
TableCell.java WebFrame.java WebLink.java WebRequest.java
Log Message:
Coding style cleanup
Index: AuthorizationRequiredException.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/AuthorizationRequiredException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AuthorizationRequiredException.java 2001/04/02 19:54:29 1.3
+++ AuthorizationRequiredException.java 2001/11/09 18:35:14 1.4
@@ -30,13 +30,13 @@
AuthorizationRequiredException( String wwwAuthenticateHeader ) throws IOException {
- int i = wwwAuthenticateHeader.indexOf( ' ' );
- if (i < 0) { // non-conforming header
+ final int index = wwwAuthenticateHeader.indexOf( ' ' );
+ if (index < 0) { // non-conforming header
_scheme = "Basic";
_params = wwwAuthenticateHeader;
} else {
- _scheme = wwwAuthenticateHeader.substring( 0, i );
- _params = wwwAuthenticateHeader.substring( i+1 );
+ _scheme = wwwAuthenticateHeader.substring( 0, index );
+ _params = wwwAuthenticateHeader.substring( index+1 );
}
_properties = new Properties();
_properties.load( new ByteArrayInputStream( _params.getBytes() ) );
Index: GetMethodWebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/GetMethodWebRequest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- GetMethodWebRequest.java 2001/04/18 03:16:07 1.8
+++ GetMethodWebRequest.java 2001/11/09 18:35:14 1.9
@@ -19,7 +19,6 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.net.MalformedURLException;
import java.net.URL;
/**
Index: HTMLSegment.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLSegment.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HTMLSegment.java 2001/04/18 03:18:35 1.2
+++ HTMLSegment.java 2001/11/09 18:35:14 1.3
@@ -19,8 +19,8 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import org.w3c.dom.Node;
import org.xml.sax.SAXException;
+
/**
* Represents the parse tree for a segment of HTML.
* @author Russell Gold
Index: HttpException.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HttpException.java 2001/11/08 22:07:52 1.3
+++ HttpException.java 2001/11/09 18:35:14 1.4
@@ -19,8 +19,6 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.util.Properties;
-import java.io.*;
import java.net.URL;
@@ -75,6 +73,5 @@
private URL _url;
private String _responseMessage;
-
}
Index: HttpUnitOptions.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- HttpUnitOptions.java 2001/10/15 18:25:59 1.11
+++ HttpUnitOptions.java 2001/11/09 18:35:14 1.12
@@ -261,9 +261,9 @@
//--------------------------------- private members --------------------------------------
- private static String DEFAULT_CONTENT_TYPE = "text/plain";
- private static String DEFAULT_CONTENT_HEADER = DEFAULT_CONTENT_TYPE;
- private static String DEFAULT_CHARACTER_SET = "iso-8859-1";
+ private static final String DEFAULT_CONTENT_TYPE = "text/plain";
+ private static final String DEFAULT_CONTENT_HEADER = DEFAULT_CONTENT_TYPE;
+ private static final String DEFAULT_CHARACTER_SET = "iso-8859-1";
private static boolean _parserWarningsEnabled;
Index: HttpWebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpWebResponse.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- HttpWebResponse.java 2001/11/08 22:07:52 1.15
+++ HttpWebResponse.java 2001/11/09 18:35:14 1.16
@@ -102,8 +102,8 @@
//------------------------------------- private members -------------------------------------
- final private static String END_OF_LINE = System.getProperty( "line.separator" );
- final private static String FILE_ENCODING = System.getProperty( "file.encoding" );
+ private final static String END_OF_LINE = System.getProperty( "line.separator" );
+ private final static String FILE_ENCODING = System.getProperty( "file.encoding" );
private int _responseCode = HttpURLConnection.HTTP_OK;
Index: IllegalRequestParameterException.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/IllegalRequestParameterException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IllegalRequestParameterException.java 2000/09/15 16:38:44 1.1
+++ IllegalRequestParameterException.java 2001/11/09 18:35:14 1.2
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000, Russell Gold
+* Copyright (c) 2000-2001, 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
@@ -19,9 +19,6 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.util.Properties;
-import java.io.*;
-
/**
* This exception is thrown on an attempt to set a form parameter in a way not possible from a browser.
Index: MimeEncodedMessageBody.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/MimeEncodedMessageBody.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MimeEncodedMessageBody.java 2001/07/31 16:08:59 1.8
+++ MimeEncodedMessageBody.java 2001/11/09 18:35:14 1.9
@@ -23,8 +23,6 @@
import java.io.OutputStream;
import java.io.InputStream;
-import java.net.URLConnection;
-
import java.util.Dictionary;
import java.util.Enumeration;
@@ -68,21 +66,21 @@
writeLn( outputStream, "Content-Disposition: form-data; name=\"" + name + '"' ); // XXX need to handle non-ascii names here
writeLn( outputStream, "Content-Type: text/plain; charset=" + getRequest().getCharacterSet() );
writeLn( outputStream, "" );
- writeLn( outputStream, values[i], getRequest().getCharacterSet() );
+ writeLn( outputStream, values[ i ], getRequest().getCharacterSet() );
}
}
Dictionary files = getPostRequest().getSelectedFiles();
+ byte[] buffer = new byte[ 8 * 1024 ];
for (Enumeration e = files.keys(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- WebRequest.UploadFileSpec spec = (WebRequest.UploadFileSpec) files.get( name );
+ String name = (String) e.nextElement();
+ WebRequest.UploadFileSpec spec = (WebRequest.UploadFileSpec) files.get( name );
writeLn( outputStream, "--" + BOUNDARY );
writeLn( outputStream, "Content-Disposition: form-data; name=\"" + encode( name ) + "\"; filename=\"" + encode( spec.getFileName() ) + '"' ); // XXX need to handle non-ascii names here
writeLn( outputStream, "Content-Type: " + spec.getContentType() );
writeLn( outputStream, "" );
InputStream in = spec.getInputStream();
- byte[] buffer = new byte[8 * 1024];
int count = 0;
do {
outputStream.write( buffer, 0, count );
@@ -91,7 +89,7 @@
in.close();
writeLn( outputStream, "" );
- }
+ }
writeLn( outputStream, "--" + BOUNDARY + "--" );
}
Index: NodeUtils.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/NodeUtils.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NodeUtils.java 2001/07/31 16:08:59 1.6
+++ NodeUtils.java 2001/11/09 18:35:14 1.7
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000, Russell Gold
+* Copyright (c) 2000-2001, 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
@@ -19,10 +19,14 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
import java.util.Stack;
-import java.util.Vector;
-import org.w3c.dom.*;
/**
* Some common utilities for manipulating DOM nodes.
Index: PostMethodWebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/PostMethodWebRequest.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- PostMethodWebRequest.java 2001/10/19 18:26:29 1.17
+++ PostMethodWebRequest.java 2001/11/09 18:35:14 1.18
@@ -24,11 +24,7 @@
import java.io.IOException;
import java.io.OutputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
import java.net.URL;
-import java.net.URLConnection;
import java.util.Dictionary;
import java.util.Hashtable;
Index: ReceivedPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ReceivedPage.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ReceivedPage.java 2001/10/26 15:41:04 1.15
+++ ReceivedPage.java 2001/11/09 18:35:14 1.16
@@ -102,7 +102,7 @@
matches.addElement( NodeUtils.getNodeAttribute( nl.item(i), "content" ) );
}
}
- String result[] = new String[ matches.size() ];
+ String[] result = new String[ matches.size() ];
matches.copyInto( result );
return result;
}
Index: SubmitButton.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/SubmitButton.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SubmitButton.java 2001/07/31 16:08:59 1.3
+++ SubmitButton.java 2001/11/09 18:35:14 1.4
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000, Russell Gold
+* Copyright (c) 2000-2001, 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
@@ -19,12 +19,8 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.net.URL;
+import org.w3c.dom.Node;
-import java.util.*;
-
-import org.w3c.dom.*;
-
/**
* This class represents a suubmit button in an HTML form.
**/
@@ -97,10 +93,10 @@
//------------------------------------------ private members ----------------------------------
- Node _node;
- String _name;
- String _value;
- boolean _isImageButton;
+ private Node _node;
+ private String _name;
+ private String _value;
+ private boolean _isImageButton;
private SubmitButton() {
Index: TableCell.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/TableCell.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TableCell.java 2001/04/02 01:53:21 1.6
+++ TableCell.java 2001/11/09 18:35:14 1.7
@@ -21,10 +21,8 @@
*******************************************************************************************************************/
import java.net.URL;
-import java.util.Stack;
-import java.util.Vector;
-
-import org.w3c.dom.*;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
Index: WebFrame.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebFrame.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WebFrame.java 2000/10/11 19:15:11 1.3
+++ WebFrame.java 2001/11/09 18:35:14 1.4
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000, Russell Gold
+* Copyright (c) 2000-2001, 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
@@ -21,12 +21,8 @@
*******************************************************************************************************************/
import java.net.URL;
-import java.util.Stack;
-import java.util.Vector;
+import org.w3c.dom.Node;
-import org.w3c.dom.*;
-
-
/**
* A frame in a web page.
**/
@@ -66,10 +62,10 @@
//----------------------------------- private fields and methods -----------------------------------
- Node _element;
+ private Node _element;
- URL _baseURL;
+ private URL _baseURL;
- String _name;
+ private String _name;
}
Index: WebLink.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- WebLink.java 2001/11/05 15:50:38 1.10
+++ WebLink.java 2001/11/09 18:35:14 1.11
@@ -21,12 +21,10 @@
*******************************************************************************************************************/
import java.net.URL;
-import java.util.Vector;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.StringTokenizer;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
/**
@@ -34,7 +32,7 @@
* structure of the link (as a DOM), or create a {@tag WebRequest} to simulate clicking
* on the link.
*
- * @author Russell Gold
+ * @author <a href="mailto:rus...@ac...">Russell Gold</a>
* @author <a href="mailto:ben...@av...>Benoit Xhenseval</a>
**/
public class WebLink extends WebRequestSource {
@@ -54,8 +52,8 @@
* Strips a URL from its parameters
**/
private String getBareURL() {
- String url = getURLString();
- int questionMarkIndex = url.indexOf("?");
+ final String url = getURLString();
+ final int questionMarkIndex = url.indexOf("?");
if (questionMarkIndex >= 1 && questionMarkIndex < url.length() - 1) {
return url.substring(0, questionMarkIndex);
}
@@ -77,8 +75,8 @@
* Gets all parameters from a URL
**/
private String getParametersString() {
- String url = getURLString();
- int questionMarkIndex = url.indexOf("?");
+ final String url = getURLString();
+ final int questionMarkIndex = url.indexOf("?");
if (questionMarkIndex >= 1 && questionMarkIndex < url.length() - 1) {
return url.substring(questionMarkIndex + 1);
}
@@ -101,10 +99,11 @@
* add a pair key-value to the hashtable, creates an array of values if param already exists.
**/
private void stripOneParameter( Hashtable params, String param ) {
- int index = param.indexOf( "=" );
- String value = (index < 0 || index == param.length() - 1)
- ? ""
- : HttpUnitUtils.decode( param.substring( index + 1 ) );
+ final int index = param.indexOf( "=" );
+ String value = ((index < 0) ? null
+ : ((index == param.length() - 1)
+ ? ""
+ : HttpUnitUtils.decode( param.substring( index + 1 ) )));
String key = (index < 0) ? param : HttpUnitUtils.decode( param.substring( 0, index ) );
params.put( key, withNewValue( (String[]) params.get( key ), value ) );
}
Index: WebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- WebRequest.java 2001/11/08 22:07:52 1.27
+++ WebRequest.java 2001/11/09 18:35:14 1.28
@@ -4,12 +4,12 @@
*
* Copyright (c) 2000-2001, 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
+* 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
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
-* The above copyright notice and this permission notice shall be included in all copies or substantial portions
+* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
@@ -61,7 +61,7 @@
/**
- * Sets the file for a parameter upload in a web request.
+ * Sets the file for a parameter upload in a web request.
**/
public void selectFile( String parameterName, File file ) {
assertFileParameter( parameterName );
@@ -140,8 +140,8 @@
_parameters.remove( name );
}
+
-
/**
* Returns the final URL associated with this web request.
**/
@@ -189,8 +189,8 @@
protected WebRequest( String urlString ) {
this( (URL) null, urlString );
}
-
-
+
+
/**
* Constructs a web request using a base URL and a relative URL string.
**/
@@ -225,8 +225,8 @@
}
}
-
+
/**
* Constructs a web request using a base request and a relative URL string.
**/
@@ -272,7 +272,7 @@
return _sourceForm.getCharacterSet();
}
}
-
+
/**
* Performs any additional processing necessary to complete the request.
@@ -446,8 +446,8 @@
private void appendParameter( StringBuffer sb, String name, String value, boolean moreToCome ) {
- sb.append( encode( name ) ).append( '=' );
- sb.append( encode( value ) );
+ sb.append( encode( name ) );
+ if (value != null) sb.append( '=' ).append( encode( value ) );
if (moreToCome) sb.append( '&' );
}
@@ -587,14 +587,14 @@
}
- private static void registerSSLProtocolHandler() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+ private static void registerSSLProtocolHandler() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
String list = System.getProperty( PROTOCOL_HANDLER_PKGS );
Method setMethod = System.class.getMethod( "setProperty", new Class[] { String.class, String.class } );
if (list == null || list.length() == 0) {
setMethod.invoke( null, new String[] { PROTOCOL_HANDLER_PKGS, SSL_PROTOCOL_HANDLER } );
} else if (list.indexOf( SSL_PROTOCOL_HANDLER ) < 0) {
setMethod.invoke( null, new String[] { PROTOCOL_HANDLER_PKGS, SSL_PROTOCOL_HANDLER + " | " + list } );
- }
+ }
}
|