1/* 2 * Copyright 2010 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package org.mockftpserver.fake 17 18import org.mockftpserver.test.AbstractGroovyTestCase 19import org.mockftpserver.test.PortTestUtil 20 21class FakeFtpServer_AlreadyStartedTest extends AbstractGroovyTestCase { 22 private FakeFtpServer ftpServer1 = new FakeFtpServer() 23 private FakeFtpServer ftpServer2 = new FakeFtpServer() 24 25 void testStartServer_WhenAlreadyStarted() { 26 ftpServer1.setServerControlPort(PortTestUtil.getFtpServerControlPort()) 27 ftpServer1.start(); 28 Thread.sleep(200L); // give it some time to get started 29 assertEquals("started - after start()", true, ftpServer1.isStarted()); 30 31 ftpServer2.setServerControlPort(PortTestUtil.getFtpServerControlPort()) 32 ftpServer2.start(); 33 log("started ftpServer2") 34 sleep(200L) // give it a chance to start and terminate 35 assert !ftpServer2.isStarted() 36 } 37 38 void tearDown() { 39 super.tearDown() 40 ftpServer1.stop(); 41 ftpServer2.stop(); 42 } 43} 44