chrismair | 00dc7bd | 2014-05-11 21:21:28 +0000 | [diff] [blame] | 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 | */
|
| 16 | package org.mockftpserver.stub.command;
|
| 17 |
|
| 18 | import org.mockftpserver.core.command.*;
|
| 19 | import org.mockftpserver.core.command.AbstractCommandHandlerTestCase;
|
| 20 |
|
| 21 | /**
|
| 22 | * Tests for the ModeCommandHandler class
|
| 23 | *
|
| 24 | * @version $Revision$ - $Date$
|
| 25 | *
|
| 26 | * @author Chris Mair
|
| 27 | */
|
| 28 | public final class ModeCommandHandlerTest extends AbstractCommandHandlerTestCase {
|
| 29 |
|
| 30 | private static final String CODE1 = "S";
|
| 31 | private static final String CODE2 = "B";
|
| 32 |
|
| 33 | private ModeCommandHandler commandHandler;
|
| 34 | private Command command1;
|
| 35 | private Command command2;
|
| 36 |
|
| 37 | /**
|
| 38 | * Test the handleCommand() method
|
| 39 | */
|
| 40 | public void testHandleCommand() throws Exception {
|
| 41 |
|
| 42 | session.sendReply(ReplyCodes.MODE_OK, replyTextFor(ReplyCodes.MODE_OK));
|
| 43 | session.sendReply(ReplyCodes.MODE_OK, replyTextFor(ReplyCodes.MODE_OK));
|
| 44 | replay(session);
|
| 45 |
|
| 46 | commandHandler.handleCommand(command1, session);
|
| 47 | commandHandler.handleCommand(command2, session);
|
| 48 | verify(session);
|
| 49 |
|
| 50 | verifyNumberOfInvocations(commandHandler, 2);
|
| 51 | verifyOneDataElement(commandHandler.getInvocation(0), ModeCommandHandler.MODE_KEY, CODE1);
|
| 52 | verifyOneDataElement(commandHandler.getInvocation(1), ModeCommandHandler.MODE_KEY, CODE2);
|
| 53 | }
|
| 54 |
|
| 55 | /**
|
| 56 | * Test the handleCommand() method, when no pathname parameter has been specified
|
| 57 | */
|
| 58 | public void testHandleCommand_MissingPathnameParameter() throws Exception {
|
| 59 | testHandleCommand_InvalidParameters(commandHandler, CommandNames.MODE, EMPTY);
|
| 60 | }
|
| 61 |
|
| 62 | /**
|
| 63 | * Perform initialization before each test
|
| 64 | *
|
| 65 | * @see org.mockftpserver.core.command.AbstractCommandHandlerTestCase#setUp()
|
| 66 | */
|
| 67 | protected void setUp() throws Exception {
|
| 68 | super.setUp();
|
| 69 | commandHandler = new ModeCommandHandler();
|
| 70 | commandHandler.setReplyTextBundle(replyTextBundle);
|
| 71 | command1 = new Command(CommandNames.MODE, array(CODE1));
|
| 72 | command2 = new Command(CommandNames.MODE, array(CODE2));
|
| 73 | }
|
| 74 |
|
| 75 | }
|