[jboss-svn-commits] JBL Code SVN: r11777 - in labs/jbossesb/workspace/dbevenius/product/core/listeners: tests/src/org/jboss/soa/esb/listeners/config/mappers and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed May 9 02:51:36 EDT 2007


Author: beve
Date: 2007-05-09 02:51:36 -0400 (Wed, 09 May 2007)
New Revision: 11777

Modified:
   labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCache.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyTest.java
   labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTest.java
Log:
Just added som java doc and minor refactoring


Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCache.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCache.java	2007-05-09 02:07:28 UTC (rev 11776)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCache.java	2007-05-09 06:51:36 UTC (rev 11777)
@@ -13,13 +13,8 @@
 import org.jboss.cache.TreeCache;
 
 /**
- * Implements a cache of file names. 
- * The main intent of this class is to be used when retreiving file 
- * names via ftp, and when the ftp server is readonly.
+ * Implements a cache of file names which can be replicated in a cluster. 
  * 
- * The class will act as a distributed cache so that the same file is not processed 
- * more then once.
- * 
  * @author Daniel Bevenius
  *
  */
@@ -73,6 +68,17 @@
 		
 	}
 	
+	/**
+	 * Gets an input stream from the specified path.
+	 * 
+	 * If the path denotes a file on the filesystem, that file
+	 * will be used. 
+	 * If a file is not found in the filesystem, this method will look 
+	 * for the file on the classpath.
+	 * 
+	 * @param path			the path to the JBossCache configuration file
+	 * @return InputStream	the inputstream for the passed-in path	
+	 */
 	protected InputStream getConfigInputStream( String path ) 
 	{
 		InputStream in = null;
@@ -85,7 +91,8 @@
 			{
 				in =  new FileInputStream ( path );
 			} 
-			catch (FileNotFoundException e) {
+			catch (FileNotFoundException e) 
+			{
 				log.error( e );
 			}
 		}
@@ -97,11 +104,19 @@
 		return in;
 	}
 
+	/**
+	 * Start the cache
+	 * @throws Exception
+	 */
 	public void start() throws Exception
 	{
 		treeCache.startService();
 	}
-
+	
+	/**
+	 * Stops the cache
+	 *
+	 */
 	public void stop()
 	{
 		treeCache.stopService();
@@ -141,11 +156,21 @@
 		return treeCache.remove( fqn, fileName );
 	}
 	
+	/**
+	 * Checks to see if the filename exists in the cache
+	 * 
+	 * @param fileName	the filename to look for
+	 * @return true	if the file exists in the cache
+	 */
 	public boolean containsFile( String fileName )
 	{
 		return treeCache.exists(  fqn, fileName );
 	}
 	
+	/**
+	 * Gets the a string of all files in the cache
+	 * @return
+	 */
 	public String getCache()
 	{
 		return treeCache.print( fqn );
@@ -166,6 +191,12 @@
 		return config;
 	}
 
+	/**
+	 * Removes all data under the fqn, but not the fqn 
+	 * itself
+	 * 
+	 * @throws CacheException
+	 */
 	public void removeAll() throws CacheException
 	{
 		treeCache.removeData( fqn );

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java	2007-05-09 02:07:28 UTC (rev 11776)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java	2007-05-09 06:51:36 UTC (rev 11777)
@@ -21,7 +21,7 @@
  */
 package org.jboss.soa.esb.listeners.config.mappers;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import java.io.IOException;
@@ -31,23 +31,20 @@
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.dom.YADOMUtil;
-import org.jboss.soa.esb.listeners.config.Bus;
 import org.jboss.soa.esb.listeners.config.Generator;
 import org.jboss.soa.esb.listeners.config.Listener;
 import org.jboss.soa.esb.listeners.config.FtpBusDocument.FtpBus;
 import org.jboss.soa.esb.listeners.config.FtpListenerDocument.FtpListener;
-import org.jboss.soa.esb.listeners.config.FtpMessageFilterDocument.FtpMessageFilter;
 import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
 import org.jboss.soa.esb.listeners.gateway.RemoteGatewayListener;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 /**
+ * Tests the class FtpListenerMapper 
  * 
  * @author Daniel Bevenius
  *
@@ -90,7 +87,6 @@
 		assertNotNull( RemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CLASS + " should have been set", 
 				remoteStrategyClass );
 		
-		
 	}
 	
 	private XMLBeansModel getXmlBeanModel( String fileName ) throws ConfigurationException, IOException

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java	2007-05-09 02:07:28 UTC (rev 11776)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener_ReadOnlyStrategyUnitTest.java	2007-05-09 06:51:36 UTC (rev 11777)
@@ -126,6 +126,11 @@
 		assertTrue ( "Should always return treu", remoteFileSystemStrategy.renameFile(  null, null  ));
 	}
 	
+	/**
+	 * This is a "negtive" test. It verifies that the file was not
+	 * renamed. The name of the method is kept so that it overrides 
+	 * the super classes method.
+	 */
 	@Test
 	public void renameFile_In_Same_Directory() throws GatewayException 
 	{ 
@@ -146,12 +151,21 @@
 		assertNotNull( "The instance should not be null!", instance );
 	}
 	
+	/**
+	 * Not a valid test for this impl
+	 */
 	@Ignore
 	public void renameFile_In_Different_Directory() throws GatewayException { }
 	
+	/**
+	 * Not a valid test for this impl
+	 */
 	@Ignore
 	public void doRun_PostDir_Different_From_InputDir() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException { }
 	
+	/**
+	 * Not a valid test for this impl
+	 */
 	@Ignore
 	public void doRun_Negative() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException {}
 	
@@ -164,7 +178,7 @@
 	{
 		ConfigTree configTree = RemoteGatewayListenerUnitTest.createConfigTree();
 		configTree.setAttribute( RemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CLASS, ReadOnlyRemoteFileSystemStrategy.class.getName());
-		configTree.setAttribute( RemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE, getConfigFile() );
+		configTree.setAttribute( RemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE, getJBossCacheConfigFile() );
 		return configTree;
 	}
 	
@@ -175,7 +189,7 @@
 		return ftpServer;
 	}
 	
-	private static String getConfigFile()
+	private static String getJBossCacheConfigFile()
 	{
 		String configFile = TestEnvironmentUtil.getBaseDir() + File.separator + 
 							"core" + File.separator + 

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyTest.java	2007-05-09 02:07:28 UTC (rev 11776)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyTest.java	2007-05-09 06:51:36 UTC (rev 11777)
@@ -5,7 +5,6 @@
 import static org.junit.Assert.fail;
 
 import java.io.File;
-import java.net.InetAddress;
 
 import org.apache.log4j.Logger;
 import org.jboss.cache.CacheException;

Modified: labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTest.java	2007-05-09 02:07:28 UTC (rev 11776)
+++ labs/jbossesb/workspace/dbevenius/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheTest.java	2007-05-09 06:51:36 UTC (rev 11777)
@@ -20,6 +20,12 @@
 import org.junit.Test;
 
 
+/**
+ * Test class FtpFileCache
+ * 
+ * @author Daniel Bevenius
+ *
+ */
 public class FtpFileCacheTest
 {
 	private static Logger log = Logger.getLogger(FtpFileCacheTest.class);
@@ -30,10 +36,10 @@
 	private static FtpFileCache ftpfileCache;
 
 	@Test
-	public void getConfigInputStream() throws Exception
+	public void getConfigInputStream_From_Classpath() throws Exception
 	{
-		String configPath = "/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/ftpfile_cache_test.xml";
-		InputStream configInputStream = ftpfileCache.getConfigInputStream( configPath );
+		String configPath_CP = "/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/ftpfile_cache_test.xml";
+		InputStream configInputStream = ftpfileCache.getConfigInputStream( configPath_CP );
 		assertNotNull( "InputStream was null", configInputStream );
 	}
 	
@@ -85,12 +91,12 @@
 	@BeforeClass
 	public static void classSetup() throws Exception
 	{
-		configFile = getConfigFile();
+		configFile = getJBossCacheConfigFile();
 		
 		registerHsqlDriver();
 		HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir() + "build" + File.separator + "hsqltestdb", "ftpcache");
 		
-		ftpfileCache = new FtpFileCache ( getConfigFile() );
+		ftpfileCache = new FtpFileCache ( getJBossCacheConfigFile() );
 		ftpfileCache.start();
 	}
 	
@@ -106,7 +112,7 @@
 		}
 	}
 	
-	private static String getConfigFile()
+	private static String getJBossCacheConfigFile()
 	{
 		String configFile = TestEnvironmentUtil.getBaseDir() + File.separator + 
 							"core" + File.separator + 




More information about the jboss-svn-commits mailing list