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;
04:
05: import junit.framework.*;
06: import junit.swingui.TestRunner;
07: import fitnesse.util.FileUtil;
08: import fitnesse.authentication.*;
09: import fitnesse.testutil.FitNesseUtil;
10:
11: import java.io.*;
12:
13: public class FitNesseMainTest extends TestCase {
14: private FitNesseContext context;
15:
16: public static void main(String[] args) {
17: TestRunner.main(new String[] { "FitNesseMainTest" });
18: }
19:
20: public void setUp() throws Exception {
21: context = new FitNesseContext();
22: }
23:
24: public void tearDown() throws Exception {
25: FileUtil.deleteFileSystemDirectory("testFitnesseRoot");
26: }
27:
28: public void testDirCreations() throws Exception {
29: context.port = 80;
30: context.rootPagePath = "testFitnesseRoot";
31: new FitNesse(context);
32:
33: assertTrue(new File("testFitnesseRoot").exists());
34: assertTrue(new File("testFitnesseRoot/files").exists());
35: }
36:
37: public void testMakeNullAuthenticator() throws Exception {
38: Authenticator a = FitNesse.makeAuthenticator(null,
39: new ComponentFactory("blah"));
40: assertTrue(a instanceof PromiscuousAuthenticator);
41: }
42:
43: public void testMakeOneUserAuthenticator() throws Exception {
44: Authenticator a = FitNesse.makeAuthenticator("bob:uncle",
45: new ComponentFactory("blah"));
46: assertTrue(a instanceof OneUserAuthenticator);
47: OneUserAuthenticator oua = (OneUserAuthenticator) a;
48: assertEquals("bob", oua.getUser());
49: assertEquals("uncle", oua.getPassword());
50: }
51:
52: public void testMakeMultiUserAuthenticator() throws Exception {
53: final String passwordFilename = "testpasswd";
54: File passwd = new File(passwordFilename);
55: passwd.createNewFile();
56: Authenticator a = FitNesse.makeAuthenticator(passwordFilename,
57: new ComponentFactory("blah"));
58: assertTrue(a instanceof MultiUserAuthenticator);
59: passwd.delete();
60: }
61:
62: public void testContextFitNesseGetSet() throws Exception {
63: FitNesse fitnesse = new FitNesse(context, false);
64: assertSame(fitnesse, context.fitnesse);
65: }
66:
67: public void testIsRunning() throws Exception {
68: context.port = FitNesseUtil.port;
69: FitNesse fitnesse = new FitNesse(context, false);
70:
71: assertFalse(fitnesse.isRunning());
72:
73: fitnesse.start();
74: assertTrue(fitnesse.isRunning());
75:
76: fitnesse.stop();
77: assertFalse(fitnesse.isRunning());
78: }
79: }
|