1/*
2 * Copyright 2008 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 */
16
17package org.mockftpserver.test;
18
19/**
20 * Contains static test utility method to determine FTP server port number to use for tests
21 *
22 * @version $Revision$ - $Date$
23 *
24 * @author Chris Mair
25 */
26public final class PortTestUtil {
27
28    private static final int DEFAULT_SERVER_CONTROL_PORT = 21;
29    private static final String FTP_SERVER_PORT_PROPERTY = "ftp.server.port";
30
31    /**
32     * Return the port number to use for the FTP server control port. If the "ftp.server.port"
33     * system property is defined, then use that value (converted to an integer), otherwise
34     * return the default port number of 21.
35     *
36     * @return the port number to use for the FTP server control port
37     */
38    public static int getFtpServerControlPort() {
39        String systemProperty = System.getProperty(FTP_SERVER_PORT_PROPERTY);
40        return (systemProperty == null) ? DEFAULT_SERVER_CONTROL_PORT : Integer.parseInt(systemProperty);
41    }
42
43}
44