01: /*
02: Very Quick Wiki - WikiWikiWeb clone
03: Copyright (C) 2001-2002 Gareth Cronin
04:
05: This program is free software; you can redistribute it and/or modify
06: it under the terms of the latest version of the GNU Lesser General
07: Public License as published by the Free Software Foundation;
08:
09: This program is distributed in the hope that it will be useful,
10: but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: GNU Lesser General Public License for more details.
13:
14: You should have received a copy of the GNU Lesser General Public License
15: along with this program (gpl.txt); if not, write to the Free Software
16: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: */
18: package vqwiki;
19:
20: import junit.framework.TestCase;
21: import org.apache.log4j.Logger;
22: import vqwiki.db.DatabaseHandler;
23:
24: public class TestDatabaseHandler extends TestCase {
25:
26: protected static Logger logger = Logger
27: .getLogger(TestDatabaseHandler.class);
28: final static String MYTOPIC1 = "MyTopic";
29: final static String CONTENTS1 = "This is SomeContents";
30:
31: /**
32: *
33: */
34: public TestDatabaseHandler(String name) {
35: super (name);
36: }
37:
38: /**
39: *
40: */
41: public void setUp() throws Exception {
42: DatabaseHandler handler = new DatabaseHandler();
43: handler.executeSQL("DROP TABLE Topic");
44: handler.executeSQL("DROP TABLE TopicLock");
45: handler.executeSQL("DROP TABLE TopicChange");
46: handler.executeSQL("DROP TABLE TopicVersion");
47: }
48:
49: /**
50: *
51: */
52: public void testStartup() throws Exception {
53: DatabaseHandler handler = new DatabaseHandler();
54: }
55:
56: /**
57: *
58: */
59: public void testTopic() throws Exception {
60: DatabaseHandler handler = new DatabaseHandler();
61: assertTrue("doesn't exist", !handler.exists("", MYTOPIC1));
62: handler.write("", CONTENTS1, true, MYTOPIC1);
63: assertTrue("does exist", handler.exists("", MYTOPIC1));
64: assertEquals("contents", CONTENTS1, handler.read("", MYTOPIC1));
65: }
66:
67: /**
68: *
69: */
70: public void testLocking() throws Exception {
71: DatabaseHandler handler = new DatabaseHandler();
72: handler.write("", CONTENTS1, true, MYTOPIC1);
73: assertTrue("lock", handler.lockTopic("", MYTOPIC1, "x"));
74: handler.unlockTopic("", MYTOPIC1);
75: assertTrue("lock", handler.lockTopic("", MYTOPIC1, "x"));
76: assertTrue("can't lock", !handler.lockTopic("", MYTOPIC1, "x"));
77: }
78: }
|