KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > dbi > DbEnvPoolTest


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2004,2006 Oracle. All rights reserved.
5  *
6  * $Id: DbEnvPoolTest.java,v 1.5 2006/10/30 21:14:43 bostic Exp $
7  */

8
9 package com.sleepycat.je.dbi;
10
11 import java.io.File JavaDoc;
12 import java.io.IOException JavaDoc;
13
14 import junit.framework.TestCase;
15
16 import com.sleepycat.je.Environment;
17 import com.sleepycat.je.EnvironmentConfig;
18 import com.sleepycat.je.util.TestUtils;
19
20 public class DbEnvPoolTest extends TestCase {
21
22     private static final boolean DEBUG = false;
23
24     private File JavaDoc envHome = new File JavaDoc(System.getProperty(TestUtils.DEST_DIR));
25
26     public DbEnvPoolTest() {
27     }
28
29     public void setUp()
30         throws IOException JavaDoc {
31
32         TestUtils.removeLogFiles("Setup", envHome, false);
33     }
34     
35     public void tearDown()
36         throws Exception JavaDoc {
37
38     TestUtils.removeLogFiles("TearDown", envHome, false);
39     }
40
41     public void testCanonicalEnvironmentName ()
42         throws Throwable JavaDoc {
43         try {
44             File JavaDoc file1 = new File JavaDoc(System.getProperty(TestUtils.DEST_DIR));
45             File JavaDoc file2 = new File JavaDoc("build/test/classes");
46
47             /* Create an environment. */
48             EnvironmentConfig envConfig = TestUtils.initEnvConfig();
49             envConfig.setAllowCreate(true);
50             Environment envA = new Environment(envHome, envConfig);
51
52             /* Look in the environment pool with the relative path name. */
53             DbEnvPool.EnvironmentImplInfo info =
54                 DbEnvPool.getInstance().getEnvironment
55                     (file2, TestUtils.initEnvConfig());
56             /* We should find this file in the pool. */
57             assertEquals(false, info.firstHandle);
58             envA.close();
59
60         } catch (Throwable JavaDoc t) {
61             /* Dump stack trace before trying to tear down. */
62             t.printStackTrace();
63             throw t;
64         }
65     }
66 }
67
Popular Tags