001: /*
002:
003: Derby - Class org.apache.derbyTesting.unitTests.store.T_Heap
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derbyTesting.unitTests.store;
023:
024: // impl imports are the preferred way to create unit tests.
025: import org.apache.derbyTesting.unitTests.harness.T_Generic;
026: import org.apache.derbyTesting.unitTests.harness.T_Fail;
027:
028: import org.apache.derby.impl.store.access.heap.*;
029:
030: import java.util.Properties;
031:
032: import java.io.PrintWriter;
033:
034: import org.apache.derby.iapi.services.context.ContextService;
035:
036: import org.apache.derby.iapi.services.monitor.Monitor;
037: import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
038:
039: import org.apache.derby.iapi.error.StandardException;
040: import org.apache.derby.iapi.store.access.AccessFactory;
041: import org.apache.derby.iapi.store.access.ConglomerateController;
042: import org.apache.derby.iapi.store.access.Qualifier;
043: import org.apache.derby.iapi.types.RowLocation;
044: import org.apache.derby.iapi.store.access.ScanController;
045: import org.apache.derby.iapi.store.access.TransactionController;
046:
047: import org.apache.derby.iapi.reference.Property;
048:
049: import java.util.Properties;
050:
051: public class T_Heap extends T_Generic {
052: private static final String testService = "heapTest";
053:
054: /*
055: ** Methods required by T_Generic
056: */
057:
058: public String getModuleToTestProtocolName() {
059: return AccessFactory.MODULE;
060: }
061:
062: /**
063: @exception T_Fail test failed.
064: */
065: protected void runTests() throws T_Fail {
066: AccessFactory store = null;
067: TransactionController tc = null;
068: boolean pass = false;
069:
070: out.println("executing heap test");
071:
072: // don't automatic boot this service if it gets left around
073: if (startParams == null) {
074: startParams = new Properties();
075: }
076: startParams.put(Property.NO_AUTO_BOOT, Boolean.TRUE.toString());
077: // remove the service directory to ensure a clean run
078: startParams.put(Property.DELETE_ON_CREATE, Boolean.TRUE
079: .toString());
080:
081: // see if we are testing encryption
082: startParams = T_Util.setEncryptionParam(startParams);
083:
084: try {
085: store = (AccessFactory) Monitor.createPersistentService(
086: getModuleToTestProtocolName(), testService,
087: startParams);
088: } catch (StandardException mse) {
089: throw T_Fail.exceptionFail(mse);
090: }
091:
092: if (store == null) {
093: throw T_Fail.testFailMsg(getModuleToTestProtocolName()
094: + " service not started.");
095: }
096: REPORT("(unitTestMain) Testing " + testService);
097:
098: try {
099:
100: tc = store.getTransaction(ContextService.getFactory()
101: .getCurrentContextManager());
102:
103: if (t_001(tc)) {
104: pass = true;
105: }
106:
107: tc.commit();
108: tc.destroy();
109: } catch (StandardException e) {
110: System.out.println("got an exception.");
111: String msg = e.getMessage();
112: if (msg == null)
113: msg = e.getClass().getName();
114: REPORT(msg);
115: throw T_Fail.exceptionFail(e);
116: }
117:
118: if (!pass)
119: throw T_Fail.testFailMsg("T_Heap test failed");
120: }
121:
122: /*
123: * Test Qualifiers.
124: */
125: protected boolean t_001(TransactionController tc)
126: throws StandardException, T_Fail {
127: REPORT("Starting t_001");
128:
129: T_QualifierTest q_test = new T_QualifierTest("heap", // create a heap
130: null, // properties
131: false, // not temporary
132: out, T_QualifierTest.ORDER_NONE); // unordered data
133:
134: boolean test_result = q_test.t_testqual(tc);
135:
136: if (!test_result)
137: throw T_Fail.testFailMsg("T_Heap.t_001 failed");
138:
139: REPORT("Ending t_001");
140:
141: return (test_result);
142: }
143: }
|