Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 72515 invoked from network); 18 Jul 2008 16:02:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jul 2008 16:02:17 -0000 Received: (qmail 33227 invoked by uid 500); 18 Jul 2008 16:02:01 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 32582 invoked by uid 500); 18 Jul 2008 16:01:59 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 32295 invoked by uid 99); 18 Jul 2008 16:01:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 09:01:57 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 15:51:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9808B2388AAF; Fri, 18 Jul 2008 08:49:58 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r677944 [11/11] - in /activemq/sandbox/kahadb: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/kahadb/ src/main/java/org/apache/kahadb/impl/ src/main/java/org/apache/kahadb/impl/async/ ... Date: Fri, 18 Jul 2008 15:49:52 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080718154958.9808B2388AAF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/IndexTestBase.java URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/IndexTestBase.java?rev=677944&view=auto ============================================================================== --- activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/IndexTestBase.java (added) +++ activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/IndexTestBase.java Fri Jul 18 08:49:48 2008 @@ -0,0 +1,409 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + * $Id: FilerTestBase.java 541504 2007-05-25 01:43:39Z vgritsenko $ + */ + +package org.apache.kahadb.xindice; + +import java.io.File; +import java.util.List; +import java.util.Vector; + +import org.apache.kahadb.xindice.Index; +import org.apache.kahadb.xindice.IndexException; +import org.apache.kahadb.xindice.Key; +import org.apache.kahadb.xindice.Record; +import org.apache.kahadb.xindice.RecordSet; +import org.apache.kahadb.xindice.Value; + +import junit.framework.TestCase; + +/** + * Base class for filer test cases + * + * @version $Revision: 541504 $, $Date: 2007-05-24 21:43:39 -0400 (Thu, 24 May 2007) $ + * @author Kimbro Staken + * @author Vladimir R. Bossicard + * @author Vadim Gritsenko + */ +public abstract class IndexTestBase extends TestCase { + + public static final String TEST_COLLECTION_NAME = "tests"; + public static final Key TEST_KEY = new Key("test.xml"); + public static final Value TEST_VALUE = new Value("Just a test"); + public static final Value TEST_VALUE_2 = new Value("Just a test 2"); + public static final Value TEST_VALUE_3 = new Value("Just a test 3"); + + private static final File ROOT = new File(TEST_COLLECTION_NAME); + + /** + * Key size for the testLargeKey. FSFiler and HashFiler will set smaller value + * for their tests. + */ + protected int LARGE_KEY_SIZE = 8192 + 32; + + protected Index index; + + abstract protected Index createIndex(File root, String name) throws Exception; + + public void setUp() throws Exception { + ROOT.mkdir(); + index = createIndex(ROOT, TEST_COLLECTION_NAME); + + if (!index.exists()) { + index.create(); + } + index.open(); + + RecordSet set = index.getRecordSet(); + while (set.hasMoreRecords()) { + Key key = set.getNextKey(); + index.deleteRecord(key); + } + assertEquals(0, index.getRecordCount()); + } + + + protected void tearDown() throws Exception { + if (index != null) { + index.close(); + } + index = null; + + String[] files = ROOT.list(); + for (int i = 0; i < files.length; i++) { + assertTrue(new File(ROOT, files[i]).delete()); + } + ROOT.delete(); + super.tearDown(); + } + + public void testSuccessWriteRecord() throws Exception { + index.writeRecord(TEST_KEY, TEST_VALUE); + assertEquals(1, index.getRecordCount()); + + Record result = index.readRecord(TEST_KEY, false); + assertEquals(TEST_VALUE, result.getValue()); + + RecordSet set = index.getRecordSet(); + assertEquals(result.getValue(), set.getNextRecord().getValue()); + assertFalse(set.hasMoreRecords()); + + index.deleteRecord(TEST_KEY); + assertEquals(0, index.getRecordCount()); + } + + public void testFailReadDeletedRecord() throws Exception { + Record result = index.readRecord(TEST_KEY, false); + assertNull(result); + } + + public void testFailWriteRecordNullKey() throws Exception { + try { + index.writeRecord(null, TEST_VALUE); + fail("Expecting IndexException"); + } catch (IndexException e) { + // Ok + } + } + + public void testFailWriteRecordNullValue() throws Exception { + try { + index.writeRecord(TEST_KEY, null); + fail("Expecting IndexException"); + } catch (IndexException e) { + // Ok + } + } + + public void testFailWriteRecordNullValueKey() throws Exception { + try { + index.writeRecord(null, null); + fail("Expecting IndexException"); + } catch (IndexException e) { + // Ok + } + } + + public void testReadRecord() throws Exception { + index.writeRecord(TEST_KEY, TEST_VALUE); + assertEquals(1, index.getRecordCount()); + + // Valid key + Record result = index.readRecord(TEST_KEY, false); + assertEquals(TEST_VALUE, result.getValue()); + } + + public void testFailReadRecordNullKey() throws Exception { + index.writeRecord(TEST_KEY, TEST_VALUE); + assertEquals(1, index.getRecordCount()); + + // Null key + Record result = index.readRecord(null, false); + assertNull(result); + } + + public void testFailReadRecordEmptyKey() throws Exception { + index.writeRecord(TEST_KEY, TEST_VALUE); + assertEquals(1, index.getRecordCount()); + + // Empty key + Record result = index.readRecord(new Key(""), false); + assertNull(result); + } + + public void testFailReadRecordUnknownKey() throws Exception { + index.writeRecord(TEST_KEY, TEST_VALUE); + assertEquals(1, index.getRecordCount()); + + // Non-existant key + Record result = index.readRecord(new Key("non-existant-key"), false); + assertNull(result); + } + + public void testDeleteRecord() throws Exception { + index.writeRecord(TEST_KEY, TEST_VALUE); + assertEquals(1, index.getRecordCount()); + + // Valid key + index.deleteRecord(TEST_KEY); + assertEquals(0, index.getRecordCount()); + Record result = index.readRecord(TEST_KEY, false); + assertNull(result); + } + + public void testDeleteRecordNullKey() throws Exception { + index.writeRecord(TEST_KEY, TEST_VALUE); + assertEquals(1, index.getRecordCount()); + + // These should all just fail silently. + assertFalse(index.deleteRecord(null)); + assertEquals(1, index.getRecordCount()); + } + + public void testDeleteRecordEmptyKey() throws Exception { + index.writeRecord(TEST_KEY, TEST_VALUE); + assertEquals(1, index.getRecordCount()); + + // These should all just fail silently. + assertFalse(index.deleteRecord(new Key(""))); + assertEquals(1, index.getRecordCount()); + } + + public void testDeleteRecordWrongKey() throws Exception { + index.writeRecord(TEST_KEY, TEST_VALUE); + assertEquals(1, index.getRecordCount()); + + // These should all just fail silently. + assertFalse(index.deleteRecord(new Key("non-existant-key"))); + assertEquals(1, index.getRecordCount()); + } + + public void testGetRecordCount() throws Exception { + assertEquals(0, index.getRecordCount()); + + index.writeRecord(TEST_KEY, TEST_VALUE); + index.writeRecord(new Key("test1"), TEST_VALUE); + index.writeRecord(new Key("test2"), TEST_VALUE); + assertEquals(3, index.getRecordCount()); + + index.writeRecord(new Key("test3"), TEST_VALUE); + assertEquals(4, index.getRecordCount()); + + assertTrue(index.deleteRecord(new Key("test3"))); + assertEquals(3, index.getRecordCount()); + + assertTrue(index.deleteRecord(TEST_KEY)); + assertTrue(index.deleteRecord(new Key("test1"))); + assertTrue(index.deleteRecord(new Key("test2"))); + + assertEquals(0, index.getRecordCount()); + } + + public void testGetRecordSet() throws Exception { + index.writeRecord(TEST_KEY, TEST_VALUE); + index.writeRecord(new Key("test2"), TEST_VALUE_2); + index.writeRecord(new Key("test3"), TEST_VALUE_3); + + RecordSet result = index.getRecordSet(); + assertNotNull(result); + + List results = new Vector(); + while (result.hasMoreRecords()) { + results.add(result.getNextRecord().getValue()); + } + assertEquals(3, results.size()); + assertTrue(results.contains(TEST_VALUE)); + assertTrue(results.contains(TEST_VALUE_2)); + assertTrue(results.contains(TEST_VALUE_3)); + + assertTrue(index.deleteRecord(TEST_KEY)); + assertTrue(index.deleteRecord(new Key("test2"))); + assertTrue(index.deleteRecord(new Key("test3"))); + + result = index.getRecordSet(); + assertTrue(!result.hasMoreRecords()); + } + + public void testInsertManyDocuments() throws Exception { + int iterations = 1000; + for (int i = 0; i < iterations; i++) { + index.writeRecord(new Key("key" + i), TEST_VALUE); + } + + assertTrue(index.getRecordCount() == iterations); + + for (int i = 0; i < iterations; i++) { + assertTrue(index.deleteRecord(new Key("key" + i))); + } + + assertTrue(index.getRecordCount() == 0); + RecordSet result = index.getRecordSet(); + assertTrue(!result.hasMoreRecords()); + } + + public void testConcurrentInsert() throws Exception { + assertEquals(0, index.getRecordCount()); + + final Object go = new Object(); + final int THREADS = 30; + final int ITERATIONS = 65; + + Thread[] threads = new Thread[THREADS]; + for (int i = 0; i < THREADS; i++) { + final int threadID = i; + threads[i] = new Thread() { + public void run() { + synchronized (go) { + try { + go.wait(); + } catch (InterruptedException e) { /* ignored */ } + } + + for (int ii = 0; ii < ITERATIONS; ii++) { + Key key = new Key("T" + threadID + "I" + ii); + Value value = new Value(""); + try { + index.writeRecord(key, value); + } catch (Exception e) { + e.printStackTrace(); + } + } + // System.out.println(this.getName() + " done."); + } + }; + threads[i].setName("IndexTest" + i); + threads[i].start(); + } + + // Start all the threads at once + Thread.sleep(250); + synchronized (go) { + go.notifyAll(); + } + for (int i = 0; i < THREADS; i++) { + threads[i].join(); + } + + // Check results + assertEquals(THREADS * ITERATIONS, index.getRecordCount()); + for (int i = 0; i < THREADS; i++) { + for (int ii = 0; ii < ITERATIONS; ii++) { + Key key = new Key("T" + i + "I" + ii); + Value value = new Value(""); + Record record = index.readRecord(key, false); + assertNotNull("Record with key '" + key + "' was not found", + record); + assertEquals("Expected record with key '" + key + "', found record with key '" + record.getKey() + "'", + key, record.getKey()); + assertEquals("Expected record with value '" + value + "', found record with value '" + record.getValue() + "'", + value, record.getValue()); + } + } + } + + public void testConcurrentSameInsert() throws Exception { + assertTrue(index.getRecordCount() == 0); + + final int THREADS = 10; + final int ITERATIONS = 5; + + Thread[] threads = new Thread[THREADS]; + for (int i = 0; i < THREADS; i++) { + threads[i] = new Thread() { + public void run() { + for (int ii = 0; ii < ITERATIONS; ii++) { + Key key = new Key("key"); + Value value = new Value(""); + try { + index.writeRecord(key, value); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + }; + threads[i].setName("IndexTest" + i); + } + + // Start all the threads at once + for (int i = 0; i < THREADS; i++) { + threads[i].start(); + } + Thread.sleep(100); + + for (int i = 0; i < THREADS; i++) { + threads[i].join(); + } + + index.flush(); + + // Check results + assertEquals(1, index.getRecordCount()); + Key key = new Key("key"); + Value value = new Value(""); + Record record = index.readRecord(key, false); + assertNotNull("Record with key '" + key + "' was not found", record); + assertEquals("Expected record with key '" + key + "', found record with key '" + record.getKey() + "'", + key, record.getKey()); + assertEquals("Expected record with value '" + value + "', found record with value '" + record.getValue() + "'", + value, record.getValue()); + } + + public void testLargeKey() throws Exception { + assertTrue(index.getRecordCount() == 0); + + StringBuffer sb = new StringBuffer(LARGE_KEY_SIZE); + sb.append("KEY"); + for (int k = 0; k < LARGE_KEY_SIZE - 3; k++) { + sb.append('0'); + } + final Key key = new Key(sb.toString()); + final Value value = new Value(""); + + index.writeRecord(key, value); + + assertEquals(index.getRecordCount(), 1); + Record record = index.readRecord(key, false); + assertNotNull("Record with key '" + key + "' was not found", + record); + assertEquals("Expected record with key '" + key + "', found record with key '" + record.getKey() + "'", + key, record.getKey()); + assertEquals("Expected record with value '" + value + "', found record with value '" + record.getValue() + "'", + value, record.getValue()); + } +} Added: activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/btree/BTreeIndexBenchmark.java URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/btree/BTreeIndexBenchmark.java?rev=677944&view=auto ============================================================================== --- activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/btree/BTreeIndexBenchmark.java (added) +++ activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/btree/BTreeIndexBenchmark.java Fri Jul 18 08:49:48 2008 @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.kahadb.xindice.btree; + +import java.io.File; + +import org.apache.kahadb.xindice.Index; +import org.apache.kahadb.xindice.IndexBenchmark; +import org.apache.kahadb.xindice.hash.HashIndex; + +public class BTreeIndexBenchmark extends IndexBenchmark { + + @Override + protected Index createIndex(File root, String name) throws Exception { + HashIndex rc = new HashIndex(); + rc.setLocation(ROOT_DIR, name); + rc.setPageCount(10000); + rc.setPageSize(4096); + return rc; + } + +} Added: activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/btree/BTreeIndexTest.java URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/btree/BTreeIndexTest.java?rev=677944&view=auto ============================================================================== --- activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/btree/BTreeIndexTest.java (added) +++ activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/btree/BTreeIndexTest.java Fri Jul 18 08:49:48 2008 @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + * $Id: BTreeFilerTest.java 541504 2007-05-25 01:43:39Z vgritsenko $ + */ + +package org.apache.kahadb.xindice.btree; + +import java.io.File; + +import org.apache.kahadb.xindice.Index; +import org.apache.kahadb.xindice.IndexTestBase; +import org.apache.kahadb.xindice.Key; +import org.apache.kahadb.xindice.btree.BTreeIndex; + +/** + * + * @version $Revision: 541504 $, $Date: 2007-05-24 21:43:39 -0400 (Thu, 24 May 2007) $ + * @author Vadim Gritsenko + */ +public class BTreeIndexTest extends IndexTestBase { + + @Override + protected Index createIndex(File root, String name) throws Exception { + BTreeIndex index = new BTreeIndex(); + index.setLocation(root, name); + index.setPageCount(128); + index.setPageSize(4096); + return index; + } + + /** + * Test to see if BTreeFiler reuses deleted pages. + */ + public void testFreePages() throws Exception { + long count = ((BTreeIndex) index).getFileHeader().getTotalCount(); + int iterations = 10; + + Key key = new Key("key"); + for (int i = 0; i < iterations; i++) { + index.writeRecord(key, TEST_VALUE); + assertTrue(index.deleteRecord(key)); + } + + // Check that file did not grow (much) + assertTrue(count + 1 >= ((BTreeIndex) index).getFileHeader().getTotalCount()); + } + +} Added: activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/fs/FileSystemIndexTest.java URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/fs/FileSystemIndexTest.java?rev=677944&view=auto ============================================================================== --- activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/fs/FileSystemIndexTest.java (added) +++ activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/fs/FileSystemIndexTest.java Fri Jul 18 08:49:48 2008 @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + * $Id: BTreeFilerTest.java 541504 2007-05-25 01:43:39Z vgritsenko $ + */ + +package org.apache.kahadb.xindice.fs; + +import java.io.File; + +import org.apache.kahadb.xindice.Index; +import org.apache.kahadb.xindice.IndexTestBase; +import org.apache.kahadb.xindice.Key; +import org.apache.kahadb.xindice.fs.FileSystemIndex; + +/** + * + * @version $Revision: 541504 $, $Date: 2007-05-24 21:43:39 -0400 (Thu, 24 May 2007) $ + * @author Vadim Gritsenko + */ +public class FileSystemIndexTest extends IndexTestBase { + + @Override + protected Index createIndex(File root, String name) throws Exception { + FileSystemIndex index = new FileSystemIndex(); + index.setLocation(root, name); + index.setDir(root); + return index; + } + + public void testLargeKey() throws Exception { + // Kay size is limited by the file system used + LARGE_KEY_SIZE = 128; + super.testLargeKey(); + } + +} Added: activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/hash/HashIndexBenchmark.java URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/hash/HashIndexBenchmark.java?rev=677944&view=auto ============================================================================== --- activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/hash/HashIndexBenchmark.java (added) +++ activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/hash/HashIndexBenchmark.java Fri Jul 18 08:49:48 2008 @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.kahadb.xindice.hash; + +import java.io.File; + +import org.apache.kahadb.xindice.Index; +import org.apache.kahadb.xindice.IndexBenchmark; +import org.apache.kahadb.xindice.btree.BTreeIndex; +import org.apache.kahadb.xindice.hash.HashIndex; + +public class HashIndexBenchmark extends IndexBenchmark { + + @Override + protected Index createIndex(File root, String name) throws Exception { + HashIndex index = new HashIndex(); + index.setLocation(ROOT_DIR, name); + index.setPageCount(10000); + index.setPageSize(4096); + return index; + } + +} Added: activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/hash/HashIndexTest.java URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/hash/HashIndexTest.java?rev=677944&view=auto ============================================================================== --- activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/hash/HashIndexTest.java (added) +++ activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/hash/HashIndexTest.java Fri Jul 18 08:49:48 2008 @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + * $Id: BTreeFilerTest.java 541504 2007-05-25 01:43:39Z vgritsenko $ + */ + +package org.apache.kahadb.xindice.hash; + +import java.io.File; + +import org.apache.kahadb.xindice.Index; +import org.apache.kahadb.xindice.IndexTestBase; +import org.apache.kahadb.xindice.Key; +import org.apache.kahadb.xindice.hash.HashIndex; + +/** + * + * @version $Revision: 541504 $, $Date: 2007-05-24 21:43:39 -0400 (Thu, 24 May 2007) $ + * @author Vadim Gritsenko + */ +public class HashIndexTest extends IndexTestBase { + + @Override + protected Index createIndex(File root, String name) throws Exception { + HashIndex index = new HashIndex(); + index.setLocation(root, name); + index.setPageCount(128); + index.setPageSize(4096); + return index; + } + + public void testLargeKey() throws Exception { + // HashFiler large key can not be large than page size (less page header) + LARGE_KEY_SIZE = 4030; + super.testLargeKey(); + } + +} Added: activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/mem/MemIndexTest.java URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/mem/MemIndexTest.java?rev=677944&view=auto ============================================================================== --- activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/mem/MemIndexTest.java (added) +++ activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/xindice/mem/MemIndexTest.java Fri Jul 18 08:49:48 2008 @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + * $Id: BTreeFilerTest.java 541504 2007-05-25 01:43:39Z vgritsenko $ + */ + +package org.apache.kahadb.xindice.mem; + +import java.io.File; + +import org.apache.kahadb.xindice.Index; +import org.apache.kahadb.xindice.IndexTestBase; +import org.apache.kahadb.xindice.Key; +import org.apache.kahadb.xindice.mem.MemIndex; + +/** + * + * @version $Revision: 541504 $, $Date: 2007-05-24 21:43:39 -0400 (Thu, 24 May 2007) $ + * @author Vadim Gritsenko + */ +public class MemIndexTest extends IndexTestBase { + + @Override + protected Index createIndex(File root, String name) throws Exception { + MemIndex index = new MemIndex(); + index.setLocation(root, name); + return index; + } + +}