directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r937388 [1/2] - in /directory/apacheds/trunk/ldap-client-test: ./ src/ src/main/ src/main/java/ src/main/resources/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/directory/ src/test/java/org/...
Date Fri, 23 Apr 2010 17:08:33 GMT
Author: elecharny
Date: Fri Apr 23 17:08:32 2010
New Revision: 937388

URL: http://svn.apache.org/viewvc?rev=937388&view=rev
Log:
moved the client api test code to apacheds

Added:
    directory/apacheds/trunk/ldap-client-test/
    directory/apacheds/trunk/ldap-client-test/.classpath
    directory/apacheds/trunk/ldap-client-test/.project
    directory/apacheds/trunk/ldap-client-test/pom.xml
    directory/apacheds/trunk/ldap-client-test/src/
    directory/apacheds/trunk/ldap-client-test/src/main/
    directory/apacheds/trunk/ldap-client-test/src/main/java/
    directory/apacheds/trunk/ldap-client-test/src/main/resources/
    directory/apacheds/trunk/ldap-client-test/src/test/
    directory/apacheds/trunk/ldap-client-test/src/test/java/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/perf/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/perf/TestClientApiPerf.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/utils/
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/utils/SASLPrep.java
    directory/apacheds/trunk/ldap-client-test/src/test/resources/
    directory/apacheds/trunk/ldap-client-test/src/test/resources/log4j.properties

Added: directory/apacheds/trunk/ldap-client-test/.classpath
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/.classpath?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/.classpath (added)
+++ directory/apacheds/trunk/ldap-client-test/.classpath Fri Apr 23 17:08:32 2010
@@ -0,0 +1,86 @@
+<classpath>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="target/maven-shared-archive-resources" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
+  <classpathentry kind="src" path="/apacheds-avl-partition"/>
+  <classpathentry kind="src" path="/apacheds-core"/>
+  <classpathentry kind="src" path="/apacheds-core-annotations"/>
+  <classpathentry kind="src" path="/apacheds-core-api"/>
+  <classpathentry kind="src" path="/apacheds-core-avl"/>
+  <classpathentry kind="src" path="/apacheds-core-constants"/>
+  <classpathentry kind="src" path="/apacheds-core-entry"/>
+  <classpathentry kind="src" path="/apacheds-core-jndi"/>
+  <classpathentry kind="src" path="/apacheds-core-mock"/>
+  <classpathentry kind="src" path="/apacheds-i18n"/>
+  <classpathentry kind="src" path="/apacheds-jdbm"/>
+  <classpathentry kind="src" path="/apacheds-jdbm-partition"/>
+  <classpathentry kind="src" path="/apacheds-jdbm-store"/>
+  <classpathentry kind="src" path="/apacheds-kerberos-shared"/>
+  <classpathentry kind="src" path="/apacheds-ldif-partition"/>
+  <classpathentry kind="src" path="/apacheds-protocol-kerberos"/>
+  <classpathentry kind="src" path="/apacheds-protocol-ldap"/>
+  <classpathentry kind="src" path="/apacheds-protocol-shared"/>
+  <classpathentry kind="src" path="/apacheds-server-annotations"/>
+  <classpathentry kind="src" path="/apacheds-test-framework"/>
+  <classpathentry kind="src" path="/apacheds-utils"/>
+  <classpathentry kind="src" path="/apacheds-xdbm-base"/>
+  <classpathentry kind="src" path="/apacheds-xdbm-search"/>
+  <classpathentry kind="src" path="/apacheds-xdbm-tools"/>
+  <classpathentry kind="var" path="M2_REPO/bouncycastle/bcprov-jdk15/140/bcprov-jdk15-140.jar" sourcepath="M2_REPO/bouncycastle/bcprov-jdk15/140/bcprov-jdk15-140-sources.jar">
+    <attributes>
+      <attribute value="jar:file:/Users/elecharny/.m2/repository/bouncycastle/bcprov-jdk15/140/bcprov-jdk15-140-javadoc.jar!/" name="javadoc_location"/>
+    </attributes>
+  </classpathentry>
+  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-sources.jar">
+    <attributes>
+      <attribute value="jar:file:/Users/elecharny/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-javadoc.jar!/" name="javadoc_location"/>
+    </attributes>
+  </classpathentry>
+  <classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.4/commons-io-1.4.jar" sourcepath="M2_REPO/commons-io/commons-io/1.4/commons-io-1.4-sources.jar">
+    <attributes>
+      <attribute value="jar:file:/Users/elecharny/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4-javadoc.jar!/" name="javadoc_location"/>
+    </attributes>
+  </classpathentry>
+  <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.5/commons-lang-2.5.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.5/commons-lang-2.5-sources.jar">
+    <attributes>
+      <attribute value="jar:file:/Users/elecharny/.m2/repository/commons-lang/commons-lang/2.5/commons-lang-2.5-javadoc.jar!/" name="javadoc_location"/>
+    </attributes>
+  </classpathentry>
+  <classpathentry kind="var" path="M2_REPO/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar" sourcepath="M2_REPO/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4-sources.jar">
+    <attributes>
+      <attribute value="jar:file:/Users/elecharny/.m2/repository/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4-javadoc.jar!/" name="javadoc_location"/>
+    </attributes>
+  </classpathentry>
+  <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.7/junit-4.7.jar" sourcepath="M2_REPO/junit/junit/4.7/junit-4.7-sources.jar"/>
+  <classpathentry kind="src" path="/ldap-client-api"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/mina/mina-core/2.0.0-RC1/mina-core-2.0.0-RC1.jar" sourcepath="M2_REPO/org/apache/mina/mina-core/2.0.0-RC1/mina-core-2.0.0-RC1-sources.jar"/>
+  <classpathentry kind="src" path="/shared-asn1"/>
+  <classpathentry kind="src" path="/shared-asn1-codec"/>
+  <classpathentry kind="src" path="/shared-cursor"/>
+  <classpathentry kind="src" path="/shared-dsml-parser"/>
+  <classpathentry kind="src" path="/shared-i18n"/>
+  <classpathentry kind="src" path="/shared-ldap"/>
+  <classpathentry kind="src" path="/shared-ldap-constants"/>
+  <classpathentry kind="src" path="/shared-ldap-converter"/>
+  <classpathentry kind="src" path="/shared-ldap-jndi"/>
+  <classpathentry kind="src" path="/shared-ldap-schema"/>
+  <classpathentry kind="src" path="/shared-ldap-schema-dao"/>
+  <classpathentry kind="src" path="/shared-ldap-schema-loader"/>
+  <classpathentry kind="src" path="/shared-ldap-schema-manager"/>
+  <classpathentry kind="src" path="/shared-ldif"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.5.10/slf4j-log4j12-1.5.10.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.5.10/slf4j-log4j12-1.5.10-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar" sourcepath="M2_REPO/xpp3/xpp3/1.1.4c/xpp3-1.1.4c-sources.jar">
+    <attributes>
+      <attribute value="jar:file:/Users/elecharny/.m2/repository/xpp3/xpp3/1.1.4c/xpp3-1.1.4c-javadoc.jar!/" name="javadoc_location"/>
+    </attributes>
+  </classpathentry>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+</classpath>
\ No newline at end of file

Added: directory/apacheds/trunk/ldap-client-test/.project
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/.project?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/.project (added)
+++ directory/apacheds/trunk/ldap-client-test/.project Fri Apr 23 17:08:32 2010
@@ -0,0 +1,57 @@
+<projectDescription>
+  <name>ldap-client-test</name>
+  <comment>LDAP Client API Tests. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+  <projects>
+    <project>apacheds-avl-partition</project>
+    <project>apacheds-core</project>
+    <project>apacheds-core-annotations</project>
+    <project>apacheds-core-api</project>
+    <project>apacheds-core-avl</project>
+    <project>apacheds-core-constants</project>
+    <project>apacheds-core-entry</project>
+    <project>apacheds-core-jndi</project>
+    <project>apacheds-core-mock</project>
+    <project>apacheds-i18n</project>
+    <project>apacheds-jdbm</project>
+    <project>apacheds-jdbm-partition</project>
+    <project>apacheds-jdbm-store</project>
+    <project>apacheds-kerberos-shared</project>
+    <project>apacheds-ldif-partition</project>
+    <project>apacheds-protocol-kerberos</project>
+    <project>apacheds-protocol-ldap</project>
+    <project>apacheds-protocol-shared</project>
+    <project>apacheds-server-annotations</project>
+    <project>apacheds-test-framework</project>
+    <project>apacheds-utils</project>
+    <project>apacheds-xdbm-base</project>
+    <project>apacheds-xdbm-search</project>
+    <project>apacheds-xdbm-tools</project>
+    <project>ldap-client-api</project>
+    <project>shared-asn1</project>
+    <project>shared-asn1-codec</project>
+    <project>shared-cursor</project>
+    <project>shared-dsml-parser</project>
+    <project>shared-i18n</project>
+    <project>shared-ldap</project>
+    <project>shared-ldap-constants</project>
+    <project>shared-ldap-converter</project>
+    <project>shared-ldap-jndi</project>
+    <project>shared-ldap-schema</project>
+    <project>shared-ldap-schema-dao</project>
+    <project>shared-ldap-schema-loader</project>
+    <project>shared-ldap-schema-manager</project>
+    <project>shared-ldif</project>
+  </projects>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+    <buildCommand>
+      <name>org.maven.ide.eclipse.maven2Builder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.maven.ide.eclipse.maven2Nature</nature>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: directory/apacheds/trunk/ldap-client-test/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/pom.xml?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/pom.xml (added)
+++ directory/apacheds/trunk/ldap-client-test/pom.xml Fri Apr 23 17:08:32 2010
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.directory.client.ldap</groupId>
+    <artifactId>ldap-client</artifactId>
+    <version>0.2-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>ldap-client-test</artifactId>
+  <name>Apache Directory LDAP Client API test</name>
+  <inceptionYear>2009</inceptionYear>
+
+  <issueManagement>
+    <system>jira</system>
+    <url>http://issues.apache.org/jira/browse/DIRAPI</url>
+  </issueManagement>
+
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/directory/clients/ldap/trunk/ldap-client-test</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/directory/clients/ldap/trunk/ldap-client-test</developerConnection>
+    <url>http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-test</url>
+  </scm>
+
+  <description>
+    LDAP Client API Tests
+  </description>
+
+  <dependencies>
+    <!-- Apacheds dependencies -->
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-annotations</artifactId>
+      <version>${org.apache.directory.server.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-api</artifactId>
+      <version>${org.apache.directory.server.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-entry</artifactId>
+      <version>${org.apache.directory.server.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-protocol-ldap</artifactId>
+      <version>${org.apache.directory.server.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-protocol-shared</artifactId>
+      <version>${org.apache.directory.server.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-server-annotations</artifactId>
+      <version>${org.apache.directory.server.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-test-framework</artifactId>
+      <version>${org.apache.directory.server.version}</version>
+    </dependency>
+
+    <!-- Shared dependencies -->
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap</artifactId>
+      <version>${org.apache.directory.shared.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-asn1</artifactId>
+      <version>${org.apache.directory.shared.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-cursor</artifactId>
+      <version>${org.apache.directory.shared.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-constants</artifactId>
+      <version>${org.apache.directory.shared.version}</version>
+    </dependency>
+
+    <!-- Other dependencies -->
+    <dependency>
+      <artifactId>ldap-client-api</artifactId>
+      <groupId>${groupId}</groupId>
+      <version>${version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.mina</groupId>
+      <artifactId>mina-core</artifactId>
+      <version>${mina.core.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit.version}</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>${slf4j.log4j12.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>${log4j.version}</version>
+    </dependency>
+        
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>${commons.io.version}</version>
+    </dependency>
+  </dependencies>
+
+  <profiles>
+    <profile>
+      <id>perf</id>
+      <activation>
+        <activeByDefault>false</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <includes>
+                <include>**/TestClientApiPerf.java</include>
+              </includes>
+              <excludes>
+                <exclude>**/*Test.java</exclude>
+              </excludes>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    
+    <profile>
+      <id>test</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <excludes>
+                <exclude>**/Abstract*</exclude>
+                <exclude>**/*RegressionTest*</exclude>
+                <exclude>**/TestClientApiPerf.java</exclude>
+              </excludes>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
+

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java Fri Apr 23 17:08:32 2010
@@ -0,0 +1,198 @@
+/*
+ *  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.shared.client.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.exception.LdapException;
+import org.apache.directory.ldap.client.api.message.BindResponse;
+import org.apache.directory.ldap.client.api.message.SearchResponse;
+import org.apache.directory.ldap.client.api.message.SearchResultEntry;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.cursor.Cursor;
+import org.apache.directory.shared.ldap.entry.StringValue;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test the LdapConnection class
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith ( FrameworkRunner.class )
+@CreateLdapServer ( 
+    transports = 
+    {
+        @CreateTransport( protocol = "LDAP" ), 
+        @CreateTransport( protocol = "LDAPS" ) 
+    })
+public class LdapConnectionTest extends AbstractLdapTestUnit
+{
+    
+    private static final String ADMIN_DN = "uid=admin,ou=system";
+
+    private LdapConnection connection;
+    
+    
+    @Before
+    public void bindConnection() throws Exception
+    {
+        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+        connection.bind( ADMIN_DN, "secret" );
+    }
+    
+    
+    @After
+    public void unbindConnection() throws Exception
+    {
+        connection.close();
+    }
+    
+    
+    /**
+     * Test a successful bind request
+     *
+     * @throws IOException
+     */
+    @Test
+    public void testBindRequest() throws Exception
+    {
+        LdapConnection connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+        try
+        {
+            BindResponse bindResponse = connection.bind( ADMIN_DN, "secret" );
+            
+            assertNotNull( bindResponse );
+            
+            //connection.unBind();
+        }
+        catch ( LdapException le )
+        {
+            fail();
+        }
+        catch ( IOException ioe )
+        {
+            fail();
+        }
+        finally
+        {
+            try
+            {
+                connection.close();
+            }
+            catch( IOException ioe )
+            {
+                fail();
+            }
+        }
+    }
+    
+    
+    @Test
+    public void testGetSupportedControls() throws Exception
+    {
+        List<String> controlList = connection.getSupportedControls();
+        assertNotNull( controlList );
+        assertFalse( controlList.isEmpty() );
+    }
+    
+    
+    @Test
+    public void testLookup() throws Exception
+    {
+        SearchResponse resp = connection.lookup( ADMIN_DN );
+        assertNotNull( resp );
+        
+        Entry entry = ( ( SearchResultEntry ) resp ).getEntry();
+        assertNull( entry.get( SchemaConstants.ENTRY_UUID_AT ) );
+
+        // perform lookup with operational attributes
+        resp = connection.lookup( ADMIN_DN, "+", "*" );
+        entry = ( ( SearchResultEntry ) resp ).getEntry();
+        assertNotNull( entry.get( SchemaConstants.ENTRY_UUID_AT ) );
+    }
+    
+
+    @Test
+    public void searchByEntryUuid() throws Exception
+    {
+        SearchResponse resp = connection.lookup( ADMIN_DN, "+" );
+        Entry entry = ( ( SearchResultEntry ) resp ).getEntry();
+        
+        String uuid = entry.get( SchemaConstants.ENTRY_UUID_AT ).getString();
+        
+        EqualityNode<String> filter = new EqualityNode<String>( SchemaConstants.ENTRY_UUID_AT, new StringValue( uuid ) );
+        
+        Cursor<SearchResponse> cursor = connection.search( ADMIN_DN, filter.toString(), SearchScope.SUBTREE, "+" );
+        cursor.next();
+
+        Entry readEntry = ( ( SearchResultEntry ) cursor.get() ).getEntry();
+        assertEquals( uuid, readEntry.get( SchemaConstants.ENTRY_UUID_AT ).getString() );
+        
+        cursor.close();
+    }
+
+    
+    @Test
+    public void testRetrieveBinaryAttibute() throws Exception
+    {
+        Entry entry = ( ( SearchResultEntry ) connection.lookup( "uid=admin,ou=system" ) ).getEntry();
+        assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isBinary() );
+
+        connection.loadSchema();
+        
+        entry = ( ( SearchResultEntry ) connection.lookup( "uid=admin,ou=system" ) ).getEntry();
+        assertTrue( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isBinary() );
+    }
+
+    
+    @Test
+    public void testLoadSchema() throws Exception
+    {
+        connection.loadSchema();
+        SchemaManager manager = connection.getSchemaManager();
+        assertNotNull( manager );
+        assertTrue( manager.isEnabled( "system" ) );
+        assertTrue( manager.isEnabled( "nis" ) );
+        assertEquals( manager.getLoader().getAllSchemas().size(), manager.getEnabled().size() );
+    }
+    
+}

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java Fri Apr 23 17:08:32 2010
@@ -0,0 +1,152 @@
+/*
+ *  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.shared.client.api;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.List;
+
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.LdapConnectionConfig;
+import org.apache.directory.ldap.client.api.message.BindResponse;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.annotations.SaslMechanism;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.ldap.handlers.bind.cramMD5.CramMd5MechanismHandler;
+import org.apache.directory.server.ldap.handlers.bind.digestMD5.DigestMd5MechanismHandler;
+import org.apache.directory.server.ldap.handlers.bind.gssapi.GssapiMechanismHandler;
+import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
+import org.apache.directory.server.ldap.handlers.bind.plain.PlainMechanismHandler;
+import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
+import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test the LdapConnection class with SSL enabled
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith ( FrameworkRunner.class ) 
+@CreateLdapServer ( 
+    transports = 
+    {
+        @CreateTransport( protocol = "LDAP" ),
+        @CreateTransport( protocol = "LDAPS" )
+    },
+    saslHost="localhost",
+    saslMechanisms = 
+    {
+        @SaslMechanism( name=SupportedSaslMechanisms.PLAIN, implClass=PlainMechanismHandler.class ),
+        @SaslMechanism( name=SupportedSaslMechanisms.CRAM_MD5, implClass=CramMd5MechanismHandler.class),
+        @SaslMechanism( name=SupportedSaslMechanisms.DIGEST_MD5, implClass=DigestMd5MechanismHandler.class),
+        @SaslMechanism( name=SupportedSaslMechanisms.GSSAPI, implClass=GssapiMechanismHandler.class),
+        @SaslMechanism( name=SupportedSaslMechanisms.NTLM, implClass=NtlmMechanismHandler.class),
+        @SaslMechanism( name=SupportedSaslMechanisms.GSS_SPNEGO, implClass=NtlmMechanismHandler.class)
+    },
+    extendedOpHandlers = 
+    {
+        StoredProcedureExtendedOperationHandler.class
+    })
+public class LdapSSLConnectionTest extends AbstractLdapTestUnit
+{
+    private LdapConnectionConfig config;
+    
+    
+    @Before
+    public void setup()
+    {
+        X509TrustManager X509 = new X509TrustManager()
+        {
+            public void checkClientTrusted( X509Certificate[] x509Certificates, String s ) throws CertificateException
+            {
+            }
+
+            public void checkServerTrusted( X509Certificate[] x509Certificates, String s ) throws CertificateException
+            {
+            }
+
+            public X509Certificate[] getAcceptedIssuers()
+            {
+                return new X509Certificate[0];
+            }
+        };
+
+        config = new LdapConnectionConfig();
+        config.setLdapHost( "localhost" );
+        config.setUseSsl( true );
+        config.setLdapPort( ldapServer.getPortSSL() );
+        config.setTrustManagers( new TrustManager[]{ X509 } );
+    }
+    
+    
+    /**
+     * Test a successful bind request
+     *
+     * @throws IOException
+     */
+    @Test
+    public void testBindRequest()
+    {
+        LdapConnection connection = null;
+        try
+        {
+            connection = new LdapNetworkConnection( config );
+            BindResponse bindResponse = connection.bind( "uid=admin,ou=system", "secret" );
+            
+            assertNotNull( bindResponse );
+            
+            connection.unBind();
+        }
+        catch ( Exception le )
+        {
+            le.printStackTrace();
+            fail();
+        }
+    }
+    
+    
+    @Test
+    public void testGetSupportedControls() throws Exception
+    {
+        LdapConnection connection = new LdapNetworkConnection( config );
+
+        DN dn = new DN( "uid=admin,ou=system" );
+        connection.bind( dn.getName(), "secret" );
+        
+        List<String> controlList = connection.getSupportedControls();
+        assertNotNull( controlList );
+        assertFalse( controlList.isEmpty() );
+    }
+}

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java Fri Apr 23 17:08:32 2010
@@ -0,0 +1,164 @@
+/*
+ *   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.shared.client.api.operations;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.directory.ldap.client.api.LdapAsyncConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.future.SearchFuture;
+import org.apache.directory.ldap.client.api.message.SearchRequest;
+import org.apache.directory.ldap.client.api.message.SearchResponse;
+import org.apache.directory.ldap.client.api.message.SearchResultDone;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.cursor.Cursor;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * A test class for ClientAbandonRequest.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer ( 
+    transports = 
+    {
+        @CreateTransport( protocol = "LDAP" ), 
+        @CreateTransport( protocol = "LDAPS" ) 
+    })
+public class ClientAbandonRequestTest extends AbstractLdapTestUnit
+{
+
+    private LdapAsyncConnection connection;
+
+    private CoreSession session;
+    
+    @Before
+    public void setup() throws Exception
+    {
+        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+        DN bindDn = new DN( "uid=admin,ou=system" );
+        connection.setTimeOut( 0L );
+        connection.bind( bindDn.getName(), "secret" );
+
+        session = ldapServer.getDirectoryService().getSession();
+    }
+    
+    
+    /**
+     * Close the LdapConnection
+     */
+    @After
+    public void shutdown()
+    {
+        try
+        {
+            if ( connection != null )
+            {
+                connection.close();
+            }
+        }
+        catch( Exception ioe )
+        {
+            fail();
+        }
+    }
+
+
+    @Test
+    public void testAbandonSearch() throws Exception
+    {
+        // injecting some values to keep the
+        // followed search operation to run for a while
+        final int numEntries = 100;
+        
+        for ( int i = 0; i < numEntries; i++ )
+        {
+            String s = String.valueOf( i );
+            DN dn = new DN( "cn=" + s + ",ou=system" );
+            Entry entry = new DefaultClientEntry( dn );
+            entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
+            entry.add( SchemaConstants.CN_AT, s );
+            entry.add( SchemaConstants.SN_AT, s );
+
+            connection.add( entry );
+        }
+        
+        SearchRequest sr = new SearchRequest();
+        sr.setFilter( "(cn=*)" );
+        sr.setBaseDn( "ou=system" );
+        sr.setScope( SearchScope.ONELEVEL );
+        sr.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
+
+        // Launch the search now
+        SearchFuture searchFuture = connection.searchAsync( sr );
+        
+        SearchResponse searchResponse = null;
+        int count = 0;
+        
+        do
+        {
+            searchResponse = searchFuture.get();
+            count++;
+            
+            if ( count > 10 )
+            {
+                searchFuture.cancel( true );
+                break;
+            }
+        }
+        while ( !(searchResponse instanceof SearchResultDone ) );
+        
+        assertTrue( numEntries > count );
+        assertTrue( searchFuture.isCancelled() );
+
+        // Now do a simple synchronous search
+        Cursor<SearchResponse> results = connection.search( sr );
+        
+        int n = -1;
+        
+        while ( results.next() )
+        {
+            results.get();
+            n++;
+        }
+        
+        assertEquals( numEntries, n );
+    }
+}

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java Fri Apr 23 17:08:32 2010
@@ -0,0 +1,147 @@
+/*
+ *  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.shared.client.api.operations;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.directory.ldap.client.api.LdapAsyncConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.future.AddFuture;
+import org.apache.directory.ldap.client.api.message.AddRequest;
+import org.apache.directory.ldap.client.api.message.AddResponse;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests the add operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer ( 
+    transports = 
+    {
+        @CreateTransport( protocol = "LDAP" ), 
+        @CreateTransport( protocol = "LDAPS" ) 
+    })
+public class ClientAddRequestTest extends AbstractLdapTestUnit
+{
+    private LdapAsyncConnection connection;
+    private CoreSession session;
+    
+    @Before
+    public void setup() throws Exception
+    {
+        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+        DN bindDn = new DN( "uid=admin,ou=system" );
+        connection.bind( bindDn.getName(), "secret" );
+        
+        session = ldapServer.getDirectoryService().getSession();
+    }
+
+    
+    /**
+     * Close the LdapConnection
+     */
+    @After
+    public void shutdown()
+    {
+        try
+        {
+            if ( connection != null )
+            {
+                connection.close();
+            }
+        }
+        catch( Exception ioe )
+        {
+            fail();
+        }
+    }
+    
+    
+    @Test
+    public void testAdd() throws Exception
+    {
+        DN dn = new DN( "cn=testadd,ou=system" );
+        Entry entry = new DefaultClientEntry( dn ); 
+        entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
+        entry.add( SchemaConstants.CN_AT, "testadd_cn" );
+        entry.add( SchemaConstants.SN_AT, "testadd_sn" );
+        
+        assertFalse( session.exists( dn ) );
+        
+        AddResponse response = connection.add( entry );
+        assertNotNull( response );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        
+        assertTrue( session.exists( dn ) );
+    }
+
+    
+    @Test
+    public void testAddAsync() throws Exception
+    {
+        DN dn = new DN( "cn=testAsyncAdd,ou=system" );
+        Entry entry = new DefaultClientEntry( dn ); 
+        entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
+        entry.add( SchemaConstants.CN_AT, "testAsyncAdd_cn" );
+        entry.add( SchemaConstants.SN_AT, "testAsyncAdd_sn" );
+        
+        assertFalse( session.exists( dn ) );
+
+        AddFuture addFuture = connection.addAsync( new AddRequest( entry ));
+
+        try
+        {
+            AddResponse addResponse = addFuture.get( 1000, TimeUnit.MILLISECONDS );
+            
+            assertNotNull( addResponse );
+            assertEquals( ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode() );
+            assertTrue( connection.isAuthenticated() );
+            assertTrue( session.exists( dn ) );
+        }
+        catch ( TimeoutException toe )
+        {
+            fail();
+        }
+    }
+}

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java Fri Apr 23 17:08:32 2010
@@ -0,0 +1,142 @@
+/*
+ *  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.shared.client.api.operations;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.directory.ldap.client.api.LdapAsyncConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.future.CompareFuture;
+import org.apache.directory.ldap.client.api.message.CompareRequest;
+import org.apache.directory.ldap.client.api.message.CompareResponse;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests the compare operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer ( 
+    transports = 
+    {
+        @CreateTransport( protocol = "LDAP" ), 
+        @CreateTransport( protocol = "LDAPS" ) 
+    })
+public class ClientCompareRequestTest extends AbstractLdapTestUnit
+{
+    private LdapAsyncConnection connection;
+    
+    private CoreSession session;
+    
+    @Before
+    public void setup() throws Exception
+    {
+        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+        DN bindDn = new DN( "uid=admin,ou=system" );
+        connection.bind( bindDn.getName(), "secret" );
+        
+        session = ldapServer.getDirectoryService().getSession();
+    }
+
+    
+    /**
+     * Close the LdapConnection
+     */
+    @After
+    public void shutdown()
+    {
+        try
+        {
+            if ( connection != null )
+            {
+                connection.close();
+            }
+        }
+        catch( Exception ioe )
+        {
+            fail();
+        }
+    }
+    
+    
+    @Test
+    public void testCompare() throws Exception
+    {
+        DN dn = new DN( "uid=admin,ou=system" );
+        
+        CompareResponse response = connection.compare( dn, SchemaConstants.UID_AT, "admin" );
+        assertNotNull( response );
+        assertTrue( response.isTrue() );
+        
+        response = connection.compare( dn.getName(), SchemaConstants.USER_PASSWORD_AT, "secret".getBytes() );
+        assertNotNull( response );
+        assertTrue( response.isTrue() );
+    }
+
+    
+    @Test
+    public void testCompareAsync() throws Exception
+    {
+        DN dn = new DN( "uid=admin,ou=system" );
+
+        CompareRequest compareRequest = new CompareRequest();
+        compareRequest.setEntryDn( dn );
+        compareRequest.setAttrName( SchemaConstants.UID_AT );
+        compareRequest.setValue( "admin" );
+        
+        connection.compare( compareRequest);
+
+        assertTrue( session.exists( dn ) );
+
+        CompareFuture compareFuture = connection.compareAsync( compareRequest );
+        
+        try
+        {
+            CompareResponse compareResponse = compareFuture.get( 1000, TimeUnit.MILLISECONDS );
+            
+            assertNotNull( compareResponse );
+            assertEquals( ResultCodeEnum.COMPARE_TRUE, compareResponse.getLdapResult().getResultCode() );
+        }
+        catch ( TimeoutException toe )
+        {
+            fail();
+        }
+    }
+}

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java Fri Apr 23 17:08:32 2010
@@ -0,0 +1,281 @@
+/*
+ *   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.shared.client.api.operations;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.directory.ldap.client.api.LdapAsyncConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.exception.LdapException;
+import org.apache.directory.ldap.client.api.future.DeleteFuture;
+import org.apache.directory.ldap.client.api.listener.DeleteListener;
+import org.apache.directory.ldap.client.api.message.DeleteRequest;
+import org.apache.directory.ldap.client.api.message.DeleteResponse;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test case for client delete operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer ( 
+    transports = 
+    {
+        @CreateTransport( protocol = "LDAP" ), 
+        @CreateTransport( protocol = "LDAPS" ) 
+    })
+@ApplyLdifs( {
+    "dn: cn=parent,ou=system",
+    "objectClass: person",
+    "cn: parent_cn",
+    "sn: parent_sn", 
+    
+    "",
+    
+    "dn: cn=child1,cn=parent,ou=system",
+    "objectClass: person",
+    "cn: child1_cn",
+    "sn: child1_sn", 
+    
+    "",
+    
+    "dn: cn=child2,cn=parent,ou=system",
+    "objectClass: person",
+    "cn: child2_cn",
+    "sn: child2_sn", 
+    
+    "",
+    
+    "dn: cn=grand_child11,cn=child1,cn=parent,ou=system",
+    "objectClass: person",
+    "cn: grand_child11_cn",
+    "sn: grand_child11_sn", 
+    
+    "",
+    
+    "dn: cn=grand_child12,cn=child1,cn=parent,ou=system",
+    "objectClass: person",
+    "cn: grand_child12_cn",
+    "sn: grand_child12_sn"
+})
+public class ClientDeleteRequestTest extends AbstractLdapTestUnit
+{
+    private LdapNetworkConnection connection;
+    
+    private CoreSession session;
+    
+    
+    @Before
+    public void setup() throws Exception
+    {
+        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+
+        DN bindDn = new DN( "uid=admin,ou=system" );
+        connection.bind( bindDn.getName(), "secret" );
+        
+        session = ldapServer.getDirectoryService().getAdminSession();
+    }
+
+    
+    /**
+     * Close the LdapConnection
+     */
+    @After
+    public void shutdown()
+    {
+        try
+        {
+            if ( connection != null )
+            {
+                connection.close();
+            }
+        }
+        catch( Exception ioe )
+        {
+            fail();
+        }
+    }
+    
+    
+    @Test
+    public void testDeleteLeafNode() throws Exception
+    {
+        DN dn = new DN( "cn=grand_child12,cn=child1,cn=parent,ou=system" );
+        
+        assertTrue( session.exists( dn ) );
+        
+        DeleteResponse response = connection.delete( dn.getName() );
+        assertNotNull( response );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        
+        assertFalse( session.exists( dn ) );
+    }
+    
+    
+    @Test
+    public void testDeleteNonLeafFailure() throws Exception
+    {
+        DN dn = new DN( "cn=child1,cn=parent,ou=system" ); // has children
+        assertTrue( session.exists( dn ) );
+ 
+        DeleteResponse response = connection.delete( dn.getName() );
+        assertNotNull( response );
+        assertEquals( ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF, response.getLdapResult().getResultCode() );
+        
+        assertTrue( session.exists( dn ) );
+    }
+    
+
+    @Test
+    @Ignore
+    public void testDeleteWithCascadeControl() throws Exception
+    {
+        DN dn = new DN( "cn=parent,ou=system" );
+        
+        assertTrue( session.exists( dn ) );
+        
+        if ( connection.isControlSupported( "1.2.840.113556.1.4.805" ) )
+        {
+            DeleteResponse response = connection.deleteTree( dn );
+            assertNotNull( response );
+            assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+            
+            assertFalse( session.exists( dn ) );
+        }
+    }
+    
+    
+    /**
+     * this method uses reflection to test deleteChildren method without using the
+     * convenient method delete( dn, true ), cause the convenient method checks 
+     * whether the server supports the CascadeControl.
+     * 
+     * Cause ADS supports this control, delete(dn, true) will never call the method
+     * deleteChildren() (which has private scope) 
+     * To test the manual deletion of the entries in the absence of this CascadeControl
+     * reflection was used to invoke the private method deleteChildren().
+     * 
+     */
+    @Test
+    @Ignore
+    public void testDeleteWithoutCascadeControl() throws Exception
+    {
+        DN dn = new DN( "cn=parent,ou=system" );
+        
+        assertTrue( session.exists( dn ) );
+
+        Method deleteChildrenMethod = connection.getClass().getDeclaredMethod( "deleteRecursive", DN.class, Map.class, DeleteListener.class );
+        deleteChildrenMethod.setAccessible( true );
+        
+        DeleteResponse response = ( DeleteResponse ) deleteChildrenMethod.invoke( connection, dn, null, null );
+        assertNotNull( response );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        
+        assertFalse( session.exists( dn ) );
+    }
+
+    
+    /**
+     * @see #testDeleteWithoutCascadeControl()
+     */
+    @Test
+    @Ignore
+    public void testDeleteAsyncWithoutCascadeControl() throws Exception
+    {
+        DN dn = new DN( "cn=parent,ou=system" );
+        
+        assertTrue( session.exists( dn ) );
+
+        Method deleteChildrenMethod = connection.getClass().getDeclaredMethod( "deleteRecursive", DN.class, Map.class, DeleteListener.class );
+        deleteChildrenMethod.setAccessible( true );
+    
+        final AtomicInteger count = new AtomicInteger();
+        
+        DeleteListener listener = new DeleteListener()
+        {
+            public void entryDeleted( LdapAsyncConnection connection, DeleteResponse response ) throws LdapException
+            {
+                assertNotNull( response );
+                assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+                count.incrementAndGet();
+            }
+        };
+        
+        try
+        {
+            connection.deleteTree( dn );
+            fail();
+        }
+        catch ( LdapException le )
+        {
+            assertTrue( true );
+        }
+    }
+
+    
+    @Test
+    public void testDeleteAsync() throws Exception
+    {
+        DN dn = new DN( "cn=grand_child12,cn=child1,cn=parent,ou=system" );
+        
+        assertTrue( session.exists( dn ) );
+        
+        DeleteFuture deleteFuture = connection.deleteAsync( new DeleteRequest( dn ));
+        
+        try
+        {
+            DeleteResponse deleteResponse = deleteFuture.get( 1000, TimeUnit.MILLISECONDS );
+            
+            assertNotNull( deleteResponse );
+            assertEquals( ResultCodeEnum.SUCCESS, deleteResponse.getLdapResult().getResultCode() );
+            assertTrue( connection.isAuthenticated() );
+            assertFalse( session.exists( dn ) );
+        }
+        catch ( TimeoutException toe )
+        {
+            fail();
+        }
+    }
+}

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java Fri Apr 23 17:08:32 2010
@@ -0,0 +1,133 @@
+/*
+ *  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.shared.client.api.operations;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import javax.naming.ldap.StartTlsRequest;
+
+import org.apache.directory.ldap.client.api.LdapAsyncConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.future.ExtendedFuture;
+import org.apache.directory.ldap.client.api.message.ExtendedRequest;
+import org.apache.directory.ldap.client.api.message.ExtendedResponse;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests the extended operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer (
+   transports =
+   {
+       @CreateTransport( protocol = "LDAP" ),
+       @CreateTransport( protocol = "LDAPS" )
+   },
+   extendedOpHandlers =
+   {
+       StartTlsHandler.class
+   })
+public class ClientExtendedRequestTest extends AbstractLdapTestUnit
+{
+   private LdapAsyncConnection connection;
+   private CoreSession session;
+
+   @Before
+   public void setup() throws Exception
+   {
+       connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+       DN bindDn = new DN( "uid=admin,ou=system" );
+       connection.bind( bindDn.getName(), "secret" );
+
+       session = ldapServer.getDirectoryService().getSession();
+   }
+
+
+   /**
+    * Close the LdapConnection
+    */
+   @After
+   public void shutdown()
+   {
+       try
+       {
+           if ( connection != null )
+           {
+               connection.close();
+           }
+       }
+       catch( Exception ioe )
+       {
+           fail();
+       }
+   }
+
+
+   @Test
+   public void testExtended() throws Exception
+   {
+       ExtendedResponse response = connection.extended( StartTlsRequest.OID );
+       assertNotNull( response );
+       assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+   }
+
+
+   @Test
+   public void testExtendedAsync() throws Exception
+   {
+       ExtendedRequest extendedRequest = new ExtendedRequest( StartTlsRequest.OID );
+
+       ExtendedFuture extendedFuture = connection.extendedAsync( extendedRequest );
+
+       try
+       {
+           ExtendedResponse extendedResponse = extendedFuture.get( 1000, TimeUnit.MILLISECONDS );
+
+           assertNotNull( extendedResponse );
+           assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
+           assertTrue( connection.isAuthenticated() );
+       }
+       catch ( TimeoutException toe )
+       {
+           fail();
+       }
+   }
+}
\ No newline at end of file

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java Fri Apr 23 17:08:32 2010
@@ -0,0 +1,179 @@
+/*
+ *   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.shared.client.api.operations;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.directory.ldap.client.api.LdapAsyncConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.future.ModifyDnFuture;
+import org.apache.directory.ldap.client.api.message.ModifyDnRequest;
+import org.apache.directory.ldap.client.api.message.ModifyDnResponse;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.name.RDN;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Testcase for modifyDn operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(FrameworkRunner.class)
+@ApplyLdifs( {
+    "dn: cn=modDn,ou=system",
+    "objectClass: person",
+    "cn: modDn",
+    "sn: snModDn" 
+})
+@CreateLdapServer ( 
+    transports = 
+    {
+        @CreateTransport( protocol = "LDAP" ), 
+        @CreateTransport( protocol = "LDAPS" ) 
+    })
+public class ClientModifyDnRequestTest extends AbstractLdapTestUnit
+{
+    private LdapAsyncConnection connection;
+    
+    private CoreSession session;
+    
+    private String dn = "cn=modDn,ou=system";
+
+    @Before
+    public void setup() throws Exception
+    {
+        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+
+        DN bindDn = new DN( "uid=admin,ou=system" );
+        connection.bind( bindDn.getName(), "secret" );
+        
+        session = ldapServer.getDirectoryService().getAdminSession();
+    }
+
+    
+    /**
+     * Close the LdapConnection
+     */
+    @After
+    public void shutdown()
+    {
+        try
+        {
+            if ( connection != null )
+            {
+                connection.close();
+            }
+        }
+        catch( Exception ioe )
+        {
+            fail();
+        }
+    }
+    
+    
+    @Test
+    public void testRename() throws Exception
+    {
+        ModifyDnResponse resp = connection.rename( dn, "cn=modifyDnWithString" );
+        assertNotNull( resp );
+        assertFalse( session.exists( new DN( dn ) ) );
+        assertTrue( session.exists( new DN( "cn=modifyDnWithString,ou=system" ) ) );
+    }
+    
+    
+    @Test
+    public void testRenameWithoutDeleteOldRdn() throws Exception
+    {
+        ModifyDnResponse resp = connection.rename( dn, "cn=modifyDnWithString", false );
+        assertNotNull( resp );
+        
+        DN oldDn = new DN( dn );
+        assertFalse( session.exists( oldDn ) );
+        
+        Entry entry = session.lookup( new DN( "cn=modifyDnWithString,ou=system" ) );
+        assertNotNull( entry );
+        
+        RDN oldRdn = oldDn.getRdn();
+        assertTrue( entry.contains( oldRdn.getUpType(), ( String ) oldRdn.getNormValue() ) );
+    }
+    
+    
+    @Test
+    public void testMove() throws Exception
+    {
+        ModifyDnResponse resp = connection.move( dn, "ou=users,ou=system" );
+        assertNotNull( resp );
+        
+        DN oldDn = new DN( dn );
+        assertFalse( session.exists( oldDn ) );
+        
+        assertTrue( session.exists( new DN( "cn=modDn,ou=users,ou=system" ) ) );
+    }
+    
+    
+    @Test
+    public void testModifyDnAsync() throws Exception
+    {
+        DN oldDn = new DN( dn );
+        DN newDn = new DN( "cn=modifyDnWithString,ou=system" );
+
+        ModifyDnRequest modDnReq = new ModifyDnRequest();
+        modDnReq.setEntryDn( oldDn );
+        modDnReq.setNewRdn( new RDN( "cn=modifyDnWithString" ) );
+        modDnReq.setDeleteOldRdn( true );
+
+        ModifyDnFuture modifyDnFuture = connection.modifyDnAsync( modDnReq );
+        
+        try
+        {
+            ModifyDnResponse response = modifyDnFuture.get( 1000, TimeUnit.MILLISECONDS );
+            
+            assertNotNull( response );
+
+            assertTrue( connection.isAuthenticated() );
+            assertFalse( session.exists( oldDn ) );
+            assertTrue( session.exists( newDn ) );
+        }
+        catch ( TimeoutException toe )
+        {
+            fail();
+        }
+
+        assertTrue( session.exists( new DN( "cn=modifyDnWithString,ou=system" ) ) );
+    }
+}

Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java?rev=937388&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java Fri Apr 23 17:08:32 2010
@@ -0,0 +1,182 @@
+/*
+ *  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.shared.client.api.operations;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.directory.ldap.client.api.LdapAsyncConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.future.ModifyFuture;
+import org.apache.directory.ldap.client.api.message.ModifyRequest;
+import org.apache.directory.ldap.client.api.message.ModifyResponse;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.ServerEntry;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Tests the modify operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer ( 
+    transports = 
+    {
+        @CreateTransport( protocol = "LDAP" ), 
+        @CreateTransport( protocol = "LDAPS" ) 
+    })
+public class ClientModifyRequestTest extends AbstractLdapTestUnit
+{
+    private LdapAsyncConnection connection;
+    
+    private CoreSession session;
+    
+    @Before
+    public void setup() throws Exception
+    {
+        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+
+        DN bindDn = new DN( "uid=admin,ou=system" );
+        connection.bind( bindDn.getName(), "secret" );
+        
+        session = ldapServer.getDirectoryService().getAdminSession();
+    }
+
+    
+    /**
+     * Close the LdapConnection
+     */
+    @After
+    public void shutdown()
+    {
+        try
+        {
+            if ( connection != null )
+            {
+                connection.close();
+            }
+        }
+        catch( Exception ioe )
+        {
+            fail();
+        }
+    }
+
+    
+    @Test
+    public void testModify() throws Exception
+    {
+        DN dn = new DN( "uid=admin,ou=system" );
+
+        String expected = String.valueOf( System.currentTimeMillis() );
+        ModifyRequest modRequest = new ModifyRequest( dn );
+        modRequest.replace( SchemaConstants.SN_AT, expected );
+
+        connection.modify( modRequest );
+
+        ServerEntry entry = session.lookup( dn );
+
+        String actual = entry.get( SchemaConstants.SN_AT ).getString();
+
+        assertEquals( expected, actual );
+    }
+
+
+    @Test
+    public void testModifyWithEntry() throws Exception
+    {
+        DN dn = new DN( "uid=admin,ou=system" );
+        
+        Entry entry = new DefaultClientEntry( dn );
+        
+        String expectedSn = String.valueOf( System.currentTimeMillis() );
+        String expectedCn = String.valueOf( System.currentTimeMillis() );
+        
+        entry.add( SchemaConstants.SN_AT, expectedSn );
+        
+        entry.add( SchemaConstants.CN_AT, expectedCn );
+        
+        connection.modify( entry, ModificationOperation.REPLACE_ATTRIBUTE );
+        
+        ServerEntry lookupEntry = session.lookup( dn );
+
+        String actualSn = lookupEntry.get( SchemaConstants.SN_AT ).getString();
+        assertEquals( expectedSn, actualSn );
+        
+        String actualCn = lookupEntry.get( SchemaConstants.CN_AT ).getString();
+        assertEquals( expectedCn, actualCn );
+    }
+    
+    
+    @Test
+    public void modifyAsync() throws Exception
+    {
+        DN dn = new DN( "uid=admin,ou=system" );
+
+        String expected = String.valueOf( System.currentTimeMillis() );
+        ModifyRequest modRequest = new ModifyRequest( dn );
+        modRequest.replace( SchemaConstants.SN_AT, expected );
+        
+        assertTrue( session.exists( dn ) );
+        
+        ModifyFuture modifyFuture = connection.modifyAsync( modRequest );
+        
+        try
+        {
+            ModifyResponse response = modifyFuture.get( 1000, TimeUnit.MILLISECONDS );
+            
+            assertNotNull( response );
+
+            ServerEntry entry = session.lookup( dn );
+
+            String actual = entry.get( SchemaConstants.SN_AT ).getString();
+
+            assertEquals( expected, actual );
+
+            assertTrue( connection.isAuthenticated() );
+            assertTrue( session.exists( dn ) );
+        }
+        catch ( TimeoutException toe )
+        {
+            fail();
+        }
+    }
+}



Mime
View raw message