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