You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ar...@hyperreal.org on 1999/11/12 03:41:44 UTC
cvs commit: jakarta-tomcat/src/tests/share/tests/request Post.java RequestMap.java get.properties post.properties
arun 99/11/11 18:41:44
Modified: src/tests/share/tests/request Post.java RequestMap.java
get.properties post.properties
Log:
Merging TOMCAT_J2EE branch with the main trunk.
Revision Changes Path
1.7 +49 -47 jakarta-tomcat/src/tests/share/tests/request/Post.java
Index: Post.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/tests/share/tests/request/Post.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Post.java 1999/11/11 22:09:30 1.6
+++ Post.java 1999/11/12 02:41:41 1.7
@@ -30,7 +30,7 @@
StringBuffer msg = new StringBuffer("");
String testsKey = props.getProperty("tests");
String debugS = props.getProperty("Debug");
- debug = Boolean.valueOf(debugS).booleanValue();
+ debug = Boolean.valueOf(debugS).booleanValue();
if (testsKey != null) {
Vector tests = new Vector();
@@ -42,17 +42,17 @@
}
Enumeration testNames = tests.elements();
-
+
while (testNames.hasMoreElements()) {
String testId = (String)testNames.nextElement();
if (! test(testId)) {
- status = false;
- String description = props.getProperty("test." + testId +
- ".description");
- msg.append("\tTest " + testId + " : " +
- description);
+ status = false;
+ String description = props.getProperty("test." + testId +
+ ".description");
+ msg.append("\tTest " + testId + " : " +
+ description);
}
}
}
@@ -67,9 +67,9 @@
}
private void init() {
-
- InputStream in =
- this.getClass().getResourceAsStream(PropFileName);
+
+ InputStream in =
+ this.getClass().getResourceAsStream(PropFileName);
if (in != null) {
try {
props.load(in);
@@ -88,23 +88,25 @@
String response = dispatch(testId);
String magnitude = props.getProperty("test." + testId + ".magnitude", "true");
- boolean testCondition = Boolean.valueOf(magnitude).booleanValue();
+ boolean testCondition = Boolean.valueOf(magnitude).booleanValue();
+
+ String responseKey = props.getProperty("test." + testId + ".response");
+ boolean responseStatus = (response.indexOf(responseKey) > -1) ? true : false;
- String responseKey = props.getProperty("test." + testId + ".response");
- boolean responseStatus = (response.indexOf(responseKey) > -1) ? true : false;
-
- if( testCondition!=responseStatus) {
- System.out.println("POST error in " + testId );
- System.out.println("Expecting: " + responseKey);
- System.out.println("Response: " + response);
- }
+ if( testCondition!=responseStatus) {
+ System.out.println("POST error in " + testId );
+ if (testCondition != true)
+ System.out.print("Not ");
+ System.out.println("Expecting: " + responseKey);
+ System.out.println("Response: " + response);
+ }
return testCondition==responseStatus;
}
private String dispatch(String testId) {
boolean responseStatus = false;
- String response="";
-
+ String response="";
+
openIO();
if (ready()) {
@@ -119,20 +121,20 @@
closeIO();
- return response;
+ return response;
}
private void openIO() {
if (ready()) {
closeIO();
}
-
+
try {
s = SocketHelper.getSocket();
pw = new PrintWriter(new OutputStreamWriter(
- s.getOutputStream()));
+ s.getOutputStream()));
br = new BufferedReader(new InputStreamReader(
- s.getInputStream()));
+ s.getInputStream()));
} catch (UnknownHostException uhe) {
uhe.printStackTrace();
} catch (UnsupportedEncodingException uee) {
@@ -164,16 +166,16 @@
private void writeRequest(String testId)
throws IOException {
- String request = props.getProperty("test." + testId + ".request");
+ String request = props.getProperty("test." + testId + ".request");
if (request == null) {
return;
}
- String description = props.getProperty("test." + testId + ".description");
- String response = props.getProperty("test." + testId + ".response");
- String host = props.getProperty("test." + testId + ".host");
- String connection = props.getProperty("test." + testId + ".connection");
- String encoding = props.getProperty("test." + testId + ".encoding");
- String content = props.getProperty("test." + testId + ".content");
+ String description = props.getProperty("test." + testId + ".description");
+ String response = props.getProperty("test." + testId + ".response");
+ String host = props.getProperty("test." + testId + ".host");
+ String connection = props.getProperty("test." + testId + ".connection");
+ String encoding = props.getProperty("test." + testId + ".encoding");
+ String content = props.getProperty("test." + testId + ".content");
if (this.debug)
@@ -196,7 +198,7 @@
}
pw.flush();
-
+
}
private String getResponse()
@@ -206,18 +208,18 @@
if (this.debug)
System.out.println("<--------");
- try {
- while ((line = br.readLine()) != null) {
- if (this.debug)
- System.out.println("\t" + line);
- sb.append(line);
- sb.append('\n');
- }
- } catch(java.net.SocketException ex ) {
- // server closed connection before reading the request.
- // Happens on Linux - it is safe to ignore the request.
- // System.out.println("Connection reset by peer - before full request read ");
- }
+ try {
+ while ((line = br.readLine()) != null) {
+ if (this.debug)
+ System.out.println("\t" + line);
+ sb.append(line);
+ sb.append('\n');
+ }
+ } catch(java.net.SocketException ex ) {
+ // server closed connection before reading the request.
+ // Happens on Linux - it is safe to ignore the request.
+ // System.out.println("Connection reset by peer - before full request read ");
+ }
if (this.debug)
System.out.println("-------->");
@@ -231,8 +233,8 @@
private PrintWriter pw = null;
private BufferedReader br = null;
private Properties props = null;
-
- private static final String PropFileName = "post.properties";
+
+ private static final String PropFileName = "post.properties";
private boolean debug = false;
}
1.5 +103 -103 jakarta-tomcat/src/tests/share/tests/request/RequestMap.java
Index: RequestMap.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/tests/share/tests/request/RequestMap.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RequestMap.java 1999/11/11 22:09:34 1.4
+++ RequestMap.java 1999/11/12 02:41:42 1.5
@@ -42,39 +42,39 @@
public TestResult runTest() {
TestResult testResult = new TestResult();
- Properties props = new Properties();
+ Properties props = new Properties();
- init(props);
+ init(props);
- boolean status = true;
- StringBuffer msg = new StringBuffer();
- String testsKey = props.getProperty("tests");
- String debugS = props.getProperty("Debug");
- debug = Boolean.valueOf(debugS).booleanValue();
+ boolean status = true;
+ StringBuffer msg = new StringBuffer();
+ String testsKey = props.getProperty("tests");
+ String debugS = props.getProperty("Debug");
+ debug = Boolean.valueOf(debugS).booleanValue();
- if (testsKey != null) {
- Vector tests = new Vector();
+ if (testsKey != null) {
+ Vector tests = new Vector();
- StringTokenizer stok = new StringTokenizer(testsKey, ",");
+ StringTokenizer stok = new StringTokenizer(testsKey, ",");
- while (stok.hasMoreTokens()) {
- tests.addElement(stok.nextToken().trim());
- }
+ while (stok.hasMoreTokens()) {
+ tests.addElement(stok.nextToken().trim());
+ }
- Enumeration testNames = tests.elements();
+ Enumeration testNames = tests.elements();
- while (testNames.hasMoreElements()) {
+ while (testNames.hasMoreElements()) {
boolean localStatus = true;
- String testId = (String)testNames.nextElement();
+ String testId = (String)testNames.nextElement();
String description = props.getProperty("test." + testId +
- ".description");
- String request = props.getProperty("test." + testId +
- ".request");
- String response = props.getProperty("test." + testId +
- ".response");
- String magnitude = props.getProperty("test." + testId +
- ".magnitude", "true");
+ ".description");
+ String request = props.getProperty("test." + testId +
+ ".request");
+ String response = props.getProperty("test." + testId +
+ ".response");
+ String magnitude = props.getProperty("test." + testId +
+ ".magnitude", "true");
try {
if (request.indexOf("://") > -1) {
@@ -100,39 +100,39 @@
if (this.debug) {
System.out.println(testId + ". Request: " + request +
- " Response: " + response);
+ " Response: " + response);
}
if (! localStatus || ! test(request, response,
- Boolean.valueOf(magnitude).booleanValue())) {
+ Boolean.valueOf(magnitude).booleanValue())) {
status = false;
msg.append("Test " + testId + " : " +
- description);
- }
- }
- }
-
- testResult.setStatus(status);
-
- if (msg.length() > 0) {
- testResult.setMessage(msg.toString());
- }
+ description);
+ }
+ }
+ }
- return testResult;
+ testResult.setStatus(status);
+
+ if (msg.length() > 0) {
+ testResult.setMessage(msg.toString());
+ }
+
+ return testResult;
}
private void init(Properties props) {
- InputStream in =
- this.getClass().getResourceAsStream(PropFileName);
+ InputStream in =
+ this.getClass().getResourceAsStream(PropFileName);
if (in != null) {
- try {
- props.load(in);
+ try {
+ props.load(in);
in.close();
- } catch (IOException ioe) {
- if (this.debug) {
- ioe.printStackTrace();
- }
- }
+ } catch (IOException ioe) {
+ if (this.debug) {
+ ioe.printStackTrace();
+ }
+ }
} else
System.out.println("Resource file not found: " + PropFileName);
}
@@ -150,7 +150,7 @@
String line = null;
while ((line = br.readLine()) != null) {
- sb.append(line.trim());
+ sb.append(line.trim());
}
isr.close();
@@ -160,56 +160,56 @@
}
private boolean test(String request, String responseKey,
- boolean testCondition) {
+ boolean testCondition) {
boolean returnStatus = false;
- if (request == null || responseKey == null) {
- return ! testCondition;
- }
+ if (request == null || responseKey == null) {
+ return ! testCondition;
+ }
String response = dispatch(request);
- boolean responseStatus =
- (response.indexOf(responseKey) > -1) ? true : false;
+ boolean responseStatus =
+ (response.indexOf(responseKey) > -1) ? true : false;
- return (testCondition) ? responseStatus : ! responseStatus;
+ return (testCondition) ? responseStatus : ! responseStatus;
}
private String dispatch(String request) {
String response = null;
openIO();
+
+ if (ready()) {
+ try {
+ writeRequest(request);
- if (ready()) {
- try {
- writeRequest(request);
-
- response = getResponse();
-
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
- }
+ response = getResponse();
- closeIO();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
- return response;
+ closeIO();
+
+ return response;
}
private void openIO() {
if (ready()) {
- closeIO();
+ closeIO();
}
- try {
- s = SocketHelper.getSocket();
- pw = new PrintWriter(new OutputStreamWriter(
- s.getOutputStream()));
- bw = new BufferedWriter(new OutputStreamWriter(
- s.getOutputStream()));
- br = new BufferedReader(new InputStreamReader(
- s.getInputStream()));
- } catch (UnknownHostException uhe) {
- uhe.printStackTrace();
+ try {
+ s = SocketHelper.getSocket();
+ pw = new PrintWriter(new OutputStreamWriter(
+ s.getOutputStream()));
+ bw = new BufferedWriter(new OutputStreamWriter(
+ s.getOutputStream()));
+ br = new BufferedReader(new InputStreamReader(
+ s.getInputStream()));
+ } catch (UnknownHostException uhe) {
+ uhe.printStackTrace();
} catch (UnsupportedEncodingException uee) {
uee.printStackTrace();
} catch (IOException ioe) {
@@ -222,33 +222,33 @@
}
private void closeIO() {
+ try {
+ br.close();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+
+ try {
+ bw.close();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+
try {
- br.close();
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
-
- try {
- bw.close();
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
-
- try {
- s.close();
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
+ s.close();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
}
private void writeRequest(String request)
throws IOException {
bw.write(request);
- bw.write('\r');
- bw.write('\n');
- bw.write('\n');
+ bw.write('\r');
+ bw.write('\n');
+ bw.write('\n');
- bw.flush();
+ bw.flush();
}
private String getResponse()
@@ -257,16 +257,16 @@
String line = null;
if (this.debug)
- System.out.println("<--------");
+ System.out.println("<--------");
while ((line = br.readLine()) != null) {
- if (this.debug)
- System.out.println("\t" + line);
- sb.append(line);
- sb.append('\n');
+ if (this.debug)
+ System.out.println("\t" + line);
+ sb.append(line);
+ sb.append('\n');
}
if (this.debug)
- System.out.println("-------->");
+ System.out.println("-------->");
- return sb.toString();
+ return sb.toString();
}
}
1.7 +9 -6 jakarta-tomcat/src/tests/share/tests/request/get.properties
Index: get.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/tests/share/tests/request/get.properties,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- get.properties 1999/11/11 22:09:38 1.6
+++ get.properties 1999/11/12 02:41:42 1.7
@@ -6,8 +6,9 @@
Debug:false
-tests:1,2,5,6,8,9,11,12,18,19,20
+tests:1,2,5,6,8,9,11,12,18,19,20,21
+
test.1.description:/request/uri/does/not/exist : 0.9 : 404
test.1.request:GET /request/uri/does/not/exist
test.1.response:Error: 404
@@ -70,15 +71,13 @@
test.12.response:HTTP/1.0 400 Bad Request
test.12.magnitude:true
-# If request is empty, why do we expect 0.9 response?
-#test.13.description: : 0.9 : 400
+#test.13.description: : : 400
#test.13.request:
#test.13.response:Error: 400
#test.13.magnitude:true
-# duplicate
# test.14.description: : 0.9 : 400
-# test.14.request:
+# test.14.request: /
# test.14.response:Error: 400
# test.14.magnitude:true
@@ -100,7 +99,7 @@
test.18.description:/servlet : 1.0 : 404
test.18.request:GET /servlet HTTP/1.0
-test.18.response:HTTP/1.0 404
+test.18.response:HTTP/1.0 404 Not Found
test.18.magnitude:true
test.19.description:/servlet/ : 1.0 : 403
@@ -113,3 +112,7 @@
test.20.response:HTTP/1.0 404 Not Found
test.20.magnitude:true
+test.21.description:/servlet/jsp : 1.0 : 404
+test.21.request:GET /servlet/jsp HTTP/1.0
+test.21.response:HTTP/1.0 200 OK
+test.21.magnitude:false
\ No newline at end of file
1.6 +1 -1 jakarta-tomcat/src/tests/share/tests/request/post.properties
Index: post.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/tests/share/tests/request/post.properties,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- post.properties 1999/11/11 22:09:41 1.5
+++ post.properties 1999/11/12 02:41:42 1.6
@@ -62,7 +62,7 @@
test.7.host:Localhost
test.7.connection:close
test.7.content:
-test.7.response:HTTP/1.0 404
+test.7.response:HTTP/1.0 404 Not Found
test.7.magnitude:true
test.8.description:/servlet/ : 1.0 : 403