01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Core License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: LockTest.java,v 1.2 2002/06/08 00:49:39 mediumnet Exp $
08:
09: package org.ozoneDB.core.test;
10:
11: import java.io.*;
12: import org.ozoneDB.*;
13: import org.ozoneDB.core.*;
14: import org.ozoneDB.tools.*;
15: import junit.framework.*;
16:
17: /**
18: * @author <a href="http://www.softwarebuero.de/">SMB</a>
19: * @version $Revision: 1.2 $Date: 2002/06/08 00:49:39 $
20: */
21: public class LockTest extends TestCase {
22:
23: protected LocalDatabase db;
24:
25: public LockTest(String name) {
26: super (name);
27: }
28:
29: protected void setUp() {
30: try {
31: // System.out.println ("setUp(): ");
32:
33: new LocalDatabase().create("/tmp/db");
34: db = (LocalDatabase) ExternalDatabase
35: .openDatabase("ozonedb:local://" + "/tmp/db");
36: } catch (Exception e) {
37: e.printStackTrace();
38: throw new RuntimeException(e.toString());
39: }
40: }
41:
42: protected void tearDown() {
43: try {
44: // System.out.println ("tearDown(): ");
45: db.close();
46: } catch (Exception e) {
47: e.printStackTrace();
48: throw new RuntimeException(e.toString());
49: }
50: }
51:
52: public void testExclusiveLock() throws Exception {
53: User owner = db.theEnv.userManager.userForName(db.userName);
54: Transaction ta1 = db.theEnv.transactionManager
55: .newTransaction(owner);
56: Transaction ta2 = db.theEnv.transactionManager
57: .newTransaction(owner);
58: Lock lock = new ExclusiveLock();
59:
60: // assert (lock.tryAcquire (ta1, Lock.LEVEL_READ));
61: // assert (lock.tryAcquire (ta1, Lock.LEVEL_READ));
62: //
63: // assert (!lock.tryAcquire (ta2, Lock.LEVEL_READ));
64: }
65:
66: public void testSharedLock() {
67: }
68:
69: public void testMROWLock() {
70: }
71:
72: public static Test suite() {
73: TestSuite suite = new TestSuite();
74:
75: suite.addTest(new LockTest("testExclusiveLock"));
76: suite.addTest(new LockTest("testSharedLock"));
77: return suite;
78: }
79:
80: public static void main(String[] args) {
81: // junit.textui.TestRunner.run( LockTest.suite() );
82: }
83:
84: }
|