Source Code Cross Referenced for StoredClassCatalogTestInit.java in  » JMX » je » com » sleepycat » collections » test » serial » 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.collections.test.serial 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2000,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: StoredClassCatalogTestInit.java,v 1.25.2.2 2008/01/07 15:14:24 cwl Exp $
007:         */
008:        package com.sleepycat.collections.test.serial;
009:
010:        import java.util.Map;
011:
012:        import junit.framework.Test;
013:        import junit.framework.TestCase;
014:        import junit.framework.TestSuite;
015:
016:        import com.sleepycat.bind.serial.SerialBinding;
017:        import com.sleepycat.bind.serial.StoredClassCatalog;
018:        import com.sleepycat.collections.StoredMap;
019:        import com.sleepycat.collections.TransactionRunner;
020:        import com.sleepycat.collections.TransactionWorker;
021:        import com.sleepycat.collections.test.DbTestUtil;
022:        import com.sleepycat.collections.test.TestEnv;
023:        import com.sleepycat.compat.DbCompat;
024:        import com.sleepycat.je.Database;
025:        import com.sleepycat.je.DatabaseConfig;
026:        import com.sleepycat.je.Environment;
027:
028:        /**
029:         * Runs part one of the StoredClassCatalogTest.  This part is run with the
030:         * old/original version of TestSerial in the classpath.  It creates a fresh
031:         * environment and databases containing serialized versions of the old class.
032:         * When StoredClassCatalogTest is run, it will read these objects from the
033:         * database created here.
034:         *
035:         * @author Mark Hayes
036:         */
037:        public class StoredClassCatalogTestInit extends TestCase implements 
038:                TransactionWorker {
039:
040:            static final String CATALOG_FILE = StoredClassCatalogTest.CATALOG_FILE;
041:            static final String STORE_FILE = StoredClassCatalogTest.STORE_FILE;
042:
043:            public static void main(String[] args) throws Exception {
044:
045:                junit.framework.TestResult tr = junit.textui.TestRunner
046:                        .run(suite());
047:                if (tr.errorCount() > 0 || tr.failureCount() > 0) {
048:                    System.exit(1);
049:                } else {
050:                    System.exit(0);
051:                }
052:            }
053:
054:            public static Test suite() throws Exception {
055:
056:                TestSuite suite = new TestSuite();
057:                for (int i = 0; i < TestEnv.ALL.length; i += 1) {
058:                    suite
059:                            .addTest(new StoredClassCatalogTestInit(
060:                                    TestEnv.ALL[i]));
061:                }
062:                return suite;
063:            }
064:
065:            private TestEnv testEnv;
066:            private Environment env;
067:            private StoredClassCatalog catalog;
068:            private Database store;
069:            private Map map;
070:            private TransactionRunner runner;
071:
072:            public StoredClassCatalogTestInit(TestEnv testEnv) {
073:
074:                super ("StoredClassCatalogTestInit-" + testEnv.getName());
075:                this .testEnv = testEnv;
076:            }
077:
078:            public void setUp() throws Exception {
079:
080:                DbTestUtil.printTestName(getName());
081:                env = testEnv
082:                        .open(StoredClassCatalogTest.makeTestName(testEnv));
083:                runner = new TransactionRunner(env);
084:
085:                catalog = new StoredClassCatalog(openDb(CATALOG_FILE));
086:
087:                SerialBinding keyBinding = new SerialBinding(catalog,
088:                        String.class);
089:                SerialBinding valueBinding = new SerialBinding(catalog,
090:                        TestSerial.class);
091:                store = openDb(STORE_FILE);
092:
093:                map = new StoredMap(store, keyBinding, valueBinding, true);
094:            }
095:
096:            private Database openDb(String file) throws Exception {
097:
098:                DatabaseConfig config = new DatabaseConfig();
099:                DbCompat.setTypeBtree(config);
100:                config.setTransactional(testEnv.isTxnMode());
101:                config.setAllowCreate(true);
102:
103:                return DbCompat.openDatabase(env, null, file, null, config);
104:            }
105:
106:            public void tearDown() {
107:
108:                try {
109:                    if (catalog != null) {
110:                        catalog.close();
111:                        catalog.close(); // should have no effect
112:                    }
113:                    if (store != null) {
114:                        store.close();
115:                    }
116:                    if (env != null) {
117:                        env.close();
118:                    }
119:                } catch (Exception e) {
120:                    System.err.println("Ignored exception during tearDown: ");
121:                    e.printStackTrace();
122:                } finally {
123:                    /* Ensure that GC can cleanup. */
124:                    catalog = null;
125:                    store = null;
126:                    env = null;
127:                    testEnv = null;
128:                    map = null;
129:                    runner = null;
130:                }
131:            }
132:
133:            public void runTest() throws Exception {
134:
135:                runner.run(this );
136:            }
137:
138:            public void doWork() throws Exception {
139:
140:                TestSerial one = new TestSerial(null);
141:                TestSerial two = new TestSerial(one);
142:                assertNull(
143:                        "Likely the classpath contains the wrong version of the"
144:                                + " TestSerial class, the 'original' version is required",
145:                        one.getStringField());
146:                assertNull(two.getStringField());
147:                map.put("one", one);
148:                map.put("two", two);
149:                one = (TestSerial) map.get("one");
150:                two = (TestSerial) map.get("two");
151:                assertEquals(one, two.getOther());
152:                assertNull(one.getStringField());
153:                assertNull(two.getStringField());
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.