commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1189775 - in /commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2: FileExtensionSelectorTest.java FileTypeSelectorTest.java
Date Thu, 27 Oct 2011 14:28:38 GMT
Author: ggregory
Date: Thu Oct 27 14:28:38 2011
New Revision: 1189775

URL: http://svn.apache.org/viewvc?rev=1189775&view=rev
Log:
New test for FileTypeSelector and Javadoc FileExtensionSelectorTest.

Added:
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/FileTypeSelectorTest.java
Modified:
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/FileExtensionSelectorTest.java

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/FileExtensionSelectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/FileExtensionSelectorTest.java?rev=1189775&r1=1189774&r2=1189775&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/FileExtensionSelectorTest.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/FileExtensionSelectorTest.java
Thu Oct 27 14:28:38 2011
@@ -25,6 +25,11 @@ import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+/**
+ * Tests FileExtensionSelector.
+ * 
+ * @since 2.1
+ */
 public class FileExtensionSelectorTest
 {
     private static FileObject BaseFolder;

Added: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/FileTypeSelectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/FileTypeSelectorTest.java?rev=1189775&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/FileTypeSelectorTest.java
(added)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/FileTypeSelectorTest.java
Thu Oct 27 14:28:38 2011
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs2;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests FileTypeSelector.
+ * 
+ * @since 2.1
+ */
+public class FileTypeSelectorTest
+{
+    private static FileObject BaseFolder;
+
+    /**
+     * Creates a RAM FS.
+     * 
+     * @throws Exception
+     */
+    @BeforeClass
+    public static void setUpClass() throws Exception
+    {
+        BaseFolder = VFS.getManager().resolveFile("ram://" + FileTypeSelectorTest.class.getName());
+        BaseFolder.resolveFile("root1.html").createFile();
+        BaseFolder.resolveFile("root2.html").createFile();
+        BaseFolder.resolveFile("f1/a.html").createFile();
+        BaseFolder.resolveFile("f2/b.html").createFile();
+        BaseFolder.resolveFile("f3/c.html").createFile();
+        BaseFolder.resolveFile("f4/").createFolder();
+        BaseFolder.resolveFile("f5/").createFolder();
+        BaseFolder.resolveFile("f6/f7").createFolder();
+    }
+
+    /**
+     * Deletes RAM FS files.
+     * 
+     * @throws Exception
+     */
+    @AfterClass
+    public static void tearDownClass() throws Exception
+    {
+        if (BaseFolder != null)
+        {
+            BaseFolder.deleteAllDescendents();
+        }
+    }
+
+    @Test
+    public void testFileOrFolders() throws Exception
+    {
+        FileSelector selector = new FileTypeSelector(FileType.FILE_OR_FOLDER);
+        FileObject[] foList = BaseFolder.findFiles(selector);
+        // Why 0?
+        Assert.assertEquals(0, foList.length);
+    }
+
+    @Test
+    public void testFiles() throws Exception
+    {
+        FileSelector selector = new FileTypeSelector(FileType.FILE);
+        FileObject[] foList = BaseFolder.findFiles(selector);
+        Assert.assertEquals(5, foList.length);
+    }
+
+    @Test
+    public void testFolders() throws Exception
+    {
+        FileSelector selector = new FileTypeSelector(FileType.FOLDER);
+        FileObject[] foList = BaseFolder.findFiles(selector);
+        Assert.assertEquals(8, foList.length);
+    }
+}



Mime
View raw message