[jboss-svn-commits] JBL Code SVN: r12870 - in labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway: remotestrategies and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jun 26 13:38:50 EDT 2007
Author: beve
Date: 2007-06-26 13:38:50 -0400 (Tue, 26 Jun 2007)
New Revision: 12870
Added:
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerIntegrationTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyIntegrationTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerIntegrationTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheIntegrationTest.java
Removed:
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheUnitTest.java
Log:
Renamed the unit test to Integration test as they will not work unless one has a configured network interface.
There seems to be a problem with running these on windows using a wireless card. Kurt reported the error.
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerIntegrationTest.java (from rev 12869, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerIntegrationTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerIntegrationTest.java 2007-06-26 17:38:50 UTC (rev 12870)
@@ -0,0 +1,323 @@
+/*
+ * 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,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.gateway;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.util.embedded.EmbeddableException;
+import org.jboss.internal.soa.esb.util.embedded.ftp.FtpTestUtil;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.MalformedEPRException;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.couriers.Courier;
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.gateway.remotestrategies.ReadOnlyRemoteFileSystemStrategy;
+import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.DeleteOnEvictTreeCacheListener;
+import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCacheTestUtil;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleThreadState;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Unit test for ReadOnlyRemoteGatewayListener that uses an embedded ftp server.
+ *
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>
+ *
+ */
+public class ReadOnlyRemoteGatewayListenerIntegrationTest extends RemoteGatewayListenerUnitTest
+{
+
+ @SuppressWarnings("unused")
+ private Logger log = Logger .getLogger( ReadOnlyRemoteGatewayListenerIntegrationTest.class );
+
+ @BeforeClass
+ public static void classSetup() throws EmbeddableException, ConfigurationException, GatewayException, RegistryException, MalformedURLException
+ {
+ ftpServer = createFtpServer();
+ ftpServer.start();
+
+ createWorkDirectories();
+ configTree = createConfigTree();
+ createRemoteGatewayListener( configTree );
+ }
+
+ @Test
+ public void deleteFile() throws GatewayException
+ {
+ File remoteFile = createAbsoluteFromFile();
+
+ gatewayListener.deleteFile( remoteFile );
+ assertTrue( "Remote file was deleted which should not be possible!", testFile.exists() );
+ }
+
+ @Test
+ public void getFileListFromRemoteDir() throws GatewayException
+ {
+ File[] fileListFromRemoteDir = gatewayListener.getFileList();
+
+ assertNotNull ( fileListFromRemoteDir );
+ assertTrue ( fileListFromRemoteDir.length > 0 );
+
+ List<File> fileList = Arrays.asList( fileListFromRemoteDir );
+ assertTrue( "The test file was not included in the List! " , fileList.contains( new File ( testFile.getName() ) ));
+ }
+
+ @Test ( timeout=3000 )
+ public void doRun_PostDir_Same_As_InputDir() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException
+ {
+ setAbsoluteInputDir();
+ setAbsolutePostDirToInputDir();
+ boolean getCourierReturnValue = true;
+
+ RemoteGatewayListenerMock mock = createAndStartListener ( configTree, getCourierReturnValue );
+
+ File inputDir = ftpServer.getLocalInputDir();
+ String doneFileName = testFile.getName();
+
+ waitForFile( inputDir, doneFileName );
+ stopdoRun( mock );
+
+ File processedFile = new File ( inputDir, doneFileName );
+ try
+ {
+ assertTrue ( processedFile.exists() );
+ }
+ finally
+ {
+ FtpTestUtil.deleteFile( processedFile );
+ }
+ }
+
+ /**
+ * 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
+ {
+ File from = createAbsoluteFromFile();
+ File to = createAbsoluteToFile();
+
+ gatewayListener.renameFile( from, to );
+
+ renamedFile = new File ( ftpServer.getLocalInputDir(), to.getName() );
+ assertFileExists( testFile );
+ assertFalse( renamedFile.exists() );
+ }
+
+ @Test
+ public void getNewInstanceNegative()
+ {
+ ReadOnlyRemoteGatewayListener listener = (ReadOnlyRemoteGatewayListener) gatewayListener;
+ try
+ {
+ listener.getNewInstanceOf( null );
+ fail ( "an IllegalArgumentException should have been thrown" );
+ }
+ catch ( Exception e)
+ {
+ assertTrue ( e instanceof IllegalArgumentException );
+ }
+
+ try
+ {
+ listener.getNewInstanceOf( "some.package.class" );
+ fail ( "a ConfigurationException should have been thrown" );
+ }
+ catch ( Exception e)
+ {
+ assertTrue ( e instanceof ConfigurationException );
+ }
+ }
+
+ @Test
+ public void getNewInstance() throws ConfigurationException
+ {
+ ReadOnlyRemoteGatewayListener listener = (ReadOnlyRemoteGatewayListener) gatewayListener;
+ ReadOnlyRemoteFileSystemStrategy instance = listener.getNewInstanceOf( ReadOnlyRemoteFileSystemStrategy.class.getName() );
+ assertNotNull( "The instance should not be null!", instance );
+ }
+
+ /**
+ * Not a valid test for this impl
+ */
+ @Override
+ public void renameFile_In_Different_Directory() throws GatewayException { }
+
+ /**
+ * Not a valid test for this impl
+ */
+ @Override
+ public void doRun_PostDir_Different_From_InputDir() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException { }
+
+ /**
+ * Not a valid test for this impl
+ */
+ @Override
+ public void doRun_Negative() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException {}
+
+ /**
+ * Override createConfigTree and add the ReadOnlyFileSystem strategy.
+ *
+ * @return
+ */
+ public static ConfigTree createConfigTree()
+ {
+ ConfigTree configTree = RemoteGatewayListenerUnitTest.createConfigTree();
+ configTree.setAttribute( ReadOnlyRemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CLASS, ReadOnlyRemoteFileSystemStrategy.class.getName() );
+ configTree.setAttribute( ReadOnlyRemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE, FtpFileCacheTestUtil.getCacheConfigFile() );
+ configTree.setAttribute( ReadOnlyRemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CACHE_LISTENER, DeleteOnEvictTreeCacheListener.class.getName() );
+ return configTree;
+ }
+
+ protected static void createRemoteGatewayListener( ConfigTree configTree )
+ throws ConfigurationException, RegistryException, GatewayException
+ {
+ gatewayListener = new ReadOnlyRemoteGatewayListener( configTree );
+ }
+
+ /**
+ * Creates a RemoteGatewayListenerMock instance with the passed in arguments, and then starts
+ * the ReadOnlyRemoteGatewayListener's doRun() method in a new Thread.
+ *
+ * @param configTree The configTree to use to configure the RemoteGatewayListenerMock object
+ * @param returnValueForCourier the return value for the getCourier method of the RemoteGatewayListenerMock object
+ * @return RemoteGatewayListenerMock Mock impl of a RemoteGatewayListener.
+ */
+ protected RemoteGatewayListenerMock createAndStartListener ( ConfigTree configTree, boolean returnValueForCourier ) throws ConfigurationException, GatewayException, RegistryException
+ {
+ final RemoteGatewayListenerMock mock = new RemoteGatewayListenerMock( configTree , returnValueForCourier );
+ mock.doInitialise();
+
+ Thread thread = new Thread ( new Runnable () {
+ public void run()
+ {
+ mock.doRun();
+ }
+ });
+ thread.start();
+
+ return mock;
+
+ }
+
+ protected void stopdoRun ( RemoteGatewayListenerMock mock )
+ {
+ if ( mock == null ) return;
+ try
+ {
+ mock.stop();
+ }
+ catch ( Exception e )
+ {
+ if ( ! (e instanceof ManagedLifecycleException ) )
+ fail ( e.getMessage() );
+ }
+ }
+
+ /**
+ * Mock impl of RemoteGatewayListener.
+ */
+ class RemoteGatewayListenerMock extends ReadOnlyRemoteGatewayListener
+ {
+ private static final long serialVersionUID = 1L;
+
+ /* value that will be returned from the getCourier( EPR ) method */
+ private boolean returnValueForCourier;
+
+ private boolean finishedOneRun;
+
+ /**
+ * Sole constructor
+ *
+ * @param configTree configTree used to configure this RemoteGatewayListener
+ * @param returnValueForCourier value to be returned from this objects getCourier( EPR ) method
+ *
+ */
+ public RemoteGatewayListenerMock ( ConfigTree configTree, boolean returnValueForCourier) throws ConfigurationException, GatewayException, RegistryException
+ {
+ super ( configTree );
+ this.returnValueForCourier = returnValueForCourier;
+ }
+
+ /**
+ * Will return a Courier instance that returns the value of the
+ * field returnValueForCourier.
+ */
+ @Override
+ protected Courier getCourier( EPR current ) throws CourierException, MalformedEPRException
+ {
+ return new Courier() {
+ public boolean deliver( Message message ) throws CourierException, MalformedEPRException
+ {
+ return returnValueForCourier;
+ }
+ public void cleanup() { }
+ };
+ }
+
+ @Override
+ protected void doInitialise()
+ {
+ _targetEprs = new ArrayList<EPR>();
+ _targetEprs.add( new JMSEpr( new EPR() ) );
+ };
+
+ @Override
+ protected boolean waitForRunningStateChange(final ManagedLifecycleThreadState state, final long terminationPeriod)
+ {
+ finishedOneRun = true;
+ return super.waitForRunningStateChange( state, terminationPeriod );
+ }
+
+ public boolean hasFinishedOneRun()
+ {
+ return finishedOneRun;
+ }
+ }
+
+ /*
+ * Just here to help Ant to find annotated test.
+ */
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter( ReadOnlyRemoteGatewayListenerIntegrationTest.class);
+ }
+
+}
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerUnitTest.java 2007-06-26 14:46:11 UTC (rev 12869)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/ReadOnlyRemoteGatewayListenerUnitTest.java 2007-06-26 17:38:50 UTC (rev 12870)
@@ -1,323 +0,0 @@
-/*
- * 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,
- * @author JBoss Inc.
- */
-package org.jboss.soa.esb.listeners.gateway;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.util.embedded.EmbeddableException;
-import org.jboss.internal.soa.esb.util.embedded.ftp.FtpTestUtil;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.MalformedEPRException;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.couriers.Courier;
-import org.jboss.soa.esb.couriers.CourierException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.gateway.remotestrategies.ReadOnlyRemoteFileSystemStrategy;
-import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.DeleteOnEvictTreeCacheListener;
-import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCacheTestUtil;
-import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
-import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleThreadState;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Unit test for ReadOnlyRemoteGatewayListener that uses an embedded ftp server.
- *
- * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>
- *
- */
-public class ReadOnlyRemoteGatewayListenerUnitTest extends RemoteGatewayListenerUnitTest
-{
-
- @SuppressWarnings("unused")
- private Logger log = Logger .getLogger( ReadOnlyRemoteGatewayListenerUnitTest.class );
-
- @BeforeClass
- public static void classSetup() throws EmbeddableException, ConfigurationException, GatewayException, RegistryException, MalformedURLException
- {
- ftpServer = createFtpServer();
- ftpServer.start();
-
- createWorkDirectories();
- configTree = createConfigTree();
- createRemoteGatewayListener( configTree );
- }
-
- @Test
- public void deleteFile() throws GatewayException
- {
- File remoteFile = createAbsoluteFromFile();
-
- gatewayListener.deleteFile( remoteFile );
- assertTrue( "Remote file was deleted which should not be possible!", testFile.exists() );
- }
-
- @Test
- public void getFileListFromRemoteDir() throws GatewayException
- {
- File[] fileListFromRemoteDir = gatewayListener.getFileList();
-
- assertNotNull ( fileListFromRemoteDir );
- assertTrue ( fileListFromRemoteDir.length > 0 );
-
- List<File> fileList = Arrays.asList( fileListFromRemoteDir );
- assertTrue( "The test file was not included in the List! " , fileList.contains( new File ( testFile.getName() ) ));
- }
-
- @Test ( timeout=3000 )
- public void doRun_PostDir_Same_As_InputDir() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException
- {
- setAbsoluteInputDir();
- setAbsolutePostDirToInputDir();
- boolean getCourierReturnValue = true;
-
- RemoteGatewayListenerMock mock = createAndStartListener ( configTree, getCourierReturnValue );
-
- File inputDir = ftpServer.getLocalInputDir();
- String doneFileName = testFile.getName();
-
- waitForFile( inputDir, doneFileName );
- stopdoRun( mock );
-
- File processedFile = new File ( inputDir, doneFileName );
- try
- {
- assertTrue ( processedFile.exists() );
- }
- finally
- {
- FtpTestUtil.deleteFile( processedFile );
- }
- }
-
- /**
- * 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
- {
- File from = createAbsoluteFromFile();
- File to = createAbsoluteToFile();
-
- gatewayListener.renameFile( from, to );
-
- renamedFile = new File ( ftpServer.getLocalInputDir(), to.getName() );
- assertFileExists( testFile );
- assertFalse( renamedFile.exists() );
- }
-
- @Test
- public void getNewInstanceNegative()
- {
- ReadOnlyRemoteGatewayListener listener = (ReadOnlyRemoteGatewayListener) gatewayListener;
- try
- {
- listener.getNewInstanceOf( null );
- fail ( "an IllegalArgumentException should have been thrown" );
- }
- catch ( Exception e)
- {
- assertTrue ( e instanceof IllegalArgumentException );
- }
-
- try
- {
- listener.getNewInstanceOf( "some.package.class" );
- fail ( "a ConfigurationException should have been thrown" );
- }
- catch ( Exception e)
- {
- assertTrue ( e instanceof ConfigurationException );
- }
- }
-
- @Test
- public void getNewInstance() throws ConfigurationException
- {
- ReadOnlyRemoteGatewayListener listener = (ReadOnlyRemoteGatewayListener) gatewayListener;
- ReadOnlyRemoteFileSystemStrategy instance = listener.getNewInstanceOf( ReadOnlyRemoteFileSystemStrategy.class.getName() );
- assertNotNull( "The instance should not be null!", instance );
- }
-
- /**
- * Not a valid test for this impl
- */
- @Override
- public void renameFile_In_Different_Directory() throws GatewayException { }
-
- /**
- * Not a valid test for this impl
- */
- @Override
- public void doRun_PostDir_Different_From_InputDir() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException { }
-
- /**
- * Not a valid test for this impl
- */
- @Override
- public void doRun_Negative() throws ManagedLifecycleException, ConfigurationException, GatewayException, RegistryException, InterruptedException {}
-
- /**
- * Override createConfigTree and add the ReadOnlyFileSystem strategy.
- *
- * @return
- */
- public static ConfigTree createConfigTree()
- {
- ConfigTree configTree = RemoteGatewayListenerUnitTest.createConfigTree();
- configTree.setAttribute( ReadOnlyRemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CLASS, ReadOnlyRemoteFileSystemStrategy.class.getName() );
- configTree.setAttribute( ReadOnlyRemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CONFIG_FILE, FtpFileCacheTestUtil.getCacheConfigFile() );
- configTree.setAttribute( ReadOnlyRemoteGatewayListener.REMOTE_FILE_SYSTEM_STRATEGY_CACHE_LISTENER, DeleteOnEvictTreeCacheListener.class.getName() );
- return configTree;
- }
-
- protected static void createRemoteGatewayListener( ConfigTree configTree )
- throws ConfigurationException, RegistryException, GatewayException
- {
- gatewayListener = new ReadOnlyRemoteGatewayListener( configTree );
- }
-
- /**
- * Creates a RemoteGatewayListenerMock instance with the passed in arguments, and then starts
- * the ReadOnlyRemoteGatewayListener's doRun() method in a new Thread.
- *
- * @param configTree The configTree to use to configure the RemoteGatewayListenerMock object
- * @param returnValueForCourier the return value for the getCourier method of the RemoteGatewayListenerMock object
- * @return RemoteGatewayListenerMock Mock impl of a RemoteGatewayListener.
- */
- protected RemoteGatewayListenerMock createAndStartListener ( ConfigTree configTree, boolean returnValueForCourier ) throws ConfigurationException, GatewayException, RegistryException
- {
- final RemoteGatewayListenerMock mock = new RemoteGatewayListenerMock( configTree , returnValueForCourier );
- mock.doInitialise();
-
- Thread thread = new Thread ( new Runnable () {
- public void run()
- {
- mock.doRun();
- }
- });
- thread.start();
-
- return mock;
-
- }
-
- protected void stopdoRun ( RemoteGatewayListenerMock mock )
- {
- if ( mock == null ) return;
- try
- {
- mock.stop();
- }
- catch ( Exception e )
- {
- if ( ! (e instanceof ManagedLifecycleException ) )
- fail ( e.getMessage() );
- }
- }
-
- /**
- * Mock impl of RemoteGatewayListener.
- */
- class RemoteGatewayListenerMock extends ReadOnlyRemoteGatewayListener
- {
- private static final long serialVersionUID = 1L;
-
- /* value that will be returned from the getCourier( EPR ) method */
- private boolean returnValueForCourier;
-
- private boolean finishedOneRun;
-
- /**
- * Sole constructor
- *
- * @param configTree configTree used to configure this RemoteGatewayListener
- * @param returnValueForCourier value to be returned from this objects getCourier( EPR ) method
- *
- */
- public RemoteGatewayListenerMock ( ConfigTree configTree, boolean returnValueForCourier) throws ConfigurationException, GatewayException, RegistryException
- {
- super ( configTree );
- this.returnValueForCourier = returnValueForCourier;
- }
-
- /**
- * Will return a Courier instance that returns the value of the
- * field returnValueForCourier.
- */
- @Override
- protected Courier getCourier( EPR current ) throws CourierException, MalformedEPRException
- {
- return new Courier() {
- public boolean deliver( Message message ) throws CourierException, MalformedEPRException
- {
- return returnValueForCourier;
- }
- public void cleanup() { }
- };
- }
-
- @Override
- protected void doInitialise()
- {
- _targetEprs = new ArrayList<EPR>();
- _targetEprs.add( new JMSEpr( new EPR() ) );
- };
-
- @Override
- protected boolean waitForRunningStateChange(final ManagedLifecycleThreadState state, final long terminationPeriod)
- {
- finishedOneRun = true;
- return super.waitForRunningStateChange( state, terminationPeriod );
- }
-
- public boolean hasFinishedOneRun()
- {
- return finishedOneRun;
- }
- }
-
- /*
- * Just here to help Ant to find annotated test.
- */
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter( ReadOnlyRemoteGatewayListenerUnitTest.class);
- }
-
-}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyIntegrationTest.java (from rev 12869, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyIntegrationTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyIntegrationTest.java 2007-06-26 17:38:50 UTC (rev 12870)
@@ -0,0 +1,143 @@
+package org.jboss.soa.esb.listeners.gateway.remotestrategies;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.jboss.cache.CacheException;
+import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCacheTestUtil;
+import org.jboss.soa.esb.testutils.HsqldbUtil;
+import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>
+ *
+ */
+public class ReadOnlyRemoteFileSystemStrategyIntegrationTest
+{
+ private static Logger log = Logger .getLogger( ReadOnlyRemoteFileSystemStrategyIntegrationTest.class );
+
+ private static ReadOnlyRemoteFileSystemStrategy strategy;
+
+ private static ReadOnlyRemoteFileSystemStrategy strategy2;
+
+ private String testFile1 = "testFile1";
+ private String testFile2 = "testFile2";
+ private String testFile3 = "testFile3";
+
+ private File[] expectedFileList = new File[] { new File( testFile1 ) , new File( testFile2 ) };
+ private File[] newFileList = new File[] { new File( testFile3 ) };
+ private File[] emptyFileList = new File[] {};
+
+ @Test
+ public void listFilesNegative()
+ {
+ try
+ {
+ strategy.filterFileList( null );
+ }
+ catch (RemoteFileSystemStrategyException e)
+ {
+ fail("Should be ok to pass null as the file array!");
+ }
+ }
+
+ @Test
+ public void listFiles() throws RemoteFileSystemStrategyException
+ {
+ File[] filteredFileList = strategy.filterFileList( expectedFileList );
+ assertEquals( expectedFileList, filteredFileList );
+
+ filteredFileList = strategy.filterFileList( expectedFileList );
+ assertEquals( "No files should have been returned. They should have been cached.", emptyFileList, filteredFileList );
+
+ filteredFileList = strategy.filterFileList( newFileList );
+ assertEquals( newFileList, filteredFileList );
+ assertTrue ( filteredFileList instanceof File[] );
+ }
+
+ @Test
+ public void listFiles_With_Two_Strategy_Instances() throws Exception
+ {
+
+ try
+ {
+ File[] filteredFileList = strategy2.filterFileList( expectedFileList );
+ assertEquals( expectedFileList, filteredFileList );
+
+ filteredFileList = strategy.filterFileList( expectedFileList );
+ assertEquals( emptyFileList, filteredFileList );
+
+ filteredFileList = strategy2.filterFileList( newFileList );
+ assertEquals( newFileList, filteredFileList );
+
+ filteredFileList = strategy.filterFileList( newFileList );
+ assertEquals( emptyFileList, filteredFileList );
+
+ }
+ catch ( Exception e )
+ {
+ log.error(e);
+ }
+ finally
+ {
+ strategy2.stop();
+ }
+
+ }
+
+ @Before
+ public void setup() throws CacheException
+ {
+ strategy.removeAllData();
+ }
+
+ @BeforeClass
+ public static void classSetup() throws Exception
+ {
+ registerHsqlDriver();
+ HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir() + "build" + File.separator + "hsqltestdb", "ftpcache");
+
+ strategy = new ReadOnlyRemoteFileSystemStrategy();
+ strategy.init( FtpFileCacheTestUtil.getCacheConfigFile() );
+
+ strategy2 = new ReadOnlyRemoteFileSystemStrategy();
+ strategy2.init( FtpFileCacheTestUtil.getCacheConfigFile() );
+ }
+
+ private static void registerHsqlDriver()
+ {
+ try
+ {
+ Class.forName( "org.hsqldb.jdbcDriver" );
+ }
+ catch (Exception e)
+ {
+ fail( "ERROR: failed to load JDBC driver." + e.getMessage() );
+ }
+ }
+
+ @AfterClass
+ public static void classTearDown() throws Exception
+ {
+ strategy.stop();
+ strategy2.stop();
+ HsqldbUtil.stopHsqldb( "jdbc:hsqldb:hsql://localhost:9001/ftpcache", "sa", "" );
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(ReadOnlyRemoteFileSystemStrategyIntegrationTest.class);
+ }
+}
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyUnitTest.java 2007-06-26 14:46:11 UTC (rev 12869)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/ReadOnlyRemoteFileSystemStrategyUnitTest.java 2007-06-26 17:38:50 UTC (rev 12870)
@@ -1,143 +0,0 @@
-package org.jboss.soa.esb.listeners.gateway.remotestrategies;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.jboss.cache.CacheException;
-import org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCacheTestUtil;
-import org.jboss.soa.esb.testutils.HsqldbUtil;
-import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- *
- * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>
- *
- */
-public class ReadOnlyRemoteFileSystemStrategyUnitTest
-{
- private static Logger log = Logger .getLogger( ReadOnlyRemoteFileSystemStrategyUnitTest.class );
-
- private static ReadOnlyRemoteFileSystemStrategy strategy;
-
- private static ReadOnlyRemoteFileSystemStrategy strategy2;
-
- private String testFile1 = "testFile1";
- private String testFile2 = "testFile2";
- private String testFile3 = "testFile3";
-
- private File[] expectedFileList = new File[] { new File( testFile1 ) , new File( testFile2 ) };
- private File[] newFileList = new File[] { new File( testFile3 ) };
- private File[] emptyFileList = new File[] {};
-
- @Test
- public void listFilesNegative()
- {
- try
- {
- strategy.filterFileList( null );
- }
- catch (RemoteFileSystemStrategyException e)
- {
- fail("Should be ok to pass null as the file array!");
- }
- }
-
- @Test
- public void listFiles() throws RemoteFileSystemStrategyException
- {
- File[] filteredFileList = strategy.filterFileList( expectedFileList );
- assertEquals( expectedFileList, filteredFileList );
-
- filteredFileList = strategy.filterFileList( expectedFileList );
- assertEquals( "No files should have been returned. They should have been cached.", emptyFileList, filteredFileList );
-
- filteredFileList = strategy.filterFileList( newFileList );
- assertEquals( newFileList, filteredFileList );
- assertTrue ( filteredFileList instanceof File[] );
- }
-
- @Test
- public void listFiles_With_Two_Strategy_Instances() throws Exception
- {
-
- try
- {
- File[] filteredFileList = strategy2.filterFileList( expectedFileList );
- assertEquals( expectedFileList, filteredFileList );
-
- filteredFileList = strategy.filterFileList( expectedFileList );
- assertEquals( emptyFileList, filteredFileList );
-
- filteredFileList = strategy2.filterFileList( newFileList );
- assertEquals( newFileList, filteredFileList );
-
- filteredFileList = strategy.filterFileList( newFileList );
- assertEquals( emptyFileList, filteredFileList );
-
- }
- catch ( Exception e )
- {
- log.error(e);
- }
- finally
- {
- strategy2.stop();
- }
-
- }
-
- @Before
- public void setup() throws CacheException
- {
- strategy.removeAllData();
- }
-
- @BeforeClass
- public static void classSetup() throws Exception
- {
- registerHsqlDriver();
- HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir() + "build" + File.separator + "hsqltestdb", "ftpcache");
-
- strategy = new ReadOnlyRemoteFileSystemStrategy();
- strategy.init( FtpFileCacheTestUtil.getCacheConfigFile() );
-
- strategy2 = new ReadOnlyRemoteFileSystemStrategy();
- strategy2.init( FtpFileCacheTestUtil.getCacheConfigFile() );
- }
-
- private static void registerHsqlDriver()
- {
- try
- {
- Class.forName( "org.hsqldb.jdbcDriver" );
- }
- catch (Exception e)
- {
- fail( "ERROR: failed to load JDBC driver." + e.getMessage() );
- }
- }
-
- @AfterClass
- public static void classTearDown() throws Exception
- {
- strategy.stop();
- strategy2.stop();
- HsqldbUtil.stopHsqldb( "jdbc:hsqldb:hsql://localhost:9001/ftpcache", "sa", "" );
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(ReadOnlyRemoteFileSystemStrategyUnitTest.class);
- }
-}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerIntegrationTest.java (from rev 12869, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerIntegrationTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerIntegrationTest.java 2007-06-26 17:38:50 UTC (rev 12870)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and
+ * individual contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY 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
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.remotestrategies.cache;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.TreeCache;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author Daniel Bevenius
+ *
+ */
+public class DeleteOnEvictTreeCacheListenerIntegrationTest
+{
+ @SuppressWarnings("unused")
+ private Logger log = Logger .getLogger( DeleteOnEvictTreeCacheListenerIntegrationTest.class );
+
+ private static DeleteOnEvictTreeCacheListener listener;
+ private static TreeCache treeCache;
+
+ private static final String FQN = "test/junit";
+ private String key = "testKey";
+ private String value = "testValue";
+ private Fqn fqnTest = new Fqn ( new String[] { FQN, key, value} );
+
+ @Test( expected=IllegalArgumentException.class )
+ public void constructor()
+ {
+ new DeleteOnEvictTreeCacheListener( null );
+ }
+
+ @Test
+ public void nodeEvict() throws CacheException
+ {
+ treeCache.put( FQN, key, value );
+ Node node = treeCache.get( fqnTest );
+ assertTrue( "The value should have been added!", treeCache.exists( FQN, key ) );
+
+ listener.nodeEvicted( fqnTest );
+ node = treeCache.get( fqnTest );
+ assertFalse( "The value should have been removed upon eviction!", treeCache.exists( fqnTest ) );
+
+ node = treeCache.get( fqnTest );
+ assertNull ( "The node should have been removed from the cache store", node );
+ }
+
+ @Test
+ public void testCacheRestart() throws Exception
+ {
+ treeCache.put( FQN, key, value );
+ Object valueBeforeCacheShutdown = treeCache.get( FQN, key );
+ treeCache.stop();
+ treeCache.start();
+ Object valueAfterCacheShutdown = treeCache.get( FQN, key );
+ assertEquals( "Objects should be equal even after a treeCache restart", valueBeforeCacheShutdown, valueAfterCacheShutdown );
+ }
+
+ @BeforeClass
+ public static void classSetup() throws Exception
+ {
+ FtpFileCacheTestUtil.startDB();
+ startCache();
+ }
+
+ private static void startCache() throws Exception
+ {
+ treeCache = new TreeCache();
+ listener = new DeleteOnEvictTreeCacheListener( treeCache );
+ treeCache.addTreeCacheListener( listener );
+ FtpFileCacheTestUtil.createTreeCache( treeCache, FtpFileCacheTestUtil.getCacheConfigFile() );
+ treeCache.start();
+ }
+
+ private static void stopCache()
+ {
+ treeCache.stop();
+ }
+
+ @AfterClass
+ public static void classTearDown() throws Exception
+ {
+ FtpFileCacheTestUtil.stopDB();
+ stopCache();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter( DeleteOnEvictTreeCacheListenerIntegrationTest.class );
+ }
+
+ @SuppressWarnings("unused")
+ private int getMaxAgeSeconds()
+ {
+ int maxAgeSeconds = 0;
+ NodeList elementsByTagName = treeCache.getEvictionPolicyConfig().getElementsByTagName( "region" );
+ for ( int i = elementsByTagName.getLength() ; i-->0 ; )
+ {
+ org.w3c.dom.Node region = elementsByTagName.item( i );
+ NamedNodeMap attributes = region.getAttributes();
+ org.w3c.dom.Node fqnNameNode = attributes.getNamedItem( "name" );
+ if ( fqnNameNode.getNodeValue().equals( "/ftp/cache" ))
+ {
+ NodeList childNodes = region.getChildNodes();
+ for ( int y = 0 ; y < childNodes.getLength() ; y ++ )
+ {
+ org.w3c.dom.Node node = childNodes.item( y );
+ if ( node.getNodeName().equals( "attribute" ))
+ {
+ NamedNodeMap attributes2 = node.getAttributes();
+ org.w3c.dom.Node namedItem = attributes2.getNamedItem( "name" );
+ if ( namedItem.getNodeValue().equals("maxAgeSeconds") )
+ {
+ maxAgeSeconds = Integer.valueOf( node.getTextContent() );
+ break;
+ }
+ }
+ }
+ }
+ }
+ return maxAgeSeconds;
+ }
+
+}
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerUnitTest.java 2007-06-26 14:46:11 UTC (rev 12869)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/DeleteOnEvictTreeCacheListenerUnitTest.java 2007-06-26 17:38:50 UTC (rev 12870)
@@ -1,156 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and
- * individual contributors as indicated by the @authors tag. See the
- * copyright.txt in the distribution for a full listing of individual
- * contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY 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
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.listeners.gateway.remotestrategies.cache;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.TreeCache;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.NodeList;
-
-/**
- *
- * @author Daniel Bevenius
- *
- */
-public class DeleteOnEvictTreeCacheListenerUnitTest
-{
- @SuppressWarnings("unused")
- private Logger log = Logger .getLogger( DeleteOnEvictTreeCacheListenerUnitTest.class );
-
- private static DeleteOnEvictTreeCacheListener listener;
- private static TreeCache treeCache;
-
- private static final String FQN = "test/junit";
- private String key = "testKey";
- private String value = "testValue";
- private Fqn fqnTest = new Fqn ( new String[] { FQN, key, value} );
-
- @Test( expected=IllegalArgumentException.class )
- public void constructor()
- {
- new DeleteOnEvictTreeCacheListener( null );
- }
-
- @Test
- public void nodeEvict() throws CacheException
- {
- treeCache.put( FQN, key, value );
- Node node = treeCache.get( fqnTest );
- assertTrue( "The value should have been added!", treeCache.exists( FQN, key ) );
-
- listener.nodeEvicted( fqnTest );
- node = treeCache.get( fqnTest );
- assertFalse( "The value should have been removed upon eviction!", treeCache.exists( fqnTest ) );
-
- node = treeCache.get( fqnTest );
- assertNull ( "The node should have been removed from the cache store", node );
- }
-
- @Test
- public void testCacheRestart() throws Exception
- {
- treeCache.put( FQN, key, value );
- Object valueBeforeCacheShutdown = treeCache.get( FQN, key );
- treeCache.stop();
- treeCache.start();
- Object valueAfterCacheShutdown = treeCache.get( FQN, key );
- assertEquals( "Objects should be equal even after a treeCache restart", valueBeforeCacheShutdown, valueAfterCacheShutdown );
- }
-
- @BeforeClass
- public static void classSetup() throws Exception
- {
- FtpFileCacheTestUtil.startDB();
- startCache();
- }
-
- private static void startCache() throws Exception
- {
- treeCache = new TreeCache();
- listener = new DeleteOnEvictTreeCacheListener( treeCache );
- treeCache.addTreeCacheListener( listener );
- FtpFileCacheTestUtil.createTreeCache( treeCache, FtpFileCacheTestUtil.getCacheConfigFile() );
- treeCache.start();
- }
-
- private static void stopCache()
- {
- treeCache.stop();
- }
-
- @AfterClass
- public static void classTearDown() throws Exception
- {
- FtpFileCacheTestUtil.stopDB();
- stopCache();
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter( FtpFileCacheUnitTest.class );
- }
-
- @SuppressWarnings("unused")
- private int getMaxAgeSeconds()
- {
- int maxAgeSeconds = 0;
- NodeList elementsByTagName = treeCache.getEvictionPolicyConfig().getElementsByTagName( "region" );
- for ( int i = elementsByTagName.getLength() ; i-->0 ; )
- {
- org.w3c.dom.Node region = elementsByTagName.item( i );
- NamedNodeMap attributes = region.getAttributes();
- org.w3c.dom.Node fqnNameNode = attributes.getNamedItem( "name" );
- if ( fqnNameNode.getNodeValue().equals( "/ftp/cache" ))
- {
- NodeList childNodes = region.getChildNodes();
- for ( int y = 0 ; y < childNodes.getLength() ; y ++ )
- {
- org.w3c.dom.Node node = childNodes.item( y );
- if ( node.getNodeName().equals( "attribute" ))
- {
- NamedNodeMap attributes2 = node.getAttributes();
- org.w3c.dom.Node namedItem = attributes2.getNamedItem( "name" );
- if ( namedItem.getNodeValue().equals("maxAgeSeconds") )
- {
- maxAgeSeconds = Integer.valueOf( node.getTextContent() );
- break;
- }
- }
- }
- }
- }
- return maxAgeSeconds;
- }
-
-}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheIntegrationTest.java (from rev 12869, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheIntegrationTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheIntegrationTest.java 2007-06-26 17:38:50 UTC (rev 12870)
@@ -0,0 +1,120 @@
+package org.jboss.soa.esb.listeners.gateway.remotestrategies.cache;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.InputStream;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.jboss.cache.CacheException;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Test class FtpFileCache
+ *
+ * @author Daniel Bevenius
+ *
+ */
+public class FtpFileCacheIntegrationTest
+{
+ private static Logger log = Logger.getLogger(FtpFileCacheIntegrationTest.class);
+
+ private static FtpFileCache ftpfileCache;
+
+ @Test
+ public void getConfigInputStream_From_Classpath() throws Exception
+ {
+ 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 );
+ }
+
+ @Test
+ public void getPutAndRemove()
+ {
+ String fileName = "testfile1";
+ try
+ {
+ ftpfileCache.putFileName( fileName );
+
+ Object obj = ftpfileCache.getFileName( fileName );
+ assertTrue( obj instanceof String );
+
+ String actualFileName = (String) obj;
+ assertEquals( fileName, actualFileName );
+ }
+ catch (CacheException e)
+ {
+ fail ( e.getMessage() );
+ }
+ finally
+ {
+ try { ftpfileCache.deleteFile( fileName ); } catch (CacheException e) { log.error( e.getMessage() ); }
+ }
+ }
+
+ @Test
+ public void addCacheListenerNegative()
+ {
+ try
+ {
+ ftpfileCache.addCacheListener( null );
+ }
+ catch ( Exception e )
+ {
+ fail("Should be ok to pass a null listener! Exception was : "+ e.getMessage() );
+ }
+ }
+
+ @Test
+ public void fileExists() throws CacheException
+ {
+ String fileName = "testfile1";
+
+ ftpfileCache.putFileName( fileName );
+
+ boolean fileExistsInCache = ftpfileCache.containsFile( fileName );
+ assertTrue ( fileExistsInCache );
+ }
+
+ @Test
+ public void removeAll() throws CacheException
+ {
+ String fileName = "testfile3";
+ ftpfileCache.putFileName( fileName );
+ ftpfileCache.removeAll();
+ assertNull ( ftpfileCache.getFileName( fileName ));
+
+ }
+
+ @BeforeClass
+ public static void classSetup() throws Exception
+ {
+ FtpFileCacheTestUtil.startDB();
+
+ ftpfileCache = new FtpFileCache ( FtpFileCacheTestUtil.getCacheConfigFile() );
+ ftpfileCache.start();
+ }
+
+
+ @AfterClass
+ public static void classTearDown() throws Exception
+ {
+ ftpfileCache.stop();
+ FtpFileCacheTestUtil.stopDB();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter( FtpFileCacheIntegrationTest.class );
+ }
+
+}
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheUnitTest.java 2007-06-26 14:46:11 UTC (rev 12869)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/remotestrategies/cache/FtpFileCacheUnitTest.java 2007-06-26 17:38:50 UTC (rev 12870)
@@ -1,120 +0,0 @@
-package org.jboss.soa.esb.listeners.gateway.remotestrategies.cache;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.InputStream;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.jboss.cache.CacheException;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-
-/**
- * Test class FtpFileCache
- *
- * @author Daniel Bevenius
- *
- */
-public class FtpFileCacheUnitTest
-{
- private static Logger log = Logger.getLogger(FtpFileCacheUnitTest.class);
-
- private static FtpFileCache ftpfileCache;
-
- @Test
- public void getConfigInputStream_From_Classpath() throws Exception
- {
- 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 );
- }
-
- @Test
- public void getPutAndRemove()
- {
- String fileName = "testfile1";
- try
- {
- ftpfileCache.putFileName( fileName );
-
- Object obj = ftpfileCache.getFileName( fileName );
- assertTrue( obj instanceof String );
-
- String actualFileName = (String) obj;
- assertEquals( fileName, actualFileName );
- }
- catch (CacheException e)
- {
- fail ( e.getMessage() );
- }
- finally
- {
- try { ftpfileCache.deleteFile( fileName ); } catch (CacheException e) { log.error( e.getMessage() ); }
- }
- }
-
- @Test
- public void addCacheListenerNegative()
- {
- try
- {
- ftpfileCache.addCacheListener( null );
- }
- catch ( Exception e )
- {
- fail("Should be ok to pass a null listener! Exception was : "+ e.getMessage() );
- }
- }
-
- @Test
- public void fileExists() throws CacheException
- {
- String fileName = "testfile1";
-
- ftpfileCache.putFileName( fileName );
-
- boolean fileExistsInCache = ftpfileCache.containsFile( fileName );
- assertTrue ( fileExistsInCache );
- }
-
- @Test
- public void removeAll() throws CacheException
- {
- String fileName = "testfile3";
- ftpfileCache.putFileName( fileName );
- ftpfileCache.removeAll();
- assertNull ( ftpfileCache.getFileName( fileName ));
-
- }
-
- @BeforeClass
- public static void classSetup() throws Exception
- {
- FtpFileCacheTestUtil.startDB();
-
- ftpfileCache = new FtpFileCache ( FtpFileCacheTestUtil.getCacheConfigFile() );
- ftpfileCache.start();
- }
-
-
- @AfterClass
- public static void classTearDown() throws Exception
- {
- ftpfileCache.stop();
- FtpFileCacheTestUtil.stopDB();
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter( FtpFileCacheUnitTest.class );
- }
-
-}
More information about the jboss-svn-commits
mailing list