Source Code Cross Referenced for TxnFSyncTest.java in  » JMX » je » com » sleepycat » je » txn » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » JMX » je » com.sleepycat.je.txn 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2002,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: TxnFSyncTest.java,v 1.10.2.3 2008/01/07 15:14:34 cwl Exp $
007:         */
008:
009:        package com.sleepycat.je.txn;
010:
011:        import junit.framework.Test;
012:
013:        import com.sleepycat.je.Database;
014:        import com.sleepycat.je.DatabaseConfig;
015:        import com.sleepycat.je.DatabaseEntry;
016:        import com.sleepycat.je.DbInternal;
017:        import com.sleepycat.je.Environment;
018:        import com.sleepycat.je.EnvironmentConfig;
019:        import com.sleepycat.je.LockMode;
020:        import com.sleepycat.je.OperationStatus;
021:        import com.sleepycat.je.Transaction;
022:        import com.sleepycat.je.config.EnvironmentParams;
023:        import com.sleepycat.je.dbi.DbEnvPool;
024:        import com.sleepycat.je.dbi.EnvironmentImpl;
025:        import com.sleepycat.je.test.TxnTestCase;
026:        import com.sleepycat.je.util.TestUtils;
027:
028:        /*
029:         * Make sure that transactions sync to disk. Mimic a crash by failing to
030:         * close the environment and explicitly flush the log manager. If we haven't
031:         * properly written and synced data to disk, we'll have unflushed data and
032:         * we won't find the expected data in the log.
033:         *
034:         * Note that this test is run with the TxnTestCase framework and will
035:         * be exercised with app-created and autocommit txns.
036:         */
037:
038:        public class TxnFSyncTest extends TxnTestCase {
039:
040:            private static final int NUM_RECS = 5;
041:
042:            private static EnvironmentConfig envConfig = TestUtils
043:                    .initEnvConfig();
044:            static {
045:                envConfig.setAllowCreate(true);
046:                setupEnvConfig(envConfig);
047:            }
048:
049:            private static void setupEnvConfig(EnvironmentConfig envConfig) {
050:                envConfig.setTransactional(true);
051:                envConfig.setConfigParam(EnvironmentParams.ENV_RUN_CHECKPOINTER
052:                        .getName(), "false");
053:            }
054:
055:            public static Test suite() {
056:                /* Run these tests with user and autocommit txns. */
057:                return txnTestSuite(TxnFSyncTest.class, envConfig,
058:                        new String[] { TxnTestCase.TXN_USER,
059:                                TxnTestCase.TXN_AUTO });
060:            }
061:
062:            public void testFSyncButNoClose() throws Exception {
063:
064:                try {
065:                    /* Create a database. */
066:                    DatabaseConfig dbConfig = new DatabaseConfig();
067:                    dbConfig.setTransactional(isTransactional);
068:                    dbConfig.setAllowCreate(true);
069:                    Transaction txn = txnBegin();
070:                    Database db = env.openDatabase(txn, "foo", dbConfig);
071:
072:                    /* Insert data. */
073:                    DatabaseEntry key = new DatabaseEntry();
074:                    DatabaseEntry data = new DatabaseEntry();
075:                    for (int i = 0; i < NUM_RECS; i++) {
076:                        Integer val = new Integer(i);
077:                        key.setData(val.toString().getBytes());
078:                        data.setData(val.toString().getBytes());
079:
080:                        assertEquals(OperationStatus.SUCCESS, db
081:                                .putNoOverwrite(txn, key, data));
082:                    }
083:                    txnCommit(txn);
084:
085:                    /*
086:                     * Now throw away this environment WITHOUT flushing the log
087:                     * manager. We do need to release the environment file lock
088:                     * and all file handles so we can recover in this test and
089:                     * run repeated test cases within this one test program.
090:                     */
091:                    EnvironmentImpl envImpl = DbInternal
092:                            .envGetEnvironmentImpl(env);
093:                    envImpl.getFileManager().clear(); // release file handles
094:                    envImpl.getFileManager().close(); // release file lock
095:                    env = null;
096:                    DbEnvPool.getInstance().clear();
097:
098:                    /*
099:                     * Open the environment and database again. The database should
100:                     * exist.
101:                     */
102:                    EnvironmentConfig envConfig2 = TestUtils.initEnvConfig();
103:                    setupEnvConfig(envConfig2);
104:                    env = new Environment(envHome, envConfig2);
105:                    dbConfig.setAllowCreate(false);
106:                    db = env.openDatabase(null, "foo", dbConfig);
107:
108:                    /* Read all the data. */
109:                    for (int i = 0; i < NUM_RECS; i++) {
110:                        Integer val = new Integer(i);
111:                        key.setData(val.toString().getBytes());
112:
113:                        assertEquals(OperationStatus.SUCCESS, db.get(null, key,
114:                                data, LockMode.DEFAULT));
115:                        /* add test of data. */
116:                    }
117:                    db.close();
118:                } catch (Exception e) {
119:                    e.printStackTrace();
120:                    throw e;
121:                }
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.