directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r513193 - in /directory/sandbox/akarasulu/custom-partition: ./ .settings/ src/ src/main/ src/main/java/ src/main/java/foo/ src/main/java/foo/bar/ src/test/ src/test/java/ src/test/java/foo/ src/test/java/foo/bar/ src/test/resources/
Date Thu, 01 Mar 2007 06:47:24 GMT
Author: akarasulu
Date: Wed Feb 28 22:47:23 2007
New Revision: 513193

URL: http://svn.apache.org/viewvc?view=rev&rev=513193
Log:
adding example custom partition configuration

Added:
    directory/sandbox/akarasulu/custom-partition/
    directory/sandbox/akarasulu/custom-partition/.settings/
    directory/sandbox/akarasulu/custom-partition/.settings/org.eclipse.jdt.core.prefs
    directory/sandbox/akarasulu/custom-partition/.settings/org.eclipse.jdt.ui.prefs
    directory/sandbox/akarasulu/custom-partition/pom.xml
    directory/sandbox/akarasulu/custom-partition/src/
    directory/sandbox/akarasulu/custom-partition/src/main/
    directory/sandbox/akarasulu/custom-partition/src/main/java/
    directory/sandbox/akarasulu/custom-partition/src/main/java/foo/
    directory/sandbox/akarasulu/custom-partition/src/main/java/foo/bar/
    directory/sandbox/akarasulu/custom-partition/src/main/java/foo/bar/CustomPartition.java
    directory/sandbox/akarasulu/custom-partition/src/test/
    directory/sandbox/akarasulu/custom-partition/src/test/java/
    directory/sandbox/akarasulu/custom-partition/src/test/java/foo/
    directory/sandbox/akarasulu/custom-partition/src/test/java/foo/bar/
    directory/sandbox/akarasulu/custom-partition/src/test/java/foo/bar/CustomPartitionTestCase.java
    directory/sandbox/akarasulu/custom-partition/src/test/resources/
    directory/sandbox/akarasulu/custom-partition/src/test/resources/log4j.properties

Added: directory/sandbox/akarasulu/custom-partition/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/custom-partition/.settings/org.eclipse.jdt.core.prefs?view=auto&rev=513193
==============================================================================
--- directory/sandbox/akarasulu/custom-partition/.settings/org.eclipse.jdt.core.prefs (added)
+++ directory/sandbox/akarasulu/custom-partition/.settings/org.eclipse.jdt.core.prefs Wed
Feb 28 22:47:23 2007
@@ -0,0 +1,12 @@
+#Thu Mar 01 01:05:05 EST 2007
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.source=1.4
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning

Added: directory/sandbox/akarasulu/custom-partition/.settings/org.eclipse.jdt.ui.prefs
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/custom-partition/.settings/org.eclipse.jdt.ui.prefs?view=auto&rev=513193
==============================================================================
--- directory/sandbox/akarasulu/custom-partition/.settings/org.eclipse.jdt.ui.prefs (added)
+++ directory/sandbox/akarasulu/custom-partition/.settings/org.eclipse.jdt.ui.prefs Wed Feb
28 22:47:23 2007
@@ -0,0 +1,3 @@
+#Thu Mar 01 00:56:28 EST 2007
+eclipse.preferences.version=1
+internal.default.compliance=default

Added: directory/sandbox/akarasulu/custom-partition/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/custom-partition/pom.xml?view=auto&rev=513193
==============================================================================
--- directory/sandbox/akarasulu/custom-partition/pom.xml (added)
+++ directory/sandbox/akarasulu/custom-partition/pom.xml Wed Feb 28 22:47:23 2007
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.directory.server</groupId>
+    <artifactId>build</artifactId>
+    <version>1.0.2-SNAPSHOT</version>
+  </parent>
+  <groupId>foo.bar</groupId>
+  <artifactId>custom-partition</artifactId>
+  <name>A custom partition implementation</name>
+  <packaging>jar</packaging>  
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>nlog4j</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-unit</artifactId>
+      <version>${pom.version}</version>
+    </dependency>  
+  </dependencies>
+
+  <profiles>
+    <profile>
+    <id>no-integration-or-perf-tests</id>
+    <activation>
+      <activeByDefault>true</activeByDefault>
+    </activation>
+    <build>
+      <plugins>
+        <plugin>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>2.2</version>
+          <configuration>
+            <excludes>
+              <exclude>**/*ITest.java</exclude>
+              <exclude>**/*PTest.java</exclude>
+            </excludes>
+          </configuration>
+        </plugin>
+        <plugin>
+          <artifactId>maven-antrun-plugin</artifactId>
+          <version>1.1</version>
+            <executions>
+              <execution>
+                <phase>validate</phase>
+                <configuration>
+                  <tasks>
+                    <echo>
+=================================================================
+                          W A R N I N G
+                          -------------
+                  
+Integration and performance tests have been disabled.  To enable 
+integration tests run maven with the -Dintegration switch.  To 
+enable performance tests run maven with the -Dperformance switch.
+=================================================================
+                    </echo>
+                  </tasks>
+                </configuration>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+   	    </plugins>
+      </build>
+    </profile>
+    <profile>
+      <id>integration</id>
+      <activation>
+        <property><name>integration</name></property>
+      </activation>
+    <build>
+      <plugins>
+        <plugin>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>2.2</version>
+          <configuration>
+            <excludes>
+              <exclude>**/*PTest.java</exclude>
+            </excludes>
+          </configuration>
+        </plugin>
+        <plugin>
+          <artifactId>maven-antrun-plugin</artifactId>
+          <version>1.1</version>
+            <executions>
+              <execution>
+                <phase>validate</phase>
+                <configuration>
+                  <tasks>
+                    <echo>
+=================================================================
+                   I N T E G R A T I O N
+                   ---------------------
+                  
+Performance tests have been disabled.  To enable 
+performance tests run maven with the -Dperformance switch.
+=================================================================
+                    </echo>
+                  </tasks>
+                </configuration>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+   	    </plugins>
+      </build>
+    </profile>
+    <profile>
+      <id>performance</id>
+      <activation>
+        <property><name>performance</name></property>
+      </activation>
+    <build>
+      <plugins>
+        <plugin>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>2.2</version>
+          <configuration>
+            <systemProperties>
+              <property>
+                <name>outputDirectory</name>
+                <value>${basedir}/target</value>
+              </property>
+            </systemProperties>
+            <excludes>
+              <exclude>**/*ITest.java</exclude>
+            </excludes>
+          </configuration>
+        </plugin>
+        <plugin>
+          <artifactId>maven-antrun-plugin</artifactId>
+          <version>1.1</version>
+            <executions>
+              <execution>
+                <phase>validate</phase>
+                <configuration>
+                  <tasks>
+                    <echo>
+=================================================================
+                   P E R F O R M A N C E
+                   ---------------------
+                  
+Integration tests have been disabled.  To enable integration
+tests run maven with the -Dintegration switch.
+=================================================================
+                    </echo>
+                  </tasks>
+                </configuration>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+   	    </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
+

Added: directory/sandbox/akarasulu/custom-partition/src/main/java/foo/bar/CustomPartition.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/custom-partition/src/main/java/foo/bar/CustomPartition.java?view=auto&rev=513193
==============================================================================
--- directory/sandbox/akarasulu/custom-partition/src/main/java/foo/bar/CustomPartition.java
(added)
+++ directory/sandbox/akarasulu/custom-partition/src/main/java/foo/bar/CustomPartition.java
Wed Feb 28 22:47:23 2007
@@ -0,0 +1,133 @@
+/**
+ * 
+ */
+package foo.bar;
+
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchControls;
+
+import org.apache.directory.server.core.partition.AbstractPartition;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.EmptyEnumeration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author akarasulu
+ *
+ */
+public class CustomPartition extends AbstractPartition
+{
+    public final static Logger log = LoggerFactory.getLogger( CustomPartition.class ); 
+    
+    
+    
+    public CustomPartition()
+    {
+       log.error( "Creating custom partition." ); 
+    }
+    
+    
+    protected void doInit() throws NamingException
+    {
+        super.doInit();
+        
+        // using error to avoid flood of debug messages
+        log.error( "Initialized successfully!" );
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.partition.Partition#add(org.apache.directory.shared.ldap.name.LdapDN,
javax.naming.directory.Attributes)
+     */
+    public void add( LdapDN name, Attributes entry ) throws NamingException
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.partition.Partition#bind(org.apache.directory.shared.ldap.name.LdapDN,
byte[], java.util.List, java.lang.String)
+     */
+    public void bind( LdapDN bindDn, byte[] credentials, List mechanisms, String saslAuthId
) throws NamingException
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.partition.Partition#delete(org.apache.directory.shared.ldap.name.LdapDN)
+     */
+    public void delete( LdapDN name ) throws NamingException
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.partition.Partition#getUpSuffix()
+     */
+    public LdapDN getUpSuffix() throws NamingException
+    {
+        return new LdapDN( "ou=mypartition" );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.partition.Partition#list(org.apache.directory.shared.ldap.name.LdapDN)
+     */
+    public NamingEnumeration list( LdapDN baseName ) throws NamingException
+    {
+        return new EmptyEnumeration();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.partition.Partition#lookup(org.apache.directory.shared.ldap.name.LdapDN,
java.lang.String[])
+     */
+    public Attributes lookup( LdapDN name, String[] attrIds ) throws NamingException
+    {
+        return new LockableAttributesImpl( "objectClass", "top", true );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.partition.Partition#modify(org.apache.directory.shared.ldap.name.LdapDN,
org.apache.directory.shared.ldap.message.ModificationItemImpl[])
+     */
+    public void modify( LdapDN name, ModificationItemImpl[] items ) throws NamingException
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.partition.Partition#modifyRn(org.apache.directory.shared.ldap.name.LdapDN,
java.lang.String, boolean)
+     */
+    public void modifyRn( LdapDN name, String newRn, boolean deleteOldRn ) throws NamingException
+    {
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.partition.Partition#search(org.apache.directory.shared.ldap.name.LdapDN,
java.util.Map, org.apache.directory.shared.ldap.filter.ExprNode, javax.naming.directory.SearchControls)
+     */
+    public NamingEnumeration search( LdapDN baseName, Map environment, ExprNode filter, SearchControls
searchControls )
+        throws NamingException
+    {
+        return new EmptyEnumeration();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.partition.Partition#unbind(org.apache.directory.shared.ldap.name.LdapDN)
+     */
+    public void unbind( LdapDN bindDn ) throws NamingException
+    {
+    }
+}

Added: directory/sandbox/akarasulu/custom-partition/src/test/java/foo/bar/CustomPartitionTestCase.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/custom-partition/src/test/java/foo/bar/CustomPartitionTestCase.java?view=auto&rev=513193
==============================================================================
--- directory/sandbox/akarasulu/custom-partition/src/test/java/foo/bar/CustomPartitionTestCase.java
(added)
+++ directory/sandbox/akarasulu/custom-partition/src/test/java/foo/bar/CustomPartitionTestCase.java
Wed Feb 28 22:47:23 2007
@@ -0,0 +1,76 @@
+package foo.bar;
+
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+
+import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
+import org.apache.directory.server.core.configuration.PartitionConfiguration;
+import org.apache.directory.server.core.jndi.CoreContextFactory;
+import org.apache.directory.server.core.unit.AbstractAdminTestCase;
+import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class CustomPartitionTestCase extends AbstractAdminTestCase
+{
+    private static final Logger log = LoggerFactory.getLogger( CustomPartitionTestCase.class
);
+    
+    
+    public void setUp() throws Exception
+    {
+        Set existing = super.configuration.getContextPartitionConfigurations();
+        Set all = new HashSet();
+        all.addAll( existing );
+        all.add( getCustomPartitionConfiguration() );
+        super.configuration.setContextPartitionConfigurations( all );
+        
+        super.setUp();
+    }
+    
+    
+    private PartitionConfiguration getCustomPartitionConfiguration() throws NamingException
+    {
+        MutablePartitionConfiguration mpc = new MutablePartitionConfiguration();
+        mpc.setCacheSize( 100 );
+        mpc.setIndexedAttributes( new HashSet() );
+        mpc.setName( "customPartition" );
+        mpc.setOptimizerEnabled( false );
+        mpc.setSuffix( "ou=mypartition" );
+        
+        LockableAttributesImpl attrs = new LockableAttributesImpl( "objectClass", "top",
true );
+        attrs.get( "objectClass" ).add( "organizationalUnit" );
+        attrs.put( "ou", "mypartition" );
+        
+        mpc.setContextEntry( attrs );
+        mpc.setContextPartition( new CustomPartition() );
+        
+        return mpc;
+    }
+
+
+    public void testServerStartup() throws Exception
+    {
+        Hashtable env = super.getOverriddenEnvironment();
+        env.put( DirContext.PROVIDER_URL, "" );
+        env.put( DirContext.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
+        DirContext ctx = new InitialDirContext( env );
+        Attributes attrs = ctx.getAttributes( "", new String[] { "namingContexts" } );
+        Attribute namingContexts = attrs.get( "namingContexts" );
+
+        // using error to avoid flood of debug messages
+        log.error( "Got the following namingContexts in the server: " + namingContexts );
+        
+        assertNotNull( namingContexts );
+        assertTrue( namingContexts.contains( "ou=mypartition" ) );
+    }
+}

Added: directory/sandbox/akarasulu/custom-partition/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/custom-partition/src/test/resources/log4j.properties?view=auto&rev=513193
==============================================================================
--- directory/sandbox/akarasulu/custom-partition/src/test/resources/log4j.properties (added)
+++ directory/sandbox/akarasulu/custom-partition/src/test/resources/log4j.properties Wed Feb
28 22:47:23 2007
@@ -0,0 +1,6 @@
+log4j.rootCategory=ERROR, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+



Mime
View raw message