directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 57566 - in incubator/directory/eve/trunk/jndi-provider: . src/java/org/apache/eve/db/jdbm src/java/org/apache/eve/jndi src/test/org/apache/eve/jndi
Date Sat, 13 Nov 2004 07:44:19 GMT
Author: akarasulu
Date: Fri Nov 12 23:44:18 2004
New Revision: 57566

Added:
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/DeadContext.java
   incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ShutdownTest.java
   incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SyncTest.java
Modified:
   incubator/directory/eve/trunk/jndi-provider/   (props changed)
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/db/jdbm/JdbmDatabase.java
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java
   incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java
Log:
found nasty bug preventing master table entries to be written

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/db/jdbm/JdbmDatabase.java
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/db/jdbm/JdbmDatabase.java
(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/db/jdbm/JdbmDatabase.java
Fri Nov 12 23:44:18 2004
@@ -855,7 +855,8 @@
         try 
         {
             master.sync();
-        } 
+            recMan.commit();
+        }
         catch ( Throwable t ) 
         {
             if ( null == rootCause ) 

Added: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/DeadContext.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/DeadContext.java
Fri Nov 12 23:44:18 2004
@@ -0,0 +1,421 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.eve.jndi;
+
+
+import java.util.Hashtable;
+
+import javax.naming.*;
+import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.ExtendedResponse;
+import javax.naming.ldap.ExtendedRequest;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+
+import org.apache.ldap.common.exception.LdapServiceUnavailableException;
+import org.apache.ldap.common.message.ResultCodeEnum;
+
+
+/**
+ * A do nothing placeholder context whose methods throw ConfigurationExceptions.
+ * The provider returns these context when the shutdown environment property key
+ * is set.  By returning a non-null Context we prevent an unnecessary exception
+ * being thrown by InitialConext and any one of its subclasses.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DeadContext implements LdapContext
+{
+    private final String EXCEPTION_MSG = "Context operation unavailable when " +
+            "invoked after Eve provider has been shutdown";
+
+
+    public Control[] getConnectControls() throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Control[] getRequestControls() throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Control[] getResponseControls() throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void reconnect( Control[] connCtls ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void setRequestControls( Control[] requestControls ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public ExtendedResponse extendedOperation( ExtendedRequest request ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public LdapContext newInstance( Control[] requestControls ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Attributes getAttributes( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void modifyAttributes( String name, int mod_op, Attributes attrs ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Attributes getAttributes( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void modifyAttributes( Name name, int mod_op, Attributes attrs ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public DirContext getSchema( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public DirContext getSchemaClassDefinition( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public DirContext getSchema( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public DirContext getSchemaClassDefinition( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void modifyAttributes( String name, ModificationItem[] mods ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void modifyAttributes( Name name, ModificationItem[] mods ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration search( String name, Attributes matchingAttributes ) throws
NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration search( Name name, Attributes matchingAttributes ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void bind( String name, Object obj, Attributes attrs ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void rebind( String name, Object obj, Attributes attrs ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void bind( Name name, Object obj, Attributes attrs ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void rebind( Name name, Object obj, Attributes attrs ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Attributes getAttributes( String name, String[] attrIds ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Attributes getAttributes( Name name, String[] attrIds ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public DirContext createSubcontext( String name, Attributes attrs ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public DirContext createSubcontext( Name name, Attributes attrs ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration search( String name, Attributes matchingAttributes, String[]
attributesToReturn ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration search( Name name, Attributes matchingAttributes, String[] attributesToReturn
) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration search( String name, String filter, SearchControls cons ) throws
NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration search( Name name, String filter, SearchControls cons ) throws
NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration search( String name, String filterExpr, Object[] filterArgs,
SearchControls cons ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration search( Name name, String filterExpr, Object[] filterArgs, SearchControls
cons ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void close() throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public String getNameInNamespace() throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void destroySubcontext( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void unbind( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Hashtable getEnvironment() throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void destroySubcontext( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void unbind( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Object lookup( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Object lookupLink( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Object removeFromEnvironment( String propName ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void bind( String name, Object obj ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void rebind( String name, Object obj ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Object lookup( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Object lookupLink( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void bind( Name name, Object obj ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void rebind( Name name, Object obj ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void rename( String oldName, String newName ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Context createSubcontext( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Context createSubcontext( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public void rename( Name oldName, Name newName ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NameParser getNameParser( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NameParser getNameParser( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration list( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration listBindings( String name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration list( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public NamingEnumeration listBindings( Name name ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Object addToEnvironment( String propName, Object propVal ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public String composeName( String name, String prefix ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+
+
+    public Name composeName( Name name, Name prefix ) throws NamingException
+    {
+        throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE
);
+    }
+}

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
Fri Nov 12 23:44:18 2004
@@ -189,8 +189,16 @@
      */
     public Context getInitialContext( Hashtable env ) throws NamingException
     {
+        Context ctx = null;
+
         if ( env.containsKey( SHUTDOWN_OP_ENV ) )
         {
+            if ( this.provider == null )
+            {
+                // monitor.shutDownCalledOnStoppedProvider()
+                return new DeadContext();
+            }
+
             try
             {
                 this.provider.shutdown();
@@ -206,17 +214,18 @@
             }
             finally
             {
+                ctx = new DeadContext();
                 provider = null;
                 initialEnv = null;
             }
 
-            return null;
+            return ctx;
         }
 
         if ( env.containsKey( SYNC_OP_ENV ) )
         {
             provider.sync();
-            return null;
+            return provider.getLdapContext( env );
         }
 
         // fire up the backend subsystem if we need to
@@ -266,7 +275,7 @@
             }
         }
 
-        EveContext ctx = ( EveContext ) provider.getLdapContext( env );
+        ctx = ( EveContext ) provider.getLdapContext( env );
         return ctx;
     }
 

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java
(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java
Fri Nov 12 23:44:18 2004
@@ -30,6 +30,7 @@
 import java.lang.reflect.InvocationHandler;
 
 import javax.naming.NamingException;
+import javax.naming.Context;
 import javax.naming.ldap.LdapContext;
 
 
@@ -306,5 +307,18 @@
                             + states[ii].getName() );
             }
         }
+    }
+
+
+    /**
+     * A dead context is requested and returned when we shutdown the system. It
+     * prevents a {@link javax.naming.NoInitialContextException} from being
+     * thrown by InitialContext or one of its subclasses.
+     *
+     * @return a unusable dead context
+     */
+    public Context getDeadContext()
+    {
+        return new DeadContext();
     }
 }

Modified: incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java
(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/AbstractJndiTest.java
Fri Nov 12 23:44:18 2004
@@ -21,6 +21,7 @@
 import java.io.File;
 import java.io.IOException;
 import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.InitialLdapContext;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
@@ -123,8 +124,7 @@
         envFinal.put( EveContextFactory.WKDIR_ENV, "target" + File.separator + "eve" );
         envFinal.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.eve.jndi.EveContextFactory"
);
         envFinal.putAll( overrides );
-        InitialContext initialContext = new InitialContext( envFinal );
-        return sysRoot = ( LdapContext ) initialContext.lookup( "" );
+        return sysRoot = new InitialLdapContext( envFinal, null );
     }
 
 

Added: incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ShutdownTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ShutdownTest.java
Fri Nov 12 23:44:18 2004
@@ -0,0 +1,81 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.eve.jndi;
+
+
+/**
+ * Tests the shutdown operation on the JNDI provider.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ShutdownTest extends AbstractJndiTest
+{
+    protected void tearDown() throws Exception
+    {
+        // since we shutdown the system already there is no point why the
+        // tearDown code should try to shut it down as well - in fact the
+        // tearDown super method will throw an LdapServiceUnavailableException
+        sysRoot = null;
+    }
+
+
+    /**
+     *
+     * @throws Exception if the test fails by generating a null context
+     */
+    public void testShutdownNonNullContext() throws Exception
+    {
+        overrides.put( EveContextFactory.SHUTDOWN_OP_ENV, "true" );
+
+        try
+        {
+            setSysRoot( "uid=admin,ou=system", "testing" );
+        }
+        finally
+        {
+            overrides.remove( EveContextFactory.SHUTDOWN_OP_ENV );
+        }
+
+        assertNotNull( sysRoot );
+    }
+
+
+    /**
+     *
+     *
+     * @throws Exception
+     */
+    public void testShutdownRestart() throws Exception
+    {
+        overrides.put( EveContextFactory.SHUTDOWN_OP_ENV, "true" );
+
+        try
+        {
+            setSysRoot( "uid=admin,ou=system", "testing" );
+        }
+        finally
+        {
+            overrides.remove( EveContextFactory.SHUTDOWN_OP_ENV );
+        }
+
+        assertNotNull( sysRoot );
+
+        // restart the system now
+        setSysRoot( "uid=admin,ou=system", "testing" );
+    }
+}

Added: incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SyncTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/SyncTest.java
Fri Nov 12 23:44:18 2004
@@ -0,0 +1,65 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.eve.jndi;
+
+
+import javax.naming.directory.Attributes;
+
+
+/**
+ * Tests the sync operation on the JNDI provider.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SyncTest extends AbstractJndiTest
+{
+    /**
+     * Makes sure the changes to the JNDI provider take effect where a sync op
+     * does not throw an exception due to a null context being returned.
+     *
+     * @throws Exception if the test fails by generating a null context
+     */
+    public void testSyncNoException() throws Exception
+    {
+        overrides.put( EveContextFactory.SYNC_OP_ENV, "true" );
+        sysRoot = setSysRoot( "uid=admin,ou=system", "testing" );
+        assertNotNull( sysRoot );
+    }
+
+
+    /**
+     * Makes sure entries can still be accessed after a sync operation.
+     * Considering the cache I don't know just how effective such a test is.
+     *
+     * @throws Exception if the test fails to retrieve and verify an entry
+     */
+    public void testPostSyncLookup() throws Exception
+    {
+        overrides.put( EveContextFactory.SYNC_OP_ENV, "true" );
+        sysRoot = setSysRoot( "uid=admin,ou=system", "testing" );
+        Attributes users = sysRoot.getAttributes( "ou=users" );
+
+        // assert making sure the entry is ok
+        assertNotNull( users );
+        assertNotNull( users.get( "ou" ) );
+        assertTrue( users.get( "ou" ).contains( "users" ) );
+        assertNotNull( users.get( "objectClass" ) );
+        assertTrue( users.get( "objectClass" ).contains( "top" ) );
+        assertTrue( users.get( "objectClass" ).contains( "organizationalUnit" ) );
+    }
+}

Mime
View raw message