EpsvCommandHandlerTest.java revision 3e469b93fd10bc09ea2c088516168bf6a5cbaa43
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.AbstractCommandHandlerTest; 19import org.mockftpserver.core.command.Command; 20import org.mockftpserver.core.command.CommandNames; 21import org.mockftpserver.core.command.ReplyCodes; 22 23import java.net.InetAddress; 24 25/** 26 * Tests for the EpsvCommandHandler class 27 * 28 * @author Chris Mair 29 * @version $Revision$ - $Date$ 30 */ 31public final class EpsvCommandHandlerTest extends AbstractCommandHandlerTest { 32 33 private static final InetAddress SERVER = inetAddress("1080::8:800:200C:417A"); 34 private static final int PORT = 6275; 35 36 private EpsvCommandHandler commandHandler; 37 38 /** 39 * Test the handleCommand() method 40 */ 41 public void testHandleCommand() throws Exception { 42 session.switchToPassiveMode(); 43 control(session).setReturnValue(PORT); 44 session.getServerHost(); 45 control(session).setReturnValue(SERVER); 46 session.sendReply(ReplyCodes.EPSV_OK, formattedReplyTextFor(ReplyCodes.EPSV_OK, Integer.toString(PORT))); 47 replay(session); 48 49 final Command COMMAND = new Command(CommandNames.EPSV, EMPTY); 50 51 commandHandler.handleCommand(COMMAND, session); 52 verify(session); 53 54 verifyNumberOfInvocations(commandHandler, 1); 55 verifyNoDataElements(commandHandler.getInvocation(0)); 56 } 57 58 /** 59 * Perform initialization before each test 60 * 61 * @see org.mockftpserver.core.command.AbstractCommandHandlerTest#setUp() 62 */ 63 protected void setUp() throws Exception { 64 super.setUp(); 65 commandHandler = new EpsvCommandHandler(); 66 commandHandler.setReplyTextBundle(replyTextBundle); 67 } 68 69}