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 java.io.File;
06:
07: import junit.framework.TestCase;
08: import fitnesse.FitNesseContext;
09: import fitnesse.http.MockRequest;
10: import fitnesse.http.Response;
11: import fitnesse.util.FileUtil;
12:
13: public class CreateDirectoryResponderTest extends TestCase {
14: public void setUp() throws Exception {
15: FileUtil.makeDir("testdir");
16: FileUtil.makeDir("testdir/files");
17: }
18:
19: public void tearDown() throws Exception {
20: FileUtil.deleteFileSystemDirectory("testdir");
21: }
22:
23: public void testMakeResponse() throws Exception {
24: FitNesseContext context = new FitNesseContext();
25: context.rootPagePath = "testdir";
26: CreateDirectoryResponder responder = new CreateDirectoryResponder();
27: MockRequest request = new MockRequest();
28: request.addInput("dirname", "subdir");
29: request.setResource("");
30:
31: Response response = responder.makeResponse(context, request);
32:
33: File file = new File("testdir/subdir");
34: assertTrue(file.exists());
35: assertTrue(file.isDirectory());
36:
37: assertEquals(303, response.getStatus());
38: assertEquals("/", response.getHeader("Location"));
39: }
40: }
|