[jboss-svn-commits] JBL Code SVN: r33711 - in labs/jbossesb/trunk/product/rosetta: tests/src/org/jboss/internal/soa/esb/util and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jun 30 15:37:34 EDT 2010


Author: tcunning
Date: 2010-06-30 15:37:34 -0400 (Wed, 30 Jun 2010)
New Revision: 33711

Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpImpl.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/FtpImplUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/embedded/ftp/FtpTestUtil.java
Log:
JBESB-3293
Change the ftp listNames so that if no suffix is passed it does not drill
down into subdirectories to list files, but only lists the files in the
current directory.    Added test to test this behavior.


Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpImpl.java	2010-06-30 18:04:23 UTC (rev 33710)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpImpl.java	2010-06-30 19:37:34 UTC (rev 33711)
@@ -344,17 +344,29 @@
         public String[] getFileListFromRemoteDir (String p_sSuffix)
                         throws RemoteFileSystemException, IOException
         {
-                String sSuffix = (null == p_sSuffix) ? "*" : "*" + p_sSuffix;
+        		if ((p_sSuffix == null) || ("".equals(p_sSuffix))) {
+                    try
+                    {
+                        changeRemoteDirectory() ;
+                        return m_oConn.listNames() ;
+                    }
+                    catch (final IOException ioe)
+                    {
+                        throw new RemoteFileSystemException(ioe) ;
+                    }        			
+        		} else {
+        			String sSuffix = "*" + p_sSuffix;
 
-                try
-                {
-                    changeRemoteDirectory() ;
-                    return m_oConn.listNames(sSuffix) ;
-                }
-                catch (final IOException ioe)
-                {
-                    throw new RemoteFileSystemException(ioe) ;
-                }
+        			try
+        			{
+        				changeRemoteDirectory() ;
+        				return m_oConn.listNames(sSuffix) ;
+        			}
+        			catch (final IOException ioe)
+        			{
+        				throw new RemoteFileSystemException(ioe) ;
+        			}
+        		}
         }
 
         /*

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/FtpImplUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/FtpImplUnitTest.java	2010-06-30 18:04:23 UTC (rev 33710)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/FtpImplUnitTest.java	2010-06-30 19:37:34 UTC (rev 33711)
@@ -302,6 +302,43 @@
 		}
 	}	
 	
+	@Test
+	public void listFilesInDirectory() throws RemoteFileSystemException
+	{
+		// Test to validate JBESB-3293
+		
+		File localFile = null;
+		File localDir = null;
+		String testFileName = "112233445566778899.test";
+		try
+		{
+			String dirName = remoteUploadDirName + File.separator + "temp";
+			
+			localDir = FtpTestUtil.createTestDirectory(dirName);
+			localFile = FtpTestUtil.createTestFile(dirName + File.separator + testFileName, TEST_FILE_CONTENT );
+
+			String[] listone = ftpImpl.getFileListFromRemoteDir("");
+
+			String fileName = null;
+			for (int i = 0; i < listone.length; i++) {
+				if ((listone[i] != null) && (listone[i].contains(testFileName))) {
+					fileName = listone[i];
+				}
+			}
+			assertTrue("The list of files should not contain " + testFileName + " but " 
+					+ fileName + " was found.", fileName == null);
+			
+			
+		} catch (Exception e) {
+			
+		}
+		finally
+		{
+			FtpTestUtil.deleteFile( localFile );
+			FtpTestUtil.deleteFile( localDir );
+		}
+	}	
+	
 	private static ConfigTree createConfigTree()
 	{
 		ConfigTree configTree = new ConfigTree( "junitFtpImplTest" );

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/embedded/ftp/FtpTestUtil.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/embedded/ftp/FtpTestUtil.java	2010-06-30 18:04:23 UTC (rev 33710)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/embedded/ftp/FtpTestUtil.java	2010-06-30 19:37:34 UTC (rev 33711)
@@ -106,6 +106,20 @@
 		}
 		return testFile;
 	}
+
+	public static File createTestDirectory(final String directoryName)
+	{
+		File testFile = new File (directoryName);
+		try
+		{
+			testFile.mkdir();
+		} 
+		catch (Exception e)
+		{
+			log.error ( e.getMessage() );
+		} 
+		return testFile;
+	}
 	
 	public static void close( Closeable c )
 	{



More information about the jboss-svn-commits mailing list