001: /*-
002: * See the file LICENSE for redistribution information.
003: *
004: * Copyright (c) 2000,2008 Oracle. All rights reserved.
005: *
006: * $Id: TestVersionCompatibility.java,v 1.1.2.5 2008/01/07 15:14:35 cwl Exp $
007: */
008: package com.sleepycat.persist.test;
009:
010: import java.io.IOException;
011: import java.util.Enumeration;
012:
013: import junit.framework.Test;
014: import junit.framework.TestSuite;
015:
016: /**
017: * Test that the catalog and data records created with a different version of
018: * the DPL are compatible with this version. This test is run as follows:
019: *
020: * 1) Run EvolveTest with version X of JE. For example:
021: *
022: * cd /jeX
023: * ant -Dtestcase=com.sleepycat.persist.test.EvolveTest test
024: * or
025: * ant -Dsuite=persist/test test
026: * or
027: * ant test
028: *
029: * Step (1) leaves the log files from all tests in the testevolve directory.
030: *
031: * 2) Run TestVersionCompatibility with version Y of JE, passing the JE
032: * testevolve directory from step (1). For example:
033: *
034: * cd /jeY
035: * ant -Dtestcase=com.sleepycat.persist.test.TestVersionCompatibility \
036: * -Dunittest.testevolvedir=/jeX/build/test/testevolve \
037: * test
038: *
039: * Currently there are 2 sets of X and Y that can be tested, one set for the
040: * CVS branch and one for the CVS trunk:
041: *
042: * CVS Version X Version Y
043: * branch je-3_2_56 je-3_2_57 or greater
044: * trunk je-3_3_41 je-3_3_42 or greater
045: *
046: * This test is not run along with the regular JE test suite run, because the
047: * class name does not end with Test. It must be run separately as described
048: * above.
049: *
050: * @author Mark Hayes
051: */
052: public class TestVersionCompatibility extends EvolveTestBase {
053:
054: public static Test suite() throws Exception {
055:
056: /*
057: * Run TestVersionCompatibility tests first to check previously evolved
058: * data without changing it. Then run the EvolveTest to try evolving
059: * it.
060: */
061: TestSuite suite = new TestSuite();
062: Enumeration e = getSuite(TestVersionCompatibility.class)
063: .tests();
064: while (e.hasMoreElements()) {
065: EvolveTestBase test = (EvolveTestBase) e.nextElement();
066: if (test.getTestInitHome(true /*evolved*/).exists()) {
067: suite.addTest(test);
068: }
069: }
070: e = getSuite(EvolveTest.class).tests();
071: while (e.hasMoreElements()) {
072: EvolveTestBase test = (EvolveTestBase) e.nextElement();
073: if (test.getTestInitHome(true /*evolved*/).exists()) {
074: suite.addTest(test);
075: }
076: }
077: return suite;
078: }
079:
080: boolean useEvolvedClass() {
081: return true;
082: }
083:
084: @Override
085: public void setUp() throws IOException {
086:
087: envHome = getTestInitHome(true /*evolved*/);
088: }
089:
090: public void testPreviouslyEvolved() throws Exception {
091:
092: /* If the store cannot be opened, this test is not appropriate. */
093: if (caseObj.getStoreOpenException() != null) {
094: return;
095: }
096:
097: /* The update occurred previously. */
098: caseObj.updated = true;
099:
100: openEnv();
101:
102: /* Open read-only and double check that everything is OK. */
103: openStoreReadOnly();
104: caseObj
105: .checkEvolvedModel(store.getModel(), env, true /*oldTypesExist*/);
106: caseObj.readObjects(store, false /*doUpdate*/);
107: caseObj
108: .checkEvolvedModel(store.getModel(), env, true /*oldTypesExist*/);
109: closeStore();
110:
111: /* Check raw objects. */
112: openRawStore();
113: caseObj
114: .checkEvolvedModel(rawStore.getModel(), env, true /*oldTypesExist*/);
115: caseObj
116: .readRawObjects(rawStore, true /*expectEvolved*/, true /*expectUpdated*/);
117: closeRawStore();
118:
119: closeAll();
120: }
121: }
|