blob: 035652b91d329ccb78e1315b081fa1178896af09 [file] [log] [blame]
chrismair00dc7bd2014-05-11 21:21:28 +00001/*
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 */
16package org.mockftpserver.fake.command
17
18import org.mockftpserver.core.command.Command
19import org.mockftpserver.core.command.CommandHandler
20import org.mockftpserver.core.command.CommandNames
21import org.mockftpserver.core.command.ReplyCodes
22
23/**
24 * Tests for PortCommandHandler
25 *
26 * @version $Revision$ - $Date$
27 *
28 * @author Chris Mair
29 */
30class PortCommandHandlerTest extends AbstractFakeCommandHandlerTestCase {
31
32 static final PARAMETERS = ["11", "22", "33", "44", "1", "206"]
33 static final PARAMETERS_INSUFFICIENT = ["7", "29", "99", "11", "77"]
34 static final PORT = (1 << 8) + 206
35 static final HOST = InetAddress.getByName("11.22.33.44")
36
37 boolean testNotLoggedIn = false
38
39 void testHandleCommand() {
40 handleCommand(PARAMETERS)
41 assertSessionReply(ReplyCodes.PORT_OK, 'port')
42 assert session.clientDataPort == PORT
43 assert session.clientDataHost == HOST
44 }
45
46 void testHandleCommand_MissingRequiredParameter() {
47 testHandleCommand_MissingRequiredParameter(PARAMETERS_INSUFFICIENT)
48 }
49
50 //-------------------------------------------------------------------------
51 // Helper Methods
52 //-------------------------------------------------------------------------
53
54 void setUp() {
55 super.setUp()
56 }
57
58 CommandHandler createCommandHandler() {
59 new PortCommandHandler()
60 }
61
62 Command createValidCommand() {
63 return new Command(CommandNames.PORT, PARAMETERS)
64 }
65
66}