commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1409638 - /commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/ConversionTestCase.java
Date Thu, 15 Nov 2012 02:20:15 GMT
Author: ggregory
Date: Thu Nov 15 02:20:15 2012
New Revision: 1409638

URL: http://svn.apache.org/viewvc?rev=1409638&view=rev
Log:
Adding @Ignore tests for VFS-443: Need an easy way to convert from a FileObject to a File.

Added:
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/ConversionTestCase.java
  (with props)

Added: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/ConversionTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/ConversionTestCase.java?rev=1409638&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/ConversionTestCase.java
(added)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/ConversionTestCase.java
Thu Nov 15 02:20:15 2012
@@ -0,0 +1,66 @@
+package org.apache.commons.vfs2.provider.local.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.vfs2.FileSystemManager;
+import org.apache.commons.vfs2.VFS;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Tests conversion from VFS to File.
+ * <p/>
+ * VFS-443 Need an easy way to convert from a FileObject to a File.
+ * 
+ * @version $Id$
+ */
+public class ConversionTestCase
+{
+
+    @Test
+    @Ignore
+    public void testFileNameWithSpaces() throws URISyntaxException, IOException
+    {
+        final File file = new File("target", "a name.txt");
+        final String fileURL = file.toURI().toURL().toExternalForm();
+        assertEquals(file.getAbsoluteFile(), new File(file.toURI().getPath()));
+        assertEquals(file.getAbsoluteFile(), new File(new URL(fileURL).toURI().getPath()));
+
+        final FileSystemManager manager = VFS.getManager();
+        final FileObject fo = manager.resolveFile(fileURL);
+        assertEquals(file.getAbsoluteFile(), new File(new URL(fo.getURL().toExternalForm()).toURI().getPath()));
+    }
+
+    @Test
+    @Ignore
+    public void testFileNameWithCharacters() throws URISyntaxException, IOException
+    {
+        final File file = new File("target", "+# %&.txt");
+        final String fileURL = file.toURI().toURL().toExternalForm();
+        assertEquals(file.getAbsoluteFile(), new File(file.toURI().getPath()));
+        assertEquals(file.getAbsoluteFile(), new File(new URL(fileURL).toURI().getPath()));
+        try
+        {
+            new FileOutputStream(file).close();
+            assertTrue(file.exists());
+
+            final FileSystemManager manager = VFS.getManager();
+            final FileObject fo = manager.resolveFile(fileURL);
+            assertTrue(fo.exists());
+            assertEquals(file.getAbsoluteFile(), new File(new URL(fo.getURL().toExternalForm()).toURI().getPath()));
+        }
+        finally
+        {
+            file.delete();
+        }
+    }
+
+}

Propchange: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/ConversionTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/ConversionTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message