Source Code Cross Referenced for EvolveCase.java in  » JMX » je » com » sleepycat » persist » test » 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.persist.test 
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: EvolveCase.java,v 1.8.2.4 2008/01/07 15:14:35 cwl Exp $
007:         */
008:        package com.sleepycat.persist.test;
009:
010:        import java.util.Iterator;
011:        import java.util.List;
012:
013:        import junit.framework.TestCase;
014:
015:        import com.sleepycat.je.DatabaseException;
016:        import com.sleepycat.je.Environment;
017:        import com.sleepycat.persist.EntityStore;
018:        import com.sleepycat.persist.StoreConfig;
019:        import com.sleepycat.persist.evolve.Mutations;
020:        import com.sleepycat.persist.model.ClassMetadata;
021:        import com.sleepycat.persist.model.EntityModel;
022:        import com.sleepycat.persist.model.Persistent;
023:        import com.sleepycat.persist.raw.RawStore;
024:        import com.sleepycat.persist.raw.RawType;
025:
026:        @Persistent
027:        abstract class EvolveCase {
028:
029:            static final String STORE_NAME = "foo";
030:
031:            transient boolean updated;
032:
033:            Mutations getMutations() {
034:                return null;
035:            }
036:
037:            void configure(EntityModel model, StoreConfig config) {
038:            }
039:
040:            String getStoreOpenException() {
041:                return null;
042:            }
043:
044:            int getNRecordsExpected() {
045:                return 1;
046:            }
047:
048:            void checkUnevolvedModel(EntityModel model, Environment env) {
049:            }
050:
051:            void checkEvolvedModel(EntityModel model, Environment env,
052:                    boolean oldTypesExist) {
053:            }
054:
055:            void writeObjects(EntityStore store) throws DatabaseException {
056:            }
057:
058:            void readObjects(EntityStore store, boolean doUpdate)
059:                    throws DatabaseException {
060:            }
061:
062:            void readRawObjects(RawStore store, boolean expectEvolved,
063:                    boolean expectUpdated) throws DatabaseException {
064:            }
065:
066:            void copyRawObjects(RawStore rawStore, EntityStore newStore)
067:                    throws DatabaseException {
068:            }
069:
070:            /**
071:             * Checks for equality and prints the entire values rather than
072:             * abbreviated values like TestCase.assertEquals does.
073:             */
074:            static void checkEquals(Object expected, Object got) {
075:                if ((expected != null) ? (!expected.equals(got))
076:                        : (got != null)) {
077:                    TestCase.fail("Expected:\n" + expected + "\nBut got:\n"
078:                            + got);
079:                }
080:            }
081:
082:            /**
083:             * Asserts than an entity database exists or does not exist.
084:             */
085:            static void assertDbExists(boolean expectExists, Environment env,
086:                    String entityClassName) {
087:                assertDbExists(expectExists, env, entityClassName, null);
088:            }
089:
090:            /**
091:             * Checks that an entity class exists or does not exist.
092:             */
093:            static void checkEntity(boolean exists, EntityModel model,
094:                    Environment env, String className, int version,
095:                    String secKeyName) {
096:                if (exists) {
097:                    TestCase.assertNotNull(model.getEntityMetadata(className));
098:                    ClassMetadata meta = model.getClassMetadata(className);
099:                    TestCase.assertNotNull(meta);
100:                    TestCase.assertEquals(version, meta.getVersion());
101:                    TestCase.assertTrue(meta.isEntityClass());
102:
103:                    RawType raw = model.getRawType(className);
104:                    TestCase.assertNotNull(raw);
105:                    TestCase.assertEquals(version, raw.getVersion());
106:                } else {
107:                    TestCase.assertNull(model.getEntityMetadata(className));
108:                    TestCase.assertNull(model.getClassMetadata(className));
109:                    TestCase.assertNull(model.getRawType(className));
110:                }
111:
112:                assertDbExists(exists, env, className);
113:                if (secKeyName != null) {
114:                    assertDbExists(exists, env, className, secKeyName);
115:                }
116:            }
117:
118:            /**
119:             * Checks that a non-entity class exists or does not exist.
120:             */
121:            static void checkNonEntity(boolean exists, EntityModel model,
122:                    Environment env, String className, int version) {
123:                if (exists) {
124:                    ClassMetadata meta = model.getClassMetadata(className);
125:                    TestCase.assertNotNull(meta);
126:                    TestCase.assertEquals(version, meta.getVersion());
127:                    TestCase.assertTrue(!meta.isEntityClass());
128:
129:                    RawType raw = model.getRawType(className);
130:                    TestCase.assertNotNull(raw);
131:                    TestCase.assertEquals(version, raw.getVersion());
132:                } else {
133:                    TestCase.assertNull(model.getClassMetadata(className));
134:                    TestCase.assertNull(model.getRawType(className));
135:                }
136:
137:                TestCase.assertNull(model.getEntityMetadata(className));
138:                assertDbExists(false, env, className);
139:            }
140:
141:            /**
142:             * Asserts than a database expectExists or does not exist. If keyName is
143:             * null, checks an entity database.  If keyName is non-null, checks a
144:             * secondary database.
145:             */
146:            static void assertDbExists(boolean expectExists, Environment env,
147:                    String entityClassName, String keyName) {
148:                PersistTestUtils.assertDbExists(expectExists, env, STORE_NAME,
149:                        entityClassName, keyName);
150:            }
151:
152:            static void checkVersions(EntityModel model, String name,
153:                    int version) {
154:                checkVersions(model, new String[] { name },
155:                        new int[] { version });
156:            }
157:
158:            static void checkVersions(EntityModel model, String name1,
159:                    int version1, String name2, int version2) {
160:                checkVersions(model, new String[] { name1, name2 }, new int[] {
161:                        version1, version2 });
162:            }
163:
164:            private static void checkVersions(EntityModel model,
165:                    String[] names, int[] versions) {
166:                List<RawType> all = model.getAllRawTypeVersions(names[0]);
167:                TestCase.assertNotNull(all);
168:
169:                assert names.length == versions.length;
170:                TestCase.assertEquals(names.length, all.size());
171:
172:                Iterator<RawType> iter = all.iterator();
173:                for (int i = 0; i < names.length; i += 1) {
174:                    RawType type = iter.next();
175:                    TestCase.assertEquals(versions[i], type.getVersion());
176:                    TestCase.assertEquals(names[i], type.getClassName());
177:                }
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.