activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r943934 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/FTPBlobTest.java
Date Thu, 13 May 2010 16:47:53 GMT
Author: dejanb
Date: Thu May 13 16:47:53 2010
New Revision: 943934

URL: http://svn.apache.org/viewvc?rev=943934&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2732 - more test refactorings

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/FTPBlobTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/FTPBlobTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/FTPBlobTest.java?rev=943934&r1=943933&r2=943934&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/FTPBlobTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/FTPBlobTest.java Thu
May 13 16:47:53 2010
@@ -28,92 +28,15 @@ import javax.jms.Session;
 
 import junit.framework.Assert;
 
-import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQSession;
 import org.apache.activemq.BlobMessage;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
 import org.apache.activemq.command.ActiveMQBlobMessage;
-import org.apache.ftpserver.FtpServer;
-import org.apache.ftpserver.FtpServerFactory;
-import org.apache.ftpserver.ftplet.AuthorizationRequest;
-import org.apache.ftpserver.ftplet.User;
-import org.apache.ftpserver.ftplet.UserManager;
-import org.apache.ftpserver.listener.ListenerFactory;
-import org.apache.ftpserver.usermanager.UsernamePasswordAuthentication;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.api.Invocation;
-import org.jmock.lib.action.CustomAction;
-
-
-public class FTPBlobTest extends EmbeddedBrokerTestSupport {
-
-    private static final String ftpServerListenerName = "default";
-    private ActiveMQConnection connection;
-    private FtpServer server;
-    final static String userNamePass = "activemq";
-
-    Mockery context = null;
-
-    protected void setUp() throws Exception {
-
-        final File ftpHomeDirFile = new File("target/FTPBlobTest/ftptest");
-        ftpHomeDirFile.mkdirs();
-        ftpHomeDirFile.getParentFile().deleteOnExit();
-
-        FtpServerFactory serverFactory = new FtpServerFactory();
-        ListenerFactory factory = new ListenerFactory();
-
-        // mock up a user manager to validate user activemq:activemq and provide
-        // home dir options
-        context = new Mockery();
-        final UserManager userManager = context.mock(UserManager.class);
-        final User user = context.mock(User.class);
-        context.checking(new Expectations() {{
-                atLeast(1).of(userManager).authenticate(
-                        with(any(UsernamePasswordAuthentication.class))); will(returnValue(user));
-                atLeast(1).of(userManager).getUserByName(userNamePass); will(returnValue(user));
-                atLeast(1).of(user).getHomeDirectory(); will(returnValue(ftpHomeDirFile.getParent()));
-                atLeast(1).of(user).getMaxIdleTime(); will(returnValue(20000));
-                atLeast(1).of(user).getName(); will(returnValue(userNamePass));
-                atLeast(1).of(user).authorize( with(any(AuthorizationRequest.class))); will(new
CustomAction("return first passed in param") {
-                    public Object invoke(Invocation invocation)
-                            throws Throwable {
-                        return invocation.getParameter(0);
-                    }
-                });
-            }
-        });
-
-        serverFactory.setUserManager(userManager);
-        factory.setPort(0);
-        serverFactory.addListener(ftpServerListenerName, factory
-                .createListener());
-        server = serverFactory.createServer();
-        server.start();
-        int ftpPort = serverFactory.getListener(ftpServerListenerName)
-                .getPort();
-
-        bindAddress = "vm://localhost?jms.blobTransferPolicy.defaultUploadUrl=ftp://"
-                + userNamePass
-                + ":"
-                + userNamePass
-                + "@localhost:"
-                + ftpPort
-                + "/ftptest/";
-        super.setUp();
 
-        connection = (ActiveMQConnection) createConnection();
-        connection.start();
-    }
 
-    protected void tearDown() throws Exception {
-        connection.close();
-        super.tearDown();
-        server.stop();
-    }
+public class FTPBlobTest extends FTPTestSupport {
 
     public void testBlobFile() throws Exception {
+        setConnection();
         // first create Message
         File file = File.createTempFile("amq-data-file-", ".dat");
         // lets write some data



Mime
View raw message