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

📄 t_rawstorefactory.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	*/	protected void T000() throws T_Fail, StandardException {		Transaction t1 = t_util.t_startTransaction();		t1.close();		t1 = t_util.t_startInternalTransaction();		t1.close();		t1 = t_util.t_startTransaction();		Transaction ti = t_util.t_startInternalTransaction();		ti.close();		t1.close();		PASS("T000");	}	/**		T001 - start and commit an empty transaction.		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T001() throws T_Fail, StandardException {		Transaction t1 = t_util.t_startTransaction();		t_util.t_commit(t1);		t1.close();		PASS("T001");	}	/**		T002 - start and abort an empty transaction.		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T002() throws T_Fail, StandardException {		Transaction t1 = t_util.t_startTransaction();		t_util.t_abort(t1);		t1.close();		PASS("T002");	}	/**		T003 - start and commit an empty transaction and then ensure		that the transaction remains open for another commit.		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T003() throws T_Fail, StandardException {		Transaction t1 = t_util.t_startTransaction();		t_util.t_commit(t1);		t_util.t_commit(t1);		t_util.t_abort(t1);		t1.close();		PASS("T003");	}	/**		T004 - start and abort an empty transaction and then ensure		that the transaction remains open for a commit and another abort.		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T004() throws T_Fail, StandardException {		Transaction t1 = t_util.t_startTransaction();		t_util.t_abort(t1);		t_util.t_commit(t1);		t_util.t_abort(t1);		t1.close();		PASS("T004");	}	/**		T005 check transaction identifiers on idle transactions.		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T005() throws T_Fail, StandardException {		Transaction t1 = t_util.t_startTransaction();        // local transactions do not have global id's		GlobalTransactionId id1 = t1.getGlobalId();		if (id1 != null)			throw T_Fail.testFailMsg("null not returned from local Transaction.getId()");        t1.close();        byte[] global_id =             { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,             10, 11, 12, 13, 14, 15, 16, 17, 18, 19,             20, 21, 22, 23, 24, 25, 26, 27, 28, 29,             30, 31, 32, 33, 34, 35, 36, 37, 38, 39,             40, 41, 42, 44, 44, 45, 46, 47, 48, 49,             50, 51, 52, 53, 54, 55, 56, 57, 58, 59,             60, 61, 62, 63};        byte[] branch_id =             { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,             10, 11, 12, 13, 14, 15, 16, 17, 18, 19,             20, 21, 22, 23, 24, 25, 26, 27, 28, 29,             30, 31, 32, 33, 34, 35, 36, 37, 38, 39,             40, 41, 42, 44, 44, 45, 46, 47, 48, 49,             50, 51, 52, 53, 54, 55, 56, 57, 58, 59,             60, 61, 62, 63};        t1 = t_util.t_startGlobalTransaction(42, global_id, branch_id);        id1 = t1.getGlobalId();		if (!id1.equals(id1))			throw T_Fail.testFailMsg("TransactionId does not compare equal to itself");		if (!id1.equals(t1.getGlobalId()))			throw T_Fail.testFailMsg("TransactionId has changed without any activity on Transaction");		if (id1.equals(this))			throw T_Fail.testFailMsg("TransactionId compared equal to an non-transaction id object");		t1.close();		t1 = null;        // change the branch_id for the second global xact.        branch_id[63] = 82;		Transaction t2 =             t_util.t_startGlobalTransaction(42, global_id, branch_id);		GlobalTransactionId id2 = t2.getGlobalId();		if (id2 == null)			throw T_Fail.testFailMsg("null returned from Transaction.getId()");		if (id1.equals(id2))			throw T_Fail.testFailMsg("TransactionId's returned equal from different transactions");		if (id2.equals(id1))			throw T_Fail.testFailMsg("TransactionId's returned equal from different transactions");		t2.close();		PASS("T005");	}	/**		T006 - savepoint basic API testing		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T006() throws T_Fail, StandardException {			Transaction t1 = t_util.t_startTransaction();		// check a random savepoint name is not accepted		t_util.t_checkInvalidSavePoint(t1, "sdfjsdfg");		t1.setSavePoint(SP1, null);		t1.rollbackToSavePoint(SP1, null);	// leaves savepoint around		t1.rollbackToSavePoint(SP1, null);	// therefore this should work		t1.releaseSavePoint(SP1, null);		// SP1 should no longer exist		t_util.t_checkInvalidSavePoint(t1, SP1);		// should be able to re-use it ...		t1.setSavePoint(SP1, null);		t1.rollbackToSavePoint(SP1, null);	// leaves savepoint around		t1.rollbackToSavePoint(SP1, null);	// therefore this should work		t1.releaseSavePoint(SP1, null);		t_util.t_checkInvalidSavePoint(t1, SP1);		t_util.t_commit(t1);		t1.close();		PASS("T006");	}	/**		T007 - savepoint nesting testing		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T007() throws T_Fail, StandardException {			Transaction t1 = t_util.t_startTransaction();		int position = 0;		/*		** Push two save points and release the first, both should disappear		*/		t1.setSavePoint(SP1, null);		t1.setSavePoint(SP2, null);		position = t1.releaseSavePoint(SP1, null);		if (position  != 0)			throw T_Fail.testFailMsg("Save Point Position in the stack isincorrect:"+									 position);		// SP1 and SP2 should no longer exist		t_util.t_checkInvalidSavePoint(t1, SP1);		t_util.t_checkInvalidSavePoint(t1, SP2);		/*		** Push two save points and remove the second, first should remain		*/		t1.setSavePoint(SP1, null);		t1.setSavePoint(SP2, null);		t1.rollbackToSavePoint(SP2, null);	// leaves savepoint around		position = t1.rollbackToSavePoint(SP2, null);	// therefore this should work				if (position  != 2)			throw T_Fail.testFailMsg("Save Point Position in the stack isincorrect:"+									 position);		position = t1.releaseSavePoint(SP2, null);		if (position  != 1)			throw T_Fail.testFailMsg("Save Point Position in the stack is incorrect:"+									 position);		t_util.t_checkInvalidSavePoint(t1, SP2);		t1.rollbackToSavePoint(SP1, null);	// this is the main test		t1.releaseSavePoint(SP1, null);		t_util.t_checkInvalidSavePoint(t1, SP1);		/*		** Push two save points and rollback to the first, the second should disappear		*/		t1.setSavePoint(SP1, null);		t1.setSavePoint(SP2, null);		position = t1.rollbackToSavePoint(SP1, null);	// leaves SP1, removes SP2		if (position  != 1)			throw T_Fail.testFailMsg("Save Point Position in the stack is incorrect:"+												 position);				t_util.t_checkInvalidSavePoint(t1, SP2);		t1.rollbackToSavePoint(SP1, null);		t1.releaseSavePoint(SP1, null);		t_util.t_commit(t1);		t1.close();		PASS("T007");	}	/**		T008 - savepoint  testing, ensure save points disappear at commit or abort.		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T008() throws T_Fail, StandardException {			Transaction t1 = t_util.t_startTransaction();		int position1 = 0;		int position2 = 0;		position1 = t1.setSavePoint(SP1, null);		position2 = t1.setSavePoint(SP2, null);		if (position1 != 1 && position2 != 2)			throw T_Fail.testFailMsg("Save Point Position in the Stack seeme to wrong");		t1.commit();		t_util.t_checkInvalidSavePoint(t1, SP1);		t_util.t_checkInvalidSavePoint(t1, SP2);		position1 = t1.setSavePoint(SP1, null);		position2 = t1.setSavePoint(SP2, null);				if (position1 != 1 && position2 != 2)			throw T_Fail.testFailMsg("Save Point Position in the Stack seeme to wrong");		t1.abort();		position1 = t1.setSavePoint(SP1, null);		position2 = t1.setSavePoint(SP2, null);		if (position1 != 1 && position2 != 2)			throw T_Fail.testFailMsg("Save Point Position in the Stack seeme to wrong");		t1.abort();		t_util.t_checkInvalidSavePoint(t1, SP1);		t_util.t_checkInvalidSavePoint(t1, SP2);		t1.close();		PASS("T008");	}	/**		T009 - add a container and remove it within the same transaction.		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T009() throws StandardException, T_Fail {		Transaction t = t_util.t_startTransaction();		long cid = t_util.t_addContainer(t, 0, 4096);		t_util.t_dropContainer(t, 0, cid);		ContainerKey id = new ContainerKey(0, cid);		ContainerHandle ch = t.openContainer(id, ContainerHandle.MODE_READONLY);		if (ch != null)			throw T_Fail.testFailMsg("Dropped Container should not open");		t_util.t_commit(t);		t.close();		PASS("T009");	}	/**		T010 - add a container with a default size and remove it within the same transaction.		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T010() throws StandardException, T_Fail {		Transaction t1 = t_util.t_startTransaction();		long cid = t_util.t_addContainer(t1, 0);		t_util.t_dropContainer(t1, 0, cid);		ContainerKey id = new ContainerKey(0, cid);		ContainerHandle ch = t1.openContainer(id, ContainerHandle.MODE_READONLY);		if (ch != null)			throw T_Fail.testFailMsg("Dropped Container should not open");		t_util.t_commit(t1);		t1.close();		PASS("T010");	}	/**		T011 - see that a container remains open over the commit of an open transaction..		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T011() throws StandardException, T_Fail {		Transaction t = t_util.t_startInternalTransaction();		long cid = t_util.t_addContainer(t, 0);		ContainerHandle c;		c = t_util.t_openContainer(t, 0, cid, true);		t.commit();		// container should still be open		Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);		t.commit();		// page should still be latched		if (!page.isLatched())			throw T_Fail.testFailMsg("page not latched after commit of internal transaction");		page.unlatch();		c.close();		t.commit();		c = t_util.t_openContainer(t, 0, cid, true);		page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);		// container and page should be closed		t.abort();		if (page.isLatched())			throw T_Fail.testFailMsg("page latched after abort of internal transaction");		try {			page = t_util.t_getLastPage(c);			throw T_Fail.testFailMsg("container open after abort of internal transaction");		} catch (StandardException te) {		}		t_util.t_dropContainer(t, 0, cid);	// cleanup		t_util.t_commit(t);		t.close();		PASS("T011");		}	/**		Test Xact.makeRecordHandle()		@exception T_Fail Unexpected behaviour from the API		@exception StandardException Unexpected exception from the implementation	*/	protected void T012() throws StandardException, T_Fail {		Transaction t = t_util.t_startTransaction();				long cid = t_util.t_addContainer(t, 0);		ContainerHandle c = t_util.t_openContainer(t, 0, cid, true);		Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);		RecordHandle r1, r2;		RecordHandle new_r1, new_r2;		T_RawStoreRow row1 = new T_RawStoreRow(REC_001);		T_RawStoreRow row2 = new T_RawStoreRow(REC_002);		r1 = t_util.t_insertAtSlot(page, 0, row1);        new_r1 = c.makeRecordHandle(r1.getPageNumber(), r1.getId());		t_util.t_checkFetch(page, new_r1, REC_001);		r2 = t_util.t_insertAtSlot(page, 1, row2);		if (r2 != null)        {            new_r2 =                 c.makeRecordHandle(r2.getPageNumber(), r2.getId());			t_util.t_checkFetch(page, r2, REC_002);        }

⌨️ 快捷键说明

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