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