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.slf4j.Logger;
|
| 19 | import org.slf4j.LoggerFactory;
|
| 20 | import org.mockftpserver.core.command.*;
|
| 21 | import org.mockftpserver.core.command.AbstractCommandHandlerTestCase;
|
| 22 | import org.mockftpserver.core.util.AssertFailedException;
|
| 23 |
|
| 24 | /**
|
| 25 | * Tests for the SystCommandHandler class
|
| 26 | *
|
| 27 | * @version $Revision$ - $Date$
|
| 28 | *
|
| 29 | * @author Chris Mair
|
| 30 | */
|
| 31 | public final class SystCommandHandlerTest extends AbstractCommandHandlerTestCase {
|
| 32 |
|
| 33 | private static final Logger LOG = LoggerFactory.getLogger(SystCommandHandlerTest.class);
|
| 34 |
|
| 35 | private SystCommandHandler commandHandler;
|
| 36 |
|
| 37 | /**
|
| 38 | * Test the handleCommand() method
|
| 39 | */
|
| 40 | public void testHandleCommand() throws Exception {
|
| 41 |
|
| 42 | final String SYSTEM_NAME = "UNIX";
|
| 43 | commandHandler.setSystemName(SYSTEM_NAME);
|
| 44 |
|
| 45 | session.sendReply(ReplyCodes.SYST_OK, formattedReplyTextFor(ReplyCodes.SYST_OK, "\"" + SYSTEM_NAME + "\""));
|
| 46 | replay(session);
|
| 47 |
|
| 48 | final Command COMMAND = new Command(CommandNames.SYST, EMPTY);
|
| 49 |
|
| 50 | commandHandler.handleCommand(COMMAND, session);
|
| 51 | verify(session);
|
| 52 |
|
| 53 | verifyNumberOfInvocations(commandHandler, 1);
|
| 54 | verifyNoDataElements(commandHandler.getInvocation(0));
|
| 55 | }
|
| 56 |
|
| 57 | /**
|
| 58 | * Test the SetSystemName method, passing in a null
|
| 59 | */
|
| 60 | public void testSetSystemName_Null() {
|
| 61 | try {
|
| 62 | commandHandler.setSystemName(null);
|
| 63 | fail("Expected AssertFailedException");
|
| 64 | }
|
| 65 | catch (AssertFailedException expected) {
|
| 66 | LOG.info("Expected: " + expected);
|
| 67 | }
|
| 68 | }
|
| 69 |
|
| 70 | /**
|
| 71 | * Perform initialization before each test
|
| 72 | * @see org.mockftpserver.core.command.AbstractCommandHandlerTestCase#setUp()
|
| 73 | */
|
| 74 | protected void setUp() throws Exception {
|
| 75 | super.setUp();
|
| 76 | commandHandler = new SystCommandHandler();
|
| 77 | commandHandler.setReplyTextBundle(replyTextBundle);
|
| 78 | }
|
| 79 |
|
| 80 | }
|