01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.responders.files;
04:
05: import junit.framework.*;
06: import fitnesse.util.FileUtil;
07: import fitnesse.http.*;
08: import fitnesse.FitNesseContext;
09:
10: import java.io.File;
11:
12: public class CreateDirectoryResponderTest extends TestCase {
13: public void setUp() throws Exception {
14: FileUtil.makeDir("testdir");
15: FileUtil.makeDir("testdir/files");
16: }
17:
18: public void tearDown() throws Exception {
19: FileUtil.deleteFileSystemDirectory("testdir");
20: }
21:
22: public void testMakeResponse() throws Exception {
23: FitNesseContext context = new FitNesseContext();
24: context.rootPagePath = "testdir";
25: CreateDirectoryResponder responder = new CreateDirectoryResponder();
26: MockRequest request = new MockRequest();
27: request.addInput("dirname", "subdir");
28: request.setResource("");
29:
30: Response response = responder.makeResponse(context, request);
31:
32: File file = new File("testdir/subdir");
33: assertTrue(file.exists());
34: assertTrue(file.isDirectory());
35:
36: assertEquals(303, response.getStatus());
37: assertEquals("/", response.getHeader("Location"));
38: }
39: }
|