[jboss-svn-commits] JBL Code SVN: r23644 - in labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file: filtering and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Oct 31 06:03:15 EDT 2008


Author: beve
Date: 2008-10-31 06:03:14 -0400 (Fri, 31 Oct 2008)
New Revision: 23644

Added:
   labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/
   labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/AlphabeticFileComparatorUnitTest.java
   labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/WildcardFileFilterUnitTest.java
   labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/WildcardFileSelectorUnitTest.java
Log:
Added tests that Tom had already written.


Added: labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/AlphabeticFileComparatorUnitTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/AlphabeticFileComparatorUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/AlphabeticFileComparatorUnitTest.java	2008-10-31 10:03:14 UTC (rev 23644)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.esb.file.filtering;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class AlphabeticFileComparatorUnitTest
+{
+    private File tmpFile1;
+    private File tmpFile2;
+
+    private String testFileName1 = "AlphabeticFileComparatorTest";
+    private String testFileName2 = "BlphabeticFileComparatorTest";
+    private String suffix = ".test";
+
+    @Test
+    public void test() throws IOException
+    {
+        tmpFile1 = File.createTempFile(testFileName1, suffix);
+        tmpFile2 = File.createTempFile(testFileName2, suffix);
+        final File tmpDir = new File(tmpFile1.getParent());
+
+        tmpFile1.deleteOnExit();
+        tmpFile2.deleteOnExit();
+
+        File[] files = tmpDir.listFiles(new TestFilter());
+        assertEquals(2, files.length);
+
+        // Ensure they're in dessending order first...
+        files[0] = tmpFile2;
+        files[1] = tmpFile1;
+
+        // Now resort them...
+        Arrays.sort(files, new AlphabeticFileComparator<File>());
+        assertEquals(tmpFile1, files[0]);
+        assertEquals(tmpFile2, files[1]);
+    }
+
+    private class TestFilter implements FileFilter
+    {
+        public boolean accept(File file)
+        {
+            return (file.getName().equals(tmpFile2.getName()) || file.getName().equals(tmpFile1.getName()));
+        }
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/WildcardFileFilterUnitTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/WildcardFileFilterUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/WildcardFileFilterUnitTest.java	2008-10-31 10:03:14 UTC (rev 23644)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.esb.file.filtering;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.Properties;
+
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class WildcardFileFilterUnitTest
+{
+    @Test
+    public void test_select() throws ConfigurationException
+    {
+        WildcardFileFilter filter = new WildcardFileFilter();
+        Properties properties = new Properties();
+
+        properties.setProperty(WildcardFileFilter.MATCH_PATTERN, "*.xml");
+        filter.setConfiguration(properties);
+        assertTrue(filter.accept(new File("x/y/zzzzz.xml")));
+        assertTrue(!filter.accept(new File("x/y/zzzzz.cxml")));
+        assertTrue(!filter.accept(new File("x/y/xml")));
+
+        properties.setProperty(WildcardFileFilter.MATCH_PATTERN, "blah.*");
+        filter.setConfiguration(properties);
+        assertTrue(filter.accept(new File("x/y/blah.xml")));
+        assertTrue(!filter.accept(new File("x/y/zzzzz.cxml")));
+        assertTrue(!filter.accept(new File("x/y/xml")));
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/WildcardFileSelectorUnitTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/WildcardFileSelectorUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/file/src/test/java/org/jboss/esb/file/filtering/WildcardFileSelectorUnitTest.java	2008-10-31 10:03:14 UTC (rev 23644)
@@ -0,0 +1,56 @@
+package org.jboss.esb.file.filtering;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class WildcardFileSelectorUnitTest
+{
+
+    @Test
+    public void test() throws ConfigurationException, IOException
+    {
+        final WildcardFileSelector selector = new WildcardFileSelector();
+        final Properties properties = new Properties();
+        properties.setProperty(WildcardFileFilter.MATCH_PATTERN, "*.wild");
+
+        final File tmpFile = File.createTempFile("WildCardFileSelectoryTest", ".wild");
+        final File tmpFile2 = File.createTempFile("WildCardFileSelectoryTest2", ".wild");
+        final File tmpDir = new File(tmpFile.getParent());
+        tmpFile.deleteOnExit();
+        tmpFile2.deleteOnExit();
+
+
+        selector.setConfiguration(properties);
+
+        final File[] selectedFiles = selector.select(tmpDir);
+        assertEquals(2, selectedFiles.length);
+    }
+}




More information about the jboss-svn-commits mailing list