StubFtpServer_StartTest.java revision 93102446a7b7c3d17888064b4e2e4e5cb534e6d0
1/*
2 * Copyright 2007 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.stub;
17
18import org.mockftpserver.stub.StubFtpServer;
19import org.mockftpserver.test.AbstractTest;
20
21/**
22 * Tests for StubFtpServer that require the StubFtpServer thread to be started.
23 *
24 * @version $Revision: 88 $ - $Date: 2007-10-27 20:18:11 -0400 (Sat, 27 Oct 2007) $
25 *
26 * @author Chris Mair
27 */
28public final class StubFtpServer_StartTest extends AbstractTest {
29
30    private StubFtpServer stubFtpServer;
31
32    /**
33     * Test the start() and stop() methods. Start the StubFtpServer and then stop it immediately.
34     */
35    public void testStartAndStop() throws Exception {
36        stubFtpServer = new StubFtpServer();
37        assertEquals("started - before", false, stubFtpServer.isStarted());
38
39        stubFtpServer.start();
40        Thread.sleep(200L);     // give it some time to get started
41        assertEquals("started - after start()", true, stubFtpServer.isStarted());
42        assertEquals("shutdown - after start()", false, stubFtpServer.isShutdown());
43
44        stubFtpServer.stop();
45
46        assertEquals("shutdown - after stop()", true, stubFtpServer.isShutdown());
47    }
48
49}
50