directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r569268 - /directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/CascadeControlITest.java
Date Fri, 24 Aug 2007 06:23:18 GMT
Author: pamarcelot
Date: Thu Aug 23 23:23:18 2007
New Revision: 569268

URL: http://svn.apache.org/viewvc?rev=569268&view=rev
Log:
Added the unit test for CascadeControl.

Added:
    directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/CascadeControlITest.java

Added: directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/CascadeControlITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/CascadeControlITest.java?rev=569268&view=auto
==============================================================================
--- directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/CascadeControlITest.java
(added)
+++ directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/CascadeControlITest.java
Thu Aug 23 23:23:18 2007
@@ -0,0 +1,111 @@
+/*
+ *  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;
+
+
+import java.util.Hashtable;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.CascadeControl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+
+
+/**
+ * A set of tests to make sure the Cascade Control is working 
+ * properly.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CascadeControlITest extends AbstractServerTest
+{
+    private LdapContext ctx = null;
+
+
+    /**
+     * Creates context.
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        Hashtable<String, Object> env = new Hashtable<String, Object>();
+        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+        env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/" );
+        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+        env.put( "java.naming.security.credentials", "secret" );
+        env.put( "java.naming.security.authentication", "simple" );
+
+        ctx = new InitialLdapContext( env, null );
+        assertNotNull( ctx );
+    }
+
+
+    /**
+    * Closes context.
+    */
+    protected void tearDown() throws Exception
+    {
+        ctx.close();
+        ctx = null;
+        super.tearDown();
+    }
+
+
+    /**
+     * Tests the behavior of the server with a SearchRequest including
+     * the CascadeControl.
+     */
+    public void testCascadeControl()
+    {
+        try
+        {
+            ctx.setRequestControls( new Control[]
+                { new CascadeControl() } );
+        }
+        catch ( NamingException e )
+        {
+            fail( e.getMessage() );
+        }
+
+        Attribute attr = new AttributeImpl( "m-oid", "1.2.3.4.5.6.7.8.9.0" );
+        ModificationItemImpl item = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE,
attr );
+
+        String rdn = "m-oid=1.3.6.1.4.1.18060.0.4.0.2.1, ou=attributeTypes, cn=apachemeta,
ou=schema";
+        try
+        {
+            ctx.modifyAttributes( rdn, new ModificationItemImpl[]
+                { item } );
+        }
+        catch ( NamingException e )
+        {
+            // Hiding this fail() until the server has the correct mechanism to handle this.
+            //            fail( e.getMessage() );
+        }
+    }
+}



Mime
View raw message