PwdCommandHandlerTest.java revision 4ca3386623ce60063f27955ad1b2b1b6cbba8b09
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 */ 16package org.mockftpserver.stub.command; 17 18import org.mockftpserver.core.command.Command; 19import org.mockftpserver.core.command.CommandNames; 20import org.mockftpserver.core.command.ReplyCodes; 21import org.mockftpserver.stub.command.PwdCommandHandler; 22 23/** 24 * Tests for the PwdCommandHandler class 25 * 26 * @version $Revision$ - $Date$ 27 * 28 * @author Chris Mair 29 */ 30public final class PwdCommandHandlerTest extends AbstractCommandHandlerTest { 31 32 private PwdCommandHandler commandHandler; 33 34 /** 35 * Test the handleCommand() method 36 */ 37 public void testHandleCommand() throws Exception { 38 39 final String RESPONSE_DATA = "current dir 1"; 40 commandHandler.setDirectory(RESPONSE_DATA); 41 42 session.sendReply(ReplyCodes.PWD_OK, formattedReplyTextFor(ReplyCodes.PWD_OK, "\"" + RESPONSE_DATA + "\"")); 43 replay(session); 44 45 final Command COMMAND = new Command(CommandNames.PWD, EMPTY); 46 47 commandHandler.handleCommand(COMMAND, session); 48 verify(session); 49 50 verifyNumberOfInvocations(commandHandler, 1); 51 verifyNoDataElements(commandHandler.getInvocation(0)); 52 } 53 54 /** 55 * Perform initialization before each test 56 * 57 * @see org.mockftpserver.stub.command.AbstractCommandHandlerTest#setUp() 58 */ 59 protected void setUp() throws Exception { 60 super.setUp(); 61 commandHandler = new PwdCommandHandler(); 62 commandHandler.setReplyTextBundle(replyTextBundle); 63 } 64 65} 66