⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_rawstorefactory.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*   Derby - Class org.apache.derbyTesting.unitTests.store.T_RawStoreFactory   Copyright 1997, 2005 The Apache Software Foundation or its licensors, as applicable.   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License. */package org.apache.derbyTesting.unitTests.store;import org.apache.derby.iapi.store.raw.*;// impl imports are the preferred way to create unit tests.import org.apache.derbyTesting.unitTests.harness.T_MultiThreadedIterations;import org.apache.derbyTesting.unitTests.harness.T_Fail;import org.apache.derby.iapi.services.context.ContextService;import org.apache.derby.iapi.services.context.ContextManager;import org.apache.derby.iapi.services.locks.*;import org.apache.derby.iapi.services.monitor.Monitor;import org.apache.derby.iapi.services.sanity.SanityManager;import org.apache.derby.iapi.services.uuid.UUIDFactory;import org.apache.derby.catalog.UUID;import org.apache.derby.iapi.services.property.PropertyUtil;import org.apache.derby.iapi.error.ExceptionSeverity;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.store.access.*;import org.apache.derby.iapi.store.access.conglomerate.LogicalUndo;import org.apache.derby.iapi.store.raw.xact.RawTransaction;import org.apache.derby.iapi.store.raw.data.RawContainerHandle;import org.apache.derby.iapi.store.raw.log.LogInstant;import org.apache.derby.iapi.types.DataValueDescriptor;// impl a logInstant implemented as log counter to test truncateLWMsimport org.apache.derby.impl.store.raw.log.LogCounter;import org.apache.derby.iapi.types.SQLChar;import org.apache.derby.iapi.reference.Property;import org.apache.derby.iapi.services.io.FormatableBitSet;import java.io.*;import java.util.Properties;/**	A protocol unit test for the RawStore interface.*/public class T_RawStoreFactory extends T_MultiThreadedIterations {	static protected final String REC_001 = "McLaren";	static protected final String REC_002 = "Ferrari";	static protected final String REC_003 = "Benetton";	static protected final String REC_004 = "Prost";	static protected final String REC_005 = "Tyrell";	static protected final String REC_006 = "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";	static protected final String REC_007 = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";	static protected final String REC_008 = "z";	static protected final String REC_009 = "nanonano";	static protected final String REC_010 = "fuzzbutt";	static protected final String REC_011 = "mork";	static protected final String REC_012 = "orson";	static protected final String REC_013 = "mindy";	static protected final String REC_014 = "thomas";	static protected final String REC_015 = "henry";	static protected final String REC_016 = "gordon";	static protected final String REC_017 = "mavis";	static protected final String REC_018 = "fatcontroller";	static protected final String REC_UNDO = "Lotus";	static protected final String REC_NULL = "NULL";	static final FormatableBitSet BS_COL_0 = new FormatableBitSet(1);	static protected final String SP1 = "savepoint1";	static protected final String SP2 = "savepoint2";	private static final String TEST_ROLLBACK_OFF = "derby.RawStore.RollbackTestOff";	private static boolean testRollbackProperty;// initialize in start	static protected boolean testRollback; // each thread has its own test rollback value	static protected RawStoreFactory	factory;	static protected LockFactory  lf;	static protected ContextService contextService;	static protected UUIDFactory uuidfactory;	protected  T_Util t_util;	protected int    openMode;	// mode flags used in all open containers.	protected boolean logDataForPurges = true; //used to test non-logged data purges	public T_RawStoreFactory() {		super();		BS_COL_0.set(0);	}	/**	  @exception StandardException cannot startup the context service	*/	public void boot(boolean create, Properties startParams)		 throws StandardException	{		super.boot(create, startParams);		contextService = ContextService.getFactory();	}	/*	** Methods required by T_Generic	*/	protected String getModuleToTestProtocolName() {		return RawStoreFactory.MODULE;	}	/**		Set up test		@exception T_Fail Unexpected behaviour from the API	 */	protected void setupTest() throws T_Fail {				String rollbackOff = PropertyUtil.getSystemProperty(TEST_ROLLBACK_OFF);		testRollback = !Boolean.valueOf(rollbackOff).booleanValue();		testRollbackProperty = testRollback; // testRollbackProperty never changes		// don't automatic boot this service if it gets left around		if (startParams == null) {			startParams = new Properties();		}		startParams.put(Property.NO_AUTO_BOOT, Boolean.TRUE.toString());		// remove the service directory to ensure a clean run		startParams.put(Property.DELETE_ON_CREATE, Boolean.TRUE.toString());		// see if we are testing encryption		startParams = T_Util.setEncryptionParam(startParams);		try {			factory = (RawStoreFactory) Monitor.createPersistentService(getModuleToTestProtocolName(),								getTestService(), startParams);			if (factory == null) {				throw T_Fail.testFailMsg(getModuleToTestProtocolName() + " service not started.");			}			lf = factory.getLockFactory();			if (lf == null) {				throw T_Fail.testFailMsg("LockFactory.MODULE not found");			}			uuidfactory = Monitor.getMonitor().getUUIDFactory();		} catch (StandardException mse) {			throw T_Fail.exceptionFail(mse);		}		REPORT("testRollback=" + testRollback);		return;	}	protected String getTestService()	{		return "rawStoreTest";	}	/**	 * T_MultiThreadedIteration method	 *	 * @exception T_Fail Unexpected behaviour from the API	 */	protected void joinSetupTest() throws T_Fail {		T_Fail.T_ASSERT(factory != null, "raw store factory not setup ");		T_Fail.T_ASSERT(lf != null, "Lock factory not setup ");		T_Fail.T_ASSERT(contextService != null, "Context service not setup ");		testRollback = testRollbackProperty;	}	protected T_MultiThreadedIterations newTestObject() {		try		{			Class thisClass = this.getClass();			return (T_MultiThreadedIterations)(thisClass.newInstance());		}		catch (InstantiationException ie)		{			return new T_RawStoreFactory();		}			catch (IllegalAccessException iae)		{			return new T_RawStoreFactory();		}	}		/**	  run the test	  @exception T_Fail Unexpected behaviour from the API	*/	protected void runTestSet() throws T_Fail {		// get a utility helper		t_util = new T_Util(factory, lf, contextService);		ContextManager cm1 = contextService.newContextManager();		contextService.setCurrentContextManager(cm1);		try {			// Run the tests with data not logged for purges.			REPORT("Running tests with no data logged  for purges");			openMode = 0;		// logged by default			runPurgeWithNoDataLoggesTests();			// Run the tests in normal logged mode			REPORT("Running tests with logging requested");			openMode = 0;		// logged by default			runEachTest();						// run the tests on temp tables			REPORT("Running tests for temp tables");			testRollback = false;	// obviously, we can't test rollback if we are not logging			runTempTests();			// Run the tests in unlogged mode			REPORT("Running tests in unlogged mode");			openMode = ContainerHandle.MODE_UNLOGGED | ContainerHandle.MODE_CREATE_UNLOGGED;			testRollback = false;	// obviously, we can't test rollback if we are not logging			runEachTest();			// if more runs are added here then you probably want to reset testRollback to			// its initial value, or add the runs before the unlogged mode.		} catch (StandardException se) {			cm1.cleanupOnError(se);			throw T_Fail.exceptionFail(se);		}		finally {			contextService.resetCurrentContextManager(cm1);		}	}	protected void runEachTest() throws T_Fail, StandardException {		t_util.setOpenMode(openMode);		// Transaction tests 		T000();		T001();		T002();		T003();		T004();		T005();		T006();		T007();		T008();		T009();		T010();		T011();        T012();		// ContainerHandle tests		C010(0);		C011();		C012(1);		C014();		C200();		C201(0);		C201(1);		// Page tests		P001(0);		P002(0);		P003(0);		P004(0);		P005(0);		P006();		P007(0);		P008(0);		P009(0);		P011(0);		P012(0);		P013();		P014();		P015();		P016();		P017();		P018();		P019();		// test addPage with preallocation turned on		P020();		// test createContainer with initialPage set to 10 pages		P021();		// test preAllocate		P022();		P023(0);	// overflowThreshold test		// long row tests		P030(0);		P031(0);		P032(0);		P033(0);		P034(0);		P035(0);	// long column test		//run  the following test because they do lot of checks 		//on rollbacking when contyainer is unlogged nothing is rolled back		if((openMode & ContainerHandle.MODE_UNLOGGED) ==  ContainerHandle.MODE_UNLOGGED)		{			openMode = 0; //run them as logged for time being			t_util.setOpenMode(openMode);		} 		// reclaiming space from long column and long rows - temp container		// row space is not reclaimed.		P036();		P037();		P038();		P039();		P040();		P041();		P042();		P043();		P050(); // rollback tests		P051();		P052();		P053();		P054();        P055(0);        P056(0);		P061(); // sparse row test        P071(); // serializable column test		// update/update partial tests with long rows		P701(0);        P702(0);		P703(0);		P704(0);		P705(0);		P706(0, false);		P706(0, true);		P707(0);		P708(0, false);		P708(0, true);		L001();	// large log record test		// checkpoint test		CP001();	}	protected void runTempTests() throws T_Fail, StandardException {		REPORT("Thread " + threadNumber + " entering temp tests ");		openMode = 0;			// logged by default		t_util.setOpenMode(openMode);	// logged mode should be overriden for temp tables		// now tests for temporary tables		C010(ContainerHandle.TEMPORARY_SEGMENT);		C012(ContainerHandle.TEMPORARY_SEGMENT);		//P001(ContainerHandle.TEMPORARY_SEGMENT);		//P002(ContainerHandle.TEMPORARY_SEGMENT);		P003(ContainerHandle.TEMPORARY_SEGMENT);		P004(ContainerHandle.TEMPORARY_SEGMENT);		P005(ContainerHandle.TEMPORARY_SEGMENT);		P011(ContainerHandle.TEMPORARY_SEGMENT);		P012(ContainerHandle.TEMPORARY_SEGMENT);		P030(ContainerHandle.TEMPORARY_SEGMENT);		// update/update partial tests with long rows		P055(ContainerHandle.TEMPORARY_SEGMENT);		P056(ContainerHandle.TEMPORARY_SEGMENT);		P701(ContainerHandle.TEMPORARY_SEGMENT);		P702(ContainerHandle.TEMPORARY_SEGMENT);		P703(ContainerHandle.TEMPORARY_SEGMENT);		P704(ContainerHandle.TEMPORARY_SEGMENT);		P705(ContainerHandle.TEMPORARY_SEGMENT);		P706(ContainerHandle.TEMPORARY_SEGMENT, false);		P706(ContainerHandle.TEMPORARY_SEGMENT, true);		P707(ContainerHandle.TEMPORARY_SEGMENT);		// tests specific to temp tables		// checking truncate at commit/rollback works		TC001();		TC002(ContainerHandle.MODE_TRUNCATE_ON_COMMIT, true);		TC002(ContainerHandle.MODE_TRUNCATE_ON_COMMIT, false);		TC002(0, false);		// checking an explict drop works ...		TC003(ContainerHandle.MODE_TRUNCATE_ON_COMMIT, true);		TC003(ContainerHandle.MODE_TRUNCATE_ON_COMMIT, false);		TC003(0, false);		TC003(0, true);		TC003(ContainerHandle.MODE_DROP_ON_COMMIT, true);		TC003(ContainerHandle.MODE_DROP_ON_COMMIT, false);		// various combinations of opens ...		TC004all();		REPORT("Thread " + threadNumber + " exiting temp tests "); 	}	protected void runPurgeWithNoDataLoggesTests() throws T_Fail, StandardException {		REPORT("Thread " + threadNumber + " entering purges with no data logged tests ");		logDataForPurges = false;		P005(0);		P006();		P014();		P036();		P037();		P709();		P710();		P711();		REPORT("Thread " + threadNumber + " exiting purge with no data logged tests ");		logDataForPurges = true;	}	/*	** The tests	**		Tnnn indicates a test that is mainly testing the Transaction interface	**		Cnnn indicates a test that is mainly testing the ContainerHandle interface	**		Pnnn indicates a test that is mainly testing the Page interface	**	**	nnn < 200 tends to indicate purely API tests, ie checking methods	**		are callable and return the right value. This includes negative tests.	**	**  nnn >= 200 tends to indicate more involved tests, ie ones that test the	**			methods actually did something.	*/	/**		T000 - ensure a transaction starts out idle.		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -