1 8 9 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.Database; 17 import com.sleepycat.je.DatabaseConfig; 18 import com.sleepycat.je.DatabaseException; 19 import com.sleepycat.je.Environment; 20 import com.sleepycat.je.EnvironmentConfig; 21 import com.sleepycat.je.config.EnvironmentParams; 22 import com.sleepycat.je.log.FileManager; 23 import com.sleepycat.je.util.TestUtils; 24 25 public class DbTreeTest extends TestCase { 26 private File envHome; 27 28 public DbTreeTest() { 29 envHome = new File (System.getProperty(TestUtils.DEST_DIR)); 30 } 31 32 public void setUp() throws IOException , DatabaseException { 33 TestUtils.removeFiles("Setup", envHome, FileManager.JE_SUFFIX); 34 } 35 36 public void tearDown() throws IOException , DatabaseException { 37 TestUtils.removeFiles("TearDown", envHome, FileManager.JE_SUFFIX); 38 } 39 40 public void testDbLookup() throws Throwable { 41 try { 42 EnvironmentConfig envConfig = TestUtils.initEnvConfig(); 43 envConfig.setTransactional(true); 44 envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "6"); 45 envConfig.setAllowCreate(true); 46 Environment env = new Environment(envHome, envConfig); 47 48 DatabaseConfig dbConfig = new DatabaseConfig(); 50 dbConfig.setTransactional(true); 51 dbConfig.setAllowCreate(true); 52 Database dbHandleAbcd = env.openDatabase(null, "abcd", dbConfig); 53 Database dbHandleXyz = env.openDatabase(null, "xyz", dbConfig); 54 55 dbConfig.setAllowCreate(false); 57 Database newAbcdHandle = env.openDatabase(null, "abcd", dbConfig); 58 Database newXyzHandle = env.openDatabase(null, "xyz", dbConfig); 59 60 dbHandleAbcd.close(); 61 dbHandleXyz.close(); 62 newAbcdHandle.close(); 63 newXyzHandle.close(); 64 env.close(); 65 } catch (Throwable t) { 66 t.printStackTrace(); 67 throw t; 68 } 69 } 70 } 71 | Popular Tags |