Source Code Cross Referenced for EvolveClasses.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) 


0001:        /*-
0002:         * See the file LICENSE for redistribution information.
0003:         *
0004:         * Copyright (c) 2000,2008 Oracle.  All rights reserved.
0005:         *
0006:         * $Id: EvolveClasses.java,v 1.11.2.9 2008/01/07 15:14:35 cwl Exp $
0007:         */
0008:        package com.sleepycat.persist.test;
0009:
0010:        import static com.sleepycat.persist.model.Relationship.ONE_TO_ONE;
0011:        import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
0012:
0013:        import java.math.BigInteger;
0014:        import java.util.Collections;
0015:        import java.util.HashMap;
0016:        import java.util.Map;
0017:        import java.util.StringTokenizer;
0018:
0019:        import junit.framework.TestCase;
0020:
0021:        import com.sleepycat.je.DatabaseException;
0022:        import com.sleepycat.je.Environment;
0023:        import com.sleepycat.persist.EntityStore;
0024:        import com.sleepycat.persist.PrimaryIndex;
0025:        import com.sleepycat.persist.SecondaryIndex;
0026:        import com.sleepycat.persist.StoreConfig;
0027:        import com.sleepycat.persist.evolve.Conversion;
0028:        import com.sleepycat.persist.evolve.Converter;
0029:        import com.sleepycat.persist.evolve.Deleter;
0030:        import com.sleepycat.persist.evolve.EntityConverter;
0031:        import com.sleepycat.persist.evolve.Mutations;
0032:        import com.sleepycat.persist.evolve.Renamer;
0033:        import com.sleepycat.persist.model.Entity;
0034:        import com.sleepycat.persist.model.EntityModel;
0035:        import com.sleepycat.persist.model.KeyField;
0036:        import com.sleepycat.persist.model.Persistent;
0037:        import com.sleepycat.persist.model.PersistentProxy;
0038:        import com.sleepycat.persist.model.PrimaryKey;
0039:        import com.sleepycat.persist.model.SecondaryKey;
0040:        import com.sleepycat.persist.raw.RawObject;
0041:        import com.sleepycat.persist.raw.RawStore;
0042:        import com.sleepycat.persist.raw.RawType;
0043:
0044:        /**
0045:         * Nested classes are modified versions of classes of the same name in
0046:         * EvolveClasses.java.original.  See EvolveTestBase.java for the steps that are
0047:         * taken to add a new class (test case).
0048:         *
0049:         * @author Mark Hayes
0050:         */
0051:        class EvolveClasses {
0052:
0053:            private static final String PREFIX = EvolveClasses.class.getName() + '$';
0054:            private static final String CASECLS = EvolveCase.class.getName();
0055:
0056:            /**
0057:             * Reads a raw object and checks its superclass names and versions.
0058:             */
0059:            private static RawObject readRaw(RawStore store, Object key,
0060:                    Object... classVersionPairs) throws DatabaseException {
0061:
0062:                TestCase.assertNotNull(store);
0063:                TestCase.assertNotNull(key);
0064:
0065:                String entityClsName = (String) classVersionPairs[0];
0066:                PrimaryIndex<Object, RawObject> index = store
0067:                        .getPrimaryIndex(entityClsName);
0068:                TestCase.assertNotNull(index);
0069:
0070:                RawObject obj = index.get(key);
0071:                TestCase.assertNotNull(obj);
0072:
0073:                checkRawType(obj.getType(), classVersionPairs);
0074:
0075:                RawObject super Obj = obj.getSuper();
0076:                for (int i = 2; i < classVersionPairs.length; i += 2) {
0077:                    Object[] a = new Object[classVersionPairs.length - i];
0078:                    System.arraycopy(classVersionPairs, i, a, 0, a.length);
0079:                    TestCase.assertNotNull(super Obj);
0080:                    checkRawType(super Obj.getType(), a);
0081:                    super Obj = super Obj.getSuper();
0082:                }
0083:
0084:                return obj;
0085:            }
0086:
0087:            /**
0088:             * Reads a raw object and checks its superclass names and versions.
0089:             */
0090:            private static void checkRawType(RawType type,
0091:                    Object... classVersionPairs) {
0092:                TestCase.assertNotNull(type);
0093:                TestCase.assertNotNull(classVersionPairs);
0094:                TestCase.assertTrue(classVersionPairs.length % 2 == 0);
0095:
0096:                for (int i = 0; i < classVersionPairs.length; i += 2) {
0097:                    String clsName = (String) classVersionPairs[i];
0098:                    int clsVersion = (Integer) classVersionPairs[i + 1];
0099:                    TestCase.assertEquals(clsName, type.getClassName());
0100:                    TestCase.assertEquals(clsVersion, type.getVersion());
0101:                    type = type.getSuperType();
0102:                }
0103:                TestCase.assertNull(type);
0104:            }
0105:
0106:            /**
0107:             * Checks that a raw object contains the specified field values.  Does not
0108:             * check superclass fields.
0109:             */
0110:            private static void checkRawFields(RawObject obj,
0111:                    Object... nameValuePairs) {
0112:                TestCase.assertNotNull(obj);
0113:                TestCase.assertNotNull(obj.getValues());
0114:                TestCase.assertNotNull(nameValuePairs);
0115:                TestCase.assertTrue(nameValuePairs.length % 2 == 0);
0116:
0117:                Map<String, Object> values = obj.getValues();
0118:                TestCase.assertEquals(nameValuePairs.length / 2, values.size());
0119:
0120:                for (int i = 0; i < nameValuePairs.length; i += 2) {
0121:                    String name = (String) nameValuePairs[i];
0122:                    Object value = nameValuePairs[i + 1];
0123:                    TestCase.assertEquals(name, value, values.get(name));
0124:                }
0125:            }
0126:
0127:            private static Map<String, Object> makeValues(
0128:                    Object... nameValuePairs) {
0129:                TestCase.assertTrue(nameValuePairs.length % 2 == 0);
0130:                Map<String, Object> values = new HashMap<String, Object>();
0131:                for (int i = 0; i < nameValuePairs.length; i += 2) {
0132:                    values.put((String) nameValuePairs[i],
0133:                            nameValuePairs[i + 1]);
0134:                }
0135:                return values;
0136:            }
0137:
0138:            /**
0139:             * Disallow removing an entity class when no Deleter mutation is specified.
0140:             */
0141:            static class DeletedEntity1_ClassRemoved_NoMutation extends
0142:                    EvolveCase {
0143:
0144:                private static final String NAME = PREFIX
0145:                        + "DeletedEntity1_ClassRemoved";
0146:
0147:                @Override
0148:                public String getStoreOpenException() {
0149:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity1_ClassRemoved version: 0 Error: java.lang.ClassNotFoundException: com.sleepycat.persist.test.EvolveClasses$DeletedEntity1_ClassRemoved";
0150:                }
0151:
0152:                @Override
0153:                void checkUnevolvedModel(EntityModel model, Environment env) {
0154:                    checkEntity(true, model, env, NAME, 0, "skey");
0155:                    checkVersions(model, NAME, 0);
0156:                }
0157:
0158:                @Override
0159:                void readRawObjects(RawStore store, boolean expectEvolved,
0160:                        boolean expectUpdated) throws DatabaseException {
0161:
0162:                    if (expectEvolved) {
0163:                        TestCase.fail();
0164:                    }
0165:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
0166:                    checkRawFields(obj, "key", 99, "skey", 88);
0167:                }
0168:            }
0169:
0170:            /**
0171:             * Allow removing an entity class when a Deleter mutation is specified.
0172:             */
0173:            static class DeletedEntity2_ClassRemoved_WithDeleter extends
0174:                    EvolveCase {
0175:
0176:                private static final String NAME = PREFIX
0177:                        + "DeletedEntity2_ClassRemoved";
0178:
0179:                @Override
0180:                int getNRecordsExpected() {
0181:                    return 0;
0182:                }
0183:
0184:                @Override
0185:                Mutations getMutations() {
0186:                    Mutations m = new Mutations();
0187:                    m.addDeleter(new Deleter(NAME, 0));
0188:                    return m;
0189:                }
0190:
0191:                @Override
0192:                void checkEvolvedModel(EntityModel model, Environment env,
0193:                        boolean oldTypesExist) {
0194:                    checkEntity(false, model, env, NAME, 0, "skey");
0195:                    if (oldTypesExist) {
0196:                        checkVersions(model, NAME, 0);
0197:                    }
0198:                }
0199:
0200:                @Override
0201:                void readRawObjects(RawStore store, boolean expectEvolved,
0202:                        boolean expectUpdated) throws DatabaseException {
0203:
0204:                    if (expectEvolved) {
0205:                        return;
0206:                    }
0207:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
0208:                    checkRawFields(obj, "key", 99, "skey", 88);
0209:                }
0210:            }
0211:
0212:            /**
0213:             * Disallow removing the Entity annotation when no Deleter mutation is
0214:             * specified.
0215:             */
0216:            static class DeletedEntity3_AnnotRemoved_NoMutation extends
0217:                    EvolveCase {
0218:
0219:                private static final String NAME = DeletedEntity3_AnnotRemoved_NoMutation.class
0220:                        .getName();
0221:
0222:                @Override
0223:                public String getStoreOpenException() {
0224:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity3_AnnotRemoved_NoMutation version: 0 Error: java.lang.IllegalArgumentException: Class could not be loaded or is not persistent: com.sleepycat.persist.test.EvolveClasses$DeletedEntity3_AnnotRemoved_NoMutation";
0225:                }
0226:
0227:                @Override
0228:                void checkUnevolvedModel(EntityModel model, Environment env) {
0229:                    checkEntity(true, model, env, NAME, 0, "skey");
0230:                    checkVersions(model, NAME, 0);
0231:                }
0232:
0233:                @Override
0234:                void readRawObjects(RawStore store, boolean expectEvolved,
0235:                        boolean expectUpdated) throws DatabaseException {
0236:
0237:                    if (expectEvolved) {
0238:                        TestCase.fail();
0239:                    }
0240:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
0241:                    checkRawFields(obj, "key", 99, "skey", 88);
0242:                }
0243:            }
0244:
0245:            /**
0246:             * Allow removing the Entity annotation when a Deleter mutation is
0247:             * specified.
0248:             */
0249:            static class DeletedEntity4_AnnotRemoved_WithDeleter extends
0250:                    EvolveCase {
0251:
0252:                private static final String NAME = DeletedEntity4_AnnotRemoved_WithDeleter.class
0253:                        .getName();
0254:
0255:                @Override
0256:                int getNRecordsExpected() {
0257:                    return 0;
0258:                }
0259:
0260:                @Override
0261:                Mutations getMutations() {
0262:                    Mutations m = new Mutations();
0263:                    m.addDeleter(new Deleter(NAME, 0));
0264:                    return m;
0265:                }
0266:
0267:                @Override
0268:                void checkEvolvedModel(EntityModel model, Environment env,
0269:                        boolean oldTypesExist) {
0270:                    checkEntity(false, model, env, NAME, 0, "skey");
0271:                    if (oldTypesExist) {
0272:                        checkVersions(model, NAME, 0);
0273:                    }
0274:                }
0275:
0276:                @Override
0277:                void readObjects(EntityStore store, boolean doUpdate)
0278:                        throws DatabaseException {
0279:
0280:                    try {
0281:                        store.getPrimaryIndex(Integer.class,
0282:                                DeletedEntity4_AnnotRemoved_WithDeleter.class);
0283:                        TestCase.fail();
0284:                    } catch (Exception e) {
0285:                        checkEquals(
0286:                                "java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity4_AnnotRemoved_WithDeleter",
0287:                                e.toString());
0288:                    }
0289:                }
0290:
0291:                @Override
0292:                void readRawObjects(RawStore store, boolean expectEvolved,
0293:                        boolean expectUpdated) throws DatabaseException {
0294:
0295:                    if (expectEvolved) {
0296:                        return;
0297:                    }
0298:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
0299:                    checkRawFields(obj, "key", 99, "skey", 88);
0300:                }
0301:            }
0302:
0303:            /**
0304:             * Disallow changing the Entity annotation to Persistent when no Deleter
0305:             * mutation is specified.
0306:             */
0307:            @Persistent(version=1)
0308:            static class DeletedEntity5_EntityToPersist_NoMutation extends
0309:                    EvolveCase {
0310:
0311:                private static final String NAME = DeletedEntity5_EntityToPersist_NoMutation.class
0312:                        .getName();
0313:
0314:                @Override
0315:                public String getStoreOpenException() {
0316:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity5_EntityToPersist_NoMutation version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity5_EntityToPersist_NoMutation version: 1 Error: @Entity switched to/from @Persistent";
0317:                }
0318:
0319:                @Override
0320:                void checkUnevolvedModel(EntityModel model, Environment env) {
0321:                    checkEntity(true, model, env, NAME, 0, "skey");
0322:                    checkVersions(model, NAME, 0);
0323:                }
0324:
0325:                @Override
0326:                void readRawObjects(RawStore store, boolean expectEvolved,
0327:                        boolean expectUpdated) throws DatabaseException {
0328:
0329:                    if (expectEvolved) {
0330:                        TestCase.fail();
0331:                    }
0332:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
0333:                    checkRawFields(obj, "key", 99, "skey", 88);
0334:                }
0335:            }
0336:
0337:            /**
0338:             * Allow changing the Entity annotation to Persistent when a Deleter
0339:             * mutation is specified.
0340:             */
0341:            @Persistent(version=1)
0342:            static class DeletedEntity6_EntityToPersist_WithDeleter extends
0343:                    EvolveCase {
0344:
0345:                private static final String NAME = DeletedEntity6_EntityToPersist_WithDeleter.class
0346:                        .getName();
0347:                private static final String NAME2 = Embed_DeletedEntity6_EntityToPersist_WithDeleter.class
0348:                        .getName();
0349:
0350:                @Override
0351:                int getNRecordsExpected() {
0352:                    return 0;
0353:                }
0354:
0355:                @Override
0356:                Mutations getMutations() {
0357:                    Mutations m = new Mutations();
0358:                    m.addDeleter(new Deleter(NAME, 0));
0359:                    return m;
0360:                }
0361:
0362:                @Override
0363:                void checkEvolvedModel(EntityModel model, Environment env,
0364:                        boolean oldTypesExist) {
0365:                    checkNonEntity(true, model, env, NAME, 1);
0366:                    if (oldTypesExist) {
0367:                        checkVersions(model, NAME, 1, NAME, 0);
0368:                    } else {
0369:                        checkVersions(model, NAME, 1);
0370:                    }
0371:                }
0372:
0373:                @Override
0374:                void readObjects(EntityStore store, boolean doUpdate)
0375:                        throws DatabaseException {
0376:
0377:                    /* Cannot get the primary index for the former entity class. */
0378:                    try {
0379:                        store
0380:                                .getPrimaryIndex(
0381:                                        Integer.class,
0382:                                        DeletedEntity6_EntityToPersist_WithDeleter.class);
0383:                        TestCase.fail();
0384:                    } catch (Exception e) {
0385:                        checkEquals(
0386:                                "java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedEntity6_EntityToPersist_WithDeleter",
0387:                                e.toString());
0388:                    }
0389:
0390:                    /* Can embed the now persistent class in another entity class. */
0391:                    PrimaryIndex<Long, Embed_DeletedEntity6_EntityToPersist_WithDeleter> index = store
0392:                            .getPrimaryIndex(
0393:                                    Long.class,
0394:                                    Embed_DeletedEntity6_EntityToPersist_WithDeleter.class);
0395:
0396:                    if (doUpdate) {
0397:                        Embed_DeletedEntity6_EntityToPersist_WithDeleter embed = new Embed_DeletedEntity6_EntityToPersist_WithDeleter();
0398:                        index.put(embed);
0399:                        embed = index.get(embed.key);
0400:                        /* This new type should exist only after update. */
0401:                        Environment env = store.getEnvironment();
0402:                        EntityModel model = store.getModel();
0403:                        checkEntity(true, model, env, NAME2, 0, null);
0404:                        checkVersions(model, NAME2, 0);
0405:                    }
0406:                }
0407:
0408:                @Override
0409:                void readRawObjects(RawStore store, boolean expectEvolved,
0410:                        boolean expectUpdated) throws DatabaseException {
0411:
0412:                    if (expectEvolved) {
0413:                        return;
0414:                    }
0415:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
0416:                    checkRawFields(obj, "key", 99, "skey", 88);
0417:                }
0418:            }
0419:
0420:            @Entity
0421:            static class Embed_DeletedEntity6_EntityToPersist_WithDeleter {
0422:
0423:                @PrimaryKey
0424:                long key = 99;
0425:
0426:                DeletedEntity6_EntityToPersist_WithDeleter embedded = new DeletedEntity6_EntityToPersist_WithDeleter();
0427:            }
0428:
0429:            /**
0430:             * Disallow removing a Persistent class when no Deleter mutation is
0431:             * specified, even when the Entity class that embedded the Persistent class
0432:             * is deleted properly (by removing the Entity annotation in this case).
0433:             */
0434:            static class DeletedPersist1_ClassRemoved_NoMutation extends
0435:                    EvolveCase {
0436:
0437:                private static final String NAME = PREFIX
0438:                        + "DeletedPersist1_ClassRemoved";
0439:
0440:                private static final String NAME2 = DeletedPersist1_ClassRemoved_NoMutation.class
0441:                        .getName();
0442:
0443:                @Override
0444:                Mutations getMutations() {
0445:                    Mutations m = new Mutations();
0446:                    m.addDeleter(new Deleter(NAME2, 0));
0447:                    return m;
0448:                }
0449:
0450:                @Override
0451:                public String getStoreOpenException() {
0452:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist1_ClassRemoved version: 0 Error: java.lang.ClassNotFoundException: com.sleepycat.persist.test.EvolveClasses$DeletedPersist1_ClassRemoved";
0453:                }
0454:
0455:                @Override
0456:                void checkUnevolvedModel(EntityModel model, Environment env) {
0457:                    checkNonEntity(true, model, env, NAME, 0);
0458:                    checkEntity(true, model, env, NAME2, 0, null);
0459:                    checkVersions(model, NAME, 0);
0460:                    checkVersions(model, NAME2, 0);
0461:                }
0462:
0463:                @Override
0464:                void readRawObjects(RawStore store, boolean expectEvolved,
0465:                        boolean expectUpdated) throws DatabaseException {
0466:
0467:                    if (expectEvolved) {
0468:                        TestCase.fail();
0469:                    }
0470:
0471:                    RawType embedType = store.getModel().getRawType(NAME);
0472:                    checkRawType(embedType, NAME, 0);
0473:
0474:                    RawObject embed = new RawObject(embedType, makeValues("f",
0475:                            123), null);
0476:
0477:                    RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
0478:                    checkRawFields(obj, "key", 99, "embed", embed);
0479:                }
0480:            }
0481:
0482:            /**
0483:             * Allow removing a Persistent class when a Deleter mutation is
0484:             * specified, and the Entity class that embedded the Persistent class
0485:             * is also be deleted properly (by removing the Entity annotation in this
0486:             * case).
0487:             */
0488:            static class DeletedPersist2_ClassRemoved_WithDeleter extends
0489:                    EvolveCase {
0490:
0491:                private static final String NAME = PREFIX
0492:                        + "DeletedPersist2_ClassRemoved";
0493:                private static final String NAME2 = DeletedPersist2_ClassRemoved_WithDeleter.class
0494:                        .getName();
0495:
0496:                @Override
0497:                int getNRecordsExpected() {
0498:                    return 0;
0499:                }
0500:
0501:                @Override
0502:                Mutations getMutations() {
0503:                    Mutations m = new Mutations();
0504:                    m.addDeleter(new Deleter(NAME, 0));
0505:                    m.addDeleter(new Deleter(NAME2, 0));
0506:                    return m;
0507:                }
0508:
0509:                @Override
0510:                void checkEvolvedModel(EntityModel model, Environment env,
0511:                        boolean oldTypesExist) {
0512:                    checkNonEntity(false, model, env, NAME, 0);
0513:                    checkEntity(false, model, env, NAME2, 0, null);
0514:                    if (oldTypesExist) {
0515:                        checkVersions(model, NAME, 0);
0516:                        checkVersions(model, NAME2, 0);
0517:                    }
0518:                }
0519:
0520:                @Override
0521:                void readObjects(EntityStore store, boolean doUpdate)
0522:                        throws DatabaseException {
0523:
0524:                    try {
0525:                        store.getPrimaryIndex(Integer.class,
0526:                                DeletedPersist2_ClassRemoved_WithDeleter.class);
0527:                        TestCase.fail();
0528:                    } catch (Exception e) {
0529:                        checkEquals(
0530:                                "java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist2_ClassRemoved_WithDeleter",
0531:                                e.toString());
0532:                    }
0533:                }
0534:
0535:                @Override
0536:                void readRawObjects(RawStore store, boolean expectEvolved,
0537:                        boolean expectUpdated) throws DatabaseException {
0538:
0539:                    if (expectEvolved) {
0540:                        return;
0541:                    }
0542:
0543:                    RawType embedType = store.getModel().getRawType(NAME);
0544:                    checkRawType(embedType, NAME, 0);
0545:
0546:                    RawObject embed = new RawObject(embedType, makeValues("f",
0547:                            123), null);
0548:
0549:                    RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
0550:                    checkRawFields(obj, "key", 99, "embed", embed);
0551:                }
0552:            }
0553:
0554:            static class DeletedPersist3_AnnotRemoved {
0555:
0556:                int f = 123;
0557:            }
0558:
0559:            /**
0560:             * Disallow removing the Persistent annotation when no Deleter mutation is
0561:             * specified, even when the Entity class that embedded the Persistent class
0562:             * is deleted properly (by removing the Entity annotation in this case).
0563:             */
0564:            static class DeletedPersist3_AnnotRemoved_NoMutation extends
0565:                    EvolveCase {
0566:
0567:                private static final String NAME = DeletedPersist3_AnnotRemoved.class
0568:                        .getName();
0569:                private static final String NAME2 = DeletedPersist3_AnnotRemoved_NoMutation.class
0570:                        .getName();
0571:
0572:                @Override
0573:                Mutations getMutations() {
0574:                    Mutations m = new Mutations();
0575:                    m.addDeleter(new Deleter(NAME2, 0));
0576:                    return m;
0577:                }
0578:
0579:                @Override
0580:                public String getStoreOpenException() {
0581:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist3_AnnotRemoved version: 0 Error: java.lang.IllegalArgumentException: Class could not be loaded or is not persistent: com.sleepycat.persist.test.EvolveClasses$DeletedPersist3_AnnotRemoved";
0582:                }
0583:
0584:                @Override
0585:                void checkUnevolvedModel(EntityModel model, Environment env) {
0586:                    checkNonEntity(true, model, env, NAME, 0);
0587:                    checkEntity(true, model, env, NAME2, 0, null);
0588:                    checkVersions(model, NAME, 0);
0589:                    checkVersions(model, NAME2, 0);
0590:                }
0591:
0592:                @Override
0593:                void readRawObjects(RawStore store, boolean expectEvolved,
0594:                        boolean expectUpdated) throws DatabaseException {
0595:
0596:                    if (expectEvolved) {
0597:                        TestCase.fail();
0598:                    }
0599:
0600:                    RawType embedType = store.getModel().getRawType(NAME);
0601:                    checkRawType(embedType, NAME, 0);
0602:
0603:                    RawObject embed = new RawObject(embedType, makeValues("f",
0604:                            123), null);
0605:
0606:                    RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
0607:                    checkRawFields(obj, "key", 99, "embed", embed);
0608:                }
0609:            }
0610:
0611:            static class DeletedPersist4_AnnotRemoved {
0612:
0613:                int f = 123;
0614:            }
0615:
0616:            /**
0617:             * Allow removing the Persistent annotation when a Deleter mutation is
0618:             * specified, and the Entity class that embedded the Persistent class
0619:             * is also be deleted properly (by removing the Entity annotation in this
0620:             * case).
0621:             */
0622:            static class DeletedPersist4_AnnotRemoved_WithDeleter extends
0623:                    EvolveCase {
0624:
0625:                private static final String NAME = DeletedPersist4_AnnotRemoved.class
0626:                        .getName();
0627:                private static final String NAME2 = DeletedPersist4_AnnotRemoved_WithDeleter.class
0628:                        .getName();
0629:
0630:                @Override
0631:                int getNRecordsExpected() {
0632:                    return 0;
0633:                }
0634:
0635:                @Override
0636:                Mutations getMutations() {
0637:                    Mutations m = new Mutations();
0638:                    m.addDeleter(new Deleter(NAME, 0));
0639:                    m.addDeleter(new Deleter(NAME2, 0));
0640:                    return m;
0641:                }
0642:
0643:                @Override
0644:                void checkEvolvedModel(EntityModel model, Environment env,
0645:                        boolean oldTypesExist) {
0646:                    checkNonEntity(false, model, env, NAME, 0);
0647:                    checkEntity(false, model, env, NAME2, 0, null);
0648:                    if (oldTypesExist) {
0649:                        checkVersions(model, NAME, 0);
0650:                        checkVersions(model, NAME2, 0);
0651:                    }
0652:                }
0653:
0654:                @Override
0655:                void readObjects(EntityStore store, boolean doUpdate)
0656:                        throws DatabaseException {
0657:
0658:                    try {
0659:                        store.getPrimaryIndex(Integer.class,
0660:                                DeletedPersist4_AnnotRemoved_WithDeleter.class);
0661:                        TestCase.fail();
0662:                    } catch (Exception e) {
0663:                        checkEquals(
0664:                                "java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist4_AnnotRemoved_WithDeleter",
0665:                                e.toString());
0666:                    }
0667:                }
0668:
0669:                @Override
0670:                void readRawObjects(RawStore store, boolean expectEvolved,
0671:                        boolean expectUpdated) throws DatabaseException {
0672:
0673:                    if (expectEvolved) {
0674:                        return;
0675:                    }
0676:
0677:                    RawType embedType = store.getModel().getRawType(NAME);
0678:                    checkRawType(embedType, NAME, 0);
0679:
0680:                    RawObject embed = new RawObject(embedType, makeValues("f",
0681:                            123), null);
0682:
0683:                    RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
0684:                    checkRawFields(obj, "key", 99, "embed", embed);
0685:                }
0686:            }
0687:
0688:            @Entity(version=1)
0689:            static class DeletedPersist5_PersistToEntity {
0690:
0691:                @PrimaryKey
0692:                int key = 99;
0693:
0694:                int f = 123;
0695:            }
0696:
0697:            /**
0698:             * Disallow changing the Entity annotation to Persistent when no Deleter
0699:             * mutation is specified, even when the Entity class that embedded the
0700:             * Persistent class is deleted properly (by removing the Entity annotation
0701:             * in this case).
0702:             */
0703:            static class DeletedPersist5_PersistToEntity_NoMutation extends
0704:                    EvolveCase {
0705:
0706:                private static final String NAME = DeletedPersist5_PersistToEntity.class
0707:                        .getName();
0708:                private static final String NAME2 = DeletedPersist5_PersistToEntity_NoMutation.class
0709:                        .getName();
0710:
0711:                @Override
0712:                Mutations getMutations() {
0713:                    Mutations m = new Mutations();
0714:                    m.addDeleter(new Deleter(NAME2, 0));
0715:                    return m;
0716:                }
0717:
0718:                @Override
0719:                public String getStoreOpenException() {
0720:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist5_PersistToEntity version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist5_PersistToEntity version: 1 Error: @Entity switched to/from @Persistent";
0721:                }
0722:
0723:                @Override
0724:                void checkUnevolvedModel(EntityModel model, Environment env) {
0725:                    checkNonEntity(true, model, env, NAME, 0);
0726:                    checkEntity(true, model, env, NAME2, 0, null);
0727:                    checkVersions(model, NAME, 0);
0728:                    checkVersions(model, NAME2, 0);
0729:                }
0730:
0731:                @Override
0732:                void readRawObjects(RawStore store, boolean expectEvolved,
0733:                        boolean expectUpdated) throws DatabaseException {
0734:
0735:                    if (expectEvolved) {
0736:                        TestCase.fail();
0737:                    }
0738:
0739:                    RawType embedType = store.getModel().getRawType(NAME);
0740:                    checkRawType(embedType, NAME, 0);
0741:
0742:                    RawObject embed = new RawObject(embedType, makeValues("f",
0743:                            123), null);
0744:
0745:                    RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
0746:                    checkRawFields(obj, "key", 99, "embed", embed);
0747:                }
0748:            }
0749:
0750:            @Entity(version=1)
0751:            static class DeletedPersist6_PersistToEntity {
0752:
0753:                @PrimaryKey
0754:                int key = 99;
0755:
0756:                int f = 123;
0757:            }
0758:
0759:            /**
0760:             * Allow changing the Entity annotation to Persistent when a Deleter
0761:             * mutation is specified, and the Entity class that embedded the Persistent
0762:             * class is also be deleted properly (by removing the Entity annotation in
0763:             * this case).
0764:             */
0765:            static class DeletedPersist6_PersistToEntity_WithDeleter extends
0766:                    EvolveCase {
0767:
0768:                private static final String NAME = DeletedPersist6_PersistToEntity.class
0769:                        .getName();
0770:                private static final String NAME2 = DeletedPersist6_PersistToEntity_WithDeleter.class
0771:                        .getName();
0772:
0773:                @Override
0774:                int getNRecordsExpected() {
0775:                    return 0;
0776:                }
0777:
0778:                @Override
0779:                Mutations getMutations() {
0780:                    Mutations m = new Mutations();
0781:                    m.addDeleter(new Deleter(NAME, 0));
0782:                    m.addDeleter(new Deleter(NAME2, 0));
0783:                    return m;
0784:                }
0785:
0786:                @Override
0787:                void checkEvolvedModel(EntityModel model, Environment env,
0788:                        boolean oldTypesExist) {
0789:                    checkEntity(false, model, env, NAME2, 0, null);
0790:                    if (oldTypesExist) {
0791:                        checkVersions(model, NAME, 1, NAME, 0);
0792:                        checkVersions(model, NAME2, 0);
0793:                    } else {
0794:                        checkVersions(model, NAME, 1);
0795:                    }
0796:                }
0797:
0798:                @Override
0799:                void readObjects(EntityStore store, boolean doUpdate)
0800:                        throws DatabaseException {
0801:
0802:                    /* Cannot get the primary index for the former entity class. */
0803:                    try {
0804:                        store
0805:                                .getPrimaryIndex(
0806:                                        Integer.class,
0807:                                        DeletedPersist6_PersistToEntity_WithDeleter.class);
0808:                        TestCase.fail();
0809:                    } catch (Exception e) {
0810:                        checkEquals(
0811:                                "java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.sleepycat.persist.test.EvolveClasses$DeletedPersist6_PersistToEntity_WithDeleter",
0812:                                e.toString());
0813:                    }
0814:
0815:                    /* Can use the primary index of the now entity class. */
0816:                    PrimaryIndex<Integer, DeletedPersist6_PersistToEntity> index = store
0817:                            .getPrimaryIndex(Integer.class,
0818:                                    DeletedPersist6_PersistToEntity.class);
0819:
0820:                    if (doUpdate) {
0821:                        DeletedPersist6_PersistToEntity obj = new DeletedPersist6_PersistToEntity();
0822:                        index.put(obj);
0823:                        obj = index.get(obj.key);
0824:                        /* This new type should exist only after update. */
0825:                        Environment env = store.getEnvironment();
0826:                        EntityModel model = store.getModel();
0827:                        checkEntity(true, model, env, NAME, 1, null);
0828:                    }
0829:                }
0830:
0831:                @Override
0832:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
0833:                        throws DatabaseException {
0834:
0835:                    PrimaryIndex<Integer, DeletedPersist6_PersistToEntity> index = newStore
0836:                            .getPrimaryIndex(Integer.class,
0837:                                    DeletedPersist6_PersistToEntity.class);
0838:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
0839:                    index.put((DeletedPersist6_PersistToEntity) newStore
0840:                            .getModel().convertRawObject(raw));
0841:                }
0842:
0843:                @Override
0844:                void readRawObjects(RawStore store, boolean expectEvolved,
0845:                        boolean expectUpdated) throws DatabaseException {
0846:
0847:                    if (expectEvolved) {
0848:                        return;
0849:                    }
0850:
0851:                    RawType embedType = store.getModel().getRawType(NAME);
0852:                    checkRawType(embedType, NAME, 0);
0853:
0854:                    RawObject embed = new RawObject(embedType, makeValues("f",
0855:                            123), null);
0856:
0857:                    RawObject obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
0858:                    checkRawFields(obj, "key", 99, "embed", embed);
0859:                }
0860:            }
0861:
0862:            /**
0863:             * Disallow renaming an entity class without a Renamer mutation.
0864:             */
0865:            @Entity(version=1)
0866:            static class RenamedEntity1_NewEntityName_NoMutation extends
0867:                    EvolveCase {
0868:
0869:                private static final String NAME = PREFIX
0870:                        + "RenamedEntity1_NewEntityName";
0871:                private static final String NAME2 = RenamedEntity1_NewEntityName_NoMutation.class
0872:                        .getName();
0873:
0874:                @PrimaryKey
0875:                int key = 99;
0876:
0877:                @SecondaryKey(relate=ONE_TO_ONE)
0878:                int skey = 88;
0879:
0880:                @Override
0881:                public String getStoreOpenException() {
0882:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$RenamedEntity1_NewEntityName version: 0 Error: java.lang.ClassNotFoundException: com.sleepycat.persist.test.EvolveClasses$RenamedEntity1_NewEntityName";
0883:                }
0884:
0885:                @Override
0886:                void checkUnevolvedModel(EntityModel model, Environment env) {
0887:                    checkEntity(true, model, env, NAME, 0, "skey");
0888:                    checkVersions(model, NAME, 0);
0889:                }
0890:
0891:                @Override
0892:                void readRawObjects(RawStore store, boolean expectEvolved,
0893:                        boolean expectUpdated) throws DatabaseException {
0894:
0895:                    if (expectEvolved) {
0896:                        TestCase.fail();
0897:                    }
0898:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
0899:                    checkRawFields(obj, "key", 99, "skey", 88);
0900:                }
0901:            }
0902:
0903:            /**
0904:             * Allow renaming an entity class with a Renamer mutation.
0905:             */
0906:            @Entity(version=1)
0907:            static class RenamedEntity2_NewEntityName_WithRenamer extends
0908:                    EvolveCase {
0909:
0910:                private static final String NAME = PREFIX
0911:                        + "RenamedEntity2_NewEntityName";
0912:                private static final String NAME2 = RenamedEntity2_NewEntityName_WithRenamer.class
0913:                        .getName();
0914:
0915:                @PrimaryKey
0916:                int key = 99;
0917:
0918:                @SecondaryKey(relate=ONE_TO_ONE)
0919:                int skey = 88;
0920:
0921:                @Override
0922:                Mutations getMutations() {
0923:                    Mutations m = new Mutations();
0924:                    m.addRenamer(new Renamer(NAME, 0, NAME2));
0925:                    return m;
0926:                }
0927:
0928:                @Override
0929:                void checkEvolvedModel(EntityModel model, Environment env,
0930:                        boolean oldTypesExist) {
0931:                    checkEntity(false, model, env, NAME, 0, null);
0932:                    checkEntity(true, model, env, NAME2, 1, null);
0933:                    if (oldTypesExist) {
0934:                        checkVersions(model, NAME2, 1, NAME, 0);
0935:                    } else {
0936:                        checkVersions(model, NAME2, 1);
0937:                    }
0938:                }
0939:
0940:                @Override
0941:                void readObjects(EntityStore store, boolean doUpdate)
0942:                        throws DatabaseException {
0943:
0944:                    PrimaryIndex<Integer, RenamedEntity2_NewEntityName_WithRenamer> index = store
0945:                            .getPrimaryIndex(
0946:                                    Integer.class,
0947:                                    RenamedEntity2_NewEntityName_WithRenamer.class);
0948:                    RenamedEntity2_NewEntityName_WithRenamer obj = index
0949:                            .get(key);
0950:                    TestCase.assertNotNull(obj);
0951:                    TestCase.assertEquals(99, obj.key);
0952:                    TestCase.assertEquals(88, obj.skey);
0953:
0954:                    SecondaryIndex<Integer, Integer, RenamedEntity2_NewEntityName_WithRenamer> sindex = store
0955:                            .getSecondaryIndex(index, Integer.class, "skey");
0956:                    obj = sindex.get(88);
0957:                    TestCase.assertNotNull(obj);
0958:                    TestCase.assertEquals(99, obj.key);
0959:                    TestCase.assertEquals(88, obj.skey);
0960:
0961:                    if (doUpdate) {
0962:                        index.put(obj);
0963:                    }
0964:                }
0965:
0966:                @Override
0967:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
0968:                        throws DatabaseException {
0969:
0970:                    PrimaryIndex<Integer, RenamedEntity2_NewEntityName_WithRenamer> index = newStore
0971:                            .getPrimaryIndex(
0972:                                    Integer.class,
0973:                                    RenamedEntity2_NewEntityName_WithRenamer.class);
0974:                    RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
0975:                    index
0976:                            .put((RenamedEntity2_NewEntityName_WithRenamer) newStore
0977:                                    .getModel().convertRawObject(raw));
0978:                }
0979:
0980:                @Override
0981:                void readRawObjects(RawStore store, boolean expectEvolved,
0982:                        boolean expectUpdated) throws DatabaseException {
0983:
0984:                    RawObject obj;
0985:                    if (expectEvolved) {
0986:                        obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
0987:                    } else {
0988:                        obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
0989:                    }
0990:                    checkRawFields(obj, "key", 99, "skey", 88);
0991:                }
0992:            }
0993:
0994:            @Persistent
0995:            static class DeleteSuperclass1_BaseClass extends EvolveCase {
0996:
0997:                int f = 123;
0998:            }
0999:
1000:            /**
1001:             * Disallow deleting a superclass from the hierarchy when the superclass
1002:             * has persistent fields and no Deleter or Converter is specified.
1003:             */
1004:            @Entity
1005:            static class DeleteSuperclass1_NoMutation extends EvolveCase {
1006:
1007:                private static final String NAME = DeleteSuperclass1_BaseClass.class
1008:                        .getName();
1009:                private static final String NAME2 = DeleteSuperclass1_NoMutation.class
1010:                        .getName();
1011:
1012:                @PrimaryKey
1013:                int key = 99;
1014:
1015:                int ff;
1016:
1017:                @Override
1018:                public String getStoreOpenException() {
1019:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeleteSuperclass1_NoMutation version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DeleteSuperclass1_NoMutation version: 0 Error: When a superclass is removed from the class hierarchy, the superclass or all of its persistent fields must be deleted with a Deleter: com.sleepycat.persist.test.EvolveClasses$DeleteSuperclass1_BaseClass";
1020:                }
1021:
1022:                @Override
1023:                void checkUnevolvedModel(EntityModel model, Environment env) {
1024:                    checkNonEntity(true, model, env, NAME, 0);
1025:                    checkEntity(true, model, env, NAME2, 0, null);
1026:                    checkVersions(model, NAME, 0);
1027:                    checkVersions(model, NAME2, 0);
1028:                }
1029:
1030:                @Override
1031:                void readRawObjects(RawStore store, boolean expectEvolved,
1032:                        boolean expectUpdated) throws DatabaseException {
1033:
1034:                    if (expectEvolved) {
1035:                        TestCase.fail();
1036:                    }
1037:                    RawObject obj = readRaw(store, 99, NAME2, 0, NAME, 0,
1038:                            CASECLS, 0);
1039:                    checkRawFields(obj, "key", 99, "ff", 88);
1040:                    checkRawFields(obj.getSuper(), "f", 123);
1041:                    checkRawFields(obj.getSuper().getSuper());
1042:                }
1043:            }
1044:
1045:            @Persistent
1046:            static class DeleteSuperclass2_BaseClass extends EvolveCase {
1047:
1048:                int f;
1049:
1050:                @SecondaryKey(relate=ONE_TO_ONE)
1051:                int skey;
1052:            }
1053:
1054:            /**
1055:             * Allow deleting a superclass from the hierarchy when the superclass has
1056:             * persistent fields and a class Converter is specified.  Also check that
1057:             * the secondary key field in the deleted base class is handled properly.
1058:             */
1059:            @Entity(version=1)
1060:            static class DeleteSuperclass2_WithConverter extends EvolveCase {
1061:
1062:                private static final String NAME = DeleteSuperclass2_BaseClass.class
1063:                        .getName();
1064:                private static final String NAME2 = DeleteSuperclass2_WithConverter.class
1065:                        .getName();
1066:
1067:                @PrimaryKey
1068:                int key;
1069:
1070:                int ff;
1071:
1072:                @SecondaryKey(relate=ONE_TO_ONE)
1073:                Integer skey2;
1074:
1075:                @SecondaryKey(relate=ONE_TO_ONE)
1076:                int skey3;
1077:
1078:                @Override
1079:                Mutations getMutations() {
1080:                    Mutations m = new Mutations();
1081:                    m.addConverter(new EntityConverter(NAME2, 0,
1082:                            new MyConversion(), Collections.singleton("skey")));
1083:                    return m;
1084:                }
1085:
1086:                static class MyConversion implements  Conversion {
1087:
1088:                    transient RawType newType;
1089:
1090:                    public void initialize(EntityModel model) {
1091:                        newType = model.getRawType(NAME2);
1092:                        TestCase.assertNotNull(newType);
1093:                    }
1094:
1095:                    public Object convert(Object fromValue) {
1096:                        TestCase.assertNotNull(newType);
1097:                        RawObject obj = (RawObject) fromValue;
1098:                        RawObject newSuper = obj.getSuper().getSuper();
1099:                        return new RawObject(newType, obj.getValues(), newSuper);
1100:                    }
1101:
1102:                    @Override
1103:                    public boolean equals(Object other) {
1104:                        return other instanceof  MyConversion;
1105:                    }
1106:                }
1107:
1108:                @Override
1109:                void checkEvolvedModel(EntityModel model, Environment env,
1110:                        boolean oldTypesExist) {
1111:                    checkEntity(true, model, env, NAME2, 1, null);
1112:                    if (oldTypesExist) {
1113:                        checkVersions(model, NAME2, 1, NAME2, 0);
1114:                        checkNonEntity(true, model, env, NAME, 0);
1115:                        checkVersions(model, NAME, 0);
1116:                    } else {
1117:                        checkVersions(model, NAME2, 1);
1118:                    }
1119:                }
1120:
1121:                @Override
1122:                void readObjects(EntityStore store, boolean doUpdate)
1123:                        throws DatabaseException {
1124:
1125:                    PrimaryIndex<Integer, DeleteSuperclass2_WithConverter> index = store
1126:                            .getPrimaryIndex(Integer.class,
1127:                                    DeleteSuperclass2_WithConverter.class);
1128:                    DeleteSuperclass2_WithConverter obj = index.get(99);
1129:                    TestCase.assertNotNull(obj);
1130:                    TestCase.assertSame(EvolveCase.class, obj.getClass()
1131:                            .getSuperclass());
1132:                    TestCase.assertEquals(99, obj.key);
1133:                    TestCase.assertEquals(88, obj.ff);
1134:                    TestCase.assertEquals(Integer.valueOf(77), obj.skey2);
1135:                    TestCase.assertEquals(66, obj.skey3);
1136:                    if (doUpdate) {
1137:                        index.put(obj);
1138:                    }
1139:                }
1140:
1141:                @Override
1142:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
1143:                        throws DatabaseException {
1144:
1145:                    PrimaryIndex<Integer, DeleteSuperclass2_WithConverter> index = newStore
1146:                            .getPrimaryIndex(Integer.class,
1147:                                    DeleteSuperclass2_WithConverter.class);
1148:                    RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1149:                    index.put((DeleteSuperclass2_WithConverter) newStore
1150:                            .getModel().convertRawObject(raw));
1151:                }
1152:
1153:                @Override
1154:                void readRawObjects(RawStore store, boolean expectEvolved,
1155:                        boolean expectUpdated) throws DatabaseException {
1156:
1157:                    RawObject obj;
1158:                    if (expectEvolved) {
1159:                        obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1160:                    } else {
1161:                        obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1162:                    }
1163:                    checkRawFields(obj, "key", 99, "ff", 88, "skey2", 77,
1164:                            "skey3", 66);
1165:                    if (expectEvolved) {
1166:                        checkRawFields(obj.getSuper());
1167:                    } else {
1168:                        checkRawFields(obj.getSuper(), "f", 123, "skey", 456);
1169:                        checkRawFields(obj.getSuper().getSuper());
1170:                    }
1171:                    Environment env = store.getEnvironment();
1172:                    assertDbExists(!expectEvolved, env, NAME2, "skey");
1173:                    assertDbExists(true, env, NAME2, "skey3");
1174:                }
1175:            }
1176:
1177:            static class DeleteSuperclass3_BaseClass extends EvolveCase {
1178:
1179:                int f;
1180:
1181:                @SecondaryKey(relate=ONE_TO_ONE)
1182:                int skey;
1183:            }
1184:
1185:            /**
1186:             * Allow deleting a superclass from the hierarchy when the superclass
1187:             * has persistent fields and a class Deleter is specified.  Also check that
1188:             * the secondary key field in the deleted base class is handled properly.
1189:             */
1190:            @Entity(version=1)
1191:            static class DeleteSuperclass3_WithDeleter extends EvolveCase {
1192:
1193:                private static final String NAME = DeleteSuperclass3_BaseClass.class
1194:                        .getName();
1195:                private static final String NAME2 = DeleteSuperclass3_WithDeleter.class
1196:                        .getName();
1197:
1198:                @PrimaryKey
1199:                int key;
1200:
1201:                int ff;
1202:
1203:                @Override
1204:                Mutations getMutations() {
1205:                    Mutations m = new Mutations();
1206:                    m.addDeleter(new Deleter(NAME, 0));
1207:                    return m;
1208:                }
1209:
1210:                @Override
1211:                void checkEvolvedModel(EntityModel model, Environment env,
1212:                        boolean oldTypesExist) {
1213:                    checkEntity(true, model, env, NAME2, 1, null);
1214:                    if (oldTypesExist) {
1215:                        checkVersions(model, NAME2, 1, NAME2, 0);
1216:                        checkNonEntity(false, model, env, NAME, 0);
1217:                        checkVersions(model, NAME, 0);
1218:                    } else {
1219:                        checkVersions(model, NAME2, 1);
1220:                    }
1221:                }
1222:
1223:                @Override
1224:                void readObjects(EntityStore store, boolean doUpdate)
1225:                        throws DatabaseException {
1226:
1227:                    PrimaryIndex<Integer, DeleteSuperclass3_WithDeleter> index = store
1228:                            .getPrimaryIndex(Integer.class,
1229:                                    DeleteSuperclass3_WithDeleter.class);
1230:                    DeleteSuperclass3_WithDeleter obj = index.get(99);
1231:                    TestCase.assertNotNull(obj);
1232:                    TestCase.assertSame(EvolveCase.class, obj.getClass()
1233:                            .getSuperclass());
1234:                    TestCase.assertEquals(99, obj.key);
1235:                    TestCase.assertEquals(88, obj.ff);
1236:                    if (doUpdate) {
1237:                        index.put(obj);
1238:                    }
1239:                }
1240:
1241:                @Override
1242:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
1243:                        throws DatabaseException {
1244:
1245:                    PrimaryIndex<Integer, DeleteSuperclass3_WithDeleter> index = newStore
1246:                            .getPrimaryIndex(Integer.class,
1247:                                    DeleteSuperclass3_WithDeleter.class);
1248:                    RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1249:                    index.put((DeleteSuperclass3_WithDeleter) newStore
1250:                            .getModel().convertRawObject(raw));
1251:                }
1252:
1253:                @Override
1254:                void readRawObjects(RawStore store, boolean expectEvolved,
1255:                        boolean expectUpdated) throws DatabaseException {
1256:
1257:                    RawObject obj;
1258:                    if (expectEvolved) {
1259:                        obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1260:                    } else {
1261:                        obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1262:                    }
1263:                    checkRawFields(obj, "key", 99, "ff", 88);
1264:                    if (expectEvolved) {
1265:                        checkRawFields(obj.getSuper());
1266:                    } else {
1267:                        checkRawFields(obj.getSuper(), "f", 123, "skey", 456);
1268:                        checkRawFields(obj.getSuper().getSuper());
1269:                    }
1270:                    Environment env = store.getEnvironment();
1271:                    assertDbExists(!expectEvolved, env, NAME2, "skey");
1272:                }
1273:            }
1274:
1275:            @Persistent
1276:            static class DeleteSuperclass4_BaseClass extends EvolveCase {
1277:            }
1278:
1279:            /**
1280:             * Allow deleting a superclass from the hierarchy when the superclass
1281:             * has NO persistent fields.  No mutations are needed.
1282:             */
1283:            @Entity(version=1)
1284:            static class DeleteSuperclass4_NoFields extends EvolveCase {
1285:
1286:                private static final String NAME = DeleteSuperclass4_BaseClass.class
1287:                        .getName();
1288:                private static final String NAME2 = DeleteSuperclass4_NoFields.class
1289:                        .getName();
1290:
1291:                @PrimaryKey
1292:                int key = 99;
1293:
1294:                int ff;
1295:
1296:                @Override
1297:                void checkEvolvedModel(EntityModel model, Environment env,
1298:                        boolean oldTypesExist) {
1299:                    checkEntity(true, model, env, NAME2, 1, null);
1300:                    if (oldTypesExist) {
1301:                        checkVersions(model, NAME2, 1, NAME2, 0);
1302:                        checkNonEntity(true, model, env, NAME, 0);
1303:                        checkVersions(model, NAME, 0);
1304:                    } else {
1305:                        checkVersions(model, NAME2, 1);
1306:                    }
1307:                }
1308:
1309:                @Override
1310:                void readObjects(EntityStore store, boolean doUpdate)
1311:                        throws DatabaseException {
1312:
1313:                    PrimaryIndex<Integer, DeleteSuperclass4_NoFields> index = store
1314:                            .getPrimaryIndex(Integer.class,
1315:                                    DeleteSuperclass4_NoFields.class);
1316:                    DeleteSuperclass4_NoFields obj = index.get(key);
1317:                    TestCase.assertNotNull(obj);
1318:                    TestCase.assertSame(EvolveCase.class, obj.getClass()
1319:                            .getSuperclass());
1320:                    TestCase.assertEquals(99, obj.key);
1321:                    TestCase.assertEquals(88, obj.ff);
1322:                    if (doUpdate) {
1323:                        index.put(obj);
1324:                    }
1325:                }
1326:
1327:                @Override
1328:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
1329:                        throws DatabaseException {
1330:
1331:                    PrimaryIndex<Integer, DeleteSuperclass4_NoFields> index = newStore
1332:                            .getPrimaryIndex(Integer.class,
1333:                                    DeleteSuperclass4_NoFields.class);
1334:                    RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1335:                    index.put((DeleteSuperclass4_NoFields) newStore.getModel()
1336:                            .convertRawObject(raw));
1337:                }
1338:
1339:                @Override
1340:                void readRawObjects(RawStore store, boolean expectEvolved,
1341:                        boolean expectUpdated) throws DatabaseException {
1342:
1343:                    RawObject obj;
1344:                    if (expectEvolved) {
1345:                        obj = readRaw(store, 99, NAME2, 1, CASECLS, 0);
1346:                    } else {
1347:                        obj = readRaw(store, 99, NAME2, 0, NAME, 0, CASECLS, 0);
1348:                    }
1349:                    checkRawFields(obj, "key", 99, "ff", 88);
1350:                    checkRawFields(obj.getSuper());
1351:                    if (expectEvolved) {
1352:                        TestCase.assertNull(obj.getSuper().getSuper());
1353:                    } else {
1354:                        checkRawFields(obj.getSuper().getSuper());
1355:                    }
1356:                }
1357:            }
1358:
1359:            @Persistent(version=1)
1360:            static class DeleteSuperclass5_Embedded {
1361:
1362:                int f;
1363:
1364:                @Override
1365:                public String toString() {
1366:                    return "" + f;
1367:                }
1368:            }
1369:
1370:            /**
1371:             * Ensure that a superclass at the top of the hierarchy can be deleted.  A
1372:             * class Deleter is used.
1373:             */
1374:            @Entity
1375:            static class DeleteSuperclass5_Top extends EvolveCase {
1376:
1377:                private static final String NAME = DeleteSuperclass5_Top.class
1378:                        .getName();
1379:                private static final String NAME2 = DeleteSuperclass5_Embedded.class
1380:                        .getName();
1381:                private static final String NAME3 = PREFIX
1382:                        + "DeleteSuperclass5_Embedded_Base";
1383:
1384:                @PrimaryKey
1385:                int key = 99;
1386:
1387:                int ff;
1388:
1389:                DeleteSuperclass5_Embedded embed = new DeleteSuperclass5_Embedded();
1390:
1391:                @Override
1392:                Mutations getMutations() {
1393:                    Mutations m = new Mutations();
1394:                    m.addDeleter(new Deleter(NAME3, 0));
1395:                    return m;
1396:                }
1397:
1398:                @Override
1399:                void checkEvolvedModel(EntityModel model, Environment env,
1400:                        boolean oldTypesExist) {
1401:                    checkEntity(true, model, env, NAME, 0, null);
1402:                    checkNonEntity(true, model, env, NAME2, 1);
1403:                    checkNonEntity(false, model, env, NAME3, 0);
1404:                    checkVersions(model, NAME, 0);
1405:                    if (oldTypesExist) {
1406:                        checkVersions(model, NAME2, 1, NAME2, 0);
1407:                        checkVersions(model, NAME3, 0);
1408:                    } else {
1409:                        checkVersions(model, NAME2, 1);
1410:                    }
1411:                }
1412:
1413:                @Override
1414:                void readObjects(EntityStore store, boolean doUpdate)
1415:                        throws DatabaseException {
1416:
1417:                    PrimaryIndex<Integer, DeleteSuperclass5_Top> index = store
1418:                            .getPrimaryIndex(Integer.class,
1419:                                    DeleteSuperclass5_Top.class);
1420:                    DeleteSuperclass5_Top obj = index.get(key);
1421:                    TestCase.assertNotNull(obj);
1422:                    TestCase.assertNotNull(obj.embed);
1423:                    TestCase.assertEquals(99, obj.key);
1424:                    TestCase.assertEquals(88, obj.ff);
1425:                    TestCase.assertEquals(123, obj.embed.f);
1426:                    if (doUpdate) {
1427:                        index.put(obj);
1428:                    }
1429:                }
1430:
1431:                @Override
1432:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
1433:                        throws DatabaseException {
1434:
1435:                    PrimaryIndex<Integer, DeleteSuperclass5_Top> index = newStore
1436:                            .getPrimaryIndex(Integer.class,
1437:                                    DeleteSuperclass5_Top.class);
1438:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
1439:                    index.put((DeleteSuperclass5_Top) newStore.getModel()
1440:                            .convertRawObject(raw));
1441:                }
1442:
1443:                @Override
1444:                void readRawObjects(RawStore store, boolean expectEvolved,
1445:                        boolean expectUpdated) throws DatabaseException {
1446:
1447:                    RawType embedType = store.getModel().getRawType(NAME2);
1448:                    RawObject embedSuper = null;
1449:                    if (!expectEvolved) {
1450:                        RawType embedSuperType = store.getModel().getRawType(
1451:                                NAME3);
1452:                        embedSuper = new RawObject(embedSuperType, makeValues(
1453:                                "g", 456), null);
1454:                    }
1455:                    RawObject embed = new RawObject(embedType, makeValues("f",
1456:                            123), embedSuper);
1457:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1458:                    checkRawFields(obj, "key", 99, "ff", 88, "embed", embed);
1459:                }
1460:            }
1461:
1462:            @Persistent
1463:            static class InsertSuperclass1_BaseClass extends EvolveCase {
1464:
1465:                int f = 123;
1466:            }
1467:
1468:            /**
1469:             * Allow inserting a superclass between two existing classes in the
1470:             * hierarchy.  No mutations are needed.
1471:             */
1472:            @Entity(version=1)
1473:            static class InsertSuperclass1_Between extends
1474:                    InsertSuperclass1_BaseClass {
1475:
1476:                private static final String NAME = InsertSuperclass1_BaseClass.class
1477:                        .getName();
1478:                private static final String NAME2 = InsertSuperclass1_Between.class
1479:                        .getName();
1480:
1481:                @PrimaryKey
1482:                int key = 99;
1483:
1484:                int ff;
1485:
1486:                @Override
1487:                void checkEvolvedModel(EntityModel model, Environment env,
1488:                        boolean oldTypesExist) {
1489:                    checkNonEntity(true, model, env, NAME, 0);
1490:                    checkEntity(true, model, env, NAME2, 1, null);
1491:                    checkVersions(model, NAME, 0);
1492:                    if (oldTypesExist) {
1493:                        checkVersions(model, NAME2, 1, NAME2, 0);
1494:                    } else {
1495:                        checkVersions(model, NAME2, 1);
1496:                    }
1497:                }
1498:
1499:                @Override
1500:                void readObjects(EntityStore store, boolean doUpdate)
1501:                        throws DatabaseException {
1502:
1503:                    PrimaryIndex<Integer, InsertSuperclass1_Between> index = store
1504:                            .getPrimaryIndex(Integer.class,
1505:                                    InsertSuperclass1_Between.class);
1506:                    InsertSuperclass1_Between obj = index.get(key);
1507:                    TestCase.assertNotNull(obj);
1508:                    TestCase.assertSame(InsertSuperclass1_BaseClass.class, obj
1509:                            .getClass().getSuperclass());
1510:                    TestCase.assertSame(EvolveCase.class, obj.getClass()
1511:                            .getSuperclass().getSuperclass());
1512:                    TestCase.assertEquals(99, obj.key);
1513:                    TestCase.assertEquals(88, obj.ff);
1514:                    TestCase.assertEquals(123, obj.f);
1515:                    if (doUpdate) {
1516:                        index.put(obj);
1517:                    }
1518:                }
1519:
1520:                @Override
1521:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
1522:                        throws DatabaseException {
1523:
1524:                    PrimaryIndex<Integer, InsertSuperclass1_Between> index = newStore
1525:                            .getPrimaryIndex(Integer.class,
1526:                                    InsertSuperclass1_Between.class);
1527:                    RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99);
1528:                    index.put((InsertSuperclass1_Between) newStore.getModel()
1529:                            .convertRawObject(raw));
1530:                }
1531:
1532:                @Override
1533:                void readRawObjects(RawStore store, boolean expectEvolved,
1534:                        boolean expectUpdated) throws DatabaseException {
1535:
1536:                    RawObject obj;
1537:                    if (expectEvolved) {
1538:                        obj = readRaw(store, 99, NAME2, 1, NAME, 0, CASECLS, 0);
1539:                    } else {
1540:                        obj = readRaw(store, 99, NAME2, 0, CASECLS, 0);
1541:                    }
1542:                    checkRawFields(obj, "key", 99, "ff", 88);
1543:                    if (expectEvolved) {
1544:                        if (expectUpdated) {
1545:                            checkRawFields(obj.getSuper(), "f", 123);
1546:                        } else {
1547:                            checkRawFields(obj.getSuper());
1548:                        }
1549:                        checkRawFields(obj.getSuper().getSuper());
1550:                        TestCase.assertNull(obj.getSuper().getSuper()
1551:                                .getSuper());
1552:                    } else {
1553:                        checkRawFields(obj.getSuper());
1554:                        TestCase.assertNull(obj.getSuper().getSuper());
1555:                    }
1556:                }
1557:            }
1558:
1559:            @Persistent
1560:            static class InsertSuperclass2_Embedded_Base {
1561:
1562:                int g = 456;
1563:            }
1564:
1565:            @Persistent(version=1)
1566:            static class InsertSuperclass2_Embedded extends
1567:                    InsertSuperclass2_Embedded_Base {
1568:
1569:                int f;
1570:            }
1571:
1572:            /**
1573:             * Allow inserting a superclass at the top of the hierarchy.  No mutations
1574:             * are needed.
1575:             */
1576:            @Entity
1577:            static class InsertSuperclass2_Top extends EvolveCase {
1578:
1579:                private static final String NAME = InsertSuperclass2_Top.class
1580:                        .getName();
1581:                private static final String NAME2 = InsertSuperclass2_Embedded.class
1582:                        .getName();
1583:                private static final String NAME3 = InsertSuperclass2_Embedded_Base.class
1584:                        .getName();
1585:
1586:                @PrimaryKey
1587:                int key = 99;
1588:
1589:                int ff;
1590:
1591:                InsertSuperclass2_Embedded embed = new InsertSuperclass2_Embedded();
1592:
1593:                @Override
1594:                void checkEvolvedModel(EntityModel model, Environment env,
1595:                        boolean oldTypesExist) {
1596:                    checkEntity(true, model, env, NAME, 0, null);
1597:                    checkNonEntity(true, model, env, NAME2, 1);
1598:                    checkNonEntity(true, model, env, NAME3, 0);
1599:                    checkVersions(model, NAME, 0);
1600:                    if (oldTypesExist) {
1601:                        checkVersions(model, NAME2, 1, NAME2, 0);
1602:                    } else {
1603:                        checkVersions(model, NAME2, 1);
1604:                    }
1605:                    checkVersions(model, NAME3, 0);
1606:                }
1607:
1608:                @Override
1609:                void readObjects(EntityStore store, boolean doUpdate)
1610:                        throws DatabaseException {
1611:
1612:                    PrimaryIndex<Integer, InsertSuperclass2_Top> index = store
1613:                            .getPrimaryIndex(Integer.class,
1614:                                    InsertSuperclass2_Top.class);
1615:                    InsertSuperclass2_Top obj = index.get(key);
1616:                    TestCase.assertNotNull(obj);
1617:                    TestCase.assertNotNull(obj.embed);
1618:                    TestCase.assertEquals(99, obj.key);
1619:                    TestCase.assertEquals(88, obj.ff);
1620:                    TestCase.assertEquals(123, obj.embed.f);
1621:                    TestCase.assertEquals(456, obj.embed.g);
1622:                    if (doUpdate) {
1623:                        index.put(obj);
1624:                    }
1625:                }
1626:
1627:                @Override
1628:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
1629:                        throws DatabaseException {
1630:
1631:                    PrimaryIndex<Integer, InsertSuperclass2_Top> index = newStore
1632:                            .getPrimaryIndex(Integer.class,
1633:                                    InsertSuperclass2_Top.class);
1634:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
1635:                    index.put((InsertSuperclass2_Top) newStore.getModel()
1636:                            .convertRawObject(raw));
1637:                }
1638:
1639:                @Override
1640:                void readRawObjects(RawStore store, boolean expectEvolved,
1641:                        boolean expectUpdated) throws DatabaseException {
1642:
1643:                    RawType embedType = store.getModel().getRawType(NAME2);
1644:                    RawObject embedSuper = null;
1645:                    if (expectEvolved) {
1646:                        RawType embedSuperType = store.getModel().getRawType(
1647:                                NAME3);
1648:                        Map<String, Object> values = expectUpdated ? makeValues(
1649:                                "g", 456)
1650:                                : makeValues();
1651:                        embedSuper = new RawObject(embedSuperType, values, null);
1652:                    }
1653:                    RawObject embed = new RawObject(embedType, makeValues("f",
1654:                            123), embedSuper);
1655:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1656:                    checkRawFields(obj, "key", 99, "ff", 88, "embed", embed);
1657:                }
1658:            }
1659:
1660:            @Entity(version=1)
1661:            static class DisallowNonKeyField_PrimitiveToObject extends
1662:                    EvolveCase {
1663:
1664:                private static final String NAME = DisallowNonKeyField_PrimitiveToObject.class
1665:                        .getName();
1666:
1667:                @PrimaryKey
1668:                int key = 99;
1669:
1670:                String ff;
1671:
1672:                @Override
1673:                public String getStoreOpenException() {
1674:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_PrimitiveToObject version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_PrimitiveToObject version: 1 Error: Old field type: int is not compatible with the new type: java.lang.String for field: ff";
1675:                }
1676:
1677:                @Override
1678:                void checkUnevolvedModel(EntityModel model, Environment env) {
1679:                    checkEntity(true, model, env, NAME, 0, null);
1680:                    checkVersions(model, NAME, 0);
1681:                }
1682:
1683:                @Override
1684:                void readRawObjects(RawStore store, boolean expectEvolved,
1685:                        boolean expectUpdated) throws DatabaseException {
1686:
1687:                    if (expectEvolved) {
1688:                        TestCase.fail();
1689:                    }
1690:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1691:                    checkRawFields(obj, "key", 99, "ff", 88);
1692:                }
1693:            }
1694:
1695:            @Entity(version=1)
1696:            static class DisallowNonKeyField_ObjectToPrimitive extends
1697:                    EvolveCase {
1698:
1699:                private static final String NAME = DisallowNonKeyField_ObjectToPrimitive.class
1700:                        .getName();
1701:
1702:                @PrimaryKey
1703:                int key = 99;
1704:
1705:                int ff;
1706:
1707:                @Override
1708:                public String getStoreOpenException() {
1709:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToPrimitive version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToPrimitive version: 1 Error: Old field type: java.lang.String is not compatible with the new type: int for field: ff";
1710:                }
1711:
1712:                @Override
1713:                void checkUnevolvedModel(EntityModel model, Environment env) {
1714:                    checkEntity(true, model, env, NAME, 0, null);
1715:                    checkVersions(model, NAME, 0);
1716:                }
1717:
1718:                @Override
1719:                void readRawObjects(RawStore store, boolean expectEvolved,
1720:                        boolean expectUpdated) throws DatabaseException {
1721:
1722:                    if (expectEvolved) {
1723:                        TestCase.fail();
1724:                    }
1725:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1726:                    checkRawFields(obj, "key", 99, "ff", "88");
1727:                }
1728:            }
1729:
1730:            @Persistent
1731:            static class MyType {
1732:
1733:                @Override
1734:                public boolean equals(Object o) {
1735:                    return o instanceof  MyType;
1736:                }
1737:            }
1738:
1739:            @Persistent
1740:            static class MySubtype extends MyType {
1741:
1742:                @Override
1743:                public boolean equals(Object o) {
1744:                    return o instanceof  MySubtype;
1745:                }
1746:            }
1747:
1748:            @Entity(version=1)
1749:            static class DisallowNonKeyField_ObjectToSubtype extends EvolveCase {
1750:
1751:                private static final String NAME = DisallowNonKeyField_ObjectToSubtype.class
1752:                        .getName();
1753:
1754:                @PrimaryKey
1755:                int key = 99;
1756:
1757:                MySubtype ff;
1758:
1759:                @Override
1760:                public String getStoreOpenException() {
1761:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToSubtype version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToSubtype version: 1 Error: Old field type: com.sleepycat.persist.test.EvolveClasses$MyType is not compatible with the new type: com.sleepycat.persist.test.EvolveClasses$MySubtype for field: ff";
1762:                }
1763:
1764:                @Override
1765:                void checkUnevolvedModel(EntityModel model, Environment env) {
1766:                    checkEntity(true, model, env, NAME, 0, null);
1767:                    checkVersions(model, NAME, 0);
1768:                }
1769:
1770:                @Override
1771:                void readRawObjects(RawStore store, boolean expectEvolved,
1772:                        boolean expectUpdated) throws DatabaseException {
1773:
1774:                    if (expectEvolved) {
1775:                        TestCase.fail();
1776:                    }
1777:                    RawType embedType = store.getModel().getRawType(
1778:                            MyType.class.getName());
1779:                    RawObject embed = new RawObject(embedType, makeValues(),
1780:                            null);
1781:
1782:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1783:                    checkRawFields(obj, "key", 99, "ff", embed);
1784:                }
1785:            }
1786:
1787:            @Entity(version=1)
1788:            static class DisallowNonKeyField_ObjectToUnrelatedSimple extends
1789:                    EvolveCase {
1790:
1791:                private static final String NAME = DisallowNonKeyField_ObjectToUnrelatedSimple.class
1792:                        .getName();
1793:
1794:                @PrimaryKey
1795:                int key = 99;
1796:
1797:                String ff;
1798:
1799:                @Override
1800:                public String getStoreOpenException() {
1801:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToUnrelatedSimple version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToUnrelatedSimple version: 1 Error: Old field type: java.lang.Integer is not compatible with the new type: java.lang.String for field: ff";
1802:                }
1803:
1804:                @Override
1805:                void checkUnevolvedModel(EntityModel model, Environment env) {
1806:                    checkEntity(true, model, env, NAME, 0, null);
1807:                    checkVersions(model, NAME, 0);
1808:                }
1809:
1810:                @Override
1811:                void readRawObjects(RawStore store, boolean expectEvolved,
1812:                        boolean expectUpdated) throws DatabaseException {
1813:
1814:                    if (expectEvolved) {
1815:                        TestCase.fail();
1816:                    }
1817:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1818:                    checkRawFields(obj, "key", 99, "ff", 88);
1819:                }
1820:            }
1821:
1822:            @Entity(version=1)
1823:            static class DisallowNonKeyField_ObjectToUnrelatedOther extends
1824:                    EvolveCase {
1825:
1826:                private static final String NAME = DisallowNonKeyField_ObjectToUnrelatedOther.class
1827:                        .getName();
1828:
1829:                @PrimaryKey
1830:                int key = 99;
1831:
1832:                MyType ff;
1833:
1834:                @Override
1835:                public String getStoreOpenException() {
1836:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToUnrelatedOther version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_ObjectToUnrelatedOther version: 1 Error: Old field type: java.lang.Integer is not compatible with the new type: com.sleepycat.persist.test.EvolveClasses$MyType for field: ff";
1837:                }
1838:
1839:                @Override
1840:                void checkUnevolvedModel(EntityModel model, Environment env) {
1841:                    checkEntity(true, model, env, NAME, 0, null);
1842:                    checkVersions(model, NAME, 0);
1843:                }
1844:
1845:                @Override
1846:                void readRawObjects(RawStore store, boolean expectEvolved,
1847:                        boolean expectUpdated) throws DatabaseException {
1848:
1849:                    if (expectEvolved) {
1850:                        TestCase.fail();
1851:                    }
1852:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1853:                    checkRawFields(obj, "key", 99, "ff", 88);
1854:                }
1855:            }
1856:
1857:            @Entity(version=1)
1858:            static class DisallowNonKeyField_byte2boolean extends EvolveCase {
1859:
1860:                private static final String NAME = DisallowNonKeyField_byte2boolean.class
1861:                        .getName();
1862:
1863:                @PrimaryKey
1864:                int key = 99;
1865:
1866:                boolean ff;
1867:
1868:                @Override
1869:                public String getStoreOpenException() {
1870:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_byte2boolean version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_byte2boolean version: 1 Error: Old field type: byte is not compatible with the new type: boolean for field: ff";
1871:                }
1872:
1873:                @Override
1874:                void checkUnevolvedModel(EntityModel model, Environment env) {
1875:                    checkEntity(true, model, env, NAME, 0, null);
1876:                    checkVersions(model, NAME, 0);
1877:                }
1878:
1879:                @Override
1880:                void readRawObjects(RawStore store, boolean expectEvolved,
1881:                        boolean expectUpdated) throws DatabaseException {
1882:
1883:                    if (expectEvolved) {
1884:                        TestCase.fail();
1885:                    }
1886:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1887:                    checkRawFields(obj, "key", 99, "ff", (byte) 88);
1888:                }
1889:            }
1890:
1891:            @Entity(version=1)
1892:            static class DisallowNonKeyField_short2byte extends EvolveCase {
1893:
1894:                private static final String NAME = DisallowNonKeyField_short2byte.class
1895:                        .getName();
1896:
1897:                @PrimaryKey
1898:                int key = 99;
1899:
1900:                byte ff;
1901:
1902:                @Override
1903:                public String getStoreOpenException() {
1904:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_short2byte version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_short2byte version: 1 Error: Old field type: short is not compatible with the new type: byte for field: ff";
1905:                }
1906:
1907:                @Override
1908:                void checkUnevolvedModel(EntityModel model, Environment env) {
1909:                    checkEntity(true, model, env, NAME, 0, null);
1910:                    checkVersions(model, NAME, 0);
1911:                }
1912:
1913:                @Override
1914:                void readRawObjects(RawStore store, boolean expectEvolved,
1915:                        boolean expectUpdated) throws DatabaseException {
1916:
1917:                    if (expectEvolved) {
1918:                        TestCase.fail();
1919:                    }
1920:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1921:                    checkRawFields(obj, "key", 99, "ff", (short) 88);
1922:                }
1923:            }
1924:
1925:            @Entity(version=1)
1926:            static class DisallowNonKeyField_int2short extends EvolveCase {
1927:
1928:                private static final String NAME = DisallowNonKeyField_int2short.class
1929:                        .getName();
1930:
1931:                @PrimaryKey
1932:                int key = 99;
1933:
1934:                short ff;
1935:
1936:                @Override
1937:                public String getStoreOpenException() {
1938:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_int2short version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_int2short version: 1 Error: Old field type: int is not compatible with the new type: short for field: ff";
1939:                }
1940:
1941:                @Override
1942:                void checkUnevolvedModel(EntityModel model, Environment env) {
1943:                    checkEntity(true, model, env, NAME, 0, null);
1944:                    checkVersions(model, NAME, 0);
1945:                }
1946:
1947:                @Override
1948:                void readRawObjects(RawStore store, boolean expectEvolved,
1949:                        boolean expectUpdated) throws DatabaseException {
1950:
1951:                    if (expectEvolved) {
1952:                        TestCase.fail();
1953:                    }
1954:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1955:                    checkRawFields(obj, "key", 99, "ff", (int) 88);
1956:                }
1957:            }
1958:
1959:            @Entity(version=1)
1960:            static class DisallowNonKeyField_long2int extends EvolveCase {
1961:
1962:                private static final String NAME = DisallowNonKeyField_long2int.class
1963:                        .getName();
1964:
1965:                @PrimaryKey
1966:                int key = 99;
1967:
1968:                int ff;
1969:
1970:                @Override
1971:                public String getStoreOpenException() {
1972:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_long2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_long2int version: 1 Error: Old field type: long is not compatible with the new type: int for field: ff";
1973:                }
1974:
1975:                @Override
1976:                void checkUnevolvedModel(EntityModel model, Environment env) {
1977:                    checkEntity(true, model, env, NAME, 0, null);
1978:                    checkVersions(model, NAME, 0);
1979:                }
1980:
1981:                @Override
1982:                void readRawObjects(RawStore store, boolean expectEvolved,
1983:                        boolean expectUpdated) throws DatabaseException {
1984:
1985:                    if (expectEvolved) {
1986:                        TestCase.fail();
1987:                    }
1988:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
1989:                    checkRawFields(obj, "key", 99, "ff", (long) 88);
1990:                }
1991:            }
1992:
1993:            @Entity(version=1)
1994:            static class DisallowNonKeyField_float2long extends EvolveCase {
1995:
1996:                private static final String NAME = DisallowNonKeyField_float2long.class
1997:                        .getName();
1998:
1999:                @PrimaryKey
2000:                int key = 99;
2001:
2002:                long ff;
2003:
2004:                @Override
2005:                public String getStoreOpenException() {
2006:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_float2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_float2long version: 1 Error: Old field type: float is not compatible with the new type: long for field: ff";
2007:                }
2008:
2009:                @Override
2010:                void checkUnevolvedModel(EntityModel model, Environment env) {
2011:                    checkEntity(true, model, env, NAME, 0, null);
2012:                    checkVersions(model, NAME, 0);
2013:                }
2014:
2015:                @Override
2016:                void readRawObjects(RawStore store, boolean expectEvolved,
2017:                        boolean expectUpdated) throws DatabaseException {
2018:
2019:                    if (expectEvolved) {
2020:                        TestCase.fail();
2021:                    }
2022:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2023:                    checkRawFields(obj, "key", 99, "ff", (float) 88);
2024:                }
2025:            }
2026:
2027:            @Entity(version=1)
2028:            static class DisallowNonKeyField_double2float extends EvolveCase {
2029:
2030:                private static final String NAME = DisallowNonKeyField_double2float.class
2031:                        .getName();
2032:
2033:                @PrimaryKey
2034:                int key = 99;
2035:
2036:                float ff;
2037:
2038:                @Override
2039:                public String getStoreOpenException() {
2040:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_double2float version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_double2float version: 1 Error: Old field type: double is not compatible with the new type: float for field: ff";
2041:                }
2042:
2043:                @Override
2044:                void checkUnevolvedModel(EntityModel model, Environment env) {
2045:                    checkEntity(true, model, env, NAME, 0, null);
2046:                    checkVersions(model, NAME, 0);
2047:                }
2048:
2049:                @Override
2050:                void readRawObjects(RawStore store, boolean expectEvolved,
2051:                        boolean expectUpdated) throws DatabaseException {
2052:
2053:                    if (expectEvolved) {
2054:                        TestCase.fail();
2055:                    }
2056:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2057:                    checkRawFields(obj, "key", 99, "ff", (double) 88);
2058:                }
2059:            }
2060:
2061:            @Entity(version=1)
2062:            static class DisallowNonKeyField_Byte2byte extends EvolveCase {
2063:
2064:                private static final String NAME = DisallowNonKeyField_Byte2byte.class
2065:                        .getName();
2066:
2067:                @PrimaryKey
2068:                int key = 99;
2069:
2070:                byte ff;
2071:
2072:                @Override
2073:                public String getStoreOpenException() {
2074:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Byte2byte version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Byte2byte version: 1 Error: Old field type: java.lang.Byte is not compatible with the new type: byte for field: ff";
2075:                }
2076:
2077:                @Override
2078:                void checkUnevolvedModel(EntityModel model, Environment env) {
2079:                    checkEntity(true, model, env, NAME, 0, null);
2080:                    checkVersions(model, NAME, 0);
2081:                }
2082:
2083:                @Override
2084:                void readRawObjects(RawStore store, boolean expectEvolved,
2085:                        boolean expectUpdated) throws DatabaseException {
2086:
2087:                    if (expectEvolved) {
2088:                        TestCase.fail();
2089:                    }
2090:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2091:                    checkRawFields(obj, "key", 99, "ff", (byte) 88);
2092:                }
2093:            }
2094:
2095:            @Entity(version=1)
2096:            static class DisallowNonKeyField_Character2char extends EvolveCase {
2097:
2098:                private static final String NAME = DisallowNonKeyField_Character2char.class
2099:                        .getName();
2100:
2101:                @PrimaryKey
2102:                int key = 99;
2103:
2104:                char ff;
2105:
2106:                @Override
2107:                public String getStoreOpenException() {
2108:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Character2char version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Character2char version: 1 Error: Old field type: java.lang.Character is not compatible with the new type: char for field: ff";
2109:                }
2110:
2111:                @Override
2112:                void checkUnevolvedModel(EntityModel model, Environment env) {
2113:                    checkEntity(true, model, env, NAME, 0, null);
2114:                    checkVersions(model, NAME, 0);
2115:                }
2116:
2117:                @Override
2118:                void readRawObjects(RawStore store, boolean expectEvolved,
2119:                        boolean expectUpdated) throws DatabaseException {
2120:
2121:                    if (expectEvolved) {
2122:                        TestCase.fail();
2123:                    }
2124:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2125:                    checkRawFields(obj, "key", 99, "ff", (char) 88);
2126:                }
2127:            }
2128:
2129:            @Entity(version=1)
2130:            static class DisallowNonKeyField_Short2short extends EvolveCase {
2131:
2132:                private static final String NAME = DisallowNonKeyField_Short2short.class
2133:                        .getName();
2134:
2135:                @PrimaryKey
2136:                int key = 99;
2137:
2138:                short ff;
2139:
2140:                @Override
2141:                public String getStoreOpenException() {
2142:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Short2short version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Short2short version: 1 Error: Old field type: java.lang.Short is not compatible with the new type: short for field: ff";
2143:                }
2144:
2145:                @Override
2146:                void checkUnevolvedModel(EntityModel model, Environment env) {
2147:                    checkEntity(true, model, env, NAME, 0, null);
2148:                    checkVersions(model, NAME, 0);
2149:                }
2150:
2151:                @Override
2152:                void readRawObjects(RawStore store, boolean expectEvolved,
2153:                        boolean expectUpdated) throws DatabaseException {
2154:
2155:                    if (expectEvolved) {
2156:                        TestCase.fail();
2157:                    }
2158:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2159:                    checkRawFields(obj, "key", 99, "ff", (short) 88);
2160:                }
2161:            }
2162:
2163:            @Entity(version=1)
2164:            static class DisallowNonKeyField_Integer2int extends EvolveCase {
2165:
2166:                private static final String NAME = DisallowNonKeyField_Integer2int.class
2167:                        .getName();
2168:
2169:                @PrimaryKey
2170:                int key = 99;
2171:
2172:                int ff;
2173:
2174:                @Override
2175:                public String getStoreOpenException() {
2176:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Integer2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Integer2int version: 1 Error: Old field type: java.lang.Integer is not compatible with the new type: int for field: ff";
2177:                }
2178:
2179:                @Override
2180:                void checkUnevolvedModel(EntityModel model, Environment env) {
2181:                    checkEntity(true, model, env, NAME, 0, null);
2182:                    checkVersions(model, NAME, 0);
2183:                }
2184:
2185:                @Override
2186:                void readRawObjects(RawStore store, boolean expectEvolved,
2187:                        boolean expectUpdated) throws DatabaseException {
2188:
2189:                    if (expectEvolved) {
2190:                        TestCase.fail();
2191:                    }
2192:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2193:                    checkRawFields(obj, "key", 99, "ff", (int) 88);
2194:                }
2195:            }
2196:
2197:            @Entity(version=1)
2198:            static class DisallowNonKeyField_Long2long extends EvolveCase {
2199:
2200:                private static final String NAME = DisallowNonKeyField_Long2long.class
2201:                        .getName();
2202:
2203:                @PrimaryKey
2204:                int key = 99;
2205:
2206:                long ff;
2207:
2208:                @Override
2209:                public String getStoreOpenException() {
2210:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Long2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Long2long version: 1 Error: Old field type: java.lang.Long is not compatible with the new type: long for field: ff";
2211:                }
2212:
2213:                @Override
2214:                void checkUnevolvedModel(EntityModel model, Environment env) {
2215:                    checkEntity(true, model, env, NAME, 0, null);
2216:                    checkVersions(model, NAME, 0);
2217:                }
2218:
2219:                @Override
2220:                void readRawObjects(RawStore store, boolean expectEvolved,
2221:                        boolean expectUpdated) throws DatabaseException {
2222:
2223:                    if (expectEvolved) {
2224:                        TestCase.fail();
2225:                    }
2226:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2227:                    checkRawFields(obj, "key", 99, "ff", (long) 88);
2228:                }
2229:            }
2230:
2231:            @Entity(version=1)
2232:            static class DisallowNonKeyField_Float2float extends EvolveCase {
2233:
2234:                private static final String NAME = DisallowNonKeyField_Float2float.class
2235:                        .getName();
2236:
2237:                @PrimaryKey
2238:                int key = 99;
2239:
2240:                float ff;
2241:
2242:                @Override
2243:                public String getStoreOpenException() {
2244:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Float2float version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Float2float version: 1 Error: Old field type: java.lang.Float is not compatible with the new type: float for field: ff";
2245:                }
2246:
2247:                @Override
2248:                void checkUnevolvedModel(EntityModel model, Environment env) {
2249:                    checkEntity(true, model, env, NAME, 0, null);
2250:                    checkVersions(model, NAME, 0);
2251:                }
2252:
2253:                @Override
2254:                void readRawObjects(RawStore store, boolean expectEvolved,
2255:                        boolean expectUpdated) throws DatabaseException {
2256:
2257:                    if (expectEvolved) {
2258:                        TestCase.fail();
2259:                    }
2260:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2261:                    checkRawFields(obj, "key", 99, "ff", (float) 88);
2262:                }
2263:            }
2264:
2265:            @Entity(version=1)
2266:            static class DisallowNonKeyField_Double2double extends EvolveCase {
2267:
2268:                private static final String NAME = DisallowNonKeyField_Double2double.class
2269:                        .getName();
2270:
2271:                @PrimaryKey
2272:                int key = 99;
2273:
2274:                double ff;
2275:
2276:                @Override
2277:                public String getStoreOpenException() {
2278:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Double2double version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_Double2double version: 1 Error: Old field type: java.lang.Double is not compatible with the new type: double for field: ff";
2279:                }
2280:
2281:                @Override
2282:                void checkUnevolvedModel(EntityModel model, Environment env) {
2283:                    checkEntity(true, model, env, NAME, 0, null);
2284:                    checkVersions(model, NAME, 0);
2285:                }
2286:
2287:                @Override
2288:                void readRawObjects(RawStore store, boolean expectEvolved,
2289:                        boolean expectUpdated) throws DatabaseException {
2290:
2291:                    if (expectEvolved) {
2292:                        TestCase.fail();
2293:                    }
2294:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2295:                    checkRawFields(obj, "key", 99, "ff", (double) 88);
2296:                }
2297:            }
2298:
2299:            @Entity(version=1)
2300:            static class DisallowNonKeyField_float2BigInt extends EvolveCase {
2301:
2302:                private static final String NAME = DisallowNonKeyField_float2BigInt.class
2303:                        .getName();
2304:
2305:                @PrimaryKey
2306:                int key = 99;
2307:
2308:                BigInteger ff;
2309:
2310:                @Override
2311:                public String getStoreOpenException() {
2312:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_float2BigInt version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_float2BigInt version: 1 Error: Old field type: float is not compatible with the new type: java.math.BigInteger for field: ff";
2313:                }
2314:
2315:                @Override
2316:                void checkUnevolvedModel(EntityModel model, Environment env) {
2317:                    checkEntity(true, model, env, NAME, 0, null);
2318:                    checkVersions(model, NAME, 0);
2319:                }
2320:
2321:                @Override
2322:                void readRawObjects(RawStore store, boolean expectEvolved,
2323:                        boolean expectUpdated) throws DatabaseException {
2324:
2325:                    if (expectEvolved) {
2326:                        TestCase.fail();
2327:                    }
2328:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2329:                    checkRawFields(obj, "key", 99, "ff", (float) 88);
2330:                }
2331:            }
2332:
2333:            @Entity(version=1)
2334:            static class DisallowNonKeyField_BigInt2long extends EvolveCase {
2335:
2336:                private static final String NAME = DisallowNonKeyField_BigInt2long.class
2337:                        .getName();
2338:
2339:                @PrimaryKey
2340:                int key = 99;
2341:
2342:                long ff;
2343:
2344:                @Override
2345:                public String getStoreOpenException() {
2346:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_BigInt2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowNonKeyField_BigInt2long version: 1 Error: Old field type: java.math.BigInteger is not compatible with the new type: long for field: ff";
2347:                }
2348:
2349:                @Override
2350:                void checkUnevolvedModel(EntityModel model, Environment env) {
2351:                    checkEntity(true, model, env, NAME, 0, null);
2352:                    checkVersions(model, NAME, 0);
2353:                }
2354:
2355:                @Override
2356:                void readRawObjects(RawStore store, boolean expectEvolved,
2357:                        boolean expectUpdated) throws DatabaseException {
2358:
2359:                    if (expectEvolved) {
2360:                        TestCase.fail();
2361:                    }
2362:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2363:                    checkRawFields(obj, "key", 99, "ff", BigInteger.valueOf(88));
2364:                }
2365:            }
2366:
2367:            @Entity(version=1)
2368:            static class DisallowSecKeyField_byte2short extends EvolveCase {
2369:
2370:                private static final String NAME = DisallowSecKeyField_byte2short.class
2371:                        .getName();
2372:
2373:                @PrimaryKey
2374:                int key = 99;
2375:
2376:                @SecondaryKey(relate=ONE_TO_ONE)
2377:                short ff;
2378:
2379:                @Override
2380:                public String getStoreOpenException() {
2381:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_byte2short version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_byte2short version: 1 Error: Old field type: byte is not compatible with the new type: short for field: ff";
2382:                }
2383:
2384:                @Override
2385:                void checkUnevolvedModel(EntityModel model, Environment env) {
2386:                    checkEntity(true, model, env, NAME, 0, "ff");
2387:                    checkVersions(model, NAME, 0);
2388:                }
2389:
2390:                @Override
2391:                void readRawObjects(RawStore store, boolean expectEvolved,
2392:                        boolean expectUpdated) throws DatabaseException {
2393:
2394:                    if (expectEvolved) {
2395:                        TestCase.fail();
2396:                    }
2397:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2398:                    checkRawFields(obj, "key", 99, "ff", (byte) 88);
2399:                }
2400:            }
2401:
2402:            @Entity(version=1)
2403:            static class DisallowSecKeyField_char2int extends EvolveCase {
2404:
2405:                private static final String NAME = DisallowSecKeyField_char2int.class
2406:                        .getName();
2407:
2408:                @PrimaryKey
2409:                int key = 99;
2410:
2411:                @SecondaryKey(relate=ONE_TO_ONE)
2412:                int ff;
2413:
2414:                @Override
2415:                public String getStoreOpenException() {
2416:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_char2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_char2int version: 1 Error: Old field type: char is not compatible with the new type: int for field: ff";
2417:                }
2418:
2419:                @Override
2420:                void checkUnevolvedModel(EntityModel model, Environment env) {
2421:                    checkEntity(true, model, env, NAME, 0, "ff");
2422:                    checkVersions(model, NAME, 0);
2423:                }
2424:
2425:                @Override
2426:                void readRawObjects(RawStore store, boolean expectEvolved,
2427:                        boolean expectUpdated) throws DatabaseException {
2428:
2429:                    if (expectEvolved) {
2430:                        TestCase.fail();
2431:                    }
2432:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2433:                    checkRawFields(obj, "key", 99, "ff", (char) 88);
2434:                }
2435:            }
2436:
2437:            @Entity(version=1)
2438:            static class DisallowSecKeyField_short2int extends EvolveCase {
2439:
2440:                private static final String NAME = DisallowSecKeyField_short2int.class
2441:                        .getName();
2442:
2443:                @PrimaryKey
2444:                int key = 99;
2445:
2446:                @SecondaryKey(relate=ONE_TO_ONE)
2447:                int ff;
2448:
2449:                @Override
2450:                public String getStoreOpenException() {
2451:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_short2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_short2int version: 1 Error: Old field type: short is not compatible with the new type: int for field: ff";
2452:                }
2453:
2454:                @Override
2455:                void checkUnevolvedModel(EntityModel model, Environment env) {
2456:                    checkEntity(true, model, env, NAME, 0, "ff");
2457:                    checkVersions(model, NAME, 0);
2458:                }
2459:
2460:                @Override
2461:                void readRawObjects(RawStore store, boolean expectEvolved,
2462:                        boolean expectUpdated) throws DatabaseException {
2463:
2464:                    if (expectEvolved) {
2465:                        TestCase.fail();
2466:                    }
2467:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2468:                    checkRawFields(obj, "key", 99, "ff", (short) 88);
2469:                }
2470:            }
2471:
2472:            @Entity(version=1)
2473:            static class DisallowSecKeyField_int2long extends EvolveCase {
2474:
2475:                private static final String NAME = DisallowSecKeyField_int2long.class
2476:                        .getName();
2477:
2478:                @PrimaryKey
2479:                int key = 99;
2480:
2481:                @SecondaryKey(relate=ONE_TO_ONE)
2482:                long ff;
2483:
2484:                @Override
2485:                public String getStoreOpenException() {
2486:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_int2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_int2long version: 1 Error: Old field type: int is not compatible with the new type: long for field: ff";
2487:                }
2488:
2489:                @Override
2490:                void checkUnevolvedModel(EntityModel model, Environment env) {
2491:                    checkEntity(true, model, env, NAME, 0, "ff");
2492:                    checkVersions(model, NAME, 0);
2493:                }
2494:
2495:                @Override
2496:                void readRawObjects(RawStore store, boolean expectEvolved,
2497:                        boolean expectUpdated) throws DatabaseException {
2498:
2499:                    if (expectEvolved) {
2500:                        TestCase.fail();
2501:                    }
2502:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2503:                    checkRawFields(obj, "key", 99, "ff", (int) 88);
2504:                }
2505:            }
2506:
2507:            @Entity(version=1)
2508:            static class DisallowSecKeyField_long2float extends EvolveCase {
2509:
2510:                private static final String NAME = DisallowSecKeyField_long2float.class
2511:                        .getName();
2512:
2513:                @PrimaryKey
2514:                int key = 99;
2515:
2516:                @SecondaryKey(relate=ONE_TO_ONE)
2517:                float ff;
2518:
2519:                @Override
2520:                public String getStoreOpenException() {
2521:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_long2float version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_long2float version: 1 Error: Old field type: long is not compatible with the new type: float for field: ff";
2522:                }
2523:
2524:                @Override
2525:                void checkUnevolvedModel(EntityModel model, Environment env) {
2526:                    checkEntity(true, model, env, NAME, 0, "ff");
2527:                    checkVersions(model, NAME, 0);
2528:                }
2529:
2530:                @Override
2531:                void readRawObjects(RawStore store, boolean expectEvolved,
2532:                        boolean expectUpdated) throws DatabaseException {
2533:
2534:                    if (expectEvolved) {
2535:                        TestCase.fail();
2536:                    }
2537:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2538:                    checkRawFields(obj, "key", 99, "ff", (long) 88);
2539:                }
2540:            }
2541:
2542:            @Entity(version=1)
2543:            static class DisallowSecKeyField_float2double extends EvolveCase {
2544:
2545:                private static final String NAME = DisallowSecKeyField_float2double.class
2546:                        .getName();
2547:
2548:                @PrimaryKey
2549:                int key = 99;
2550:
2551:                @SecondaryKey(relate=ONE_TO_ONE)
2552:                double ff;
2553:
2554:                @Override
2555:                public String getStoreOpenException() {
2556:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_float2double version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_float2double version: 1 Error: Old field type: float is not compatible with the new type: double for field: ff";
2557:                }
2558:
2559:                @Override
2560:                void checkUnevolvedModel(EntityModel model, Environment env) {
2561:                    checkEntity(true, model, env, NAME, 0, "ff");
2562:                    checkVersions(model, NAME, 0);
2563:                }
2564:
2565:                @Override
2566:                void readRawObjects(RawStore store, boolean expectEvolved,
2567:                        boolean expectUpdated) throws DatabaseException {
2568:
2569:                    if (expectEvolved) {
2570:                        TestCase.fail();
2571:                    }
2572:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2573:                    checkRawFields(obj, "key", 99, "ff", (float) 88);
2574:                }
2575:            }
2576:
2577:            @Entity(version=1)
2578:            static class DisallowSecKeyField_Byte2short2 extends EvolveCase {
2579:
2580:                private static final String NAME = DisallowSecKeyField_Byte2short2.class
2581:                        .getName();
2582:
2583:                @PrimaryKey
2584:                int key = 99;
2585:
2586:                @SecondaryKey(relate=ONE_TO_ONE)
2587:                short ff;
2588:
2589:                @Override
2590:                public String getStoreOpenException() {
2591:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Byte2short2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Byte2short2 version: 1 Error: Old field type: java.lang.Byte is not compatible with the new type: short for field: ff";
2592:                }
2593:
2594:                @Override
2595:                void checkUnevolvedModel(EntityModel model, Environment env) {
2596:                    checkEntity(true, model, env, NAME, 0, "ff");
2597:                    checkVersions(model, NAME, 0);
2598:                }
2599:
2600:                @Override
2601:                void readRawObjects(RawStore store, boolean expectEvolved,
2602:                        boolean expectUpdated) throws DatabaseException {
2603:
2604:                    if (expectEvolved) {
2605:                        TestCase.fail();
2606:                    }
2607:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2608:                    checkRawFields(obj, "key", 99, "ff", (byte) 88);
2609:                }
2610:            }
2611:
2612:            @Entity(version=1)
2613:            static class DisallowSecKeyField_Character2int extends EvolveCase {
2614:
2615:                private static final String NAME = DisallowSecKeyField_Character2int.class
2616:                        .getName();
2617:
2618:                @PrimaryKey
2619:                int key = 99;
2620:
2621:                @SecondaryKey(relate=ONE_TO_ONE)
2622:                int ff;
2623:
2624:                @Override
2625:                public String getStoreOpenException() {
2626:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Character2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Character2int version: 1 Error: Old field type: java.lang.Character is not compatible with the new type: int for field: ff";
2627:                }
2628:
2629:                @Override
2630:                void checkUnevolvedModel(EntityModel model, Environment env) {
2631:                    checkEntity(true, model, env, NAME, 0, "ff");
2632:                    checkVersions(model, NAME, 0);
2633:                }
2634:
2635:                @Override
2636:                void readRawObjects(RawStore store, boolean expectEvolved,
2637:                        boolean expectUpdated) throws DatabaseException {
2638:
2639:                    if (expectEvolved) {
2640:                        TestCase.fail();
2641:                    }
2642:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2643:                    checkRawFields(obj, "key", 99, "ff", (char) 88);
2644:                }
2645:            }
2646:
2647:            @Entity(version=1)
2648:            static class DisallowSecKeyField_Short2int2 extends EvolveCase {
2649:
2650:                private static final String NAME = DisallowSecKeyField_Short2int2.class
2651:                        .getName();
2652:
2653:                @PrimaryKey
2654:                int key = 99;
2655:
2656:                @SecondaryKey(relate=ONE_TO_ONE)
2657:                int ff;
2658:
2659:                @Override
2660:                public String getStoreOpenException() {
2661:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Short2int2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Short2int2 version: 1 Error: Old field type: java.lang.Short is not compatible with the new type: int for field: ff";
2662:                }
2663:
2664:                @Override
2665:                void checkUnevolvedModel(EntityModel model, Environment env) {
2666:                    checkEntity(true, model, env, NAME, 0, "ff");
2667:                    checkVersions(model, NAME, 0);
2668:                }
2669:
2670:                @Override
2671:                void readRawObjects(RawStore store, boolean expectEvolved,
2672:                        boolean expectUpdated) throws DatabaseException {
2673:
2674:                    if (expectEvolved) {
2675:                        TestCase.fail();
2676:                    }
2677:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2678:                    checkRawFields(obj, "key", 99, "ff", (short) 88);
2679:                }
2680:            }
2681:
2682:            @Entity(version=1)
2683:            static class DisallowSecKeyField_Integer2long extends EvolveCase {
2684:
2685:                private static final String NAME = DisallowSecKeyField_Integer2long.class
2686:                        .getName();
2687:
2688:                @PrimaryKey
2689:                int key = 99;
2690:
2691:                @SecondaryKey(relate=ONE_TO_ONE)
2692:                long ff;
2693:
2694:                @Override
2695:                public String getStoreOpenException() {
2696:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Integer2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Integer2long version: 1 Error: Old field type: java.lang.Integer is not compatible with the new type: long for field: ff";
2697:                }
2698:
2699:                @Override
2700:                void checkUnevolvedModel(EntityModel model, Environment env) {
2701:                    checkEntity(true, model, env, NAME, 0, "ff");
2702:                    checkVersions(model, NAME, 0);
2703:                }
2704:
2705:                @Override
2706:                void readRawObjects(RawStore store, boolean expectEvolved,
2707:                        boolean expectUpdated) throws DatabaseException {
2708:
2709:                    if (expectEvolved) {
2710:                        TestCase.fail();
2711:                    }
2712:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2713:                    checkRawFields(obj, "key", 99, "ff", (int) 88);
2714:                }
2715:            }
2716:
2717:            @Entity(version=1)
2718:            static class DisallowSecKeyField_Long2float2 extends EvolveCase {
2719:
2720:                private static final String NAME = DisallowSecKeyField_Long2float2.class
2721:                        .getName();
2722:
2723:                @PrimaryKey
2724:                int key = 99;
2725:
2726:                @SecondaryKey(relate=ONE_TO_ONE)
2727:                float ff;
2728:
2729:                @Override
2730:                public String getStoreOpenException() {
2731:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Long2float2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Long2float2 version: 1 Error: Old field type: java.lang.Long is not compatible with the new type: float for field: ff";
2732:                }
2733:
2734:                @Override
2735:                void checkUnevolvedModel(EntityModel model, Environment env) {
2736:                    checkEntity(true, model, env, NAME, 0, "ff");
2737:                    checkVersions(model, NAME, 0);
2738:                }
2739:
2740:                @Override
2741:                void readRawObjects(RawStore store, boolean expectEvolved,
2742:                        boolean expectUpdated) throws DatabaseException {
2743:
2744:                    if (expectEvolved) {
2745:                        TestCase.fail();
2746:                    }
2747:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2748:                    checkRawFields(obj, "key", 99, "ff", (long) 88);
2749:                }
2750:            }
2751:
2752:            @Entity(version=1)
2753:            static class DisallowSecKeyField_Float2double2 extends EvolveCase {
2754:
2755:                private static final String NAME = DisallowSecKeyField_Float2double2.class
2756:                        .getName();
2757:
2758:                @PrimaryKey
2759:                int key = 99;
2760:
2761:                @SecondaryKey(relate=ONE_TO_ONE)
2762:                double ff;
2763:
2764:                @Override
2765:                public String getStoreOpenException() {
2766:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Float2double2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_Float2double2 version: 1 Error: Old field type: java.lang.Float is not compatible with the new type: double for field: ff";
2767:                }
2768:
2769:                @Override
2770:                void checkUnevolvedModel(EntityModel model, Environment env) {
2771:                    checkEntity(true, model, env, NAME, 0, "ff");
2772:                    checkVersions(model, NAME, 0);
2773:                }
2774:
2775:                @Override
2776:                void readRawObjects(RawStore store, boolean expectEvolved,
2777:                        boolean expectUpdated) throws DatabaseException {
2778:
2779:                    if (expectEvolved) {
2780:                        TestCase.fail();
2781:                    }
2782:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2783:                    checkRawFields(obj, "key", 99, "ff", (float) 88);
2784:                }
2785:            }
2786:
2787:            @Entity(version=1)
2788:            static class DisallowSecKeyField_int2BigInt extends EvolveCase {
2789:
2790:                private static final String NAME = DisallowSecKeyField_int2BigInt.class
2791:                        .getName();
2792:
2793:                @PrimaryKey
2794:                int key = 99;
2795:
2796:                @SecondaryKey(relate=ONE_TO_ONE)
2797:                BigInteger ff;
2798:
2799:                @Override
2800:                public String getStoreOpenException() {
2801:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_int2BigInt version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowSecKeyField_int2BigInt version: 1 Error: Old field type: int is not compatible with the new type: java.math.BigInteger for field: ff";
2802:                }
2803:
2804:                @Override
2805:                void checkUnevolvedModel(EntityModel model, Environment env) {
2806:                    checkEntity(true, model, env, NAME, 0, "ff");
2807:                    checkVersions(model, NAME, 0);
2808:                }
2809:
2810:                @Override
2811:                void readRawObjects(RawStore store, boolean expectEvolved,
2812:                        boolean expectUpdated) throws DatabaseException {
2813:
2814:                    if (expectEvolved) {
2815:                        TestCase.fail();
2816:                    }
2817:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
2818:                    checkRawFields(obj, "key", 99, "ff", 88);
2819:                }
2820:            }
2821:
2822:            // ---
2823:
2824:            @Entity(version=1)
2825:            static class DisallowPriKeyField_byte2short extends EvolveCase {
2826:
2827:                private static final String NAME = DisallowPriKeyField_byte2short.class
2828:                        .getName();
2829:
2830:                @PrimaryKey
2831:                short key;
2832:
2833:                @Override
2834:                public String getStoreOpenException() {
2835:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_byte2short version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_byte2short version: 1 Error: Old field type: byte is not compatible with the new type: short for field: key";
2836:                }
2837:
2838:                @Override
2839:                void checkUnevolvedModel(EntityModel model, Environment env) {
2840:                    checkEntity(true, model, env, NAME, 0, null);
2841:                    checkVersions(model, NAME, 0);
2842:                }
2843:
2844:                @Override
2845:                void readRawObjects(RawStore store, boolean expectEvolved,
2846:                        boolean expectUpdated) throws DatabaseException {
2847:
2848:                    if (expectEvolved) {
2849:                        TestCase.fail();
2850:                    }
2851:                    RawObject obj = readRaw(store, (byte) 99, NAME, 0, CASECLS,
2852:                            0);
2853:                    checkRawFields(obj, "key", (byte) 99);
2854:                }
2855:            }
2856:
2857:            @Entity(version=1)
2858:            static class DisallowPriKeyField_char2int extends EvolveCase {
2859:
2860:                private static final String NAME = DisallowPriKeyField_char2int.class
2861:                        .getName();
2862:
2863:                @PrimaryKey
2864:                int key;
2865:
2866:                @Override
2867:                public String getStoreOpenException() {
2868:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_char2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_char2int version: 1 Error: Old field type: char is not compatible with the new type: int for field: key";
2869:                }
2870:
2871:                @Override
2872:                void checkUnevolvedModel(EntityModel model, Environment env) {
2873:                    checkEntity(true, model, env, NAME, 0, null);
2874:                    checkVersions(model, NAME, 0);
2875:                }
2876:
2877:                @Override
2878:                void readRawObjects(RawStore store, boolean expectEvolved,
2879:                        boolean expectUpdated) throws DatabaseException {
2880:
2881:                    if (expectEvolved) {
2882:                        TestCase.fail();
2883:                    }
2884:                    RawObject obj = readRaw(store, (char) 99, NAME, 0, CASECLS,
2885:                            0);
2886:                    checkRawFields(obj, "key", (char) 99);
2887:                }
2888:            }
2889:
2890:            @Entity(version=1)
2891:            static class DisallowPriKeyField_short2int extends EvolveCase {
2892:
2893:                private static final String NAME = DisallowPriKeyField_short2int.class
2894:                        .getName();
2895:
2896:                @PrimaryKey
2897:                int key;
2898:
2899:                @Override
2900:                public String getStoreOpenException() {
2901:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_short2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_short2int version: 1 Error: Old field type: short is not compatible with the new type: int for field: key";
2902:                }
2903:
2904:                @Override
2905:                void checkUnevolvedModel(EntityModel model, Environment env) {
2906:                    checkEntity(true, model, env, NAME, 0, null);
2907:                    checkVersions(model, NAME, 0);
2908:                }
2909:
2910:                @Override
2911:                void readRawObjects(RawStore store, boolean expectEvolved,
2912:                        boolean expectUpdated) throws DatabaseException {
2913:
2914:                    if (expectEvolved) {
2915:                        TestCase.fail();
2916:                    }
2917:                    RawObject obj = readRaw(store, (short) 99, NAME, 0,
2918:                            CASECLS, 0);
2919:                    checkRawFields(obj, "key", (short) 99);
2920:                }
2921:            }
2922:
2923:            @Entity(version=1)
2924:            static class DisallowPriKeyField_int2long extends EvolveCase {
2925:
2926:                private static final String NAME = DisallowPriKeyField_int2long.class
2927:                        .getName();
2928:
2929:                @PrimaryKey
2930:                long key;
2931:
2932:                @Override
2933:                public String getStoreOpenException() {
2934:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_int2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_int2long version: 1 Error: Old field type: int is not compatible with the new type: long for field: key";
2935:                }
2936:
2937:                @Override
2938:                void checkUnevolvedModel(EntityModel model, Environment env) {
2939:                    checkEntity(true, model, env, NAME, 0, null);
2940:                    checkVersions(model, NAME, 0);
2941:                }
2942:
2943:                @Override
2944:                void readRawObjects(RawStore store, boolean expectEvolved,
2945:                        boolean expectUpdated) throws DatabaseException {
2946:
2947:                    if (expectEvolved) {
2948:                        TestCase.fail();
2949:                    }
2950:                    RawObject obj = readRaw(store, (int) 99, NAME, 0, CASECLS,
2951:                            0);
2952:                    checkRawFields(obj, "key", (int) 99);
2953:                }
2954:            }
2955:
2956:            @Entity(version=1)
2957:            static class DisallowPriKeyField_long2float extends EvolveCase {
2958:
2959:                private static final String NAME = DisallowPriKeyField_long2float.class
2960:                        .getName();
2961:
2962:                @PrimaryKey
2963:                float key;
2964:
2965:                @Override
2966:                public String getStoreOpenException() {
2967:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_long2float version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_long2float version: 1 Error: Old field type: long is not compatible with the new type: float for field: key";
2968:                }
2969:
2970:                @Override
2971:                void checkUnevolvedModel(EntityModel model, Environment env) {
2972:                    checkEntity(true, model, env, NAME, 0, null);
2973:                    checkVersions(model, NAME, 0);
2974:                }
2975:
2976:                @Override
2977:                void readRawObjects(RawStore store, boolean expectEvolved,
2978:                        boolean expectUpdated) throws DatabaseException {
2979:
2980:                    if (expectEvolved) {
2981:                        TestCase.fail();
2982:                    }
2983:                    RawObject obj = readRaw(store, (long) 99, NAME, 0, CASECLS,
2984:                            0);
2985:                    checkRawFields(obj, "key", (long) 99);
2986:                }
2987:            }
2988:
2989:            @Entity(version=1)
2990:            static class DisallowPriKeyField_float2double extends EvolveCase {
2991:
2992:                private static final String NAME = DisallowPriKeyField_float2double.class
2993:                        .getName();
2994:
2995:                @PrimaryKey
2996:                double key;
2997:
2998:                @Override
2999:                public String getStoreOpenException() {
3000:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_float2double version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_float2double version: 1 Error: Old field type: float is not compatible with the new type: double for field: key";
3001:                }
3002:
3003:                @Override
3004:                void checkUnevolvedModel(EntityModel model, Environment env) {
3005:                    checkEntity(true, model, env, NAME, 0, null);
3006:                    checkVersions(model, NAME, 0);
3007:                }
3008:
3009:                @Override
3010:                void readRawObjects(RawStore store, boolean expectEvolved,
3011:                        boolean expectUpdated) throws DatabaseException {
3012:
3013:                    if (expectEvolved) {
3014:                        TestCase.fail();
3015:                    }
3016:                    RawObject obj = readRaw(store, (float) 99, NAME, 0,
3017:                            CASECLS, 0);
3018:                    checkRawFields(obj, "key", (float) 99);
3019:                }
3020:            }
3021:
3022:            @Entity(version=1)
3023:            static class DisallowPriKeyField_Byte2short2 extends EvolveCase {
3024:
3025:                private static final String NAME = DisallowPriKeyField_Byte2short2.class
3026:                        .getName();
3027:
3028:                @PrimaryKey
3029:                short key;
3030:
3031:                @Override
3032:                public String getStoreOpenException() {
3033:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Byte2short2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Byte2short2 version: 1 Error: Old field type: java.lang.Byte is not compatible with the new type: short for field: key";
3034:                }
3035:
3036:                @Override
3037:                void checkUnevolvedModel(EntityModel model, Environment env) {
3038:                    checkEntity(true, model, env, NAME, 0, null);
3039:                    checkVersions(model, NAME, 0);
3040:                }
3041:
3042:                @Override
3043:                void readRawObjects(RawStore store, boolean expectEvolved,
3044:                        boolean expectUpdated) throws DatabaseException {
3045:
3046:                    if (expectEvolved) {
3047:                        TestCase.fail();
3048:                    }
3049:                    RawObject obj = readRaw(store, (byte) 99, NAME, 0, CASECLS,
3050:                            0);
3051:                    checkRawFields(obj, "key", (byte) 99);
3052:                }
3053:            }
3054:
3055:            @Entity(version=1)
3056:            static class DisallowPriKeyField_Character2int extends EvolveCase {
3057:
3058:                private static final String NAME = DisallowPriKeyField_Character2int.class
3059:                        .getName();
3060:
3061:                @PrimaryKey
3062:                int key;
3063:
3064:                @Override
3065:                public String getStoreOpenException() {
3066:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Character2int version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Character2int version: 1 Error: Old field type: java.lang.Character is not compatible with the new type: int for field: key";
3067:                }
3068:
3069:                @Override
3070:                void checkUnevolvedModel(EntityModel model, Environment env) {
3071:                    checkEntity(true, model, env, NAME, 0, null);
3072:                    checkVersions(model, NAME, 0);
3073:                }
3074:
3075:                @Override
3076:                void readRawObjects(RawStore store, boolean expectEvolved,
3077:                        boolean expectUpdated) throws DatabaseException {
3078:
3079:                    if (expectEvolved) {
3080:                        TestCase.fail();
3081:                    }
3082:                    RawObject obj = readRaw(store, (char) 99, NAME, 0, CASECLS,
3083:                            0);
3084:                    checkRawFields(obj, "key", (char) 99);
3085:                }
3086:            }
3087:
3088:            @Entity(version=1)
3089:            static class DisallowPriKeyField_Short2int2 extends EvolveCase {
3090:
3091:                private static final String NAME = DisallowPriKeyField_Short2int2.class
3092:                        .getName();
3093:
3094:                @PrimaryKey
3095:                int key;
3096:
3097:                @Override
3098:                public String getStoreOpenException() {
3099:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Short2int2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Short2int2 version: 1 Error: Old field type: java.lang.Short is not compatible with the new type: int for field: key";
3100:                }
3101:
3102:                @Override
3103:                void checkUnevolvedModel(EntityModel model, Environment env) {
3104:                    checkEntity(true, model, env, NAME, 0, null);
3105:                    checkVersions(model, NAME, 0);
3106:                }
3107:
3108:                @Override
3109:                void readRawObjects(RawStore store, boolean expectEvolved,
3110:                        boolean expectUpdated) throws DatabaseException {
3111:
3112:                    if (expectEvolved) {
3113:                        TestCase.fail();
3114:                    }
3115:                    RawObject obj = readRaw(store, (short) 99, NAME, 0,
3116:                            CASECLS, 0);
3117:                    checkRawFields(obj, "key", (short) 99);
3118:                }
3119:            }
3120:
3121:            @Entity(version=1)
3122:            static class DisallowPriKeyField_Integer2long extends EvolveCase {
3123:
3124:                private static final String NAME = DisallowPriKeyField_Integer2long.class
3125:                        .getName();
3126:
3127:                @PrimaryKey
3128:                long key;
3129:
3130:                @Override
3131:                public String getStoreOpenException() {
3132:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Integer2long version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Integer2long version: 1 Error: Old field type: java.lang.Integer is not compatible with the new type: long for field: key";
3133:                }
3134:
3135:                @Override
3136:                void checkUnevolvedModel(EntityModel model, Environment env) {
3137:                    checkEntity(true, model, env, NAME, 0, null);
3138:                    checkVersions(model, NAME, 0);
3139:                }
3140:
3141:                @Override
3142:                void readRawObjects(RawStore store, boolean expectEvolved,
3143:                        boolean expectUpdated) throws DatabaseException {
3144:
3145:                    if (expectEvolved) {
3146:                        TestCase.fail();
3147:                    }
3148:                    RawObject obj = readRaw(store, (int) 99, NAME, 0, CASECLS,
3149:                            0);
3150:                    checkRawFields(obj, "key", (int) 99);
3151:                }
3152:            }
3153:
3154:            @Entity(version=1)
3155:            static class DisallowPriKeyField_Long2float2 extends EvolveCase {
3156:
3157:                private static final String NAME = DisallowPriKeyField_Long2float2.class
3158:                        .getName();
3159:
3160:                @PrimaryKey
3161:                float key;
3162:
3163:                @Override
3164:                public String getStoreOpenException() {
3165:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Long2float2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Long2float2 version: 1 Error: Old field type: java.lang.Long is not compatible with the new type: float for field: key";
3166:                }
3167:
3168:                @Override
3169:                void checkUnevolvedModel(EntityModel model, Environment env) {
3170:                    checkEntity(true, model, env, NAME, 0, null);
3171:                    checkVersions(model, NAME, 0);
3172:                }
3173:
3174:                @Override
3175:                void readRawObjects(RawStore store, boolean expectEvolved,
3176:                        boolean expectUpdated) throws DatabaseException {
3177:
3178:                    if (expectEvolved) {
3179:                        TestCase.fail();
3180:                    }
3181:                    RawObject obj = readRaw(store, (long) 99, NAME, 0, CASECLS,
3182:                            0);
3183:                    checkRawFields(obj, "key", (long) 99);
3184:                }
3185:            }
3186:
3187:            @Entity(version=1)
3188:            static class DisallowPriKeyField_Float2double2 extends EvolveCase {
3189:
3190:                private static final String NAME = DisallowPriKeyField_Float2double2.class
3191:                        .getName();
3192:
3193:                @PrimaryKey
3194:                double key;
3195:
3196:                @Override
3197:                public String getStoreOpenException() {
3198:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Float2double2 version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Float2double2 version: 1 Error: Old field type: java.lang.Float is not compatible with the new type: double for field: key";
3199:                }
3200:
3201:                @Override
3202:                void checkUnevolvedModel(EntityModel model, Environment env) {
3203:                    checkEntity(true, model, env, NAME, 0, null);
3204:                    checkVersions(model, NAME, 0);
3205:                }
3206:
3207:                @Override
3208:                void readRawObjects(RawStore store, boolean expectEvolved,
3209:                        boolean expectUpdated) throws DatabaseException {
3210:
3211:                    if (expectEvolved) {
3212:                        TestCase.fail();
3213:                    }
3214:                    RawObject obj = readRaw(store, (float) 99, NAME, 0,
3215:                            CASECLS, 0);
3216:                    checkRawFields(obj, "key", (float) 99);
3217:                }
3218:            }
3219:
3220:            @Entity(version=1)
3221:            static class DisallowPriKeyField_Long2BigInt extends EvolveCase {
3222:
3223:                private static final String NAME = DisallowPriKeyField_Long2BigInt.class
3224:                        .getName();
3225:
3226:                @PrimaryKey
3227:                BigInteger key;
3228:
3229:                @Override
3230:                public String getStoreOpenException() {
3231:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Long2BigInt version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowPriKeyField_Long2BigInt version: 1 Error: Old field type: java.lang.Long is not compatible with the new type: java.math.BigInteger for field: key";
3232:                }
3233:
3234:                @Override
3235:                void checkUnevolvedModel(EntityModel model, Environment env) {
3236:                    checkEntity(true, model, env, NAME, 0, null);
3237:                    checkVersions(model, NAME, 0);
3238:                }
3239:
3240:                @Override
3241:                void readRawObjects(RawStore store, boolean expectEvolved,
3242:                        boolean expectUpdated) throws DatabaseException {
3243:
3244:                    if (expectEvolved) {
3245:                        TestCase.fail();
3246:                    }
3247:                    RawObject obj = readRaw(store, 99L, NAME, 0, CASECLS, 0);
3248:                    checkRawFields(obj, "key", 99L);
3249:                }
3250:            }
3251:
3252:            @Persistent(version=1)
3253:            static class DisallowCompositeKeyField_byte2short_Key {
3254:
3255:                @KeyField(1)
3256:                int f1 = 1;
3257:
3258:                @KeyField(2)
3259:                short f2 = 2;
3260:
3261:                @KeyField(3)
3262:                String f3 = "3";
3263:            }
3264:
3265:            @Entity
3266:            static class DisallowCompositeKeyField_byte2short extends
3267:                    EvolveCase {
3268:
3269:                private static final String NAME = DisallowCompositeKeyField_byte2short.class
3270:                        .getName();
3271:                private static final String NAME2 = DisallowCompositeKeyField_byte2short_Key.class
3272:                        .getName();
3273:
3274:                @PrimaryKey
3275:                DisallowCompositeKeyField_byte2short_Key key;
3276:
3277:                @Override
3278:                public String getStoreOpenException() {
3279:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Type may not be changed for a primary key field or composite key class field when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowCompositeKeyField_byte2short_Key version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowCompositeKeyField_byte2short_Key version: 1 Error: Old field type: byte is not compatible with the new type: short for field: f2";
3280:                }
3281:
3282:                @Override
3283:                void checkUnevolvedModel(EntityModel model, Environment env) {
3284:                    checkEntity(true, model, env, NAME, 0, null);
3285:                    checkNonEntity(true, model, env, NAME2, 0);
3286:                    checkVersions(model, NAME, 0);
3287:                    checkVersions(model, NAME2, 0);
3288:                }
3289:
3290:                @Override
3291:                void readRawObjects(RawStore store, boolean expectEvolved,
3292:                        boolean expectUpdated) throws DatabaseException {
3293:
3294:                    if (expectEvolved) {
3295:                        TestCase.fail();
3296:                    }
3297:                    RawType rawKeyType = store.getModel().getRawType(NAME2);
3298:                    RawObject rawKey = new RawObject(rawKeyType, makeValues(
3299:                            "f1", (int) 1, "f2", (byte) 2, "f3", "3"), null);
3300:
3301:                    RawObject obj = readRaw(store, rawKey, NAME, 0, CASECLS, 0);
3302:                    checkRawFields(obj, "key", rawKey);
3303:                }
3304:            }
3305:
3306:            @Entity(version=1)
3307:            static class AllowPriKeyField_byte2Byte extends EvolveCase {
3308:
3309:                private static final String NAME = AllowPriKeyField_byte2Byte.class
3310:                        .getName();
3311:
3312:                @PrimaryKey
3313:                Byte key = 99;
3314:
3315:                @Override
3316:                void checkEvolvedModel(EntityModel model, Environment env,
3317:                        boolean oldTypesExist) {
3318:                    checkEntity(true, model, env, NAME, 1, null);
3319:                    if (oldTypesExist) {
3320:                        checkVersions(model, NAME, 1, NAME, 0);
3321:                    } else {
3322:                        checkVersions(model, NAME, 1);
3323:                    }
3324:                }
3325:
3326:                @Override
3327:                void readObjects(EntityStore store, boolean doUpdate)
3328:                        throws DatabaseException {
3329:
3330:                    PrimaryIndex<Byte, AllowPriKeyField_byte2Byte> index = store
3331:                            .getPrimaryIndex(Byte.class,
3332:                                    AllowPriKeyField_byte2Byte.class);
3333:                    AllowPriKeyField_byte2Byte obj = index.get(key);
3334:                    TestCase.assertNotNull(obj);
3335:                    TestCase.assertEquals(Byte.valueOf((byte) 99), obj.key);
3336:
3337:                    if (doUpdate) {
3338:                        index.put(obj);
3339:                    }
3340:                }
3341:
3342:                @Override
3343:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
3344:                        throws DatabaseException {
3345:
3346:                    PrimaryIndex<Byte, AllowPriKeyField_byte2Byte> index = newStore
3347:                            .getPrimaryIndex(Byte.class,
3348:                                    AllowPriKeyField_byte2Byte.class);
3349:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(
3350:                            (byte) 99);
3351:                    index.put((AllowPriKeyField_byte2Byte) newStore.getModel()
3352:                            .convertRawObject(raw));
3353:                }
3354:
3355:                @Override
3356:                void readRawObjects(RawStore store, boolean expectEvolved,
3357:                        boolean expectUpdated) throws DatabaseException {
3358:
3359:                    RawObject obj;
3360:                    if (expectEvolved) {
3361:                        obj = readRaw(store, (byte) 99, NAME, 1, CASECLS, 0);
3362:                    } else {
3363:                        obj = readRaw(store, (byte) 99, NAME, 0, CASECLS, 0);
3364:                    }
3365:                    checkRawFields(obj, "key", (byte) 99);
3366:                }
3367:            }
3368:
3369:            @Entity(version=1)
3370:            static class AllowPriKeyField_Byte2byte2 extends EvolveCase {
3371:
3372:                private static final String NAME = AllowPriKeyField_Byte2byte2.class
3373:                        .getName();
3374:
3375:                @PrimaryKey
3376:                byte key = 99;
3377:
3378:                @Override
3379:                void checkEvolvedModel(EntityModel model, Environment env,
3380:                        boolean oldTypesExist) {
3381:                    checkEntity(true, model, env, NAME, 1, null);
3382:                    if (oldTypesExist) {
3383:                        checkVersions(model, NAME, 1, NAME, 0);
3384:                    } else {
3385:                        checkVersions(model, NAME, 1);
3386:                    }
3387:                }
3388:
3389:                @Override
3390:                void readObjects(EntityStore store, boolean doUpdate)
3391:                        throws DatabaseException {
3392:
3393:                    PrimaryIndex<Byte, AllowPriKeyField_Byte2byte2> index = store
3394:                            .getPrimaryIndex(Byte.class,
3395:                                    AllowPriKeyField_Byte2byte2.class);
3396:                    AllowPriKeyField_Byte2byte2 obj = index.get(key);
3397:                    TestCase.assertNotNull(obj);
3398:                    TestCase.assertEquals((byte) 99, obj.key);
3399:
3400:                    if (doUpdate) {
3401:                        index.put(obj);
3402:                    }
3403:                }
3404:
3405:                @Override
3406:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
3407:                        throws DatabaseException {
3408:
3409:                    PrimaryIndex<Byte, AllowPriKeyField_Byte2byte2> index = newStore
3410:                            .getPrimaryIndex(Byte.class,
3411:                                    AllowPriKeyField_Byte2byte2.class);
3412:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(
3413:                            (byte) 99);
3414:                    index.put((AllowPriKeyField_Byte2byte2) newStore.getModel()
3415:                            .convertRawObject(raw));
3416:                }
3417:
3418:                @Override
3419:                void readRawObjects(RawStore store, boolean expectEvolved,
3420:                        boolean expectUpdated) throws DatabaseException {
3421:
3422:                    RawObject obj;
3423:                    if (expectEvolved) {
3424:                        obj = readRaw(store, (byte) 99, NAME, 1, CASECLS, 0);
3425:                    } else {
3426:                        obj = readRaw(store, (byte) 99, NAME, 0, CASECLS, 0);
3427:                    }
3428:                    checkRawFields(obj, "key", (byte) 99);
3429:                }
3430:            }
3431:
3432:            @Persistent(version=1)
3433:            static class AllowFieldTypeChanges_Key {
3434:
3435:                AllowFieldTypeChanges_Key() {
3436:                    this (false);
3437:                }
3438:
3439:                AllowFieldTypeChanges_Key(boolean init) {
3440:                    if (init) {
3441:                        f1 = true;
3442:                        f2 = (byte) 2;
3443:                        f3 = (short) 3;
3444:                        f4 = 4;
3445:                        f5 = 5L;
3446:                        f6 = 6F;
3447:                        f7 = 7D;
3448:                        f8 = (char) 8;
3449:                        f9 = true;
3450:                        f10 = (byte) 10;
3451:                        f11 = (short) 11;
3452:                        f12 = 12;
3453:                        f13 = 13L;
3454:                        f14 = 14F;
3455:                        f15 = 15D;
3456:                        f16 = (char) 16;
3457:                    }
3458:                }
3459:
3460:                @KeyField(1)
3461:                boolean f1;
3462:
3463:                @KeyField(2)
3464:                byte f2;
3465:
3466:                @KeyField(3)
3467:                short f3;
3468:
3469:                @KeyField(4)
3470:                int f4;
3471:
3472:                @KeyField(5)
3473:                long f5;
3474:
3475:                @KeyField(6)
3476:                float f6;
3477:
3478:                @KeyField(7)
3479:                double f7;
3480:
3481:                @KeyField(8)
3482:                char f8;
3483:
3484:                @KeyField(9)
3485:                Boolean f9;
3486:
3487:                @KeyField(10)
3488:                Byte f10;
3489:
3490:                @KeyField(11)
3491:                Short f11;
3492:
3493:                @KeyField(12)
3494:                Integer f12;
3495:
3496:                @KeyField(13)
3497:                Long f13;
3498:
3499:                @KeyField(14)
3500:                Float f14;
3501:
3502:                @KeyField(15)
3503:                Double f15;
3504:
3505:                @KeyField(16)
3506:                Character f16;
3507:            }
3508:
3509:            @Persistent(version=1)
3510:            static class AllowFieldTypeChanges_Base extends EvolveCase {
3511:
3512:                @SecondaryKey(relate=ONE_TO_ONE)
3513:                AllowFieldTypeChanges_Key kComposite;
3514:
3515:                Integer f_long2Integer;
3516:                Long f_String2Long;
3517:            }
3518:
3519:            /**
3520:             * Allow field type changes: automatic widening, supported widening,
3521:             * and Converter mutations.  Also tests primary and secondary key field
3522:             * renaming.
3523:             */
3524:            @Entity(version=1)
3525:            static class AllowFieldTypeChanges extends
3526:                    AllowFieldTypeChanges_Base {
3527:
3528:                private static final String NAME = AllowFieldTypeChanges.class
3529:                        .getName();
3530:                private static final String NAME2 = AllowFieldTypeChanges_Base.class
3531:                        .getName();
3532:                private static final String NAME3 = AllowFieldTypeChanges_Key.class
3533:                        .getName();
3534:
3535:                @PrimaryKey
3536:                Integer pkeyInteger;
3537:
3538:                @SecondaryKey(relate=ONE_TO_ONE)
3539:                Boolean kBoolean;
3540:
3541:                @SecondaryKey(relate=ONE_TO_ONE)
3542:                Byte kByte;
3543:
3544:                @SecondaryKey(relate=ONE_TO_ONE)
3545:                Short kShort;
3546:
3547:                @SecondaryKey(relate=ONE_TO_ONE)
3548:                Integer kInteger;
3549:
3550:                @SecondaryKey(relate=ONE_TO_ONE)
3551:                Long kLong;
3552:
3553:                @SecondaryKey(relate=ONE_TO_ONE)
3554:                Float kFloat;
3555:
3556:                @SecondaryKey(relate=ONE_TO_ONE)
3557:                Double kDouble;
3558:
3559:                @SecondaryKey(relate=ONE_TO_ONE)
3560:                Character kCharacter;
3561:
3562:                short f01;
3563:                int f02;
3564:                long f03;
3565:                float f04;
3566:                double f06;
3567:                int f07;
3568:                long f08;
3569:                float f09;
3570:                double f10;
3571:                int f11;
3572:                long f12;
3573:                float f13;
3574:                double f14;
3575:                long f15;
3576:                float f16;
3577:                double f17;
3578:                float f18;
3579:                double f19;
3580:                double f20;
3581:
3582:                Short f21;
3583:                Integer f22;
3584:                Long f23;
3585:                Float f24;
3586:                Double f26;
3587:                Integer f27;
3588:                Long f28;
3589:                Float f29;
3590:                Double f30;
3591:                Integer f31;
3592:                Long f32;
3593:                Float f33;
3594:                Double f34;
3595:                Long f35;
3596:                Float f36;
3597:                Double f37;
3598:                Float f38;
3599:                Double f39;
3600:                Double f40;
3601:
3602:                Short f41;
3603:                Integer f42;
3604:                Long f43;
3605:                Float f44;
3606:                Double f46;
3607:                Integer f47;
3608:                Long f48;
3609:                Float f49;
3610:                Double f50;
3611:                Integer f51;
3612:                Long f52;
3613:                Float f53;
3614:                Double f54;
3615:                Long f55;
3616:                Float f56;
3617:                Double f57;
3618:                Float f58;
3619:                Double f59;
3620:                Double f60;
3621:
3622:                BigInteger f70;
3623:                BigInteger f71;
3624:                BigInteger f72;
3625:                BigInteger f73;
3626:                BigInteger f74;
3627:                BigInteger f75;
3628:                BigInteger f76;
3629:                BigInteger f77;
3630:                BigInteger f78;
3631:                BigInteger f79;
3632:
3633:                int f_long2int;
3634:                long f_String2long;
3635:
3636:                @Override
3637:                Mutations getMutations() {
3638:                    Mutations m = new Mutations();
3639:                    m
3640:                            .addRenamer(new Renamer(NAME, 0, "pkeyint",
3641:                                    "pkeyInteger"));
3642:                    m.addRenamer(new Renamer(NAME, 0, "kboolean", "kBoolean"));
3643:                    m.addRenamer(new Renamer(NAME, 0, "kbyte", "kByte"));
3644:                    m.addRenamer(new Renamer(NAME, 0, "kshort", "kShort"));
3645:                    m.addRenamer(new Renamer(NAME, 0, "kint", "kInteger"));
3646:                    m.addRenamer(new Renamer(NAME, 0, "klong", "kLong"));
3647:                    m.addRenamer(new Renamer(NAME, 0, "kfloat", "kFloat"));
3648:                    m.addRenamer(new Renamer(NAME, 0, "kdouble", "kDouble"));
3649:                    m.addRenamer(new Renamer(NAME, 0, "kchar", "kCharacter"));
3650:                    m.addRenamer(new Renamer(NAME2, 0, "kcomposite",
3651:                            "kComposite"));
3652:
3653:                    Conversion conv1 = new MyConversion1();
3654:                    Conversion conv2 = new MyConversion2();
3655:
3656:                    m.addConverter(new Converter(NAME, 0, "f_long2int", conv1));
3657:                    m.addConverter(new Converter(NAME, 0, "f_String2long",
3658:                            conv2));
3659:                    m.addConverter(new Converter(NAME2, 0, "f_long2Integer",
3660:                            conv1));
3661:                    m.addConverter(new Converter(NAME2, 0, "f_String2Long",
3662:                            conv2));
3663:                    return m;
3664:                }
3665:
3666:                static class MyConversion1 implements  Conversion {
3667:
3668:                    public void initialize(EntityModel model) {
3669:                    }
3670:
3671:                    public Object convert(Object o) {
3672:                        return ((Long) o).intValue();
3673:                    }
3674:
3675:                    @Override
3676:                    public boolean equals(Object other) {
3677:                        return true;
3678:                    }
3679:                }
3680:
3681:                static class MyConversion2 implements  Conversion {
3682:
3683:                    public void initialize(EntityModel model) {
3684:                    }
3685:
3686:                    public Object convert(Object o) {
3687:                        return Long.valueOf((String) o);
3688:                    }
3689:
3690:                    @Override
3691:                    public boolean equals(Object other) {
3692:                        return true;
3693:                    }
3694:                }
3695:
3696:                @Override
3697:                void checkEvolvedModel(EntityModel model, Environment env,
3698:                        boolean oldTypesExist) {
3699:                    checkEntity(true, model, env, NAME, 1, null);
3700:                    checkNonEntity(true, model, env, NAME2, 1);
3701:                    if (oldTypesExist) {
3702:                        checkVersions(model, NAME, 1, NAME, 0);
3703:                        checkVersions(model, NAME2, 1, NAME2, 0);
3704:                        checkVersions(model, NAME3, 1, NAME3, 0);
3705:                    } else {
3706:                        checkVersions(model, NAME, 1);
3707:                        checkVersions(model, NAME2, 1);
3708:                        checkVersions(model, NAME3, 1);
3709:                    }
3710:                }
3711:
3712:                @Override
3713:                void readObjects(EntityStore store, boolean doUpdate)
3714:                        throws DatabaseException {
3715:
3716:                    PrimaryIndex<Integer, AllowFieldTypeChanges> index = store
3717:                            .getPrimaryIndex(Integer.class,
3718:                                    AllowFieldTypeChanges.class);
3719:                    AllowFieldTypeChanges obj = index.get((int) 99);
3720:                    checkValues(obj);
3721:                    checkSecondaries(store, index);
3722:
3723:                    if (doUpdate) {
3724:                        index.put(obj);
3725:                        checkSecondaries(store, index);
3726:                    }
3727:                }
3728:
3729:                @Override
3730:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
3731:                        throws DatabaseException {
3732:
3733:                    PrimaryIndex<Integer, AllowFieldTypeChanges> index = newStore
3734:                            .getPrimaryIndex(Integer.class,
3735:                                    AllowFieldTypeChanges.class);
3736:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
3737:                    index.put((AllowFieldTypeChanges) newStore.getModel()
3738:                            .convertRawObject(raw));
3739:                }
3740:
3741:                private void checkSecondaries(EntityStore store,
3742:                        PrimaryIndex<Integer, AllowFieldTypeChanges> index)
3743:                        throws DatabaseException {
3744:
3745:                    checkValues(store.getSecondaryIndex(index, Boolean.class,
3746:                            "kBoolean").get(true));
3747:                    checkValues(store.getSecondaryIndex(index, Byte.class,
3748:                            "kByte").get((byte) 77));
3749:                    checkValues(store.getSecondaryIndex(index, Short.class,
3750:                            "kShort").get((short) 66));
3751:                    checkValues(store.getSecondaryIndex(index, Integer.class,
3752:                            "kInteger").get((int) 55));
3753:                    checkValues(store.getSecondaryIndex(index, Long.class,
3754:                            "kLong").get((long) 44));
3755:                    checkValues(store.getSecondaryIndex(index, Float.class,
3756:                            "kFloat").get((float) 33));
3757:                    checkValues(store.getSecondaryIndex(index, Double.class,
3758:                            "kDouble").get((double) 22));
3759:                    checkValues(store.getSecondaryIndex(index, Character.class,
3760:                            "kCharacter").get((char) 11));
3761:                    checkValues(store.getSecondaryIndex(index,
3762:                            AllowFieldTypeChanges_Key.class, "kComposite").get(
3763:                            new AllowFieldTypeChanges_Key(true)));
3764:                }
3765:
3766:                private void checkValues(AllowFieldTypeChanges obj) {
3767:                    TestCase.assertNotNull(obj);
3768:                    TestCase.assertEquals(obj.pkeyInteger, Integer.valueOf(99));
3769:                    TestCase.assertEquals(obj.kBoolean, Boolean.valueOf(true));
3770:                    TestCase.assertEquals(obj.kByte, Byte.valueOf((byte) 77));
3771:                    TestCase
3772:                            .assertEquals(obj.kShort, Short.valueOf((short) 66));
3773:                    TestCase.assertEquals(obj.kInteger, Integer.valueOf(55));
3774:                    TestCase.assertEquals(obj.kLong, Long.valueOf(44));
3775:                    TestCase.assertEquals(obj.kFloat, Float.valueOf(33));
3776:                    TestCase.assertEquals(obj.kDouble, Double.valueOf(22));
3777:                    TestCase.assertEquals(obj.kCharacter, Character
3778:                            .valueOf((char) 11));
3779:
3780:                    AllowFieldTypeChanges_Key embed = obj.kComposite;
3781:                    TestCase.assertNotNull(embed);
3782:                    TestCase.assertEquals(embed.f1, true);
3783:                    TestCase.assertEquals(embed.f2, (byte) 2);
3784:                    TestCase.assertEquals(embed.f3, (short) 3);
3785:                    TestCase.assertEquals(embed.f4, 4);
3786:                    TestCase.assertEquals(embed.f5, 5L);
3787:                    TestCase.assertEquals(embed.f6, 6F);
3788:                    TestCase.assertEquals(embed.f7, 7D);
3789:                    TestCase.assertEquals(embed.f8, (char) 8);
3790:                    TestCase.assertEquals(embed.f9, Boolean.valueOf(true));
3791:                    TestCase.assertEquals(embed.f10, Byte.valueOf((byte) 10));
3792:                    TestCase.assertEquals(embed.f11, Short.valueOf((short) 11));
3793:                    TestCase.assertEquals(embed.f12, Integer.valueOf(12));
3794:                    TestCase.assertEquals(embed.f13, Long.valueOf(13L));
3795:                    TestCase.assertEquals(embed.f14, Float.valueOf(14F));
3796:                    TestCase.assertEquals(embed.f15, Double.valueOf(15D));
3797:                    TestCase.assertEquals(embed.f16, Character
3798:                            .valueOf((char) 16));
3799:
3800:                    TestCase.assertEquals(obj.f01, (short) 1);
3801:                    TestCase.assertEquals(obj.f02, (int) 2);
3802:                    TestCase.assertEquals(obj.f03, (long) 3);
3803:                    TestCase.assertEquals(obj.f04, (float) 4);
3804:                    TestCase.assertEquals(obj.f06, (double) 6);
3805:                    TestCase.assertEquals(obj.f07, (int) 7);
3806:                    TestCase.assertEquals(obj.f08, (long) 8);
3807:                    TestCase.assertEquals(obj.f09, (float) 9);
3808:                    TestCase.assertEquals(obj.f10, (double) 10);
3809:                    TestCase.assertEquals(obj.f11, (int) 11);
3810:                    TestCase.assertEquals(obj.f12, (long) 12);
3811:                    TestCase.assertEquals(obj.f13, (float) 13);
3812:                    TestCase.assertEquals(obj.f14, (double) 14);
3813:                    TestCase.assertEquals(obj.f15, 15L);
3814:                    TestCase.assertEquals(obj.f16, 16F);
3815:                    TestCase.assertEquals(obj.f17, 17D);
3816:                    TestCase.assertEquals(obj.f18, (float) 18);
3817:                    TestCase.assertEquals(obj.f19, (double) 19);
3818:                    TestCase.assertEquals(obj.f20, (double) 20);
3819:
3820:                    TestCase.assertEquals(obj.f21, Short.valueOf((byte) 21));
3821:                    TestCase.assertEquals(obj.f22, Integer.valueOf((byte) 22));
3822:                    TestCase.assertEquals(obj.f23, Long.valueOf((byte) 23));
3823:                    TestCase.assertEquals(obj.f24, Float.valueOf((byte) 24));
3824:                    TestCase.assertEquals(obj.f26, Double.valueOf((byte) 26));
3825:                    TestCase.assertEquals(obj.f27, Integer.valueOf((short) 27));
3826:                    TestCase.assertEquals(obj.f28, Long.valueOf((short) 28));
3827:                    TestCase.assertEquals(obj.f29, Float.valueOf((short) 29));
3828:                    TestCase.assertEquals(obj.f30, Double.valueOf((short) 30));
3829:                    TestCase.assertEquals(obj.f31, Integer.valueOf((char) 31));
3830:                    TestCase.assertEquals(obj.f32, Long.valueOf((char) 32));
3831:                    TestCase.assertEquals(obj.f33, Float.valueOf((char) 33));
3832:                    TestCase.assertEquals(obj.f34, Double.valueOf((char) 34));
3833:                    TestCase.assertEquals(obj.f35, Long.valueOf(35));
3834:                    TestCase.assertEquals(obj.f36, Float.valueOf(36));
3835:                    TestCase.assertEquals(obj.f37, Double.valueOf(37));
3836:                    TestCase.assertEquals(obj.f38, Float.valueOf((long) 38));
3837:                    TestCase.assertEquals(obj.f39, Double.valueOf((long) 39));
3838:                    TestCase.assertEquals(obj.f40, Double.valueOf((float) 40));
3839:
3840:                    TestCase.assertEquals(obj.f41, Short.valueOf((byte) 41));
3841:                    TestCase.assertEquals(obj.f42, Integer.valueOf((byte) 42));
3842:                    TestCase.assertEquals(obj.f43, Long.valueOf((byte) 43));
3843:                    TestCase.assertEquals(obj.f44, Float.valueOf((byte) 44));
3844:                    TestCase.assertEquals(obj.f46, Double.valueOf((byte) 46));
3845:                    TestCase.assertEquals(obj.f47, Integer.valueOf((short) 47));
3846:                    TestCase.assertEquals(obj.f48, Long.valueOf((short) 48));
3847:                    TestCase.assertEquals(obj.f49, Float.valueOf((short) 49));
3848:                    TestCase.assertEquals(obj.f50, Double.valueOf((short) 50));
3849:                    TestCase.assertEquals(obj.f51, Integer.valueOf((char) 51));
3850:                    TestCase.assertEquals(obj.f52, Long.valueOf((char) 52));
3851:                    TestCase.assertEquals(obj.f53, Float.valueOf((char) 53));
3852:                    TestCase.assertEquals(obj.f54, Double.valueOf((char) 54));
3853:                    TestCase.assertEquals(obj.f55, Long.valueOf(55));
3854:                    TestCase.assertEquals(obj.f56, Float.valueOf(56));
3855:                    TestCase.assertEquals(obj.f57, Double.valueOf(57));
3856:                    TestCase.assertEquals(obj.f58, Float.valueOf((long) 58));
3857:                    TestCase.assertEquals(obj.f59, Double.valueOf((long) 59));
3858:                    TestCase.assertEquals(obj.f60, Double.valueOf((float) 60));
3859:
3860:                    TestCase.assertEquals(obj.f70, BigInteger.valueOf(70));
3861:                    TestCase.assertEquals(obj.f71, BigInteger.valueOf(71));
3862:                    TestCase.assertEquals(obj.f72, BigInteger.valueOf(72));
3863:                    TestCase.assertEquals(obj.f73, BigInteger.valueOf(73));
3864:                    TestCase.assertEquals(obj.f74, BigInteger.valueOf(74));
3865:                    TestCase.assertEquals(obj.f75, BigInteger.valueOf(75));
3866:                    TestCase.assertEquals(obj.f76, BigInteger.valueOf(76));
3867:                    TestCase.assertEquals(obj.f77, BigInteger.valueOf(77));
3868:                    TestCase.assertEquals(obj.f78, BigInteger.valueOf(78));
3869:                    TestCase.assertEquals(obj.f79, BigInteger.valueOf(79));
3870:
3871:                    TestCase.assertEquals(obj.f_long2Integer, Integer
3872:                            .valueOf(111));
3873:                    TestCase.assertEquals(obj.f_String2Long, Long.valueOf(222));
3874:                    TestCase.assertEquals(obj.f_long2int, 333);
3875:                    TestCase.assertEquals(obj.f_String2long, 444L);
3876:                }
3877:
3878:                @Override
3879:                void readRawObjects(RawStore store, boolean expectEvolved,
3880:                        boolean expectUpdated) throws DatabaseException {
3881:
3882:                    RawType embedType = store.getModel().getRawType(NAME3);
3883:                    RawObject embed = new RawObject(embedType, makeValues("f1",
3884:                            true, "f2", (byte) 2, "f3", (short) 3, "f4", 4,
3885:                            "f5", 5L, "f6", 6F, "f7", 7D, "f8", (char) 8, "f9",
3886:                            true, "f10", (byte) 10, "f11", (short) 11, "f12",
3887:                            12, "f13", 13L, "f14", 14F, "f15", 15D, "f16",
3888:                            (char) 16), null);
3889:
3890:                    RawObject obj;
3891:                    if (expectEvolved) {
3892:                        obj = readRaw(store, 99, NAME, 1, NAME2, 1, CASECLS, 0);
3893:                        checkRawFields(obj, "pkeyInteger", (int) 99,
3894:                                "kBoolean", true, "kByte", (byte) 77, "kShort",
3895:                                (short) 66, "kInteger", (int) 55, "kLong",
3896:                                (long) 44, "kFloat", (float) 33, "kDouble",
3897:                                (double) 22, "kCharacter", (char) 11,
3898:
3899:                                "f01", (short) 1, "f02", (int) 2, "f03",
3900:                                (long) 3, "f04", (float) 4, "f06", (double) 6,
3901:                                "f07", (int) 7, "f08", (long) 8, "f09",
3902:                                (float) 9, "f10", (double) 10, "f11", (int) 11,
3903:                                "f12", (long) 12, "f13", (float) 13, "f14",
3904:                                (double) 14, "f15", 15L, "f16", 16F, "f17",
3905:                                17D, "f18", (float) 18, "f19", (double) 19,
3906:                                "f20", (double) 20,
3907:
3908:                                "f21", (short) 21, "f22", (int) 22, "f23",
3909:                                (long) 23, "f24", (float) 24, "f26",
3910:                                (double) 26, "f27", (int) 27, "f28", (long) 28,
3911:                                "f29", (float) 29, "f30", (double) 30, "f31",
3912:                                (int) 31, "f32", (long) 32, "f33", (float) 33,
3913:                                "f34", (double) 34, "f35", 35L, "f36", 36F,
3914:                                "f37", 37D, "f38", (float) 38, "f39",
3915:                                (double) 39, "f40", (double) 40,
3916:
3917:                                "f41", (short) 41, "f42", (int) 42, "f43",
3918:                                (long) 43, "f44", (float) 44, "f46",
3919:                                (double) 46, "f47", (int) 47, "f48", (long) 48,
3920:                                "f49", (float) 49, "f50", (double) 50, "f51",
3921:                                (int) 51, "f52", (long) 52, "f53", (float) 53,
3922:                                "f54", (double) 54, "f55", 55L, "f56", 56F,
3923:                                "f57", 57D, "f58", (float) 58, "f59",
3924:                                (double) 59, "f60", (double) 60,
3925:
3926:                                "f70", BigInteger.valueOf(70), "f71",
3927:                                BigInteger.valueOf(71), "f72", BigInteger
3928:                                        .valueOf(72), "f73", BigInteger
3929:                                        .valueOf(73), "f74", BigInteger
3930:                                        .valueOf(74), "f75", BigInteger
3931:                                        .valueOf(75), "f76", BigInteger
3932:                                        .valueOf(76), "f77", BigInteger
3933:                                        .valueOf(77), "f78", BigInteger
3934:                                        .valueOf(78), "f79", BigInteger
3935:                                        .valueOf(79),
3936:
3937:                                "f_long2int", 333, "f_String2long", 444L);
3938:                        checkRawFields(obj.getSuper(), "kComposite", embed,
3939:                                "f_long2Integer", 111, "f_String2Long", 222L);
3940:                    } else {
3941:                        obj = readRaw(store, 99, NAME, 0, NAME2, 0, CASECLS, 0);
3942:                        checkRawFields(obj, "pkeyint", (int) 99, "kboolean",
3943:                                true, "kbyte", (byte) 77, "kshort", (short) 66,
3944:                                "kint", (int) 55, "klong", (long) 44, "kfloat",
3945:                                (float) 33, "kdouble", (double) 22, "kchar",
3946:                                (char) 11,
3947:
3948:                                "f01", (byte) 1, "f02", (byte) 2, "f03",
3949:                                (byte) 3, "f04", (byte) 4, "f06", (byte) 6,
3950:                                "f07", (short) 7, "f08", (short) 8, "f09",
3951:                                (short) 9, "f10", (short) 10, "f11", (char) 11,
3952:                                "f12", (char) 12, "f13", (char) 13, "f14",
3953:                                (char) 14, "f15", 15, "f16", 16, "f17", 17,
3954:                                "f18", (long) 18, "f19", (long) 19, "f20",
3955:                                (float) 20,
3956:
3957:                                "f21", (byte) 21, "f22", (byte) 22, "f23",
3958:                                (byte) 23, "f24", (byte) 24, "f26", (byte) 26,
3959:                                "f27", (short) 27, "f28", (short) 28, "f29",
3960:                                (short) 29, "f30", (short) 30, "f31",
3961:                                (char) 31, "f32", (char) 32, "f33", (char) 33,
3962:                                "f34", (char) 34, "f35", 35, "f36", 36, "f37",
3963:                                37, "f38", (long) 38, "f39", (long) 39, "f40",
3964:                                (float) 40,
3965:
3966:                                "f41", (byte) 41, "f42", (byte) 42, "f43",
3967:                                (byte) 43, "f44", (byte) 44, "f46", (byte) 46,
3968:                                "f47", (short) 47, "f48", (short) 48, "f49",
3969:                                (short) 49, "f50", (short) 50, "f51",
3970:                                (char) 51, "f52", (char) 52, "f53", (char) 53,
3971:                                "f54", (char) 54, "f55", 55, "f56", 56, "f57",
3972:                                57, "f58", (long) 58, "f59", (long) 59, "f60",
3973:                                (float) 60,
3974:
3975:                                "f70", (byte) 70, "f71", (short) 71, "f72",
3976:                                (char) 72, "f73", 73, "f74", (long) 74, "f75",
3977:                                (byte) 75, "f76", (short) 76, "f77", (char) 77,
3978:                                "f78", 78, "f79", (long) 79,
3979:
3980:                                "f_long2int", 333L, "f_String2long", "444");
3981:
3982:                        checkRawFields(obj.getSuper(), "kcomposite", embed,
3983:                                "f_long2Integer", 111L, "f_String2Long", "222");
3984:                    }
3985:                    Environment env = store.getEnvironment();
3986:
3987:                    assertDbExists(expectEvolved, env, NAME, "kBoolean");
3988:                    assertDbExists(expectEvolved, env, NAME, "kByte");
3989:                    assertDbExists(expectEvolved, env, NAME, "kShort");
3990:                    assertDbExists(expectEvolved, env, NAME, "kInteger");
3991:                    assertDbExists(expectEvolved, env, NAME, "kLong");
3992:                    assertDbExists(expectEvolved, env, NAME, "kFloat");
3993:                    assertDbExists(expectEvolved, env, NAME, "kDouble");
3994:                    assertDbExists(expectEvolved, env, NAME, "kCharacter");
3995:                    assertDbExists(expectEvolved, env, NAME, "kComposite");
3996:
3997:                    assertDbExists(!expectEvolved, env, NAME, "kboolean");
3998:                    assertDbExists(!expectEvolved, env, NAME, "kbyte");
3999:                    assertDbExists(!expectEvolved, env, NAME, "kshort");
4000:                    assertDbExists(!expectEvolved, env, NAME, "kint");
4001:                    assertDbExists(!expectEvolved, env, NAME, "klong");
4002:                    assertDbExists(!expectEvolved, env, NAME, "kfloat");
4003:                    assertDbExists(!expectEvolved, env, NAME, "kdouble");
4004:                    assertDbExists(!expectEvolved, env, NAME, "kchar");
4005:                    assertDbExists(!expectEvolved, env, NAME, "kcomposite");
4006:                }
4007:            }
4008:
4009:            @Persistent(version=1)
4010:            static class ConvertExample1_Address {
4011:                String street;
4012:                String city;
4013:                String state;
4014:                int zipCode;
4015:            }
4016:
4017:            static class ConvertExample1_Conversion implements  Conversion {
4018:
4019:                public void initialize(EntityModel model) {
4020:                }
4021:
4022:                public Object convert(Object fromValue) {
4023:                    return Integer.valueOf((String) fromValue);
4024:                }
4025:
4026:                @Override
4027:                public boolean equals(Object o) {
4028:                    return o instanceof  ConvertExample1_Conversion;
4029:                }
4030:            }
4031:
4032:            @Entity
4033:            static class ConvertExample1_Entity extends EvolveCase {
4034:
4035:                private static final String NAME = ConvertExample1_Entity.class
4036:                        .getName();
4037:                private static final String NAME2 = ConvertExample1_Address.class
4038:                        .getName();
4039:
4040:                @PrimaryKey
4041:                int key = 99;
4042:
4043:                ConvertExample1_Address embed;
4044:
4045:                @Override
4046:                Mutations getMutations() {
4047:                    Mutations m = new Mutations();
4048:                    Converter converter = new Converter(
4049:                            ConvertExample1_Address.class.getName(), 0,
4050:                            "zipCode", new ConvertExample1_Conversion());
4051:                    m.addConverter(converter);
4052:                    return m;
4053:                }
4054:
4055:                @Override
4056:                void checkEvolvedModel(EntityModel model, Environment env,
4057:                        boolean oldTypesExist) {
4058:                    checkEntity(true, model, env, NAME, 0, null);
4059:                    checkVersions(model, NAME, 0);
4060:                    if (oldTypesExist) {
4061:                        checkVersions(model, NAME2, 1, NAME2, 0);
4062:                    } else {
4063:                        checkVersions(model, NAME2, 1);
4064:                    }
4065:                }
4066:
4067:                @Override
4068:                void readObjects(EntityStore store, boolean doUpdate)
4069:                        throws DatabaseException {
4070:
4071:                    PrimaryIndex<Integer, ConvertExample1_Entity> index = store
4072:                            .getPrimaryIndex(Integer.class,
4073:                                    ConvertExample1_Entity.class);
4074:                    ConvertExample1_Entity obj = index.get(99);
4075:                    TestCase.assertNotNull(obj);
4076:                    TestCase.assertEquals(99, obj.key);
4077:                    TestCase.assertNotNull(obj.embed);
4078:                    TestCase.assertEquals("street", obj.embed.street);
4079:                    TestCase.assertEquals("city", obj.embed.city);
4080:                    TestCase.assertEquals("state", obj.embed.state);
4081:                    TestCase.assertEquals(12345, obj.embed.zipCode);
4082:
4083:                    if (doUpdate) {
4084:                        index.put(obj);
4085:                    }
4086:                }
4087:
4088:                @Override
4089:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
4090:                        throws DatabaseException {
4091:
4092:                    PrimaryIndex<Integer, ConvertExample1_Entity> index = newStore
4093:                            .getPrimaryIndex(Integer.class,
4094:                                    ConvertExample1_Entity.class);
4095:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4096:                    index.put((ConvertExample1_Entity) newStore.getModel()
4097:                            .convertRawObject(raw));
4098:                }
4099:
4100:                @Override
4101:                void readRawObjects(RawStore store, boolean expectEvolved,
4102:                        boolean expectUpdated) throws DatabaseException {
4103:
4104:                    RawType embedType = store.getModel().getRawType(NAME2);
4105:                    RawObject embed;
4106:                    if (expectEvolved) {
4107:                        embed = new RawObject(embedType, makeValues("street",
4108:                                "street", "city", "city", "state", "state",
4109:                                "zipCode", 12345), null);
4110:                    } else {
4111:                        embed = new RawObject(embedType, makeValues("street",
4112:                                "street", "city", "city", "state", "state",
4113:                                "zipCode", "12345"), null);
4114:                    }
4115:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
4116:                    checkRawFields(obj, "key", 99, "embed", embed);
4117:                }
4118:            }
4119:
4120:            @Persistent
4121:            static class ConvertExample2_Address {
4122:                String street;
4123:                String city;
4124:                String state;
4125:                int zipCode;
4126:            }
4127:
4128:            @Entity(version=1)
4129:            static class ConvertExample2_Person extends EvolveCase {
4130:
4131:                private static final String NAME = ConvertExample2_Person.class
4132:                        .getName();
4133:                private static final String NAME2 = ConvertExample2_Address.class
4134:                        .getName();
4135:
4136:                @PrimaryKey
4137:                int key;
4138:
4139:                ConvertExample2_Address address;
4140:
4141:                @Override
4142:                Mutations getMutations() {
4143:                    Mutations m = new Mutations();
4144:                    Converter converter = new Converter(
4145:                            ConvertExample2_Person.class.getName(), 0,
4146:                            "address", new ConvertExample2_Conversion());
4147:                    m.addConverter(converter);
4148:                    return m;
4149:                }
4150:
4151:                @Override
4152:                void checkEvolvedModel(EntityModel model, Environment env,
4153:                        boolean oldTypesExist) {
4154:                    checkEntity(true, model, env, NAME, 1, null);
4155:                    if (oldTypesExist) {
4156:                        checkVersions(model, NAME, 1, NAME, 0);
4157:                    } else {
4158:                        checkVersions(model, NAME, 1);
4159:                    }
4160:                    checkVersions(model, NAME2, 0);
4161:                }
4162:
4163:                @Override
4164:                void readObjects(EntityStore store, boolean doUpdate)
4165:                        throws DatabaseException {
4166:
4167:                    PrimaryIndex<Integer, ConvertExample2_Person> index = store
4168:                            .getPrimaryIndex(Integer.class,
4169:                                    ConvertExample2_Person.class);
4170:                    ConvertExample2_Person obj = index.get(99);
4171:                    TestCase.assertNotNull(obj);
4172:                    TestCase.assertEquals(99, obj.key);
4173:                    TestCase.assertNotNull(obj.address);
4174:                    TestCase.assertEquals("street", obj.address.street);
4175:                    TestCase.assertEquals("city", obj.address.city);
4176:                    TestCase.assertEquals("state", obj.address.state);
4177:                    TestCase.assertEquals(12345, obj.address.zipCode);
4178:
4179:                    if (doUpdate) {
4180:                        index.put(obj);
4181:                    }
4182:                }
4183:
4184:                @Override
4185:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
4186:                        throws DatabaseException {
4187:
4188:                    PrimaryIndex<Integer, ConvertExample2_Person> index = newStore
4189:                            .getPrimaryIndex(Integer.class,
4190:                                    ConvertExample2_Person.class);
4191:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4192:                    index.put((ConvertExample2_Person) newStore.getModel()
4193:                            .convertRawObject(raw));
4194:                }
4195:
4196:                @Override
4197:                void readRawObjects(RawStore store, boolean expectEvolved,
4198:                        boolean expectUpdated) throws DatabaseException {
4199:
4200:                    Object embed;
4201:                    if (expectEvolved) {
4202:                        RawType embedType = store.getModel().getRawType(NAME2);
4203:                        embed = new RawObject(embedType, makeValues("street",
4204:                                "street", "city", "city", "state", "state",
4205:                                "zipCode", 12345), null);
4206:                    } else {
4207:                        embed = "street#city#state#12345";
4208:                    }
4209:                    RawObject obj = readRaw(store, 99, NAME, expectEvolved ? 1
4210:                            : 0, CASECLS, 0);
4211:                    checkRawFields(obj, "key", 99, "address", embed);
4212:                }
4213:            }
4214:
4215:            static class ConvertExample2_Conversion implements  Conversion {
4216:                private transient RawType addressType;
4217:
4218:                public void initialize(EntityModel model) {
4219:                    addressType = model
4220:                            .getRawType(ConvertExample2_Address.class.getName());
4221:                }
4222:
4223:                public Object convert(Object fromValue) {
4224:
4225:                    String oldAddress = (String) fromValue;
4226:                    Map<String, Object> addressValues = new HashMap<String, Object>();
4227:                    addressValues.put("street", parseAddress(1, oldAddress));
4228:                    addressValues.put("city", parseAddress(2, oldAddress));
4229:                    addressValues.put("state", parseAddress(3, oldAddress));
4230:                    addressValues.put("zipCode", Integer.valueOf(parseAddress(
4231:                            4, oldAddress)));
4232:
4233:                    return new RawObject(addressType, addressValues, null);
4234:                }
4235:
4236:                @Override
4237:                public boolean equals(Object o) {
4238:                    return o instanceof  ConvertExample2_Conversion;
4239:                }
4240:
4241:                private String parseAddress(int fieldNum, String oldAddress) {
4242:                    StringTokenizer tokens = new StringTokenizer(oldAddress,
4243:                            "#");
4244:                    String field = null;
4245:                    for (int i = 0; i < fieldNum; i += 1) {
4246:                        field = tokens.nextToken();
4247:                    }
4248:                    return field;
4249:                }
4250:            }
4251:
4252:            @Persistent
4253:            static class ConvertExample3_Address {
4254:                String street;
4255:                String city;
4256:                String state;
4257:                int zipCode;
4258:            }
4259:
4260:            static class ConvertExample3_Conversion implements  Conversion {
4261:                private transient RawType newPersonType;
4262:                private transient RawType addressType;
4263:
4264:                public void initialize(EntityModel model) {
4265:                    newPersonType = model
4266:                            .getRawType(ConvertExample3_Person.class.getName());
4267:                    addressType = model
4268:                            .getRawType(ConvertExample3_Address.class.getName());
4269:                }
4270:
4271:                public Object convert(Object fromValue) {
4272:
4273:                    RawObject person = (RawObject) fromValue;
4274:                    Map<String, Object> personValues = person.getValues();
4275:                    Map<String, Object> addressValues = new HashMap<String, Object>();
4276:                    RawObject address = new RawObject(addressType,
4277:                            addressValues, null);
4278:
4279:                    addressValues.put("street", personValues.remove("street"));
4280:                    addressValues.put("city", personValues.remove("city"));
4281:                    addressValues.put("state", personValues.remove("state"));
4282:                    addressValues
4283:                            .put("zipCode", personValues.remove("zipCode"));
4284:                    personValues.put("address", address);
4285:
4286:                    return new RawObject(newPersonType, personValues, person
4287:                            .getSuper());
4288:                }
4289:
4290:                @Override
4291:                public boolean equals(Object o) {
4292:                    return o instanceof  ConvertExample3_Conversion;
4293:                }
4294:            }
4295:
4296:            @Entity(version=1)
4297:            static class ConvertExample3_Person extends EvolveCase {
4298:
4299:                private static final String NAME = ConvertExample3_Person.class
4300:                        .getName();
4301:                private static final String NAME2 = ConvertExample3_Address.class
4302:                        .getName();
4303:
4304:                @PrimaryKey
4305:                int key;
4306:
4307:                ConvertExample3_Address address;
4308:
4309:                @Override
4310:                Mutations getMutations() {
4311:                    Mutations m = new Mutations();
4312:                    Converter converter = new Converter(
4313:                            ConvertExample3_Person.class.getName(), 0,
4314:                            new ConvertExample3_Conversion());
4315:                    m.addConverter(converter);
4316:                    return m;
4317:                }
4318:
4319:                @Override
4320:                void checkEvolvedModel(EntityModel model, Environment env,
4321:                        boolean oldTypesExist) {
4322:                    checkEntity(true, model, env, NAME, 1, null);
4323:                    if (oldTypesExist) {
4324:                        checkVersions(model, NAME, 1, NAME, 0);
4325:                    } else {
4326:                        checkVersions(model, NAME, 1);
4327:                    }
4328:                    checkVersions(model, NAME2, 0);
4329:                }
4330:
4331:                @Override
4332:                void readObjects(EntityStore store, boolean doUpdate)
4333:                        throws DatabaseException {
4334:
4335:                    PrimaryIndex<Integer, ConvertExample3_Person> index = store
4336:                            .getPrimaryIndex(Integer.class,
4337:                                    ConvertExample3_Person.class);
4338:                    ConvertExample3_Person obj = index.get(99);
4339:                    TestCase.assertNotNull(obj);
4340:                    TestCase.assertEquals(99, obj.key);
4341:                    TestCase.assertNotNull(obj.address);
4342:                    TestCase.assertEquals("street", obj.address.street);
4343:                    TestCase.assertEquals("city", obj.address.city);
4344:                    TestCase.assertEquals("state", obj.address.state);
4345:                    TestCase.assertEquals(12345, obj.address.zipCode);
4346:
4347:                    if (doUpdate) {
4348:                        index.put(obj);
4349:                    }
4350:                }
4351:
4352:                @Override
4353:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
4354:                        throws DatabaseException {
4355:
4356:                    PrimaryIndex<Integer, ConvertExample3_Person> index = newStore
4357:                            .getPrimaryIndex(Integer.class,
4358:                                    ConvertExample3_Person.class);
4359:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4360:                    index.put((ConvertExample3_Person) newStore.getModel()
4361:                            .convertRawObject(raw));
4362:                }
4363:
4364:                @Override
4365:                void readRawObjects(RawStore store, boolean expectEvolved,
4366:                        boolean expectUpdated) throws DatabaseException {
4367:
4368:                    RawObject obj = readRaw(store, 99, NAME, expectEvolved ? 1
4369:                            : 0, CASECLS, 0);
4370:                    if (expectEvolved) {
4371:                        RawType embedType = store.getModel().getRawType(NAME2);
4372:                        Object embed = new RawObject(embedType, makeValues(
4373:                                "street", "street", "city", "city", "state",
4374:                                "state", "zipCode", 12345), null);
4375:                        checkRawFields(obj, "key", 99, "address", embed);
4376:                    } else {
4377:                        checkRawFields(obj, "key", 99, "street", "street",
4378:                                "city", "city", "state", "state", "zipCode",
4379:                                12345);
4380:                    }
4381:                }
4382:            }
4383:
4384:            @Persistent(version=1)
4385:            static class ConvertExample4_A extends ConvertExample4_B {
4386:            }
4387:
4388:            @Persistent(version=1)
4389:            static class ConvertExample4_B {
4390:                String name;
4391:            }
4392:
4393:            static class Example4_Conversion implements  Conversion {
4394:                private transient RawType newAType;
4395:                private transient RawType newBType;
4396:
4397:                public void initialize(EntityModel model) {
4398:                    newAType = model.getRawType(ConvertExample4_A.class
4399:                            .getName());
4400:                    newBType = model.getRawType(ConvertExample4_B.class
4401:                            .getName());
4402:                }
4403:
4404:                public Object convert(Object fromValue) {
4405:                    RawObject oldA = (RawObject) fromValue;
4406:                    RawObject oldB = oldA.getSuper();
4407:                    Map<String, Object> aValues = oldA.getValues();
4408:                    Map<String, Object> bValues = oldB.getValues();
4409:                    bValues.put("name", aValues.remove("name"));
4410:                    RawObject newB = new RawObject(newBType, bValues, oldB
4411:                            .getSuper());
4412:                    RawObject newA = new RawObject(newAType, aValues, newB);
4413:                    return newA;
4414:                }
4415:
4416:                @Override
4417:                public boolean equals(Object o) {
4418:                    return o instanceof  Example4_Conversion;
4419:                }
4420:            }
4421:
4422:            @Entity(version=1)
4423:            static class ConvertExample4_Entity extends EvolveCase {
4424:
4425:                private static final String NAME = ConvertExample4_Entity.class
4426:                        .getName();
4427:                private static final String NAME2 = ConvertExample4_A.class
4428:                        .getName();
4429:                private static final String NAME3 = ConvertExample4_B.class
4430:                        .getName();
4431:
4432:                @PrimaryKey
4433:                int key;
4434:
4435:                ConvertExample4_A embed;
4436:
4437:                @Override
4438:                Mutations getMutations() {
4439:                    Mutations m = new Mutations();
4440:                    Converter converter = new Converter(ConvertExample4_A.class
4441:                            .getName(), 0, new Example4_Conversion());
4442:                    m.addConverter(converter);
4443:                    return m;
4444:                }
4445:
4446:                @Override
4447:                void checkEvolvedModel(EntityModel model, Environment env,
4448:                        boolean oldTypesExist) {
4449:                    checkEntity(true, model, env, NAME, 1, null);
4450:                    if (oldTypesExist) {
4451:                        checkVersions(model, NAME, 1, NAME, 0);
4452:                        checkVersions(model, NAME2, 1, NAME2, 0);
4453:                        checkVersions(model, NAME3, 1, NAME3, 0);
4454:                    } else {
4455:                        checkVersions(model, NAME, 1);
4456:                        checkVersions(model, NAME2, 1);
4457:                        checkVersions(model, NAME3, 1);
4458:                    }
4459:                }
4460:
4461:                @Override
4462:                void readObjects(EntityStore store, boolean doUpdate)
4463:                        throws DatabaseException {
4464:
4465:                    PrimaryIndex<Integer, ConvertExample4_Entity> index = store
4466:                            .getPrimaryIndex(Integer.class,
4467:                                    ConvertExample4_Entity.class);
4468:                    ConvertExample4_Entity obj = index.get(99);
4469:                    TestCase.assertNotNull(obj);
4470:                    TestCase.assertEquals(99, obj.key);
4471:                    TestCase.assertNotNull(obj.embed);
4472:                    TestCase.assertEquals("name", obj.embed.name);
4473:
4474:                    if (doUpdate) {
4475:                        index.put(obj);
4476:                    }
4477:                }
4478:
4479:                @Override
4480:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
4481:                        throws DatabaseException {
4482:
4483:                    PrimaryIndex<Integer, ConvertExample4_Entity> index = newStore
4484:                            .getPrimaryIndex(Integer.class,
4485:                                    ConvertExample4_Entity.class);
4486:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4487:                    index.put((ConvertExample4_Entity) newStore.getModel()
4488:                            .convertRawObject(raw));
4489:                }
4490:
4491:                @Override
4492:                void readRawObjects(RawStore store, boolean expectEvolved,
4493:                        boolean expectUpdated) throws DatabaseException {
4494:
4495:                    RawType embedTypeA = store.getModel().getRawType(NAME2);
4496:                    RawType embedTypeB = store.getModel().getRawType(NAME3);
4497:                    Object embed;
4498:                    if (expectEvolved) {
4499:                        embed = new RawObject(embedTypeA, makeValues(),
4500:                                new RawObject(embedTypeB, makeValues("name",
4501:                                        "name"), null));
4502:                    } else {
4503:                        embed = new RawObject(embedTypeA, makeValues("name",
4504:                                "name"), new RawObject(embedTypeB,
4505:                                makeValues(), null));
4506:                    }
4507:                    RawObject obj = readRaw(store, 99, NAME, expectEvolved ? 1
4508:                            : 0, CASECLS, 0);
4509:                    checkRawFields(obj, "key", 99, "embed", embed);
4510:                }
4511:            }
4512:
4513:            @Persistent(version=1)
4514:            static class ConvertExample5_Pet {
4515:                String name;
4516:            }
4517:
4518:            @Persistent
4519:            static class ConvertExample5_Cat extends ConvertExample5_Pet {
4520:                int finickyLevel;
4521:            }
4522:
4523:            @Persistent
4524:            static class ConvertExample5_Dog extends ConvertExample5_Pet {
4525:                double barkVolume;
4526:            }
4527:
4528:            static class ConvertExample5_Conversion implements  Conversion {
4529:                private transient RawType newPetType;
4530:                private transient RawType dogType;
4531:                private transient RawType catType;
4532:
4533:                public void initialize(EntityModel model) {
4534:                    newPetType = model.getRawType(ConvertExample5_Pet.class
4535:                            .getName());
4536:                    dogType = model.getRawType(ConvertExample5_Dog.class
4537:                            .getName());
4538:                    catType = model.getRawType(ConvertExample5_Cat.class
4539:                            .getName());
4540:                }
4541:
4542:                public Object convert(Object fromValue) {
4543:                    RawObject pet = (RawObject) fromValue;
4544:                    Map<String, Object> petValues = pet.getValues();
4545:                    Map<String, Object> subTypeValues = new HashMap<String, Object>();
4546:                    Boolean isCat = (Boolean) petValues.remove("isCatNotDog");
4547:                    Integer finickyLevel = (Integer) petValues
4548:                            .remove("finickyLevel");
4549:                    Double barkVolume = (Double) petValues.remove("barkVolume");
4550:                    RawType newSubType;
4551:                    if (isCat) {
4552:                        newSubType = catType;
4553:                        subTypeValues.put("finickyLevel", finickyLevel);
4554:                    } else {
4555:                        newSubType = dogType;
4556:                        subTypeValues.put("barkVolume", barkVolume);
4557:                    }
4558:                    RawObject newPet = new RawObject(newPetType, petValues, pet
4559:                            .getSuper());
4560:                    return new RawObject(newSubType, subTypeValues, newPet);
4561:                }
4562:
4563:                @Override
4564:                public boolean equals(Object o) {
4565:                    return o instanceof  ConvertExample5_Conversion;
4566:                }
4567:            }
4568:
4569:            @Entity(version=1)
4570:            static class ConvertExample5_Entity extends EvolveCase {
4571:
4572:                private static final String NAME = ConvertExample5_Entity.class
4573:                        .getName();
4574:                private static final String NAME2 = ConvertExample5_Pet.class
4575:                        .getName();
4576:                private static final String NAME3 = ConvertExample5_Cat.class
4577:                        .getName();
4578:                private static final String NAME4 = ConvertExample5_Dog.class
4579:                        .getName();
4580:
4581:                @PrimaryKey
4582:                int key;
4583:
4584:                ConvertExample5_Cat cat;
4585:                ConvertExample5_Dog dog;
4586:
4587:                @Override
4588:                Mutations getMutations() {
4589:                    Mutations m = new Mutations();
4590:                    Converter converter = new Converter(
4591:                            ConvertExample5_Pet.class.getName(), 0,
4592:                            new ConvertExample5_Conversion());
4593:                    m.addConverter(converter);
4594:                    return m;
4595:                }
4596:
4597:                @Override
4598:                void checkEvolvedModel(EntityModel model, Environment env,
4599:                        boolean oldTypesExist) {
4600:                    checkEntity(true, model, env, NAME, 1, null);
4601:                    if (oldTypesExist) {
4602:                        checkVersions(model, NAME, 1, NAME, 0);
4603:                        checkVersions(model, NAME2, 1, NAME2, 0);
4604:                    } else {
4605:                        checkVersions(model, NAME, 1);
4606:                        checkVersions(model, NAME2, 1);
4607:                    }
4608:                    checkVersions(model, NAME3, 0);
4609:                    checkVersions(model, NAME4, 0);
4610:                }
4611:
4612:                @Override
4613:                void readObjects(EntityStore store, boolean doUpdate)
4614:                        throws DatabaseException {
4615:
4616:                    PrimaryIndex<Integer, ConvertExample5_Entity> index = store
4617:                            .getPrimaryIndex(Integer.class,
4618:                                    ConvertExample5_Entity.class);
4619:                    ConvertExample5_Entity obj = index.get(99);
4620:                    TestCase.assertNotNull(obj);
4621:                    TestCase.assertEquals(99, obj.key);
4622:                    TestCase.assertNotNull(obj.cat);
4623:                    TestCase.assertEquals("Jeffry", obj.cat.name);
4624:                    TestCase.assertEquals(999, obj.cat.finickyLevel);
4625:                    TestCase.assertNotNull(obj.dog);
4626:                    TestCase.assertEquals("Nelson", obj.dog.name);
4627:                    TestCase.assertEquals(0.01, obj.dog.barkVolume);
4628:
4629:                    if (doUpdate) {
4630:                        index.put(obj);
4631:                    }
4632:                }
4633:
4634:                @Override
4635:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
4636:                        throws DatabaseException {
4637:
4638:                    PrimaryIndex<Integer, ConvertExample5_Entity> index = newStore
4639:                            .getPrimaryIndex(Integer.class,
4640:                                    ConvertExample5_Entity.class);
4641:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4642:                    index.put((ConvertExample5_Entity) newStore.getModel()
4643:                            .convertRawObject(raw));
4644:                }
4645:
4646:                @Override
4647:                void readRawObjects(RawStore store, boolean expectEvolved,
4648:                        boolean expectUpdated) throws DatabaseException {
4649:
4650:                    RawType petType = store.getModel().getRawType(NAME2);
4651:                    RawObject cat;
4652:                    RawObject dog;
4653:                    if (expectEvolved) {
4654:                        RawType catType = store.getModel().getRawType(NAME3);
4655:                        RawType dogType = store.getModel().getRawType(NAME4);
4656:                        cat = new RawObject(catType, makeValues("finickyLevel",
4657:                                999), new RawObject(petType, makeValues("name",
4658:                                "Jeffry"), null));
4659:                        dog = new RawObject(dogType, makeValues("barkVolume",
4660:                                0.01), new RawObject(petType, makeValues(
4661:                                "name", "Nelson"), null));
4662:                    } else {
4663:                        cat = new RawObject(petType, makeValues("name",
4664:                                "Jeffry", "isCatNotDog", true, "finickyLevel",
4665:                                999, "barkVolume", 0.0), null);
4666:                        dog = new RawObject(petType, makeValues("name",
4667:                                "Nelson", "isCatNotDog", false, "finickyLevel",
4668:                                0, "barkVolume", 0.01), null);
4669:                    }
4670:                    RawObject obj = readRaw(store, 99, NAME, expectEvolved ? 1
4671:                            : 0, CASECLS, 0);
4672:                    checkRawFields(obj, "key", 99, "cat", cat, "dog", dog);
4673:                }
4674:            }
4675:
4676:            @Persistent(version=1)
4677:            static class AllowFieldAddDelete_Embed {
4678:                private String f0 = "0";
4679:                private String f2;
4680:                private int f3 = 3;
4681:                private String f4;
4682:                private int f5 = 5;
4683:                private String f8 = "8";
4684:                private int f9 = 9;
4685:            }
4686:
4687:            @Persistent(version=1)
4688:            static class AllowFieldAddDelete_Base extends EvolveCase {
4689:
4690:                private String f0 = "0";
4691:                private String f2;
4692:                private int f3 = 3;
4693:                private String f4;
4694:                private int f5 = 5;
4695:                private String f8 = "8";
4696:                private int f9 = 9;
4697:            }
4698:
4699:            @Entity(version=1)
4700:            static class AllowFieldAddDelete extends AllowFieldAddDelete_Base {
4701:
4702:                private static final String NAME = AllowFieldAddDelete.class
4703:                        .getName();
4704:                private static final String NAME2 = AllowFieldAddDelete_Base.class
4705:                        .getName();
4706:                private static final String NAME3 = AllowFieldAddDelete_Embed.class
4707:                        .getName();
4708:
4709:                @PrimaryKey
4710:                int key;
4711:
4712:                AllowFieldAddDelete_Embed embed;
4713:
4714:                private String f0 = "0";
4715:                private String f2;
4716:                private int f3 = 3;
4717:                private String f4;
4718:                private int f5 = 5;
4719:                private String f8 = "8";
4720:                private int f9 = 9;
4721:
4722:                @Override
4723:                Mutations getMutations() {
4724:                    Mutations m = new Mutations();
4725:                    for (String name : new String[] { NAME, NAME2, NAME3 }) {
4726:                        m.addDeleter(new Deleter(name, 0, "f1"));
4727:                        m.addDeleter(new Deleter(name, 0, "f6"));
4728:                        m.addDeleter(new Deleter(name, 0, "f7"));
4729:                    }
4730:                    return m;
4731:                }
4732:
4733:                @Override
4734:                void checkEvolvedModel(EntityModel model, Environment env,
4735:                        boolean oldTypesExist) {
4736:                    checkEntity(true, model, env, NAME, 1, null);
4737:                    if (oldTypesExist) {
4738:                        checkVersions(model, NAME, 1, NAME, 0);
4739:                        checkVersions(model, NAME2, 1, NAME2, 0);
4740:                        checkVersions(model, NAME3, 1, NAME3, 0);
4741:                    } else {
4742:                        checkVersions(model, NAME, 1);
4743:                        checkVersions(model, NAME2, 1);
4744:                        checkVersions(model, NAME3, 1);
4745:                    }
4746:                }
4747:
4748:                @Override
4749:                void readObjects(EntityStore store, boolean doUpdate)
4750:                        throws DatabaseException {
4751:
4752:                    PrimaryIndex<Integer, AllowFieldAddDelete> index = store
4753:                            .getPrimaryIndex(Integer.class,
4754:                                    AllowFieldAddDelete.class);
4755:                    AllowFieldAddDelete obj = index.get(99);
4756:                    TestCase.assertNotNull(obj);
4757:                    TestCase.assertEquals(99, obj.key);
4758:                    {
4759:                        AllowFieldAddDelete o = obj;
4760:
4761:                        TestCase.assertNotNull(o);
4762:                        TestCase.assertEquals("0", o.f0);
4763:                        TestCase.assertEquals("2", o.f2);
4764:                        TestCase.assertEquals(3, o.f3);
4765:                        TestCase.assertEquals("4", o.f4);
4766:                        TestCase.assertEquals(5, o.f5);
4767:                        TestCase.assertEquals("8", o.f8);
4768:                        TestCase.assertEquals(9, o.f9);
4769:                    }
4770:                    {
4771:                        AllowFieldAddDelete_Base o = (AllowFieldAddDelete_Base) obj;
4772:
4773:                        TestCase.assertNotNull(o);
4774:                        TestCase.assertEquals("0", o.f0);
4775:                        TestCase.assertEquals("2", o.f2);
4776:                        TestCase.assertEquals(3, o.f3);
4777:                        TestCase.assertEquals("4", o.f4);
4778:                        TestCase.assertEquals(5, o.f5);
4779:                        TestCase.assertEquals("8", o.f8);
4780:                        TestCase.assertEquals(9, o.f9);
4781:                    }
4782:                    {
4783:                        AllowFieldAddDelete_Embed o = obj.embed;
4784:
4785:                        TestCase.assertNotNull(o);
4786:                        TestCase.assertEquals("0", o.f0);
4787:                        TestCase.assertEquals("2", o.f2);
4788:                        TestCase.assertEquals(3, o.f3);
4789:                        TestCase.assertEquals("4", o.f4);
4790:                        TestCase.assertEquals(5, o.f5);
4791:                        TestCase.assertEquals("8", o.f8);
4792:                        TestCase.assertEquals(9, o.f9);
4793:                    }
4794:
4795:                    if (doUpdate) {
4796:                        index.put(obj);
4797:                    }
4798:                }
4799:
4800:                @Override
4801:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
4802:                        throws DatabaseException {
4803:
4804:                    PrimaryIndex<Integer, AllowFieldAddDelete> index = newStore
4805:                            .getPrimaryIndex(Integer.class,
4806:                                    AllowFieldAddDelete.class);
4807:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4808:                    index.put((AllowFieldAddDelete) newStore.getModel()
4809:                            .convertRawObject(raw));
4810:                }
4811:
4812:                static final Object[] fixedFields0 = { "f1", 1, "f2", "2",
4813:                        "f4", "4", "f6", 6, "f7", "7", };
4814:
4815:                static final Object[] fixedFields1 = { "f2", "2", "f4", "4", };
4816:
4817:                static final Object[] fixedFields2 = { "f0", "0", "f2", "2",
4818:                        "f3", 3, "f4", "4", "f5", 5, "f8", "8", "f9", 9, };
4819:
4820:                @Override
4821:                void readRawObjects(RawStore store, boolean expectEvolved,
4822:                        boolean expectUpdated) throws DatabaseException {
4823:
4824:                    RawType baseType = store.getModel().getRawType(NAME2);
4825:                    RawType embedType = store.getModel().getRawType(NAME3);
4826:
4827:                    Object[] ff;
4828:                    if (expectEvolved) {
4829:                        if (expectUpdated) {
4830:                            ff = fixedFields2;
4831:                        } else {
4832:                            ff = fixedFields1;
4833:                        }
4834:                    } else {
4835:                        ff = fixedFields0;
4836:                    }
4837:                    RawObject embed = new RawObject(embedType, makeValues(ff),
4838:                            null);
4839:                    RawObject obj = readRaw(store, 99, NAME, expectEvolved ? 1
4840:                            : 0, NAME2, expectEvolved ? 1 : 0, CASECLS, 0);
4841:                    checkRaw(obj, ff, "key", 99, "embed", embed);
4842:                    checkRaw(obj.getSuper(), ff);
4843:                }
4844:
4845:                private void checkRaw(RawObject obj, Object[] fixedFields,
4846:                        Object... otherFields) {
4847:                    Object[] allFields = new Object[otherFields.length
4848:                            + fixedFields.length];
4849:                    System.arraycopy(otherFields, 0, allFields, 0,
4850:                            otherFields.length);
4851:                    System.arraycopy(fixedFields, 0, allFields,
4852:                            otherFields.length, fixedFields.length);
4853:                    checkRawFields(obj, allFields);
4854:                }
4855:            }
4856:
4857:            static class ProxiedClass {
4858:                int data;
4859:
4860:                ProxiedClass(int data) {
4861:                    this .data = data;
4862:                }
4863:            }
4864:
4865:            @Persistent(version=1,proxyFor=ProxiedClass.class)
4866:            static class ProxiedClass_Proxy implements 
4867:                    PersistentProxy<ProxiedClass> {
4868:                long data;
4869:
4870:                public void initializeProxy(ProxiedClass o) {
4871:                    data = o.data;
4872:                }
4873:
4874:                public ProxiedClass convertProxy() {
4875:                    return new ProxiedClass((int) data);
4876:                }
4877:            }
4878:
4879:            @Entity
4880:            static class ProxiedClass_Entity extends EvolveCase {
4881:
4882:                private static final String NAME = ProxiedClass_Entity.class
4883:                        .getName();
4884:                private static final String NAME2 = ProxiedClass_Proxy.class
4885:                        .getName();
4886:
4887:                @PrimaryKey
4888:                int key;
4889:
4890:                ProxiedClass embed;
4891:
4892:                @Override
4893:                void configure(EntityModel model, StoreConfig config) {
4894:                    model.registerClass(ProxiedClass_Proxy.class);
4895:                }
4896:
4897:                @Override
4898:                void checkEvolvedModel(EntityModel model, Environment env,
4899:                        boolean oldTypesExist) {
4900:                    checkEntity(true, model, env, NAME, 0, null);
4901:                    checkVersions(model, NAME, 0);
4902:                    if (oldTypesExist) {
4903:                        checkVersions(model, NAME2, 1, NAME2, 0);
4904:                    } else {
4905:                        checkVersions(model, NAME2, 1);
4906:                    }
4907:                }
4908:
4909:                @Override
4910:                void readObjects(EntityStore store, boolean doUpdate)
4911:                        throws DatabaseException {
4912:
4913:                    PrimaryIndex<Integer, ProxiedClass_Entity> index = store
4914:                            .getPrimaryIndex(Integer.class,
4915:                                    ProxiedClass_Entity.class);
4916:                    ProxiedClass_Entity obj = index.get(99);
4917:                    TestCase.assertNotNull(obj);
4918:                    TestCase.assertEquals(99, obj.key);
4919:                    TestCase.assertNotNull(obj.embed);
4920:                    TestCase.assertEquals(88, obj.embed.data);
4921:
4922:                    if (doUpdate) {
4923:                        index.put(obj);
4924:                    }
4925:                }
4926:
4927:                @Override
4928:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
4929:                        throws DatabaseException {
4930:
4931:                    PrimaryIndex<Integer, ProxiedClass_Entity> index = newStore
4932:                            .getPrimaryIndex(Integer.class,
4933:                                    ProxiedClass_Entity.class);
4934:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
4935:                    index.put((ProxiedClass_Entity) newStore.getModel()
4936:                            .convertRawObject(raw));
4937:                }
4938:
4939:                @Override
4940:                void readRawObjects(RawStore store, boolean expectEvolved,
4941:                        boolean expectUpdated) throws DatabaseException {
4942:
4943:                    RawType embedType = store.getModel().getRawType(NAME2);
4944:                    RawObject embed;
4945:                    if (expectEvolved) {
4946:                        embed = new RawObject(embedType,
4947:                                makeValues("data", 88L), null);
4948:                    } else {
4949:                        embed = new RawObject(embedType,
4950:                                makeValues("data", 88), null);
4951:                    }
4952:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
4953:                    checkRawFields(obj, "key", 99, "embed", embed);
4954:                }
4955:            }
4956:
4957:            @Persistent(proxyFor=StringBuffer.class)
4958:            static class DisallowChangeProxyFor_Proxy2 implements 
4959:                    PersistentProxy<StringBuffer> {
4960:
4961:                String data;
4962:
4963:                public void initializeProxy(StringBuffer o) {
4964:                    data = o.toString();
4965:                }
4966:
4967:                public StringBuffer convertProxy() {
4968:                    return new StringBuffer(data);
4969:                }
4970:            }
4971:
4972:            @Persistent(proxyFor=StringBuilder.class)
4973:            static class DisallowChangeProxyFor_Proxy implements 
4974:                    PersistentProxy<StringBuilder> {
4975:
4976:                String data;
4977:
4978:                public void initializeProxy(StringBuilder o) {
4979:                    data = o.toString();
4980:                }
4981:
4982:                public StringBuilder convertProxy() {
4983:                    return new StringBuilder(data);
4984:                }
4985:            }
4986:
4987:            @Entity
4988:            static class DisallowChangeProxyFor extends EvolveCase {
4989:
4990:                @PrimaryKey
4991:                int key;
4992:
4993:                @Override
4994:                public String getStoreOpenException() {
4995:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Error when evolving class: java.lang.StringBuffer version: 0 to class: java.lang.StringBuffer version: 0 Error: The proxy class for this type has been changed from: com.sleepycat.persist.test.EvolveClasses$DisallowChangeProxyFor_Proxy to: com.sleepycat.persist.test.EvolveClasses$DisallowChangeProxyFor_Proxy2";
4996:                }
4997:
4998:                @Override
4999:                void configure(EntityModel model, StoreConfig config) {
5000:                    model.registerClass(DisallowChangeProxyFor_Proxy.class);
5001:                    model.registerClass(DisallowChangeProxyFor_Proxy2.class);
5002:                }
5003:            }
5004:
5005:            @Persistent
5006:            static class DisallowDeleteProxyFor_Proxy {
5007:                String data;
5008:            }
5009:
5010:            @Entity
5011:            static class DisallowDeleteProxyFor extends EvolveCase {
5012:
5013:                @PrimaryKey
5014:                int key;
5015:
5016:                @Override
5017:                public String getStoreOpenException() {
5018:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Mutation is missing to evolve class: java.lang.StringBuffer version: 0 Error: java.lang.IllegalArgumentException: Class could not be loaded or is not persistent: java.lang.StringBuffer";
5019:                }
5020:            }
5021:
5022:            @Persistent(version=1)
5023:            static class ArrayNameChange_Component_Renamed {
5024:
5025:                long data;
5026:            }
5027:
5028:            @Entity
5029:            static class ArrayNameChange_Entity extends EvolveCase {
5030:
5031:                private static final String NAME = ArrayNameChange_Entity.class
5032:                        .getName();
5033:                private static final String NAME2 = ArrayNameChange_Component_Renamed.class
5034:                        .getName();
5035:                private static final String NAME3 = PREFIX
5036:                        + "ArrayNameChange_Component";
5037:
5038:                @PrimaryKey
5039:                int key;
5040:
5041:                ArrayNameChange_Component_Renamed[] embed;
5042:                ArrayNameChange_Component_Renamed embed2;
5043:
5044:                @Override
5045:                Mutations getMutations() {
5046:                    Mutations m = new Mutations();
5047:                    m.addRenamer(new Renamer(NAME3, 0, NAME2));
5048:                    return m;
5049:                }
5050:
5051:                @Override
5052:                void checkEvolvedModel(EntityModel model, Environment env,
5053:                        boolean oldTypesExist) {
5054:                    checkEntity(true, model, env, NAME, 0, null);
5055:                    checkVersions(model, NAME, 0);
5056:                    if (oldTypesExist) {
5057:                        checkVersions(model, NAME2, 1, NAME3, 0);
5058:                    } else {
5059:                        checkVersions(model, NAME2, 1);
5060:                    }
5061:                }
5062:
5063:                @Override
5064:                void readObjects(EntityStore store, boolean doUpdate)
5065:                        throws DatabaseException {
5066:
5067:                    PrimaryIndex<Integer, ArrayNameChange_Entity> index = store
5068:                            .getPrimaryIndex(Integer.class,
5069:                                    ArrayNameChange_Entity.class);
5070:                    ArrayNameChange_Entity obj = index.get(99);
5071:                    TestCase.assertNotNull(obj);
5072:                    TestCase.assertEquals(99, obj.key);
5073:                    TestCase.assertNotNull(obj.embed);
5074:                    TestCase.assertEquals(1, obj.embed.length);
5075:                    TestCase.assertEquals(88L, obj.embed[0].data);
5076:                    TestCase.assertSame(obj.embed2, obj.embed[0]);
5077:
5078:                    if (doUpdate) {
5079:                        index.put(obj);
5080:                    }
5081:                }
5082:
5083:                @Override
5084:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
5085:                        throws DatabaseException {
5086:
5087:                    PrimaryIndex<Integer, ArrayNameChange_Entity> index = newStore
5088:                            .getPrimaryIndex(Integer.class,
5089:                                    ArrayNameChange_Entity.class);
5090:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5091:                    index.put((ArrayNameChange_Entity) newStore.getModel()
5092:                            .convertRawObject(raw));
5093:                }
5094:
5095:                @Override
5096:                void readRawObjects(RawStore store, boolean expectEvolved,
5097:                        boolean expectUpdated) throws DatabaseException {
5098:
5099:                    String compTypeName = expectEvolved ? NAME2 : NAME3;
5100:                    String arrayTypeName = "[L" + compTypeName + ';';
5101:                    RawType compType = store.getModel()
5102:                            .getRawType(compTypeName);
5103:                    RawType arrayType = store.getModel().getRawType(
5104:                            arrayTypeName);
5105:                    RawObject embed2;
5106:                    if (expectEvolved) {
5107:                        embed2 = new RawObject(compType,
5108:                                makeValues("data", 88L), null);
5109:                    } else {
5110:                        embed2 = new RawObject(compType,
5111:                                makeValues("data", 88), null);
5112:                    }
5113:                    RawObject embed = new RawObject(arrayType,
5114:                            new Object[] { embed2 });
5115:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
5116:                    checkRawFields(obj, "key", 99, "embed", embed, "embed2",
5117:                            embed2);
5118:                }
5119:            }
5120:
5121:            enum AddEnumConstant_Enum {
5122:                A, B, C;
5123:            }
5124:
5125:            @Entity(version=1)
5126:            static class AddEnumConstant_Entity extends EvolveCase {
5127:
5128:                private static final String NAME = AddEnumConstant_Entity.class
5129:                        .getName();
5130:                private static final String NAME2 = AddEnumConstant_Enum.class
5131:                        .getName();
5132:
5133:                @PrimaryKey
5134:                int key;
5135:
5136:                AddEnumConstant_Enum e1;
5137:                AddEnumConstant_Enum e2;
5138:                AddEnumConstant_Enum e3 = AddEnumConstant_Enum.C;
5139:
5140:                @Override
5141:                void checkEvolvedModel(EntityModel model, Environment env,
5142:                        boolean oldTypesExist) {
5143:                    checkEntity(true, model, env, NAME, 1, null);
5144:                    if (oldTypesExist) {
5145:                        checkVersions(model, NAME, 1, NAME, 0);
5146:                        checkVersions(model, NAME2, 0, NAME2, 0);
5147:                    } else {
5148:                        checkVersions(model, NAME, 1);
5149:                        checkVersions(model, NAME2, 0);
5150:                    }
5151:                }
5152:
5153:                @Override
5154:                void readObjects(EntityStore store, boolean doUpdate)
5155:                        throws DatabaseException {
5156:
5157:                    PrimaryIndex<Integer, AddEnumConstant_Entity> index = store
5158:                            .getPrimaryIndex(Integer.class,
5159:                                    AddEnumConstant_Entity.class);
5160:                    AddEnumConstant_Entity obj = index.get(99);
5161:                    TestCase.assertNotNull(obj);
5162:                    TestCase.assertEquals(99, obj.key);
5163:                    TestCase.assertSame(AddEnumConstant_Enum.A, obj.e1);
5164:                    TestCase.assertSame(AddEnumConstant_Enum.B, obj.e2);
5165:                    TestCase.assertSame(AddEnumConstant_Enum.C, obj.e3);
5166:
5167:                    if (doUpdate) {
5168:                        index.put(obj);
5169:                    }
5170:                }
5171:
5172:                @Override
5173:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
5174:                        throws DatabaseException {
5175:
5176:                    PrimaryIndex<Integer, AddEnumConstant_Entity> index = newStore
5177:                            .getPrimaryIndex(Integer.class,
5178:                                    AddEnumConstant_Entity.class);
5179:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5180:                    index.put((AddEnumConstant_Entity) newStore.getModel()
5181:                            .convertRawObject(raw));
5182:                }
5183:
5184:                @Override
5185:                void readRawObjects(RawStore store, boolean expectEvolved,
5186:                        boolean expectUpdated) throws DatabaseException {
5187:
5188:                    RawObject obj = readRaw(store, 99, NAME, expectEvolved ? 1
5189:                            : 0, CASECLS, 0);
5190:                    RawType enumType = store.getModel().getRawType(NAME2);
5191:                    if (expectUpdated) {
5192:                        checkRawFields(obj, "key", 99, "e1", new RawObject(
5193:                                enumType, "A"), "e2", new RawObject(enumType,
5194:                                "B"), "e3", new RawObject(enumType, "C"));
5195:                    } else {
5196:                        checkRawFields(obj, "key", 99, "e1", new RawObject(
5197:                                enumType, "A"), "e2", new RawObject(enumType,
5198:                                "B"));
5199:                    }
5200:                }
5201:            }
5202:
5203:            enum DeleteEnumConstant_Enum {
5204:                A, C;
5205:            }
5206:
5207:            /**
5208:             * For now we don't allow deleting enum values.  This test case has code
5209:             * for testing conversions, for when we add versioning to enums.
5210:             */
5211:            @Entity
5212:            static class DeleteEnumConstant_NoMutation extends EvolveCase {
5213:
5214:                private static final String NAME = DeleteEnumConstant_NoMutation.class
5215:                        .getName();
5216:                private static final String NAME2 = DeleteEnumConstant_Enum.class
5217:                        .getName();
5218:
5219:                @PrimaryKey
5220:                int key;
5221:
5222:                DeleteEnumConstant_Enum e1;
5223:                DeleteEnumConstant_Enum e2;
5224:                DeleteEnumConstant_Enum e3;
5225:
5226:                @Override
5227:                public String getStoreOpenException() {
5228:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Incompatible enum type changed detected when evolving class: com.sleepycat.persist.test.EvolveClasses$DeleteEnumConstant_Enum version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DeleteEnumConstant_Enum version: 0 Error: Enum values may not be removed: [B]";
5229:                }
5230:
5231:                /*
5232:                Mutation is missing to evolve class: com.sleepycat.persist.test.EvolveClasses$DeleteEnumConstant_Enum version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DeleteEnumConstant_Enum version: 0 Error: Converter is required when a value is removed from an enum: [B]
5233:                 */
5234:
5235:                /*
5236:                @Override
5237:                Mutations getMutations() {
5238:                    Mutations m = new Mutations();
5239:                    Converter converter = new Converter(NAME2, 0, new MyConversion());
5240:                    m.addConverter(converter);
5241:                    return m;
5242:                }
5243:                 */
5244:
5245:                static class MyConversion implements  Conversion {
5246:
5247:                    transient RawType newType;
5248:
5249:                    public void initialize(EntityModel model) {
5250:                        newType = model.getRawType(NAME2);
5251:                        TestCase.assertNotNull(newType);
5252:                    }
5253:
5254:                    public Object convert(Object fromValue) {
5255:                        TestCase.assertNotNull(newType);
5256:                        RawObject obj = (RawObject) fromValue;
5257:                        String val = obj.getEnum();
5258:                        TestCase.assertNotNull(val);
5259:                        if ("B".equals(val)) {
5260:                            val = "C";
5261:                        }
5262:                        return new RawObject(newType, val);
5263:                    }
5264:
5265:                    @Override
5266:                    public boolean equals(Object other) {
5267:                        return other instanceof  MyConversion;
5268:                    }
5269:                }
5270:
5271:                @Override
5272:                void checkEvolvedModel(EntityModel model, Environment env,
5273:                        boolean oldTypesExist) {
5274:                    checkEntity(true, model, env, NAME, 0, null);
5275:                    checkVersions(model, NAME, 0);
5276:                    if (oldTypesExist) {
5277:                        checkVersions(model, NAME2, 0, NAME2, 0);
5278:                    } else {
5279:                        checkVersions(model, NAME2, 0);
5280:                    }
5281:                }
5282:
5283:                @Override
5284:                void readObjects(EntityStore store, boolean doUpdate)
5285:                        throws DatabaseException {
5286:
5287:                    PrimaryIndex<Integer, DeleteEnumConstant_NoMutation> index = store
5288:                            .getPrimaryIndex(Integer.class,
5289:                                    DeleteEnumConstant_NoMutation.class);
5290:                    DeleteEnumConstant_NoMutation obj = index.get(99);
5291:                    TestCase.assertNotNull(obj);
5292:                    TestCase.assertEquals(99, obj.key);
5293:                    TestCase.assertSame(DeleteEnumConstant_Enum.A, obj.e1);
5294:                    TestCase.assertSame(DeleteEnumConstant_Enum.C, obj.e2);
5295:                    TestCase.assertSame(DeleteEnumConstant_Enum.C, obj.e3);
5296:
5297:                    if (doUpdate) {
5298:                        index.put(obj);
5299:                    }
5300:                }
5301:
5302:                @Override
5303:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
5304:                        throws DatabaseException {
5305:
5306:                    PrimaryIndex<Integer, DeleteEnumConstant_NoMutation> index = newStore
5307:                            .getPrimaryIndex(Integer.class,
5308:                                    DeleteEnumConstant_NoMutation.class);
5309:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5310:                    index.put((DeleteEnumConstant_NoMutation) newStore
5311:                            .getModel().convertRawObject(raw));
5312:                }
5313:
5314:                @Override
5315:                void readRawObjects(RawStore store, boolean expectEvolved,
5316:                        boolean expectUpdated) throws DatabaseException {
5317:
5318:                    RawObject obj = readRaw(store, 99, NAME, 0, CASECLS, 0);
5319:                    RawType enumType = store.getModel().getRawType(NAME2);
5320:                    if (expectEvolved) {
5321:                        checkRawFields(obj, "key", 99, "e1", new RawObject(
5322:                                enumType, "A"), "e2", new RawObject(enumType,
5323:                                "C"), "e3", new RawObject(enumType, "C"));
5324:                    } else {
5325:                        checkRawFields(obj, "key", 99, "e1", new RawObject(
5326:                                enumType, "A"), "e2", new RawObject(enumType,
5327:                                "B"), "e3", new RawObject(enumType, "C"));
5328:                    }
5329:                }
5330:            }
5331:
5332:            @Entity
5333:            static class DisallowChangeKeyRelate extends EvolveCase {
5334:
5335:                private static final String NAME = DisallowChangeKeyRelate.class
5336:                        .getName();
5337:
5338:                @PrimaryKey
5339:                int key;
5340:
5341:                @SecondaryKey(relate=MANY_TO_ONE)
5342:                int skey;
5343:
5344:                @Override
5345:                public String getStoreOpenException() {
5346:                    return "com.sleepycat.persist.evolve.IncompatibleClassException: Change detected in the relate attribute (Relationship) of a secondary key when evolving class: com.sleepycat.persist.test.EvolveClasses$DisallowChangeKeyRelate version: 0 to class: com.sleepycat.persist.test.EvolveClasses$DisallowChangeKeyRelate version: 0 Error: Old key: skey relate: ONE_TO_ONE new key: skey relate: MANY_TO_ONE";
5347:                }
5348:            }
5349:
5350:            @Entity(version=1)
5351:            static class AllowChangeKeyMetadata extends EvolveCase {
5352:
5353:                private static final String NAME = AllowChangeKeyMetadata.class
5354:                        .getName();
5355:
5356:                @PrimaryKey
5357:                int key;
5358:
5359:                /*
5360:                 * Combined fields from version 0 and 1:
5361:                 *  addAnnotation = 88;
5362:                 *  dropField = 77;
5363:                 *  dropAnnotation = 66;
5364:                 *  addField = 55;
5365:                 *  aa = 33;
5366:                 *  ff = 22;
5367:                 */
5368:
5369:                int aa;
5370:
5371:                @SecondaryKey(relate=ONE_TO_ONE)
5372:                int addAnnotation;
5373:
5374:                int dropAnnotation;
5375:
5376:                @SecondaryKey(relate=ONE_TO_ONE)
5377:                Integer addField;
5378:
5379:                int ff;
5380:
5381:                @Override
5382:                Mutations getMutations() {
5383:                    Mutations m = new Mutations();
5384:                    m.addDeleter(new Deleter(NAME, 0, "dropField"));
5385:                    return m;
5386:                }
5387:
5388:                @Override
5389:                void checkEvolvedModel(EntityModel model, Environment env,
5390:                        boolean oldTypesExist) {
5391:                    checkEntity(true, model, env, NAME, 1, null);
5392:                    if (oldTypesExist) {
5393:                        checkVersions(model, NAME, 1, NAME, 0);
5394:                    } else {
5395:                        checkVersions(model, NAME, 1);
5396:                    }
5397:                }
5398:
5399:                @Override
5400:                void readObjects(EntityStore store, boolean doUpdate)
5401:                        throws DatabaseException {
5402:
5403:                    PrimaryIndex<Integer, AllowChangeKeyMetadata> index = store
5404:                            .getPrimaryIndex(Integer.class,
5405:                                    AllowChangeKeyMetadata.class);
5406:                    AllowChangeKeyMetadata obj = index.get(99);
5407:                    checkValues(obj);
5408:
5409:                    checkValues(store.getSecondaryIndex(index, Integer.class,
5410:                            "addAnnotation").get(88));
5411:                    if (updated) {
5412:                        checkValues(store.getSecondaryIndex(index,
5413:                                Integer.class, "addField").get(55));
5414:                    } else {
5415:                        TestCase.assertNull(store.getSecondaryIndex(index,
5416:                                Integer.class, "addField").get(55));
5417:                    }
5418:
5419:                    if (doUpdate) {
5420:                        obj.addField = 55;
5421:                        index.put(obj);
5422:                        updated = true;
5423:                        checkValues(store.getSecondaryIndex(index,
5424:                                Integer.class, "addAnnotation").get(88));
5425:                        checkValues(store.getSecondaryIndex(index,
5426:                                Integer.class, "addField").get(55));
5427:                    }
5428:                }
5429:
5430:                @Override
5431:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
5432:                        throws DatabaseException {
5433:
5434:                    PrimaryIndex<Integer, AllowChangeKeyMetadata> index = newStore
5435:                            .getPrimaryIndex(Integer.class,
5436:                                    AllowChangeKeyMetadata.class);
5437:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5438:                    index.put((AllowChangeKeyMetadata) newStore.getModel()
5439:                            .convertRawObject(raw));
5440:                }
5441:
5442:                private void checkValues(AllowChangeKeyMetadata obj) {
5443:                    TestCase.assertNotNull(obj);
5444:                    TestCase.assertEquals(99, obj.key);
5445:                    TestCase.assertEquals(88, obj.addAnnotation);
5446:                    TestCase.assertEquals(66, obj.dropAnnotation);
5447:                    TestCase.assertEquals(33, obj.aa);
5448:                    TestCase.assertEquals(22, obj.ff);
5449:                    if (updated) {
5450:                        TestCase
5451:                                .assertEquals(Integer.valueOf(55), obj.addField);
5452:                    } else {
5453:                        TestCase.assertNull(obj.addField);
5454:                    }
5455:                }
5456:
5457:                @Override
5458:                void readRawObjects(RawStore store, boolean expectEvolved,
5459:                        boolean expectUpdated) throws DatabaseException {
5460:
5461:                    RawObject obj = readRaw(store, 99, NAME, expectEvolved ? 1
5462:                            : 0, CASECLS, 0);
5463:                    if (expectUpdated) {
5464:                        checkRawFields(obj, "key", 99, "addAnnotation", 88,
5465:                                "dropAnnotation", 66, "addField", 55, "aa", 33,
5466:                                "ff", 22);
5467:                    } else if (expectEvolved) {
5468:                        checkRawFields(obj, "key", 99, "addAnnotation", 88,
5469:                                "dropAnnotation", 66, "aa", 33, "ff", 22);
5470:                    } else {
5471:                        checkRawFields(obj, "key", 99, "addAnnotation", 88,
5472:                                "dropField", 77, "dropAnnotation", 66, "aa",
5473:                                33, "ff", 22);
5474:                    }
5475:                    Environment env = store.getEnvironment();
5476:                    assertDbExists(expectEvolved, env, NAME, "addAnnotation");
5477:                    assertDbExists(expectEvolved, env, NAME, "addField");
5478:                    assertDbExists(!expectEvolved, env, NAME, "dropField");
5479:                    assertDbExists(!expectEvolved, env, NAME, "dropAnnotation");
5480:                }
5481:            }
5482:
5483:            /** [#15524] */
5484:            @Entity(version=1)
5485:            static class AllowAddSecondary extends EvolveCase {
5486:
5487:                private static final String NAME = AllowAddSecondary.class
5488:                        .getName();
5489:
5490:                @PrimaryKey
5491:                long key;
5492:
5493:                @SecondaryKey(relate=ONE_TO_ONE)
5494:                int a;
5495:
5496:                @SecondaryKey(relate=ONE_TO_ONE)
5497:                int b;
5498:
5499:                @Override
5500:                void checkEvolvedModel(EntityModel model, Environment env,
5501:                        boolean oldTypesExist) {
5502:                    checkEntity(true, model, env, NAME, 1, null);
5503:                    if (oldTypesExist) {
5504:                        checkVersions(model, NAME, 1, NAME, 0);
5505:                    } else {
5506:                        checkVersions(model, NAME, 1);
5507:                    }
5508:                }
5509:
5510:                @Override
5511:                void readObjects(EntityStore store, boolean doUpdate)
5512:                        throws DatabaseException {
5513:
5514:                    PrimaryIndex<Long, AllowAddSecondary> index = store
5515:                            .getPrimaryIndex(Long.class,
5516:                                    AllowAddSecondary.class);
5517:                    AllowAddSecondary obj = index.get(99L);
5518:                    checkValues(obj);
5519:
5520:                    checkValues(store.getSecondaryIndex(index, Integer.class,
5521:                            "a").get(1));
5522:                    if (updated) {
5523:                        checkValues(store.getSecondaryIndex(index,
5524:                                Integer.class, "b").get(3));
5525:                        TestCase.assertNull(store.getSecondaryIndex(index,
5526:                                Integer.class, "b").get(2));
5527:                    } else {
5528:                        checkValues(store.getSecondaryIndex(index,
5529:                                Integer.class, "b").get(2));
5530:                        TestCase.assertNull(store.getSecondaryIndex(index,
5531:                                Integer.class, "b").get(3));
5532:                    }
5533:
5534:                    if (doUpdate) {
5535:                        obj.b = 3;
5536:                        index.put(obj);
5537:                        updated = true;
5538:                        checkValues(store.getSecondaryIndex(index,
5539:                                Integer.class, "a").get(1));
5540:                        checkValues(store.getSecondaryIndex(index,
5541:                                Integer.class, "b").get(3));
5542:                    }
5543:                }
5544:
5545:                @Override
5546:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
5547:                        throws DatabaseException {
5548:
5549:                    PrimaryIndex<Long, AllowAddSecondary> index = newStore
5550:                            .getPrimaryIndex(Long.class,
5551:                                    AllowAddSecondary.class);
5552:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99L);
5553:                    index.put((AllowAddSecondary) newStore.getModel()
5554:                            .convertRawObject(raw));
5555:                }
5556:
5557:                private void checkValues(AllowAddSecondary obj) {
5558:                    TestCase.assertNotNull(obj);
5559:                    TestCase.assertEquals(99L, obj.key);
5560:                    TestCase.assertEquals(1, obj.a);
5561:                    if (updated) {
5562:                        TestCase.assertEquals(3, obj.b);
5563:                    } else {
5564:                        TestCase.assertEquals(2, obj.b);
5565:                    }
5566:                }
5567:
5568:                @Override
5569:                void readRawObjects(RawStore store, boolean expectEvolved,
5570:                        boolean expectUpdated) throws DatabaseException {
5571:
5572:                    RawObject obj = readRaw(store, 99L, NAME, expectEvolved ? 1
5573:                            : 0, CASECLS, 0);
5574:                    if (expectUpdated) {
5575:                        checkRawFields(obj, "key", 99L, "a", 1, "b", 3);
5576:                    } else {
5577:                        checkRawFields(obj, "key", 99L, "a", 1, "b", 2);
5578:                    }
5579:                    Environment env = store.getEnvironment();
5580:                    assertDbExists(expectEvolved, env, NAME, "a");
5581:                    assertDbExists(expectEvolved, env, NAME, "b");
5582:                }
5583:            }
5584:
5585:            @Entity(version=1)
5586:            static class FieldAddAndConvert extends EvolveCase {
5587:
5588:                private static final String NAME = FieldAddAndConvert.class
5589:                        .getName();
5590:
5591:                @PrimaryKey
5592:                int key;
5593:
5594:                private String f0 = "0"; // new field
5595:                private String f1 = "1"; // converted field
5596:                private String f2 = "2"; // new field
5597:                private String f3 = "3"; // converted field
5598:                private String f4 = "4"; // new field
5599:
5600:                @Override
5601:                Mutations getMutations() {
5602:                    Mutations m = new Mutations();
5603:                    m.addConverter(new Converter(NAME, 0, "f1",
5604:                            new IntToString()));
5605:                    m.addConverter(new Converter(NAME, 0, "f3",
5606:                            new IntToString()));
5607:                    return m;
5608:                }
5609:
5610:                private static class IntToString implements  Conversion {
5611:
5612:                    public void initialize(EntityModel model) {
5613:                    }
5614:
5615:                    public Object convert(Object fromValue) {
5616:                        return fromValue.toString();
5617:                    }
5618:
5619:                    @Override
5620:                    public boolean equals(Object other) {
5621:                        return other instanceof  IntToString;
5622:                    }
5623:                }
5624:
5625:                @Override
5626:                void checkEvolvedModel(EntityModel model, Environment env,
5627:                        boolean oldTypesExist) {
5628:                    checkEntity(true, model, env, NAME, 1, null);
5629:                    if (oldTypesExist) {
5630:                        checkVersions(model, NAME, 1, NAME, 0);
5631:                    } else {
5632:                        checkVersions(model, NAME, 1);
5633:                    }
5634:                }
5635:
5636:                @Override
5637:                void readObjects(EntityStore store, boolean doUpdate)
5638:                        throws DatabaseException {
5639:
5640:                    PrimaryIndex<Integer, FieldAddAndConvert> index = store
5641:                            .getPrimaryIndex(Integer.class,
5642:                                    FieldAddAndConvert.class);
5643:                    FieldAddAndConvert obj = index.get(99);
5644:                    TestCase.assertNotNull(obj);
5645:                    TestCase.assertEquals(99, obj.key);
5646:                    TestCase.assertEquals("0", obj.f0);
5647:                    TestCase.assertEquals("1", obj.f1);
5648:                    TestCase.assertEquals("2", obj.f2);
5649:                    TestCase.assertEquals("3", obj.f3);
5650:                    TestCase.assertEquals("4", obj.f4);
5651:
5652:                    if (doUpdate) {
5653:                        index.put(obj);
5654:                    }
5655:                }
5656:
5657:                @Override
5658:                void copyRawObjects(RawStore rawStore, EntityStore newStore)
5659:                        throws DatabaseException {
5660:
5661:                    PrimaryIndex<Integer, FieldAddAndConvert> index = newStore
5662:                            .getPrimaryIndex(Integer.class,
5663:                                    FieldAddAndConvert.class);
5664:                    RawObject raw = rawStore.getPrimaryIndex(NAME).get(99);
5665:                    index.put((FieldAddAndConvert) newStore.getModel()
5666:                            .convertRawObject(raw));
5667:                }
5668:
5669:                @Override
5670:                void readRawObjects(RawStore store, boolean expectEvolved,
5671:                        boolean expectUpdated) throws DatabaseException {
5672:
5673:                    RawObject obj = readRaw(store, 99, NAME, expectEvolved ? 1
5674:                            : 0, CASECLS, 0);
5675:                    if (expectUpdated) {
5676:                        checkRawFields(obj, "key", 99, "f0", "0", "f1", "1",
5677:                                "f2", "2", "f3", "3", "f4", "4");
5678:                    } else if (expectEvolved) {
5679:                        checkRawFields(obj, "key", 99, "f1", "1", "f3", "3");
5680:                    } else {
5681:                        checkRawFields(obj, "key", 99, "f1", 1, "f3", 3);
5682:                    }
5683:                }
5684:            }
5685:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.