01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2004,2008 Oracle. All rights reserved.
05: *
06: * $Id: DbEnvPoolTest.java,v 1.5.2.3 2008/01/07 15:14:26 cwl Exp $
07: */
08:
09: package com.sleepycat.je.dbi;
10:
11: import java.io.File;
12: import java.io.IOException;
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 envHome = new File(System
25: .getProperty(TestUtils.DEST_DIR));
26:
27: public DbEnvPoolTest() {
28: }
29:
30: public void setUp() throws IOException {
31:
32: TestUtils.removeLogFiles("Setup", envHome, false);
33: }
34:
35: public void tearDown() throws Exception {
36:
37: TestUtils.removeLogFiles("TearDown", envHome, false);
38: }
39:
40: public void testCanonicalEnvironmentName() throws Throwable {
41: try {
42: File file1 = new File(System
43: .getProperty(TestUtils.DEST_DIR));
44: File file2 = new File("build/test/classes");
45:
46: /* Create an environment. */
47: EnvironmentConfig envConfig = TestUtils.initEnvConfig();
48: envConfig.setAllowCreate(true);
49: Environment envA = new Environment(envHome, envConfig);
50:
51: /* Look in the environment pool with the relative path name. */
52: DbEnvPool.EnvironmentImplInfo info = DbEnvPool
53: .getInstance().getEnvironment(file2,
54: TestUtils.initEnvConfig());
55: /* We should find this file in the pool. */
56: assertEquals(false, info.firstHandle);
57: envA.close();
58:
59: } catch (Throwable t) {
60: /* Dump stack trace before trying to tear down. */
61: t.printStackTrace();
62: throw t;
63: }
64: }
65: }
|