2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 2002, 2012 Oracle and/or its affiliates. All rights reserved.
7 package com.sleepycat.db.test;
9 import org.junit.After;
10 import org.junit.AfterClass;
11 import org.junit.Before;
12 import org.junit.BeforeClass;
13 import org.junit.Test;
14 import static org.junit.Assert.assertEquals;
15 import static org.junit.Assert.assertTrue;
16 import static org.junit.Assert.fail;
18 import com.sleepycat.db.*;
21 import java.io.FileNotFoundException;
22 import java.io.FileOutputStream;
23 import java.io.IOException;
24 import java.io.OutputStream;
26 import com.sleepycat.db.test.TestUtils;
27 public class VerboseConfigTest {
28 public static final String VERBOSECONFIGTEST_DBNAME = "verboseconfigtest.db";
29 @BeforeClass public static void ClassInit() {
30 TestUtils.loadConfig(null);
31 TestUtils.check_file_removed(TestUtils.getDBFileName(VERBOSECONFIGTEST_DBNAME), true, true);
32 TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR, TestUtils.getDBFileName(VERBOSECONFIGTEST_DBNAME));
35 @AfterClass public static void ClassShutdown() {
36 TestUtils.check_file_removed(TestUtils.getDBFileName(VERBOSECONFIGTEST_DBNAME), true, true);
37 TestUtils.removeall(true, true, TestUtils.BASETEST_DBDIR, TestUtils.getDBFileName(VERBOSECONFIGTEST_DBNAME));
40 @Before public void PerTestInit()
44 @After public void PerTestShutdown()
48 * Test case implementations.
49 * To disable a test mark it with @Ignore
50 * To set a timeout(ms) notate like: @Test(timeout=1000)
51 * To indicate an expected exception notate like: (expected=Exception)
54 @Test public void test1()
55 throws DatabaseException, FileNotFoundException
57 EnvironmentConfig envc = new EnvironmentConfig();
58 envc.setAllowCreate(true);
59 envc.setInitializeCache(true);
60 envc.setVerbose(VerboseConfig.DEADLOCK, true);
61 envc.setVerbose(VerboseConfig.FILEOPS, true);
62 envc.setVerbose(VerboseConfig.FILEOPS_ALL, true);
63 envc.setVerbose(VerboseConfig.RECOVERY, true);
64 envc.setVerbose(VerboseConfig.REGISTER, true);
65 envc.setVerbose(VerboseConfig.REPLICATION, true);
66 envc.setVerbose(VerboseConfig.WAITSFOR, true);
67 envc.setMessageStream(new FileOutputStream(new File("messages.txt")));
68 Environment db_env = new Environment(TestUtils.BASETEST_DBFILE, envc);
70 new File("messages.txt").delete();
74 * Tests for old (now deprecated) API.
76 @Test public void test2()
77 throws DatabaseException, FileNotFoundException
79 EnvironmentConfig envc = new EnvironmentConfig();
80 envc.setAllowCreate(true);
81 envc.setInitializeCache(true);
82 envc.setVerboseDeadlock(true);
83 envc.setVerboseRecovery(true);
84 envc.setVerboseRegister(true);
85 envc.setVerboseReplication(true);
86 envc.setVerboseWaitsFor(true);
87 envc.setMessageStream(new FileOutputStream(new File("messages.txt")));
88 Environment db_env = new Environment(TestUtils.BASETEST_DBFILE, envc);
90 new File("messages.txt").delete();
92 @Test public void test3() throws Exception
94 EnvironmentConfig ec = new EnvironmentConfig();
95 ec.setAllowCreate(true);
96 ec.setInitializeCache(true);
97 ec.setInitializeLocking(true);
98 ec.setInitializeLogging(true);
99 ec.setInitializeReplication(true);
100 ec.setTransactional(true);
102 ec.setVerbose(VerboseConfig.REPLICATION_SYSTEM, false);
103 assertTrue(!ec.getVerbose(VerboseConfig.REPLICATION_SYSTEM));
104 Environment env = new Environment(TestUtils.BASETEST_DBFILE, ec);
105 assertTrue(!env.getConfig().getVerbose(VerboseConfig.REPLICATION_SYSTEM));