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.db4ounit.common.exceptions;
022:
023: import com.db4o.*;
024:
025: import db4ounit.*;
026: import db4ounit.extensions.*;
027:
028: public class DatabaseClosedExceptionTestCase extends
029: AbstractDb4oTestCase {
030:
031: public static void main(String[] args) {
032: new DatabaseClosedExceptionTestCase().runAll();
033: }
034:
035: public void testRollback() {
036: db().close();
037: Assert.expect(DatabaseClosedException.class, new CodeBlock() {
038: public void run() throws Throwable {
039: db().rollback();
040: }
041: });
042: }
043:
044: public void testCommit() {
045: db().close();
046: Assert.expect(DatabaseClosedException.class, new CodeBlock() {
047: public void run() throws Throwable {
048: db().commit();
049: }
050: });
051: }
052:
053: public void testSet() {
054: db().close();
055: Assert.expect(DatabaseClosedException.class, new CodeBlock() {
056: public void run() throws Throwable {
057: db().set(new Item());
058: }
059: });
060: }
061:
062: public void testDelete() {
063: db().close();
064: Assert.expect(DatabaseClosedException.class, new CodeBlock() {
065: public void run() throws Throwable {
066: db().delete(null);
067: }
068: });
069: }
070:
071: public void testQueryClass() {
072: db().close();
073: Assert.expect(DatabaseClosedException.class, new CodeBlock() {
074: public void run() throws Throwable {
075: db().query(this .getClass());
076: }
077: });
078: }
079:
080: public void testQuery() {
081: db().close();
082: Assert.expect(DatabaseClosedException.class, new CodeBlock() {
083: public void run() throws Throwable {
084: db().query();
085: }
086: });
087: }
088:
089: public void testDeactivate() {
090: db().close();
091: Assert.expect(DatabaseClosedException.class, new CodeBlock() {
092: public void run() throws Throwable {
093: db().deactivate(null, 1);
094: }
095: });
096: }
097:
098: public void testActivate() {
099: db().close();
100: Assert.expect(DatabaseClosedException.class, new CodeBlock() {
101: public void run() throws Throwable {
102: db().activate(null, 1);
103: }
104: });
105: }
106:
107: public void testGet() {
108: db().close();
109: Assert.expect(DatabaseClosedException.class, new CodeBlock() {
110: public void run() throws Throwable {
111: db().get(null);
112: }
113: });
114: }
115:
116: }
|