[jboss-svn-commits] JBoss Common SVN: r2854 - in common-core/trunk/src: test/java/org/jboss/test/util/test/protocol and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Jun 8 11:52:46 EDT 2008


Author: dimitris at jboss.org
Date: 2008-06-08 11:52:45 -0400 (Sun, 08 Jun 2008)
New Revision: 2854

Modified:
   common-core/trunk/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java
   common-core/trunk/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java
Log:
JBCOMMON-55, fix the test and remove the 'file' protocol from the initialization list

Modified: common-core/trunk/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java
===================================================================
--- common-core/trunk/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java	2008-05-30 18:39:39 UTC (rev 2853)
+++ common-core/trunk/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java	2008-06-08 15:52:45 UTC (rev 2854)
@@ -1,30 +1,30 @@
 /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.net.protocol;
 
 import java.net.URL;
 import java.net.URLStreamHandler;
+import java.util.ArrayList;
 import java.util.Collections;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -50,14 +50,14 @@
  * @author Scott.Stark at jboss.org
  */
 @SuppressWarnings("unchecked")
-public class URLStreamHandlerFactory
-   implements java.net.URLStreamHandlerFactory
+public class URLStreamHandlerFactory implements java.net.URLStreamHandlerFactory
 {
    /** Class logger. */
    private static final Logger log = Logger.getLogger(URLStreamHandlerFactory.class);
    
    /** The package prefix where JBoss protocol handlers live. */
    public static final String PACKAGE_PREFIX = "org.jboss.net.protocol";
+   
    /** A map of protocol names to handlers. Since there can only be one
     URLStreamHandlerFactory installed, this is a static map that may be
     cleared.
@@ -99,6 +99,7 @@
     property + the org.jboss.net.protocol default package.
     */
    private String[] handlerPkgs = {PACKAGE_PREFIX};
+   
    /** The last java.protocol.handler.pkgs value. Used to determine if the
     java.protocol.handler.pkgs property has changed since handlerPkgs was
     last built.
@@ -107,8 +108,7 @@
 
    /** A list of JBoss specific protocols for preloading. */
    public static final String PROTOCOLS[] = {
-      "resource",
-      "file"
+      "resource"
    };
 
    /**

Modified: common-core/trunk/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java
===================================================================
--- common-core/trunk/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java	2008-05-30 18:39:39 UTC (rev 2853)
+++ common-core/trunk/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java	2008-06-08 15:52:45 UTC (rev 2854)
@@ -32,6 +32,7 @@
  * Tests of the expected jdk file: url connection protocol handler behaviors.
  * 
  * @author Scott.Stark at jboss.org
+ * @author Dimitris.Andreadis at jboss.org
  * @version $Revision:$
  */
 public class FileURLConnectionTestCase extends TestCase
@@ -42,19 +43,24 @@
       File tmp = File.createTempFile("testLastModified", "test");
       tmp.deleteOnExit();
       long lastModified = tmp.lastModified();
-      System.out.println(tmp.getAbsolutePath()+", lastModified:"+lastModified);
+      System.out.print(tmp.getAbsolutePath()+", lastModified:"+lastModified);
       URL tmpURL = tmp.toURL();
       URLConnection tmpConn = tmpURL.openConnection();
       assertEquals(lastModified, tmpConn.getLastModified());
       long lastModifiedHdr = tmpConn.getHeaderFieldDate("Last-Modified", 0);
-      System.out.println("Last-Modified: "+lastModifiedHdr);
-      assertEquals(lastModified, lastModifiedHdr);
+      System.out.println(", Last-Modified: "+lastModifiedHdr);
+      System.out.println("Got URLConnection of type: " + tmpConn.getClass().getName());
+      // the last-modified header is expected to strip the milliseconds to
+      // comply with the (dd MMM yyyy HH:mm:ss) format, so the following assertions
+      // is invalid on windows that provide millisecond accuracy to File.lastModified()
+      // see, http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4504473
+      // assertEquals(lastModified, lastModifiedHdr);
    }
 
    public void testLength()
       throws Exception
    {
-      File tmp = File.createTempFile("testLastModified", "test");
+      File tmp = File.createTempFile("testLength", "test");
       tmp.deleteOnExit();
       FileOutputStream fos = new FileOutputStream(tmp);
       fos.write("testLength".getBytes());




More information about the jboss-svn-commits mailing list