You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2005/09/24 04:13:40 UTC

svn commit: r291234 - /directory/apacheds/trunk/main/src/test/org/apache/ldap/server/UnknownExtendedOperationTest.java

Author: akarasulu
Date: Fri Sep 23 19:13:35 2005
New Revision: 291234

URL: http://svn.apache.org/viewcvs?rev=291234&view=rev
Log:
adding test contribution from stefan in DIREVE-256 here http://issues.apache.org/jira/browse/DIREVE-256

Added:
    directory/apacheds/trunk/main/src/test/org/apache/ldap/server/UnknownExtendedOperationTest.java   (with props)

Added: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/UnknownExtendedOperationTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/main/src/test/org/apache/ldap/server/UnknownExtendedOperationTest.java?rev=291234&view=auto
==============================================================================
--- directory/apacheds/trunk/main/src/test/org/apache/ldap/server/UnknownExtendedOperationTest.java (added)
+++ directory/apacheds/trunk/main/src/test/org/apache/ldap/server/UnknownExtendedOperationTest.java Fri Sep 23 19:13:35 2005
@@ -0,0 +1,106 @@
+/*
+ *   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.ldap.server;
+
+import java.util.Hashtable;
+
+import javax.naming.CommunicationException;
+import javax.naming.NamingException;
+import javax.naming.ldap.ExtendedRequest;
+import javax.naming.ldap.ExtendedResponse;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+/**
+ * Check the behaviour of the server for an unknown extended operation. Created
+ * to demonstrate DIREVE-256 ("Extended operation causes client to hang.").
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class UnknownExtendedOperationTest extends AbstractServerTest
+{
+    private LdapContext ctx = null;
+
+    /**
+     * Create context.
+     */
+    public void setUp() throws Exception
+    {
+        super.setUp();
+
+        Hashtable env = new Hashtable();
+        env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
+        env.put("java.naming.provider.url", "ldap://localhost:" + port + "/ou=system");
+        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);
+    }
+
+    /**
+     * Close context.
+     */
+    public void tearDown() throws Exception
+    {
+        ctx.close();
+        ctx = null;
+        super.tearDown();
+    }
+
+    /**
+     * Calls an extended exception, which does not exist. Expected behaviour is
+     * a CommunicationException.
+     */
+    public void testUnknownExtendedOperation() throws NamingException
+    {
+        try {
+            ctx.extendedOperation(new UnknownExtendedOperationRequest());
+            fail("Calling an unknown extended operation should fail.");
+        } catch (CommunicationException ce) {
+            // expected behaviour
+        }
+    }
+
+    /**
+     * Class for the request of an extended operation which does not exist.
+     */
+    private class UnknownExtendedOperationRequest implements ExtendedRequest
+    {
+
+        private static final long serialVersionUID = 1L;
+
+        public String getID()
+        {
+            return "1.1"; // Never an OID for an extended operation
+        }
+
+        public byte[] getEncodedValue()
+        {
+            return null;
+        }
+
+        public ExtendedResponse createExtendedResponse(String id, byte[] berValue, int offset, int length)
+                throws NamingException
+        {
+            return null;
+        }
+    }
+
+}

Propchange: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/UnknownExtendedOperationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native