incubator-depot-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: rev 10515 - in incubator/depot/trunk/update/src: java/org/apache/depot/update/util/io java/org/apache/depot/update/util/net test/org/apache/depot/update/util/io test/org/apache/depot/update/util/net
Date Mon, 03 May 2004 20:57:40 GMT
Author: ajack
Date: Mon May  3 13:57:40 2004
New Revision: 10515

Modified:
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java
   incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/VirtualResourceLocator.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/FileTests.java
   incubator/depot/trunk/update/src/test/org/apache/depot/update/util/net/VirtualResourceLocatorTests.java
Log:
Working on file utilities.


Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/io/FileUtils.java	Mon
May  3 13:57:40 2004
@@ -64,12 +64,11 @@
 		String str = null;
 		try {
 			str = toURI(file.getAbsolutePath());
-
 			url = new URL(str);
 		} catch (MalformedURLException e) {
 			//:TODO: Ought never happen, so it is a bug on
 			// us ..
-			throw new UpdateRuntimeException("Bogus: " + str, e);
+			throw new UpdateRuntimeException("Bogus: " + file + " ? " + str, e);
 		}
 
 		return url;
@@ -85,13 +84,6 @@
 		String pathString = path.getAbsolutePath();
 
 		StringBuffer sb = new StringBuffer(UpdateConstants.FILE_PREFIX);
-
-		// add an extra slash for filesystems with drive-specifiers
-		//:TODO: determine if too dodgy.
-		if (!pathString.startsWith(File.separator)
-				&& (-1 != pathString.indexOf(":"))) {
-			sb.append("/");
-		}
 
 		//
 		// Make and DOS \ into /

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/VirtualResourceLocator.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/VirtualResourceLocator.java
(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/net/VirtualResourceLocator.java
Mon May  3 13:57:40 2004
@@ -84,7 +84,7 @@
 
 		// Extract Protocol
 		int colonPosn = url.indexOf(':');
-		if (-1 != colonPosn)
+		if ( (-1 != colonPosn) && ( 1 < colonPosn) )
 			m_protocol = url.substring(0, colonPosn);
 		else
 			m_protocol = Protocol.FILE_PROTOCOL;

Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/FileTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/FileTests.java	(original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/util/io/FileTests.java	Mon
May  3 13:57:40 2004
@@ -55,8 +55,12 @@
 	public void testURIs() throws Exception {
 		String uri1 = FileUtils.toURI(ResolvedFile.resolve("."));
 		String uri2 = FileUtils.toURI(ResolvedFile.resolve(SystemUtils.getCWD().getAbsoluteFile()));
-
 		assertEquals("Equal", uri1, uri2);
+	}
+	
+	public void testURIsWithColons() throws Exception {
+		String uri = FileUtils.toURI("X:/Fred");
+		assertEquals("Equal", "file://X:/Fred", uri);
 	}
 
 	public static void main(String[] args) {

Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/util/net/VirtualResourceLocatorTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/util/net/VirtualResourceLocatorTests.java
(original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/util/net/VirtualResourceLocatorTests.java
Mon May  3 13:57:40 2004
@@ -20,6 +20,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.depot.common.util.debug.DebugUtils;
 import org.apache.depot.update.protocols.Protocol;
 import org.apache.depot.update.util.io.ResolvedFile;
 
@@ -55,6 +56,21 @@
 			"File Protocol",
 			Protocol.FILE_PROTOCOL,
 			vrl.getProtocol());
+	}
+
+	public void testVRLToFromMicrosoftFile() throws Exception {
+		VirtualResourceLocator vrl =
+			new VirtualResourceLocator(ResolvedFile.resolve("X:\\Fred"));
+
+		assertEquals(
+			"File Protocol",
+			Protocol.FILE_PROTOCOL,
+			vrl.getProtocol());
+		
+		assertEquals(
+				"URL",
+				"file://X:/Fred",
+				vrl.toExternalForm());
 	}
 
 	public void testEquals() {

Mime
View raw message