001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.test;
022:
023: import com.db4o.*;
024:
025: public class VMTermination {
026:
027: private String str;
028:
029: public VMTermination() {
030: }
031:
032: public VMTermination(String str) {
033: this .str = str;
034: }
035:
036: public static void main(String[] args) throws Exception {
037:
038: // to circumvent the shutdown-hook, run this
039: // testcase with a breakpoint in the debugger
040: // see comments below
041:
042: // run one at a time, one after the other
043:
044: int step = 0;
045:
046: switch (step) {
047: case 0:
048: // Test.delete();
049: Test.statistics();
050: break;
051: case 1:
052: killSingleUser();
053: break;
054: case 2:
055: testSingleUser();
056: break;
057: case 3:
058: killServer1();
059: break;
060: case 4:
061: testServer1();
062: break;
063: case 5:
064: killServer2();
065: break;
066: case 6:
067: testServer2();
068: break;
069: }
070:
071: }
072:
073: public static void killSingleUser() throws Exception {
074: Test.runServer = false;
075: Test.clientServer = false;
076: Test.delete();
077: ObjectContainer con = Test.open();
078: con.set(new VMTermination("willbethere"));
079: con.commit();
080:
081: // place a breakpoint on the following line
082: // and stop the debugger
083:
084: System.exit(0);
085: }
086:
087: public static void testSingleUser() {
088: Test.runServer = false;
089: Test.clientServer = false;
090: ObjectContainer con = Test.open();
091: Test.ensureOccurrences(new VMTermination(), 1);
092: Test.logAll();
093: Test.end();
094: }
095:
096: public static void killServer1() throws Exception {
097: Test.runServer = true;
098: Test.clientServer = true;
099: Test.delete();
100: ObjectContainer con = Test.open();
101: con.set(new VMTermination("willbethere"));
102: con.commit();
103:
104: // place a breakpoint on the following line
105: // and stop the debugger
106: System.exit(0);
107: }
108:
109: public static void testServer1() {
110: Test.runServer = true;
111: Test.clientServer = true;
112: ObjectContainer con = Test.open();
113: Test.ensureOccurrences(new VMTermination(), 1);
114: Test.logAll();
115: Test.end();
116: }
117:
118: public static void killServer2() throws Exception {
119: Test.runServer = true;
120: Test.clientServer = true;
121: ObjectContainer con = Test.open();
122: con.set(new VMTermination("willbethere"));
123:
124: // a bit tougher now: place a
125: // breakpoint in commit sourcecode
126: // and stop the debugger there
127: con.commit();
128: }
129:
130: public static void testServer2() {
131: Test.runServer = true;
132: Test.clientServer = true;
133: ObjectContainer con = Test.open();
134: Test.ensureOccurrences(new VMTermination(), 2);
135: Test.logAll();
136: Test.end();
137: }
138:
139: }
|