directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r642801 - in /directory/sandbox/akarasulu/bigbang/apacheds: xdbm-search/ xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/ xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/
Date Sun, 30 Mar 2008 18:36:37 GMT
Author: akarasulu
Date: Sun Mar 30 11:36:36 2008
New Revision: 642801

URL: http://svn.apache.org/viewvc?rev=642801&view=rev
Log:
setup to test presence cursor

Added:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/pom.xml
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexUtils.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/pom.xml?rev=642801&r1=642800&r2=642801&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/pom.xml (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/pom.xml Sun Mar 30 11:36:36 2008
@@ -36,6 +36,12 @@
       <artifactId>apacheds-btree-base</artifactId>
       <version>${pom.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-jdbm-store</artifactId>
+      <version>${pom.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <packaging>jar</packaging>

Added: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java?rev=642801&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
(added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
Sun Mar 30 11:36:36 2008
@@ -0,0 +1,128 @@
+/*
+ *  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.directory.server.xdbm.search.impl;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.directory.server.schema.registries.*;
+import org.apache.directory.server.schema.SerializableComparator;
+import org.apache.directory.server.schema.bootstrap.*;
+import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.tools.StoreUtils;
+import org.apache.directory.server.xdbm.tools.IndexUtils;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.commons.io.FileUtils;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import javax.naming.directory.Attributes;
+import java.io.File;
+import java.util.Set;
+import java.util.HashSet;
+
+
+/**
+ * TODO doc me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $$Rev$$
+ */
+public class PresenceCursorTest
+{
+    private static final Logger LOG = LoggerFactory.getLogger( PresenceCursorTest.class.getSimpleName()
);
+
+    File wkdir;
+    Store<Attributes> store;
+    Registries registries = null;
+    AttributeTypeRegistry attributeRegistry;
+
+
+    public PresenceCursorTest() throws Exception
+    {
+        // setup the standard registries
+        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+        OidRegistry oidRegistry = new DefaultOidRegistry();
+        registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
+        SerializableComparator.setRegistry( registries.getComparatorRegistry() );
+
+        // load essential bootstrap schemas
+        Set<Schema> bootstrapSchemas = new HashSet<Schema>();
+        bootstrapSchemas.add( new ApachemetaSchema() );
+        bootstrapSchemas.add( new ApacheSchema() );
+        bootstrapSchemas.add( new CoreSchema() );
+        bootstrapSchemas.add( new SystemSchema() );
+        loader.loadWithDependencies( bootstrapSchemas, registries );
+        attributeRegistry = registries.getAttributeTypeRegistry();
+    }
+
+
+    @Before
+    public void createStore() throws Exception
+    {
+        destryStore();
+
+        // setup the working directory for the store
+        wkdir = File.createTempFile( getClass().getSimpleName(), "db" );
+        wkdir.delete();
+        wkdir = new File( wkdir.getParentFile(), getClass().getSimpleName() );
+        wkdir.mkdirs();
+
+        // initialize the store
+        store = new JdbmStore<Attributes>();
+        store.setName( "example" );
+        store.setCacheSize( 10 );
+        store.setWorkingDirectory( wkdir );
+        store.setSyncOnWrite( false );
+
+        store.addIndex( new JdbmIndex( SchemaConstants.OU_AT_OID ) );
+        store.addIndex( new JdbmIndex( SchemaConstants.UID_AT_OID ) );
+        StoreUtils.loadExampleData( store, registries );
+        LOG.debug( "Created new store" );
+    }
+
+
+    @After
+    public void destryStore() throws Exception
+    {
+        if ( store != null )
+        {
+            store.destroy();
+        }
+
+        store = null;
+        if ( wkdir != null )
+        {
+            FileUtils.deleteDirectory( wkdir );
+        }
+
+        wkdir = null;
+    }
+
+
+    @Test
+    public void testPresenceIndex() throws Exception
+    {
+        IndexUtils.printContents( store.getPresenceIndex() );
+    }
+}

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexUtils.java?rev=642801&r1=642800&r2=642801&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexUtils.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexUtils.java
Sun Mar 30 11:36:36 2008
@@ -35,6 +35,12 @@
  */
 public class IndexUtils
 {
+    public static void printContents( Index idx ) throws Exception
+    {
+        printContents( idx, System.out );    
+    }
+
+
     public static void printContents( Index idx, OutputStream outputStream ) throws Exception
     {
         PrintStream out;



Mime
View raw message