TypeCommandHandlerTest.groovy revision 5303c6ae1dde5f399fe48803e677942fc4326344
1/*
2 * Copyright 2008 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.fake.command
17
18import org.mockftpserver.core.command.Command
19import org.mockftpserver.core.command.CommandHandler
20import org.mockftpserver.core.command.CommandNames
21import org.mockftpserver.core.command.ReplyCodes
22import org.mockftpserver.core.session.SessionKeys
23
24/**
25 * Tests for TestCommandHandler
26 *
27 * @version $Revision$ - $Date$
28 *
29 * @author Chris Mair
30 */
31class TypeCommandHandlerTest extends AbstractFakeCommandHandlerTestCase {
32
33    void testHandleCommand_Ascii() {
34        handleCommand(['A'])
35        assertSessionReply(ReplyCodes.TYPE_OK, 'type')
36        assert session.getAttribute(SessionKeys.ASCII_TYPE) == true
37    }
38
39    void testHandleCommand_NonAscii() {
40        handleCommand(['I'])
41        assertSessionReply(ReplyCodes.TYPE_OK, 'type')
42        assert session.getAttribute(SessionKeys.ASCII_TYPE) == false
43    }
44
45    void testHandleCommand_MissingRequiredParameter() {
46        testHandleCommand_MissingRequiredParameter([])
47        assert session.getAttribute(SessionKeys.ASCII_TYPE) == null
48    }
49
50    //-------------------------------------------------------------------------
51    // Helper Methods
52    //-------------------------------------------------------------------------
53
54    CommandHandler createCommandHandler() {
55        new TypeCommandHandler()
56    }
57
58    Command createValidCommand() {
59        return new Command(CommandNames.TYPE, ['A'])
60    }
61
62    void setUp() {
63        super.setUp()
64    }
65
66}