This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: getHeaderFields test fixlet and new tests


Hi,

I committed the following patch to correct an minor issue with http tests
and extended the tests for the other protocols. We pass all tests.

2006-03-06  Wolfgang Baer  <WBaer@gmx.de>

	* gnu/testlet/java/net/URLConnection/getHeaderFields.java:
	(check): Use checkPoint instead of test names. Fix header key = String
	test to use second header entry to work on http.
	(test): Extend the basic test to all protocol implementations.

Wolfgang

Index: getHeaderFields.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/net/URLConnection/getHeaderFields.java,v
retrieving revision 1.1
diff -u -r1.1 getHeaderFields.java
--- getHeaderFields.java	1 Dec 2004 07:51:45 -0000	1.1
+++ getHeaderFields.java	6 Mar 2006 19:59:53 -0000
@@ -1,6 +1,7 @@
 /* getHeaderFields.java --
-   Copyright (c) 2004 by Free Software Foundation, Inc.
+   Copyright (c) 2004, 2006 by Free Software Foundation, Inc.
    Written by Michael Koch <konqueror@gmx.de>
+   Written by Wolfgang Baer <WBaer@gmx.de>
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
@@ -12,18 +13,23 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation
-   Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA */
+   along with this program; if not, write to the Free Software Foundation,
+   51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA. */
 
 package gnu.testlet.java.net.URLConnection;
 
+import gnu.testlet.ResourceNotFoundException;
 import gnu.testlet.TestHarness;
 import gnu.testlet.Testlet;
 
+import java.io.File;
 import java.io.IOException;
 import java.net.*;
 import java.util.*;
 
+/**
+ * Tests getHeaderFields for the various protocol implementations.
+ */
 public class getHeaderFields implements Testlet
 {
   private void check(TestHarness h, String urlString)
@@ -36,13 +42,13 @@
 
 	Map headers = conn.getHeaderFields();
     
-	h.check(headers != null, "returned valid Map object");
+	h.check(headers != null);
 
 	if (! headers.isEmpty())
 	  {
-	    Map.Entry entry = (Map.Entry) headers.entrySet().toArray()[0];
-	    h.check(entry.getKey() instanceof String, "key is instance of java.lang.String");
-	    h.check(entry.getValue() instanceof List, "value is instance of java.util.List");
+	    Map.Entry entry = (Map.Entry) headers.entrySet().toArray()[1];
+	    h.check(entry.getKey() instanceof String);
+	    h.check(entry.getValue() instanceof List);
 	  }
       }
     catch (MalformedURLException e)
@@ -58,11 +64,31 @@
   public void test(TestHarness h)
   {
     // Returns a map of headers.
+    h.checkPoint("Test HTTP");
     check(h, "http://www.gnu.org/";);
 
     // Returns an empty map.
+    h.checkPoint("Test FTP");
     check(h, "ftp://ftp.gnu.org";);
-
-    // FIXME: We should check jar: and other protocol implementations here too.
+        
+    // Returns a map of headers.
+    h.checkPoint("Test HTTPS");
+    check(h, "https://www.gmx.net/";);
+    
+    try
+      {
+        // Returns an empty map.
+        h.checkPoint("Test JAR");
+        File jarfile = h.getResourceFile("gnu#testlet#java#util#jar#JarFile#jartest.jar");    
+        check(h, "jar:file:" + jarfile.toString() + "!/");
+        
+        h.checkPoint("Test File");
+        check(h, "file://" + jarfile.toString());
+      }
+    catch (ResourceNotFoundException e)
+      {
+        h.debug("Unexpected exception");
+        h.debug(e);
+      }
   }
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]