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 RnfrCommandHandler class
|
| 23 | *
|
| 24 | * @version $Revision$ - $Date$
|
| 25 | *
|
| 26 | * @author Chris Mair
|
| 27 | */
|
| 28 | public final class RnfrCommandHandlerTest extends AbstractCommandHandlerTestCase {
|
| 29 |
|
| 30 | private RnfrCommandHandler commandHandler;
|
| 31 | private Command command1;
|
| 32 | private Command command2;
|
| 33 |
|
| 34 | /**
|
| 35 | * Test the handleCommand() method
|
| 36 | */
|
| 37 | public void testHandleCommand() throws Exception {
|
| 38 |
|
| 39 | session.sendReply(ReplyCodes.RNFR_OK, replyTextFor(ReplyCodes.RNFR_OK));
|
| 40 | session.sendReply(ReplyCodes.RNFR_OK, replyTextFor(ReplyCodes.RNFR_OK));
|
| 41 | replay(session);
|
| 42 |
|
| 43 | commandHandler.handleCommand(command1, session);
|
| 44 | commandHandler.handleCommand(command2, session);
|
| 45 | verify(session);
|
| 46 |
|
| 47 | verifyNumberOfInvocations(commandHandler, 2);
|
| 48 | verifyOneDataElement(commandHandler.getInvocation(0), RnfrCommandHandler.PATHNAME_KEY, FILENAME1);
|
| 49 | verifyOneDataElement(commandHandler.getInvocation(1), RnfrCommandHandler.PATHNAME_KEY, FILENAME2);
|
| 50 | }
|
| 51 |
|
| 52 | /**
|
| 53 | * Test the handleCommand() method, when no pathname parameter has been specified
|
| 54 | */
|
| 55 | public void testHandleCommand_MissingPathnameParameter() throws Exception {
|
| 56 | testHandleCommand_InvalidParameters(commandHandler, CommandNames.RNFR, EMPTY);
|
| 57 | }
|
| 58 |
|
| 59 | /**
|
| 60 | * Perform initialization before each test
|
| 61 | *
|
| 62 | * @see org.mockftpserver.core.command.AbstractCommandHandlerTestCase#setUp()
|
| 63 | */
|
| 64 | protected void setUp() throws Exception {
|
| 65 | super.setUp();
|
| 66 | commandHandler = new RnfrCommandHandler();
|
| 67 | commandHandler.setReplyTextBundle(replyTextBundle);
|
| 68 | command1 = new Command(CommandNames.RNFR, array(FILENAME1));
|
| 69 | command2 = new Command(CommandNames.RNFR, array(FILENAME2));
|
| 70 | }
|
| 71 |
|
| 72 | }
|