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 2006/02/12 06:51:22 UTC
svn commit: r377135 [34/36] - in /directory/sandbox/akarasulu/rc1:
apacheds/core-plugin/src/main/java/org/apache/directory/server/core/tools/schema/
apacheds/core-plugin/src/test/java/org/apache/directory/server/core/tools/schema/
apacheds/core-shared/...
Modified: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/AllTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/AllTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/AllTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/AllTests.java Sat Feb 11 21:50:03 2006
@@ -1,40 +1,40 @@
-/*
- * 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.testsuite.ldaptests.jndi.ops.delete;
-
-import junit.framework.TestSuite;
-
-/**
- * Contains the test classes for the LDAP delete operation executed via JNDI. It
- * is used to form the complete suite into a structure.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
- */
-public class AllTests extends TestSuite
-{
-
- public static TestSuite suite()
- {
- TestSuite suite = new TestSuite("Delete");
-
- suite.addTestSuite(BasicDeleteTests.class);
- suite.addTestSuite(TreeDeleteControlTests.class);
-
- return suite;
- }
-}
+/*
+ * 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.testsuite.ldaptests.jndi.ops.delete;
+
+import junit.framework.TestSuite;
+
+/**
+ * Contains the test classes for the LDAP delete operation executed via JNDI. It
+ * is used to form the complete suite into a structure.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class AllTests extends TestSuite
+{
+
+ public static TestSuite suite()
+ {
+ TestSuite suite = new TestSuite("Delete");
+
+ suite.addTestSuite(BasicDeleteTests.class);
+ suite.addTestSuite(TreeDeleteControlTests.class);
+
+ return suite;
+ }
+}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/AllTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/AllTests.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 11 21:50:03 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/BasicDeleteTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/BasicDeleteTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/BasicDeleteTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/BasicDeleteTests.java Sat Feb 11 21:50:03 2006
@@ -1,112 +1,112 @@
-/*
- * 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.testsuite.ldaptests.jndi.ops.delete;
-
-import javax.naming.ContextNotEmptyException;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-
-import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
-import org.apache.ldap.testsuite.ldaptests.jndi.util.AttributesFactory;
-
-/**
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
- */
-public class BasicDeleteTests extends BaseProtocolTest
-{
- /**
- * Basic deletion test. Creates an entry, delete it, and check whether it is
- * gone.
- *
- * @throws NamingException
- */
- public void testDeleteEntry() throws NamingException
- {
-
- final String ou = "myUnit";
- final String rdn = "ou=myUnit";
-
- DirContext ctx = this.createContext();
- DirContext target = (DirContext) ctx.lookup(this.getTestContainerRdn());
-
- // Add an entry
- Attributes attributes = AttributesFactory.createOrganizationalUnitAttributes(ou);
- DirContext orgUnit = target.createSubcontext(rdn, attributes);
-
- // Check wether entry is created
- orgUnit = (DirContext) target.lookup(rdn);
- assertNotNull(orgUnit);
-
- // Delete Entry
- target.unbind(rdn);
-
- // Check whether it is gone
- try {
- orgUnit = (DirContext) target.lookup(rdn);
- fail("Deletion of entry failed");
- } catch (NameNotFoundException nnfe) {
- // expected behaviour
- assertTrue(true);
- }
-
- ctx.close();
- }
-
- /**
- * Deletion of an entry which is not a leaf.
- *
- * @throws NamingException
- */
- public void testDeleteNonEmptyEntry() throws NamingException
- {
- DirContext ctx = this.createContext();
- DirContext target = (DirContext) ctx.lookup(this.getTestContainerRdn());
-
- // Add an entry
- final String ou = "nonLeaf";
- final String rdn = "ou=" + ou;
- Attributes attributes = AttributesFactory.createOrganizationalUnitAttributes(ou);
- target.createSubcontext(rdn, attributes);
-
- // Check wether entry is created
- DirContext nonLeafRdn = (DirContext) target.lookup(rdn);
- assertNotNull(nonLeafRdn);
-
- // Add an entry below this
- final String ouLeaf = "leaf";
- final String rdnLeaf = "ou=" + ouLeaf;
- attributes = AttributesFactory.createOrganizationalUnitAttributes(ouLeaf);
- nonLeafRdn.createSubcontext(rdnLeaf, attributes);
-
- // Try to delete subtree Entry
- try {
- target.unbind(rdn);
- fail("deletion of entry should fail.");
- } catch (ContextNotEmptyException e) {
- // expected;
- }
-
- // Verify that entry soes exist
- nonLeafRdn = (DirContext) target.lookup(rdn);
- assertNotNull(nonLeafRdn);
-
- ctx.close();
- }
-}
+/*
+ * 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.testsuite.ldaptests.jndi.ops.delete;
+
+import javax.naming.ContextNotEmptyException;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+
+import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
+import org.apache.ldap.testsuite.ldaptests.jndi.util.AttributesFactory;
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BasicDeleteTests extends BaseProtocolTest
+{
+ /**
+ * Basic deletion test. Creates an entry, delete it, and check whether it is
+ * gone.
+ *
+ * @throws NamingException
+ */
+ public void testDeleteEntry() throws NamingException
+ {
+
+ final String ou = "myUnit";
+ final String rdn = "ou=myUnit";
+
+ DirContext ctx = this.createContext();
+ DirContext target = (DirContext) ctx.lookup(this.getTestContainerRdn());
+
+ // Add an entry
+ Attributes attributes = AttributesFactory.createOrganizationalUnitAttributes(ou);
+ DirContext orgUnit = target.createSubcontext(rdn, attributes);
+
+ // Check wether entry is created
+ orgUnit = (DirContext) target.lookup(rdn);
+ assertNotNull(orgUnit);
+
+ // Delete Entry
+ target.unbind(rdn);
+
+ // Check whether it is gone
+ try {
+ orgUnit = (DirContext) target.lookup(rdn);
+ fail("Deletion of entry failed");
+ } catch (NameNotFoundException nnfe) {
+ // expected behaviour
+ assertTrue(true);
+ }
+
+ ctx.close();
+ }
+
+ /**
+ * Deletion of an entry which is not a leaf.
+ *
+ * @throws NamingException
+ */
+ public void testDeleteNonEmptyEntry() throws NamingException
+ {
+ DirContext ctx = this.createContext();
+ DirContext target = (DirContext) ctx.lookup(this.getTestContainerRdn());
+
+ // Add an entry
+ final String ou = "nonLeaf";
+ final String rdn = "ou=" + ou;
+ Attributes attributes = AttributesFactory.createOrganizationalUnitAttributes(ou);
+ target.createSubcontext(rdn, attributes);
+
+ // Check wether entry is created
+ DirContext nonLeafRdn = (DirContext) target.lookup(rdn);
+ assertNotNull(nonLeafRdn);
+
+ // Add an entry below this
+ final String ouLeaf = "leaf";
+ final String rdnLeaf = "ou=" + ouLeaf;
+ attributes = AttributesFactory.createOrganizationalUnitAttributes(ouLeaf);
+ nonLeafRdn.createSubcontext(rdnLeaf, attributes);
+
+ // Try to delete subtree Entry
+ try {
+ target.unbind(rdn);
+ fail("deletion of entry should fail.");
+ } catch (ContextNotEmptyException e) {
+ // expected;
+ }
+
+ // Verify that entry soes exist
+ nonLeafRdn = (DirContext) target.lookup(rdn);
+ assertNotNull(nonLeafRdn);
+
+ ctx.close();
+ }
+}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/BasicDeleteTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/BasicDeleteTests.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 11 21:50:03 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/TreeDeleteControlTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/TreeDeleteControlTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/TreeDeleteControlTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/TreeDeleteControlTests.java Sat Feb 11 21:50:03 2006
@@ -1,113 +1,113 @@
-/*
- * 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.testsuite.ldaptests.jndi.ops.delete;
-
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.naming.OperationNotSupportedException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.ldap.Control;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
-import org.apache.ldap.testsuite.ldaptests.jndi.util.AttributesFactory;
-
-/**
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
- */
-public class TreeDeleteControlTests extends BaseProtocolTest
-{
- class TreeDeleteControl implements Control
- {
- private static final long serialVersionUID = 1L;
-
- private boolean critical;
-
- TreeDeleteControl() {
- this(Control.CRITICAL);
- }
-
- TreeDeleteControl(boolean criticalValue) {
- this.critical = criticalValue;
- }
-
- public String getID()
- {
- return "1.2.840.113556.1.4.805";
- }
-
- public boolean isCritical()
- {
- return this.critical;
- }
-
- public byte[] getEncodedValue()
- {
- return null;
- }
- }
-
- public void testDeleteSubtreeWithControl() throws NamingException
- {
- LdapContext ctx = this.createContext();
- LdapContext target = (LdapContext) ctx.lookup(this.getTestContainerRdn());
-
- // Add an entry
- final String ou = "nonLeaf";
- final String rdn = "ou=" + ou;
- Attributes attributes = AttributesFactory.createOrganizationalUnitAttributes(ou);
- target.createSubcontext(rdn, attributes);
-
- // Check wether entry is created
- DirContext nonLeafRdn = (DirContext) target.lookup(rdn);
- assertNotNull(nonLeafRdn);
-
- // Add an entry below this
- final String ouLeaf = "leaf";
- final String rdnLeaf = "ou=" + ouLeaf;
- attributes = AttributesFactory.createOrganizationalUnitAttributes(ouLeaf);
- nonLeafRdn.createSubcontext(rdnLeaf, attributes);
-
- // Try to delete subtree Entry
- boolean supported = true;
- try {
- target.setRequestControls(new Control[] { new TreeDeleteControl(Control.CRITICAL) });
- target.unbind(rdn);
- } catch (OperationNotSupportedException e) {
- // expected;
- supported = false;
- }
- target.setRequestControls(null);
-
- // Check, whether entry is deleted
- boolean deleted = false;
- try {
- target.lookup(rdn);
- } catch (NameNotFoundException e) {
- deleted = true;
- }
-
- // Two option are valid here:
- // 1. The control is not supported and the entry still exists
- // 2. The control is supported and te entry is deleted
- assertTrue((!supported & !deleted) || (supported & deleted));
-
- ctx.close();
- }
-}
+/*
+ * 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.testsuite.ldaptests.jndi.ops.delete;
+
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
+import org.apache.ldap.testsuite.ldaptests.jndi.util.AttributesFactory;
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TreeDeleteControlTests extends BaseProtocolTest
+{
+ class TreeDeleteControl implements Control
+ {
+ private static final long serialVersionUID = 1L;
+
+ private boolean critical;
+
+ TreeDeleteControl() {
+ this(Control.CRITICAL);
+ }
+
+ TreeDeleteControl(boolean criticalValue) {
+ this.critical = criticalValue;
+ }
+
+ public String getID()
+ {
+ return "1.2.840.113556.1.4.805";
+ }
+
+ public boolean isCritical()
+ {
+ return this.critical;
+ }
+
+ public byte[] getEncodedValue()
+ {
+ return null;
+ }
+ }
+
+ public void testDeleteSubtreeWithControl() throws NamingException
+ {
+ LdapContext ctx = this.createContext();
+ LdapContext target = (LdapContext) ctx.lookup(this.getTestContainerRdn());
+
+ // Add an entry
+ final String ou = "nonLeaf";
+ final String rdn = "ou=" + ou;
+ Attributes attributes = AttributesFactory.createOrganizationalUnitAttributes(ou);
+ target.createSubcontext(rdn, attributes);
+
+ // Check wether entry is created
+ DirContext nonLeafRdn = (DirContext) target.lookup(rdn);
+ assertNotNull(nonLeafRdn);
+
+ // Add an entry below this
+ final String ouLeaf = "leaf";
+ final String rdnLeaf = "ou=" + ouLeaf;
+ attributes = AttributesFactory.createOrganizationalUnitAttributes(ouLeaf);
+ nonLeafRdn.createSubcontext(rdnLeaf, attributes);
+
+ // Try to delete subtree Entry
+ boolean supported = true;
+ try {
+ target.setRequestControls(new Control[] { new TreeDeleteControl(Control.CRITICAL) });
+ target.unbind(rdn);
+ } catch (OperationNotSupportedException e) {
+ // expected;
+ supported = false;
+ }
+ target.setRequestControls(null);
+
+ // Check, whether entry is deleted
+ boolean deleted = false;
+ try {
+ target.lookup(rdn);
+ } catch (NameNotFoundException e) {
+ deleted = true;
+ }
+
+ // Two option are valid here:
+ // 1. The control is not supported and the entry still exists
+ // 2. The control is supported and te entry is deleted
+ assertTrue((!supported & !deleted) || (supported & deleted));
+
+ ctx.close();
+ }
+}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/TreeDeleteControlTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/delete/TreeDeleteControlTests.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 11 21:50:03 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/AllTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/AllTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/AllTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/AllTests.java Sat Feb 11 21:50:03 2006
@@ -1,38 +1,38 @@
-/*
- * 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.testsuite.ldaptests.jndi.ops.extended;
-
-import junit.framework.TestSuite;
-
-/**
- * Contains the test classes for the LDAP extended operation executed via JNDI.
- * It is used to form the complete suite into a structure.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev: $
- */
-public class AllTests extends TestSuite
-{
-
- public static TestSuite suite()
- {
- TestSuite suite = new TestSuite("Extended");
- suite.addTestSuite(UnknownExtendedOperationTest.class);
-
- return suite;
- }
-}
+/*
+ * 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.testsuite.ldaptests.jndi.ops.extended;
+
+import junit.framework.TestSuite;
+
+/**
+ * Contains the test classes for the LDAP extended operation executed via JNDI.
+ * It is used to form the complete suite into a structure.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class AllTests extends TestSuite
+{
+
+ public static TestSuite suite()
+ {
+ TestSuite suite = new TestSuite("Extended");
+ suite.addTestSuite(UnknownExtendedOperationTest.class);
+
+ return suite;
+ }
+}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/AllTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/AllTests.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sat Feb 11 21:50:03 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/UnknownExtendedOperationTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/UnknownExtendedOperationTest.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/UnknownExtendedOperationTest.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/UnknownExtendedOperationTest.java Sat Feb 11 21:50:03 2006
@@ -1,87 +1,87 @@
-/*
- * 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.testsuite.ldaptests.jndi.ops.extended;
-
-import javax.naming.CommunicationException;
-import javax.naming.NamingException;
-import javax.naming.ldap.ExtendedRequest;
-import javax.naming.ldap.ExtendedResponse;
-import javax.naming.ldap.LdapContext;
-
-/**
- * Checks the behaviour of the server for an unknown extended operation. Because
- * extended operations are server dependent, this is the only test case for them
- * within the suite.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev: $
- */
-public class UnknownExtendedOperationTest extends org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest
-{
-
- /**
- * Checks the behaviour of the server for an unknown extended operation. It
- * calls an extended exception, which does not exist. Expected behaviour is
- * a CommunicationException.
- *
- * @throws NamingException
- */
- public void testUnknownExtendedOperation() throws NamingException
- {
- LdapContext ctx = this.createContext();
-
- 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. This
- * is forced by using OID "1.1".
- */
- private class UnknownExtendedOperationRequest implements ExtendedRequest
- {
-
- private static final long serialVersionUID = 1L;
-
- public static final String OID = "1.1";
-
- /**
- * Returns the OID of the extended operation.
- *
- * @return the OID
- */
- public String getID()
- {
- return OID;
- }
-
- public byte[] getEncodedValue()
- {
- return null;
- }
-
- public ExtendedResponse createExtendedResponse(String id, byte[] berValue, int offset, int length)
- throws NamingException
- {
- return null;
- }
- }
+/*
+ * 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.testsuite.ldaptests.jndi.ops.extended;
+
+import javax.naming.CommunicationException;
+import javax.naming.NamingException;
+import javax.naming.ldap.ExtendedRequest;
+import javax.naming.ldap.ExtendedResponse;
+import javax.naming.ldap.LdapContext;
+
+/**
+ * Checks the behaviour of the server for an unknown extended operation. Because
+ * extended operations are server dependent, this is the only test case for them
+ * within the suite.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class UnknownExtendedOperationTest extends org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest
+{
+
+ /**
+ * Checks the behaviour of the server for an unknown extended operation. It
+ * calls an extended exception, which does not exist. Expected behaviour is
+ * a CommunicationException.
+ *
+ * @throws NamingException
+ */
+ public void testUnknownExtendedOperation() throws NamingException
+ {
+ LdapContext ctx = this.createContext();
+
+ 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. This
+ * is forced by using OID "1.1".
+ */
+ private class UnknownExtendedOperationRequest implements ExtendedRequest
+ {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String OID = "1.1";
+
+ /**
+ * Returns the OID of the extended operation.
+ *
+ * @return the OID
+ */
+ public String getID()
+ {
+ return OID;
+ }
+
+ public byte[] getEncodedValue()
+ {
+ return null;
+ }
+
+ public ExtendedResponse createExtendedResponse(String id, byte[] berValue, int offset, int length)
+ throws NamingException
+ {
+ return null;
+ }
+ }
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/UnknownExtendedOperationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/extended/UnknownExtendedOperationTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sat Feb 11 21:50:03 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/AllTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/AllTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/AllTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/AllTests.java Sat Feb 11 21:50:03 2006
@@ -1,42 +1,42 @@
-/*
- * 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.testsuite.ldaptests.jndi.ops.modify;
-
-import junit.framework.TestSuite;
-
-/**
- * Contains the test classes for the LDAP modify operation executed via JNDI. It
- * is used to form the complete suite into a structure.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
- */
-public class AllTests extends TestSuite
-{
-
- public static TestSuite suite()
- {
- TestSuite suite = new TestSuite("Modify");
-
- suite.addTestSuite(BasicModifyAddTests.class);
- suite.addTestSuite(BasicModifyRemoveTests.class);
- suite.addTestSuite(BasicModifyReplaceTests.class);
- suite.addTestSuite(MixedModifyFailureTests.class);
-
- return suite;
- }
+/*
+ * 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.testsuite.ldaptests.jndi.ops.modify;
+
+import junit.framework.TestSuite;
+
+/**
+ * Contains the test classes for the LDAP modify operation executed via JNDI. It
+ * is used to form the complete suite into a structure.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class AllTests extends TestSuite
+{
+
+ public static TestSuite suite()
+ {
+ TestSuite suite = new TestSuite("Modify");
+
+ suite.addTestSuite(BasicModifyAddTests.class);
+ suite.addTestSuite(BasicModifyRemoveTests.class);
+ suite.addTestSuite(BasicModifyReplaceTests.class);
+ suite.addTestSuite(MixedModifyFailureTests.class);
+
+ return suite;
+ }
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/AllTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/AllTests.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 11 21:50:03 2006
@@ -1 +1,4 @@
-HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
+Rev
+Revision
+Date
+Id
Modified: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyAddTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyAddTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyAddTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyAddTests.java Sat Feb 11 21:50:03 2006
@@ -1,181 +1,181 @@
-/*
- * 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.testsuite.ldaptests.jndi.ops.modify;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.AttributeInUseException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
-
-import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
-
-/**
- * Tests for the modify operations with JNDI, which only include replace
- * modifications.
- *
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev: $
- */
-public class BasicModifyAddTests extends BaseProtocolTest
-{
-
- DirContext start;
-
- DirContext ctx;
-
- public static final String RDN = "cn=Tori Amos";
-
- public static final String PERSON_DESCRIPTION = "an American singer-songwriter";
-
- protected Attributes getPersonAttributes(String sn, String cn)
- {
- Attributes attributes = new BasicAttributes();
- Attribute attribute = new BasicAttribute("objectClass");
- attribute.add("top");
- attribute.add("person");
- attributes.put(attribute);
- attributes.put("cn", cn);
- attributes.put("sn", sn);
-
- return attributes;
- }
-
- public void setUp() throws NamingException
- {
- super.setUp();
-
- start = this.createContext();
- ctx = (DirContext) start.lookup(this.getTestContainerRdn());
-
- // Create a person with description
- Attributes attributes = this.getPersonAttributes("Amos", "Tori Amos");
- attributes.put("description", PERSON_DESCRIPTION);
-
- ctx.createSubcontext(RDN, attributes);
- }
-
- public void tearDown() throws NamingException
- {
- ctx.unbind(RDN);
- ctx.close();
-
- start.close();
- start = null;
-
- super.tearDown();
- }
-
- /**
- * @throws NamingException
- */
- public void testAddNewAttributeValue() throws NamingException
- {
-
- // Change description attribute
- String newValue = "1234567890";
- Attributes attrs = new BasicAttributes("telephoneNumber", newValue);
- ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, attrs);
-
- // Verify, that attribute value changed
- attrs = ctx.getAttributes(RDN);
- Attribute attr = attrs.get("telephoneNumber");
- assertNotNull(attr);
- assertTrue(attr.contains(newValue));
- assertEquals(1, attr.size());
- }
-
- /**
- * @throws NamingException
- */
- public void testAddNewAttributeValues() throws NamingException
- {
-
- // Change description attribute
- String[] newValues = { "1234567890", "999999999" };
- Attribute attr = new BasicAttribute("telephoneNumber");
- attr.add(newValues[0]);
- attr.add(newValues[1]);
- Attributes attrs = new BasicAttributes();
- attrs.put(attr);
- ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, attrs);
-
- // Verify, that attribute values are present
- attrs = ctx.getAttributes(RDN);
- attr = attrs.get("telephoneNumber");
- assertNotNull(attr);
- assertTrue(attr.contains(newValues[0]));
- assertTrue(attr.contains(newValues[1]));
- assertEquals(newValues.length, attr.size());
- }
-
- /**
- * @throws NamingException
- */
- public void testAddAdditionalAttributeValue() throws NamingException
- {
-
- // A new description attribute value
- String newValue = "A new description for this person";
- assertFalse(newValue.equals(PERSON_DESCRIPTION));
- Attributes attrs = new BasicAttributes("description", newValue);
-
- ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, attrs);
-
- // Verify, that attribute value is added
- attrs = ctx.getAttributes(RDN);
- Attribute attr = attrs.get("description");
- assertNotNull(attr);
- assertTrue(attr.contains(newValue));
- assertTrue(attr.contains(PERSON_DESCRIPTION));
- assertEquals(2, attr.size());
- }
-
- /**
- * Try to add an already existing attribute value.
- *
- * Expected behaviour: Modify operation fails with an
- * AttributeInUseException. Original LDAP Error code: 20 (Indicates that the
- * attribute value specified in a modify or add operation already exists as
- * a value for that attribute).
- *
- * @throws NamingException
- */
- public void testAddExistingAttributeValue() throws NamingException
- {
-
- // Change description attribute
- Attributes attrs = new BasicAttributes("description", PERSON_DESCRIPTION);
- try {
- ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, attrs);
- fail("Adding an already existing atribute value should fail.");
- } catch (AttributeInUseException e) {
- // expected behaviour
- }
-
- // Verify, that attribute is still there, and is the only one
- attrs = ctx.getAttributes(RDN);
- Attribute attr = attrs.get("description");
- assertNotNull(attr);
- assertTrue(attr.contains(PERSON_DESCRIPTION));
- assertEquals(1, attr.size());
- }
-
+/*
+ * 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.testsuite.ldaptests.jndi.ops.modify;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.AttributeInUseException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+
+import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
+
+/**
+ * Tests for the modify operations with JNDI, which only include replace
+ * modifications.
+ *
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BasicModifyAddTests extends BaseProtocolTest
+{
+
+ DirContext start;
+
+ DirContext ctx;
+
+ public static final String RDN = "cn=Tori Amos";
+
+ public static final String PERSON_DESCRIPTION = "an American singer-songwriter";
+
+ protected Attributes getPersonAttributes(String sn, String cn)
+ {
+ Attributes attributes = new BasicAttributes();
+ Attribute attribute = new BasicAttribute("objectClass");
+ attribute.add("top");
+ attribute.add("person");
+ attributes.put(attribute);
+ attributes.put("cn", cn);
+ attributes.put("sn", sn);
+
+ return attributes;
+ }
+
+ public void setUp() throws NamingException
+ {
+ super.setUp();
+
+ start = this.createContext();
+ ctx = (DirContext) start.lookup(this.getTestContainerRdn());
+
+ // Create a person with description
+ Attributes attributes = this.getPersonAttributes("Amos", "Tori Amos");
+ attributes.put("description", PERSON_DESCRIPTION);
+
+ ctx.createSubcontext(RDN, attributes);
+ }
+
+ public void tearDown() throws NamingException
+ {
+ ctx.unbind(RDN);
+ ctx.close();
+
+ start.close();
+ start = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * @throws NamingException
+ */
+ public void testAddNewAttributeValue() throws NamingException
+ {
+
+ // Change description attribute
+ String newValue = "1234567890";
+ Attributes attrs = new BasicAttributes("telephoneNumber", newValue);
+ ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, attrs);
+
+ // Verify, that attribute value changed
+ attrs = ctx.getAttributes(RDN);
+ Attribute attr = attrs.get("telephoneNumber");
+ assertNotNull(attr);
+ assertTrue(attr.contains(newValue));
+ assertEquals(1, attr.size());
+ }
+
+ /**
+ * @throws NamingException
+ */
+ public void testAddNewAttributeValues() throws NamingException
+ {
+
+ // Change description attribute
+ String[] newValues = { "1234567890", "999999999" };
+ Attribute attr = new BasicAttribute("telephoneNumber");
+ attr.add(newValues[0]);
+ attr.add(newValues[1]);
+ Attributes attrs = new BasicAttributes();
+ attrs.put(attr);
+ ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, attrs);
+
+ // Verify, that attribute values are present
+ attrs = ctx.getAttributes(RDN);
+ attr = attrs.get("telephoneNumber");
+ assertNotNull(attr);
+ assertTrue(attr.contains(newValues[0]));
+ assertTrue(attr.contains(newValues[1]));
+ assertEquals(newValues.length, attr.size());
+ }
+
+ /**
+ * @throws NamingException
+ */
+ public void testAddAdditionalAttributeValue() throws NamingException
+ {
+
+ // A new description attribute value
+ String newValue = "A new description for this person";
+ assertFalse(newValue.equals(PERSON_DESCRIPTION));
+ Attributes attrs = new BasicAttributes("description", newValue);
+
+ ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, attrs);
+
+ // Verify, that attribute value is added
+ attrs = ctx.getAttributes(RDN);
+ Attribute attr = attrs.get("description");
+ assertNotNull(attr);
+ assertTrue(attr.contains(newValue));
+ assertTrue(attr.contains(PERSON_DESCRIPTION));
+ assertEquals(2, attr.size());
+ }
+
+ /**
+ * Try to add an already existing attribute value.
+ *
+ * Expected behaviour: Modify operation fails with an
+ * AttributeInUseException. Original LDAP Error code: 20 (Indicates that the
+ * attribute value specified in a modify or add operation already exists as
+ * a value for that attribute).
+ *
+ * @throws NamingException
+ */
+ public void testAddExistingAttributeValue() throws NamingException
+ {
+
+ // Change description attribute
+ Attributes attrs = new BasicAttributes("description", PERSON_DESCRIPTION);
+ try {
+ ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, attrs);
+ fail("Adding an already existing atribute value should fail.");
+ } catch (AttributeInUseException e) {
+ // expected behaviour
+ }
+
+ // Verify, that attribute is still there, and is the only one
+ attrs = ctx.getAttributes(RDN);
+ Attribute attr = attrs.get("description");
+ assertNotNull(attr);
+ assertTrue(attr.contains(PERSON_DESCRIPTION));
+ assertEquals(1, attr.size());
+ }
+
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyAddTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyAddTests.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sat Feb 11 21:50:03 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyRemoveTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyRemoveTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyRemoveTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyRemoveTests.java Sat Feb 11 21:50:03 2006
@@ -1,273 +1,273 @@
-/*
- * 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.testsuite.ldaptests.jndi.ops.modify;
-
-import javax.naming.InvalidNameException;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.InvalidAttributeIdentifierException;
-import javax.naming.directory.NoSuchAttributeException;
-import javax.naming.directory.SchemaViolationException;
-
-import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
-
-/**
- * Tests for the modify operations with JNDI, which only include simple remove
- * modifications.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev: $
- */
-public class BasicModifyRemoveTests extends BaseProtocolTest
-{
-
- DirContext ctx;
-
- DirContext target;
-
- public static final String RDN = "cn=Tori Amos";
-
- protected Attributes getInetOrgPersonAttributes(String sn, String cn)
- {
- Attributes attributes = new BasicAttributes();
- Attribute attribute = new BasicAttribute("objectClass");
- attribute.add("top");
- attribute.add("person");
- attribute.add("organizationalPerson");
- attribute.add("inetOrgPerson");
-
- attributes.put(attribute);
- attributes.put("cn", cn);
- attributes.put("sn", sn);
-
- return attributes;
- }
-
- public void setUp() throws NamingException
- {
- super.setUp();
-
- ctx = this.createContext();
- target = (DirContext) ctx.lookup(this.getTestContainerRdn());
-
- // Create a person with description
- Attributes attributes = this.getInetOrgPersonAttributes("Amos", "Tori Amos");
- attributes.put("description", "an American singer-songwriter");
-
- target.createSubcontext(RDN, attributes);
- }
-
- public void tearDown() throws NamingException
- {
- target.unbind(RDN);
- target.close();
-
- ctx.close();
- ctx = null;
-
- super.tearDown();
- }
-
- /**
- * Remove an attribute, which is not required.
- *
- * Expected result: After successful deletion, attribute is not present in
- * entry.
- *
- * @throws NamingException
- */
- public void testRemoveNotRequiredAttribute() throws NamingException
- {
-
- // Remove description Attribute
- Attribute attr = new BasicAttribute("description");
- Attributes attrs = new BasicAttributes();
- attrs.put(attr);
- target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
-
- // Verify, that attribute is deleted
- attrs = target.getAttributes(RDN);
- attr = attrs.get("description");
- assertNull(attr);
- }
-
- /**
- * Remove two not required attributes.
- *
- * Expected result: After successful deletion, both attributes ar not
- * present in entry.
- *
- * @throws NamingException
- */
- public void testRemoveTwoNotRequiredAttributes() throws NamingException
- {
-
- // add telephoneNumber to entry
- Attributes tn = new BasicAttributes("telephoneNumber", "12345678");
- target.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, tn);
-
- // Remove description and telephoneNumber to Attribute
- Attributes attrs = new BasicAttributes();
- attrs.put(new BasicAttribute("description"));
- attrs.put(new BasicAttribute("telephoneNumber"));
- target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
-
- // Verify, that attributes are deleted
- attrs = target.getAttributes(RDN);
- assertNull(attrs.get("description"));
- assertNull(attrs.get("telephoneNumber"));
- assertNotNull(attrs.get("cn"));
- assertNotNull(attrs.get("sn"));
- }
-
- /**
- * Remove a required attribute.
- *
- * Expected Result: Deletion fails with NamingException (Schema Violation).
- *
- * @throws NamingException
- */
- public void testRemoveRequiredAttribute() throws NamingException
- {
-
- // Remove sn attribute
- Attribute attr = new BasicAttribute("sn");
- Attributes attrs = new BasicAttributes();
- attrs.put(attr);
-
- try {
- target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
- fail("Deletion of required attribute should fail.");
- } catch (SchemaViolationException e) {
- // expected behaviour
- }
- }
-
- /**
- * Remove a required attribute from RDN.
- *
- * Expected Result: Deletion fails with SchemaViolationException.
- *
- * @throws NamingException
- */
- public void testRemovePartOfRdn() throws NamingException
- {
-
- // Remove sn attribute
- Attribute attr = new BasicAttribute("cn");
- Attributes attrs = new BasicAttributes();
- attrs.put(attr);
-
- try {
- target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
- fail("Deletion of RDN attribute should fail.");
- } catch (NamingException e) {
- // expected behaviour
- }
- }
-
- /**
- * Remove a not required attribute from RDN.
- *
- * Expected Result: Deletion fails with SchemaViolationException.
- *
- * @throws NamingException
- */
- public void testRemovePartOfRdnNotRequired() throws NamingException
- {
-
- // add uid attribute
- Attributes uid = new BasicAttributes("uid", "tamos");
- target.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, uid);
-
- // Change RDN to another attribute (uid)
- String newRdn = "uid=tamos";
- target.addToEnvironment("java.naming.ldap.deleteRDN", "false");
- target.rename(RDN, newRdn);
-
- // Remove uid, which is now RDN attribute
- Attribute attr = new BasicAttribute("uid");
- Attributes attrs = new BasicAttributes();
- attrs.put(attr);
-
- try {
- target.modifyAttributes(newRdn, DirContext.REMOVE_ATTRIBUTE, attrs);
- fail("Deletion of RDN attribute should fail.");
- } catch (SchemaViolationException e) {
- // expected behaviour
- } catch (InvalidNameException e) {
- // Expected behaviour
- }
-
- // Change RDN back to original
- target.addToEnvironment("java.naming.ldap.deleteRDN", "false");
- target.rename(newRdn, RDN);
- }
-
- /**
- * Remove a an attribute which is not present on the entry, but in the
- * schema.
- *
- * Expected result: Deletion fails with NoSuchAttributeException
- *
- * @throws NamingException
- */
- public void testRemoveAttributeNotPresent() throws NamingException
- {
-
- // Remove telephoneNumber Attribute
- Attribute attr = new BasicAttribute("telephoneNumber");
- Attributes attrs = new BasicAttributes();
- attrs.put(attr);
-
- try {
- target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
- fail("Deletion of attribute, which is not present in the entry, should fail.");
- } catch (NoSuchAttributeException e) {
- // expected behaviour
- }
- }
-
- /**
- * Remove a an attribute which is not present in the schema.
- *
- * Expected result: Deletion fails with NoSuchAttributeException
- *
- * @throws NamingException
- */
- public void testRemoveAttributeNotValid() throws NamingException
- {
-
- // Remove phantasy attribute
- Attribute attr = new BasicAttribute("XXX");
- Attributes attrs = new BasicAttributes();
- attrs.put(attr);
-
- try {
- target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
- fail("Deletion of an invalid attribute should fail.");
- } catch (NoSuchAttributeException e) {
- // expected behaviour
- } catch (InvalidAttributeIdentifierException e) {
- // expected behaviour
- }
- }
+/*
+ * 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.testsuite.ldaptests.jndi.ops.modify;
+
+import javax.naming.InvalidNameException;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidAttributeIdentifierException;
+import javax.naming.directory.NoSuchAttributeException;
+import javax.naming.directory.SchemaViolationException;
+
+import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
+
+/**
+ * Tests for the modify operations with JNDI, which only include simple remove
+ * modifications.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BasicModifyRemoveTests extends BaseProtocolTest
+{
+
+ DirContext ctx;
+
+ DirContext target;
+
+ public static final String RDN = "cn=Tori Amos";
+
+ protected Attributes getInetOrgPersonAttributes(String sn, String cn)
+ {
+ Attributes attributes = new BasicAttributes();
+ Attribute attribute = new BasicAttribute("objectClass");
+ attribute.add("top");
+ attribute.add("person");
+ attribute.add("organizationalPerson");
+ attribute.add("inetOrgPerson");
+
+ attributes.put(attribute);
+ attributes.put("cn", cn);
+ attributes.put("sn", sn);
+
+ return attributes;
+ }
+
+ public void setUp() throws NamingException
+ {
+ super.setUp();
+
+ ctx = this.createContext();
+ target = (DirContext) ctx.lookup(this.getTestContainerRdn());
+
+ // Create a person with description
+ Attributes attributes = this.getInetOrgPersonAttributes("Amos", "Tori Amos");
+ attributes.put("description", "an American singer-songwriter");
+
+ target.createSubcontext(RDN, attributes);
+ }
+
+ public void tearDown() throws NamingException
+ {
+ target.unbind(RDN);
+ target.close();
+
+ ctx.close();
+ ctx = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Remove an attribute, which is not required.
+ *
+ * Expected result: After successful deletion, attribute is not present in
+ * entry.
+ *
+ * @throws NamingException
+ */
+ public void testRemoveNotRequiredAttribute() throws NamingException
+ {
+
+ // Remove description Attribute
+ Attribute attr = new BasicAttribute("description");
+ Attributes attrs = new BasicAttributes();
+ attrs.put(attr);
+ target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
+
+ // Verify, that attribute is deleted
+ attrs = target.getAttributes(RDN);
+ attr = attrs.get("description");
+ assertNull(attr);
+ }
+
+ /**
+ * Remove two not required attributes.
+ *
+ * Expected result: After successful deletion, both attributes ar not
+ * present in entry.
+ *
+ * @throws NamingException
+ */
+ public void testRemoveTwoNotRequiredAttributes() throws NamingException
+ {
+
+ // add telephoneNumber to entry
+ Attributes tn = new BasicAttributes("telephoneNumber", "12345678");
+ target.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, tn);
+
+ // Remove description and telephoneNumber to Attribute
+ Attributes attrs = new BasicAttributes();
+ attrs.put(new BasicAttribute("description"));
+ attrs.put(new BasicAttribute("telephoneNumber"));
+ target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
+
+ // Verify, that attributes are deleted
+ attrs = target.getAttributes(RDN);
+ assertNull(attrs.get("description"));
+ assertNull(attrs.get("telephoneNumber"));
+ assertNotNull(attrs.get("cn"));
+ assertNotNull(attrs.get("sn"));
+ }
+
+ /**
+ * Remove a required attribute.
+ *
+ * Expected Result: Deletion fails with NamingException (Schema Violation).
+ *
+ * @throws NamingException
+ */
+ public void testRemoveRequiredAttribute() throws NamingException
+ {
+
+ // Remove sn attribute
+ Attribute attr = new BasicAttribute("sn");
+ Attributes attrs = new BasicAttributes();
+ attrs.put(attr);
+
+ try {
+ target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
+ fail("Deletion of required attribute should fail.");
+ } catch (SchemaViolationException e) {
+ // expected behaviour
+ }
+ }
+
+ /**
+ * Remove a required attribute from RDN.
+ *
+ * Expected Result: Deletion fails with SchemaViolationException.
+ *
+ * @throws NamingException
+ */
+ public void testRemovePartOfRdn() throws NamingException
+ {
+
+ // Remove sn attribute
+ Attribute attr = new BasicAttribute("cn");
+ Attributes attrs = new BasicAttributes();
+ attrs.put(attr);
+
+ try {
+ target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
+ fail("Deletion of RDN attribute should fail.");
+ } catch (NamingException e) {
+ // expected behaviour
+ }
+ }
+
+ /**
+ * Remove a not required attribute from RDN.
+ *
+ * Expected Result: Deletion fails with SchemaViolationException.
+ *
+ * @throws NamingException
+ */
+ public void testRemovePartOfRdnNotRequired() throws NamingException
+ {
+
+ // add uid attribute
+ Attributes uid = new BasicAttributes("uid", "tamos");
+ target.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE, uid);
+
+ // Change RDN to another attribute (uid)
+ String newRdn = "uid=tamos";
+ target.addToEnvironment("java.naming.ldap.deleteRDN", "false");
+ target.rename(RDN, newRdn);
+
+ // Remove uid, which is now RDN attribute
+ Attribute attr = new BasicAttribute("uid");
+ Attributes attrs = new BasicAttributes();
+ attrs.put(attr);
+
+ try {
+ target.modifyAttributes(newRdn, DirContext.REMOVE_ATTRIBUTE, attrs);
+ fail("Deletion of RDN attribute should fail.");
+ } catch (SchemaViolationException e) {
+ // expected behaviour
+ } catch (InvalidNameException e) {
+ // Expected behaviour
+ }
+
+ // Change RDN back to original
+ target.addToEnvironment("java.naming.ldap.deleteRDN", "false");
+ target.rename(newRdn, RDN);
+ }
+
+ /**
+ * Remove a an attribute which is not present on the entry, but in the
+ * schema.
+ *
+ * Expected result: Deletion fails with NoSuchAttributeException
+ *
+ * @throws NamingException
+ */
+ public void testRemoveAttributeNotPresent() throws NamingException
+ {
+
+ // Remove telephoneNumber Attribute
+ Attribute attr = new BasicAttribute("telephoneNumber");
+ Attributes attrs = new BasicAttributes();
+ attrs.put(attr);
+
+ try {
+ target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
+ fail("Deletion of attribute, which is not present in the entry, should fail.");
+ } catch (NoSuchAttributeException e) {
+ // expected behaviour
+ }
+ }
+
+ /**
+ * Remove a an attribute which is not present in the schema.
+ *
+ * Expected result: Deletion fails with NoSuchAttributeException
+ *
+ * @throws NamingException
+ */
+ public void testRemoveAttributeNotValid() throws NamingException
+ {
+
+ // Remove phantasy attribute
+ Attribute attr = new BasicAttribute("XXX");
+ Attributes attrs = new BasicAttributes();
+ attrs.put(attr);
+
+ try {
+ target.modifyAttributes(RDN, DirContext.REMOVE_ATTRIBUTE, attrs);
+ fail("Deletion of an invalid attribute should fail.");
+ } catch (NoSuchAttributeException e) {
+ // expected behaviour
+ } catch (InvalidAttributeIdentifierException e) {
+ // expected behaviour
+ }
+ }
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyRemoveTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyRemoveTests.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sat Feb 11 21:50:03 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyReplaceTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyReplaceTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyReplaceTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyReplaceTests.java Sat Feb 11 21:50:03 2006
@@ -1,134 +1,134 @@
-/*
- * 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.testsuite.ldaptests.jndi.ops.modify;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
-
-import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
-
-/**
- * Tests for the modify operations with JNDI, which only include replace
- * modifications.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev: $
- */
-public class BasicModifyReplaceTests extends BaseProtocolTest
-{
-
- DirContext ctx;
-
- DirContext target;
-
- public static final String RDN = "cn=Tori Amos";
-
- protected Attributes getPersonAttributes(String sn, String cn)
- {
- Attributes attributes = new BasicAttributes();
- Attribute attribute = new BasicAttribute("objectClass");
- attribute.add("top");
- attribute.add("person");
- attributes.put(attribute);
- attributes.put("cn", cn);
- attributes.put("sn", sn);
-
- return attributes;
- }
-
- public void setUp() throws NamingException
- {
- super.setUp();
-
- ctx = this.createContext();
- target = (DirContext) ctx.lookup(this.getTestContainerRdn());
-
- // Create a person with description
- Attributes attributes = this.getPersonAttributes("Amos", "Tori Amos");
- attributes.put("description", "an American singer-songwriter");
-
- target.createSubcontext(RDN, attributes);
- }
-
- public void tearDown() throws NamingException
- {
- target.unbind(RDN);
- target.close();
-
- ctx.close();
- ctx = null;
-
- super.tearDown();
- }
-
- /**
- * Replace a not required attribute.
- *
- * Expected result: After successful deletion, attribute is not present in
- * entry
- *
- * @throws NamingException
- */
- public void testReplaceNotRequiredAttribute() throws NamingException
- {
-
- // Change description attribute
- String newValue = "A new description for this person";
- Attribute attr = new BasicAttribute("description", newValue);
- Attributes attrs = new BasicAttributes();
- attrs.put(attr);
- target.modifyAttributes(RDN, DirContext.REPLACE_ATTRIBUTE, attrs);
-
- // Verify, that attribute value changed
- attrs = target.getAttributes(RDN);
- attr = attrs.get("description");
- assertTrue(attr.contains(newValue));
- assertEquals(1, attr.size());
-
- }
-
- /**
- * Try to Replace RDN.
- *
- * @throws NamingException
- */
- public void testTryToReplaceRdn() throws NamingException
- {
-
- // Change RDN attribute cn
- String newValue = "New Value";
- Attribute attr = new BasicAttribute("cn", newValue);
- Attributes attrs = new BasicAttributes();
- attrs.put(attr);
- try {
- target.modifyAttributes(RDN, DirContext.REPLACE_ATTRIBUTE, attrs);
- } catch (NamingException e) {
- // expected behaviour
- // TODO: refine Exception
- }
-
- // Verify, that attribute value has not changed
- attrs = target.getAttributes(RDN);
- attr = attrs.get("cn");
- assertEquals(1, attr.size());
- assertFalse(attr.contains(newValue));
- }
+/*
+ * 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.testsuite.ldaptests.jndi.ops.modify;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+
+import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
+
+/**
+ * Tests for the modify operations with JNDI, which only include replace
+ * modifications.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BasicModifyReplaceTests extends BaseProtocolTest
+{
+
+ DirContext ctx;
+
+ DirContext target;
+
+ public static final String RDN = "cn=Tori Amos";
+
+ protected Attributes getPersonAttributes(String sn, String cn)
+ {
+ Attributes attributes = new BasicAttributes();
+ Attribute attribute = new BasicAttribute("objectClass");
+ attribute.add("top");
+ attribute.add("person");
+ attributes.put(attribute);
+ attributes.put("cn", cn);
+ attributes.put("sn", sn);
+
+ return attributes;
+ }
+
+ public void setUp() throws NamingException
+ {
+ super.setUp();
+
+ ctx = this.createContext();
+ target = (DirContext) ctx.lookup(this.getTestContainerRdn());
+
+ // Create a person with description
+ Attributes attributes = this.getPersonAttributes("Amos", "Tori Amos");
+ attributes.put("description", "an American singer-songwriter");
+
+ target.createSubcontext(RDN, attributes);
+ }
+
+ public void tearDown() throws NamingException
+ {
+ target.unbind(RDN);
+ target.close();
+
+ ctx.close();
+ ctx = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Replace a not required attribute.
+ *
+ * Expected result: After successful deletion, attribute is not present in
+ * entry
+ *
+ * @throws NamingException
+ */
+ public void testReplaceNotRequiredAttribute() throws NamingException
+ {
+
+ // Change description attribute
+ String newValue = "A new description for this person";
+ Attribute attr = new BasicAttribute("description", newValue);
+ Attributes attrs = new BasicAttributes();
+ attrs.put(attr);
+ target.modifyAttributes(RDN, DirContext.REPLACE_ATTRIBUTE, attrs);
+
+ // Verify, that attribute value changed
+ attrs = target.getAttributes(RDN);
+ attr = attrs.get("description");
+ assertTrue(attr.contains(newValue));
+ assertEquals(1, attr.size());
+
+ }
+
+ /**
+ * Try to Replace RDN.
+ *
+ * @throws NamingException
+ */
+ public void testTryToReplaceRdn() throws NamingException
+ {
+
+ // Change RDN attribute cn
+ String newValue = "New Value";
+ Attribute attr = new BasicAttribute("cn", newValue);
+ Attributes attrs = new BasicAttributes();
+ attrs.put(attr);
+ try {
+ target.modifyAttributes(RDN, DirContext.REPLACE_ATTRIBUTE, attrs);
+ } catch (NamingException e) {
+ // expected behaviour
+ // TODO: refine Exception
+ }
+
+ // Verify, that attribute value has not changed
+ attrs = target.getAttributes(RDN);
+ attr = attrs.get("cn");
+ assertEquals(1, attr.size());
+ assertFalse(attr.contains(newValue));
+ }
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyReplaceTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/modify/BasicModifyReplaceTests.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sat Feb 11 21:50:03 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id