blob: a26d4515ed0fc7cd9c78b4dca044058414c0621a [file] [log] [blame]
chrismair00dc7bd2014-05-11 21:21:28 +00001/*
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 PwdCommandHandler
26 *
27 * @version $Revision$ - $Date$
28 *
29 * @author Chris Mair
30 */
31class PwdCommandHandlerTest extends AbstractFakeCommandHandlerTestCase {
32
33 static final DIR = "/usr/abc"
34
35 boolean testNotLoggedIn = false
36
37 void testHandleCommand() {
38 session.setAttribute(SessionKeys.CURRENT_DIRECTORY, DIR)
39 handleCommand([])
40 assertSessionReply(ReplyCodes.PWD_OK, ["pwd", DIR])
41 }
42
43 void testHandleCommand_CurrentDirectoryNotSet() {
44 handleCommand([])
45 assertSessionReply(ReplyCodes.READ_FILE_ERROR, 'filesystem.currentDirectoryNotSet')
46 }
47
48 //-------------------------------------------------------------------------
49 // Helper Methods
50 //-------------------------------------------------------------------------
51
52 CommandHandler createCommandHandler() {
53 new PwdCommandHandler()
54 }
55
56 Command createValidCommand() {
57 return new Command(CommandNames.PWD, [])
58 }
59
60}