* URLTest - The world has changed
@ 2002-04-05 7:09 Mark Wielaard
2002-04-14 10:00 ` Mark Wielaard
0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2002-04-05 7:09 UTC (permalink / raw)
To: mauve-discuss
[-- Attachment #1: Type: text/plain, Size: 339 bytes --]
Hi,
The web pages referred to by URLTest are now served by newer http
daemons, have cooler content, etc.
* gnu/testlet/java/net/URL/URLTest.java (test_openConnection): Be less
strict in server name/version (Apache) and content type (text/html)
(test_openStream): Be less strict in actual content (HTML).
Any objections?
Cheers,
Mark
[-- Attachment #2: URLTest.patch --]
[-- Type: text/x-patch, Size: 1349 bytes --]
Index: gnu/testlet/java/net/URL/URLTest.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/net/URL/URLTest.java,v
retrieving revision 1.3
diff -u -r1.3 URLTest.java
--- URLTest.java 2000/03/04 02:19:21 1.3
+++ URLTest.java 2002/04/05 15:04:51
@@ -128,9 +128,11 @@
URLConnection conn = url.openConnection();
- harness.check (conn.getHeaderField(2), "Apache/1.3.9 (Unix)");
+ harness.check (conn.getHeaderField(2).indexOf("Apache") != -1,
+ "I want my Apache server!");
String conttype = conn.getContentType();
- harness.check (conttype, "text/html");
+ harness.check (conttype.indexOf("text/html") != -1,
+ "Content must be text/html");
Object obj = url.getContent();
harness.check (url.toExternalForm(),
@@ -156,11 +158,12 @@
URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
java.io.InputStream conn = url.openStream();
- byte b [] = new byte[6];
- conn.read(b , 0 , 6 );
+ byte b [] = new byte[256];
+ conn.read(b , 0 , 256 );
String str = new String( b ) ;
- harness.check (str, "<HTML>");
+ harness.check (str.indexOf("HTML") != -1,
+ "Need some HTML");
}catch ( Exception e ){
harness.fail(" Error in test_openStream - 2 " +
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: URLTest - The world has changed
2002-04-05 7:09 URLTest - The world has changed Mark Wielaard
@ 2002-04-14 10:00 ` Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2002-04-14 10:00 UTC (permalink / raw)
To: mauve-discuss
[-- Attachment #1: Type: text/plain, Size: 503 bytes --]
Hi,
On Fri, 2002-04-05 at 17:09, Mark Wielaard wrote:
>
> The web pages referred to by URLTest are now served by newer http
> daemons, have cooler content, etc.
The same is true for the URLConnectionTest.
2002-04-14 Mark Wielaard <mark@klomp.org>
* gnu/testlet/java/net/URLConnection/URLConnectionTest.java:
sourceware.cygnus.com -> sources.redhat.com.
Don't depend on order of HeaderFields.
It also removes some tests that depended on the order of the header
fields returned.
Cheers,
Mark
[-- Attachment #2: Type: text/x-patch, Size: 10013 bytes --]
Index: gnu/testlet/java/net/URLConnection/URLConnectionTest.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/net/URLConnection/URLConnectionTest.java,v
retrieving revision 1.1
diff -u -r1.1 URLConnectionTest.java
--- gnu/testlet/java/net/URLConnection/URLConnectionTest.java 29 Apr 1999 15:05:29 -0000 1.1
+++ gnu/testlet/java/net/URLConnection/URLConnectionTest.java 14 Apr 2002 16:55:03 -0000
@@ -47,7 +47,7 @@
harness.fail("Error: Handler - 55");
}
- URL url = new URL("http://sourceware.cygnus.com:80/mauve/testarea/index.html" );
+ URL url = new URL("http://sources.redhat.com:80/mauve/testarea/index.html" );
URLConnection conn = url.openConnection();
@@ -75,13 +75,13 @@
}
catch ( Exception e )
{
- e.printStackTrace();
+ harness.debug(e);
harness.fail("Error in test_Basics - 2 " +
" should not have raised exception here " );
}
catch ( Throwable e )
{
- e.printStackTrace();
+ harness.debug(e);
harness.fail("Error in test_Basics - 2 " +
" should not have raised Throwable here " );
}
@@ -94,7 +94,7 @@
try {
URLConnection.setDefaultAllowUserInteraction( false );
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
URLConnection conn = url.openConnection();
@@ -120,10 +120,11 @@
{
harness.checkPoint("getContentFunctions");
try {
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
URLConnection conn = url.openConnection();
+ // Cannot actually check size since it may return -1
int siz = conn.getContentLength();
String type = conn.getContentType();
@@ -133,29 +134,25 @@
java.io.InputStream is = (java.io.InputStream)conn.getContent();
- byte b[] = new byte[21];
- is.read( b , 0 , 7);;
+ byte b[] = new byte[256];
is.read( b , 0 , b.length);
String cont = new String( b );
- harness.check( type, "text/html",
+ harness.check( type.indexOf("text/html") != -1,
"Error in test_getContentFunctions - 1 " +
" content type was not correct " );
harness.check( enc, null, "Error in test_getContentFunctions - 2 " +
"encoding was not correct " );
- harness.check( siz, 1030, "Error in test_getContentFunctions - 3 " +
- "size was not correct " );
-
- harness.check ( cont, "<!DOCTYPE HTML PUBLIC",
+ harness.check ( cont.indexOf("<!DOCTYPE HTML PUBLIC") != -1,
"Error in test_getContentFunctions - 4 " +
"getContent did not return proper results " );
}
catch ( Exception e )
{
- e.printStackTrace();
+ harness.debug(e);
harness.fail("Error in test_getContentFunctions - 5 " +
" should not have raised exception here " );
}
@@ -166,7 +163,7 @@
{
harness.checkPoint("streams");
try {
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
URLConnection conn = url.openConnection();
@@ -185,7 +182,7 @@
}
try {
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
URLConnection conn = url.openConnection();
@@ -208,7 +205,7 @@
{
harness.checkPoint("DefaultRequestProperty");
try {
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
String str = HttpURLConnection.getDefaultRequestProperty("ACCEPT");
@@ -232,7 +229,7 @@
{
harness.checkPoint("DefaultUseCaches");
try {
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
URLConnection conn = url.openConnection();
boolean bool = conn.getDefaultUseCaches();
@@ -259,7 +256,7 @@
{
harness.checkPoint("DoInputOutput");
try {
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
URLConnection conn = url.openConnection();
boolean bool = conn.getDoInput();
@@ -288,21 +285,27 @@
{
harness.checkPoint("getHeaderField");
try {
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
URLConnection conn = url.openConnection();
String str0 = conn.getHeaderField(0);
- String str1 = conn.getHeaderField(1);
- String str2 = conn.getHeaderField(2);
- String str3 = conn.getHeaderField(3);
- String str4 = conn.getHeaderField(4);
- String str5 = conn.getHeaderField(5);
+ harness.debug("header-0: " + str0);
+ String str1 = conn.getHeaderField("Date");
+ harness.debug("header-1: " + str1);
+ String str2 = conn.getHeaderField("Server");
+ harness.debug("header-2: " + str2);
+ String str3 = conn.getHeaderField("Last-Modified");
+ harness.debug("header-3: " + str3);
+ String str4 = conn.getHeaderField("Transfer-Encoding");
+ harness.debug("header-4: " + str4);
+ String str5 = conn.getHeaderField("Content-Type");
+ harness.debug("header-5: " + str5);
harness.check ( str0, "HTTP/1.1 200 OK",
"Error in test_getHeaderField - 0 " +
" 0 header field wrong" );
- harness.check ( str2, "Apache/1.3.4 (Unix)",
+ harness.check ( str2.indexOf("Apache") != -1,
"Error in test_getHeaderField - 1 " +
" 2 header field wrong" );
@@ -310,42 +313,12 @@
"Error in test_getHeaderField - 2 " +
" 4 header field wrong" );
- harness.check ( str5, "text/html",
+ harness.check ( str5.indexOf("text/html") != -1,
"Error in test_getHeaderField - 3 " +
" 5 header field wrong" );
((HttpURLConnection)conn).disconnect();
- str1 = conn.getHeaderFieldKey(1);
- str2 = conn.getHeaderFieldKey(2);
- str3 = conn.getHeaderFieldKey(3);
- str4 = conn.getHeaderFieldKey(4);
- str5 = conn.getHeaderFieldKey(5);
-
- harness.check ( str0, "",
- "Error in test_getHeaderField - 4 " +
- " 0 headerkey field wrong" );
-
- harness.check ( str1, "Date",
- "Error in test_getHeaderField - 5 " +
- " first headerkey field wrong" );
-
- harness.check ( str2, "Server",
- "Error in test_getHeaderField - 6 " +
- " 2 headerkey field wrong" );
-
- harness.check ( str3, "Last-Modified",
- "Error in test_getHeaderField - 7 " +
- " 3 headerkey field wrong" );
-
- harness.check ( str4, "Transfer-Encoding",
- "Error in test_getHeaderField - 8 " +
- " 4 headerkey field wrong" );
-
- harness.check ( str5, "Content-Type",
- "Error in test_getHeaderField - 9 " +
- " 5 headerkey field wrong" );
-
}
catch ( Exception e )
{
@@ -358,7 +331,7 @@
{
harness.checkPoint("URLConnection");
try {
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
MyURLConnection conn = new MyURLConnection(url);
harness.check(conn.getURL(), url,
@@ -428,7 +401,7 @@
// if(!MyURLConnection.guessContentTypeFromStream(null).equals(""))
// harness.fail("Error in test_URLConnection - 22 ");
} catch (Exception e) {
- e.printStackTrace();
+ harness.debug(e);
harness.fail("Error in test_URLConnection - 23 " +
" should not have raised exception here " );
}
@@ -438,7 +411,7 @@
{
harness.checkPoint("HttpURLConnection");
try {
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
MyHttpURLConnection conn = new MyHttpURLConnection(url);
conn.setRequestMethod("GET");
harness.check(conn.getRequestMethod(), "GET",
@@ -449,7 +422,7 @@
harness.check(MyHttpURLConnection.getFollowRedirects(),
"Error in test_HttpURLConnection - 2 ");
} catch (Exception e) {
- e.printStackTrace();
+ harness.debug(e);
harness.fail("Error in test_HttpURLConnection - 3 " +
" should not have raised exception here " );
}
@@ -459,7 +432,7 @@
{
harness.checkPoint("HttpURLConnectionI");
try {
- URL url = new URL ( "http://sourceware.cygnus.com/mauve/testarea/index.html");
+ URL url = new URL ( "http://sources.redhat.com/mauve/testarea/index.html");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.getExpiration();
conn.getLastModified();
@@ -468,13 +441,9 @@
conn.usingProxy();
harness.check(true);
} catch (Exception e) {
- e.printStackTrace();
+ harness.debug(e);
harness.fail("Error in test_HttpURLConnectionI - 1 " +
" should not have raised exception here " );
- } catch (Throwable e) {
- e.printStackTrace();
- harness.fail("Error in test_HttpURLConnectionI - 1 " +
- " should not have raised Throwable here " );
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-04-14 17:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-05 7:09 URLTest - The world has changed Mark Wielaard
2002-04-14 10:00 ` Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).