summaryrefslogtreecommitdiff
path: root/tags/2.5/src/test/groovy/org/mockftpserver/core/server/AbstractFtpServer_MultipleStartAndStopTest.groovy
diff options
context:
space:
mode:
Diffstat (limited to 'tags/2.5/src/test/groovy/org/mockftpserver/core/server/AbstractFtpServer_MultipleStartAndStopTest.groovy')
-rw-r--r--tags/2.5/src/test/groovy/org/mockftpserver/core/server/AbstractFtpServer_MultipleStartAndStopTest.groovy69
1 files changed, 69 insertions, 0 deletions
diff --git a/tags/2.5/src/test/groovy/org/mockftpserver/core/server/AbstractFtpServer_MultipleStartAndStopTest.groovy b/tags/2.5/src/test/groovy/org/mockftpserver/core/server/AbstractFtpServer_MultipleStartAndStopTest.groovy
new file mode 100644
index 0000000..9ab39ad
--- /dev/null
+++ b/tags/2.5/src/test/groovy/org/mockftpserver/core/server/AbstractFtpServer_MultipleStartAndStopTest.groovy
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mockftpserver.core.server
+
+import org.mockftpserver.fake.FakeFtpServer
+import org.mockftpserver.test.AbstractGroovyTestCase
+import org.mockftpserver.test.PortTestUtil
+
+/**
+ * Test starting and stopping Abstract(Fake)FtpServer multiple times.
+ *
+ * @version $Revision: 242 $ - $Date: 2010-03-21 07:41:01 -0400 (Sun, 21 Mar 2010) $
+ *
+ * @author Chris Mair
+ */
+class AbstractFtpServer_MultipleStartAndStopTest extends AbstractGroovyTestCase {
+
+ private FakeFtpServer ftpServer = new FakeFtpServer()
+
+ // Takes ~ 500ms per start/stop
+
+ void testStartAndStop() {
+ 10.times {
+ final def port = PortTestUtil.getFtpServerControlPort()
+ ftpServer.setServerControlPort(port);
+
+ ftpServer.start();
+ assert ftpServer.getServerControlPort() == port
+ Thread.sleep(100L); // give it some time to get started
+ assertEquals("started - after start()", true, ftpServer.isStarted());
+ assertEquals("shutdown - after start()", false, ftpServer.isShutdown());
+
+ ftpServer.stop();
+
+ assertEquals("shutdown - after stop()", true, ftpServer.isShutdown());
+ }
+ }
+
+ void testStartAndStop_UseDynamicFreePort() {
+ 5.times {
+ ftpServer.setServerControlPort(0);
+ assert ftpServer.getServerControlPort() == 0
+
+ ftpServer.start();
+ log("Using port ${ftpServer.getServerControlPort()}")
+ assert ftpServer.getServerControlPort() != 0
+
+ ftpServer.stop();
+ }
+ }
+
+ void tearDown() {
+ super.tearDown()
+ ftpServer.stop(); // just to be sure
+ }
+}