1 8 9 package com.sleepycat.je.recovery; 10 11 import java.io.File ; 12 import java.io.IOException ; 13 14 import junit.framework.TestCase; 15 16 import com.sleepycat.je.DatabaseException; 17 import com.sleepycat.je.Environment; 18 import com.sleepycat.je.EnvironmentConfig; 19 import com.sleepycat.je.tree.Node; 20 import com.sleepycat.je.util.TestUtils; 21 22 public class MultiEnvTest extends TestCase { 23 24 private File envHome1; 25 private File envHome2; 26 private Environment env1; 27 private Environment env2; 28 29 public MultiEnvTest() { 30 envHome1 = new File (System.getProperty(TestUtils.DEST_DIR)); 31 envHome2 = new File (System.getProperty(TestUtils.DEST_DIR), 32 "propTest"); 33 } 34 35 public void setUp() 36 throws IOException { 37 38 TestUtils.removeLogFiles("Setup", envHome1, false); 39 TestUtils.removeLogFiles("Setup", envHome2, false); 40 } 41 42 public void tearDown() 43 throws Exception { 44 45 TestUtils.removeLogFiles("TearDown", envHome1, false); 46 TestUtils.removeLogFiles("TearDown", envHome2, false); 47 } 48 49 public void testNodeIdsAfterRecovery() 50 throws Throwable { 51 try { 52 56 env1 = openEnv(envHome1); 57 long maxNodeId1 = Node.getLastId(); 58 env1.close(); 59 60 63 env2 = openEnv(envHome2); 64 long maxNodeId2 = Node.getLastId(); 65 66 67 assertTrue(maxNodeId2 > maxNodeId1); 68 69 73 env1 = openEnv(envHome1); 74 long maxNodeId3 = Node.getLastId(); 75 assertTrue(maxNodeId3 >= maxNodeId2); 76 env2.close(); 77 } catch (Throwable t) { 78 79 t.printStackTrace(); 80 throw t; 81 } 82 } 83 84 private Environment openEnv(File envHome) 85 throws DatabaseException { 86 87 88 EnvironmentConfig envConfig = TestUtils.initEnvConfig(); 89 envConfig.setAllowCreate(true); 90 Environment e = new Environment(envHome, envConfig); 91 return e; 92 } 93 } 94 | Popular Tags |