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 [33/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/add/AllTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/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/add/AllTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/AllTests.java Sat Feb 11 21:50:03 2006
@@ -1,41 +1,41 @@
-/*
- * 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.add;
-
-import junit.framework.TestSuite;
-
-/**
- * Contains the test classes for the LDAP add 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("Add");
-
- suite.addTestSuite(BasicAddTests.class);
- suite.addTestSuite(SpecialCharacterAddTests.class);
- suite.addTestSuite(BinaryDataAddTest.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.add;
+
+import junit.framework.TestSuite;
+
+/**
+ * Contains the test classes for the LDAP add 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("Add");
+
+ suite.addTestSuite(BasicAddTests.class);
+ suite.addTestSuite(SpecialCharacterAddTests.class);
+ suite.addTestSuite(BinaryDataAddTest.class);
+
+ return suite;
+ }
+}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/AllTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/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/add/BasicAddTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BasicAddTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BasicAddTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BasicAddTests.java Sat Feb 11 21:50:03 2006
@@ -1,144 +1,144 @@
-/*
- * 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.add;
-
-import javax.naming.NameAlreadyBoundException;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.DirContext;
-
-import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
-import org.apache.ldap.testsuite.ldaptests.jndi.util.AttributesFactory;
-
-/**
- * Basic tests for the LDAP add operation.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
- */
-public class BasicAddTests extends BaseProtocolTest
-{
-
- private static String PERSON_SN_VALUE = "Amos";
-
- private static String PERSON_CN_VALUE = "Tori Amos";
-
- private static String PERSON_RDN = "cn=" + PERSON_CN_VALUE;
-
- DirContext ctx;
-
- public void setUp() throws NamingException
- {
- super.setUp();
-
- ctx = this.createContext();
- ctx = (DirContext) ctx.lookup(this.getTestContainerRdn());
- }
-
- public void tearDown() throws NamingException
- {
- ctx.close();
- ctx = null;
-
- super.tearDown();
- }
-
- /**
- * Just checks whether creation of a simple entry succeeds.
- *
- * @throws NamingException
- */
- public void testAddEntry() throws NamingException
- {
- // Add a person
- Attributes attributes = AttributesFactory.createPersonAttributes(PERSON_CN_VALUE, PERSON_SN_VALUE);
- DirContext person = ctx.createSubcontext(PERSON_RDN, attributes);
-
- // Check wether person looks fine
- person = (DirContext) ctx.lookup(PERSON_RDN);
- assertNotNull(person);
- attributes = person.getAttributes("");
-
- // objectclasses
- // TODO: Move this useful algorithm to a tool class
- Attribute ocls = attributes.get("objectClass");
- String[] expectedOcls = { "top", "person" };
- for (int i = 0; i < expectedOcls.length; i++) {
- boolean found = false;
- String name = expectedOcls[i].toLowerCase();
- for (int j = 0; j < ocls.size(); j++) {
- if (name.equalsIgnoreCase(ocls.get(j).toString())) {
- found = true;
- }
- }
- assertTrue("object class " + name + " is not present", found);
- }
-
- // Other attributes
- Attribute cn = attributes.get("cn");
- assertTrue("cn value", cn.contains(PERSON_CN_VALUE));
- Attribute sn = attributes.get("sn");
- assertTrue("sn value", sn.contains(PERSON_SN_VALUE));
- }
-
- /**
- * Checks whether adding an entry with existing DN causes an error.
- *
- * @throws NamingException
- */
- public void testAddDuplicateEntry() throws NamingException
- {
- Attributes attributes = AttributesFactory.createPersonAttributes(PERSON_CN_VALUE, PERSON_SN_VALUE);
- ctx.createSubcontext(PERSON_RDN, attributes);
-
- try {
- ctx.createSubcontext(PERSON_RDN, attributes);
- fail("duplicate entry should fail");
- } catch (NameAlreadyBoundException e) {
- // Excepted behaviour;
- assertTrue(true);
- }
- }
-
- /**
- * Checks whether adding an entry with multi valued attribute succeeds.
- *
- * @throws NamingException
- */
- public void testAddEntryWithMultipleValues() throws NamingException
- {
- // Create a person, description has multiple attributes
- Attributes attributes = AttributesFactory.createPersonAttributes(PERSON_CN_VALUE, PERSON_SN_VALUE);
- Attribute descr = new BasicAttribute("description");
- descr.add("a description for the person");
- descr.add("another description for this person");
- attributes.put(descr);
- int two = descr.size();
-
- ctx.createSubcontext(PERSON_RDN, attributes);
-
- DirContext tori = (DirContext) ctx.lookup(PERSON_RDN);
- attributes = tori.getAttributes("");
- descr = attributes.get("description");
-
- assertEquals(two, descr.size());
- }
-
- // TODO: Add test for binary data (here, or in an own test case
+/*
+ * 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.add;
+
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.DirContext;
+
+import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
+import org.apache.ldap.testsuite.ldaptests.jndi.util.AttributesFactory;
+
+/**
+ * Basic tests for the LDAP add operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BasicAddTests extends BaseProtocolTest
+{
+
+ private static String PERSON_SN_VALUE = "Amos";
+
+ private static String PERSON_CN_VALUE = "Tori Amos";
+
+ private static String PERSON_RDN = "cn=" + PERSON_CN_VALUE;
+
+ DirContext ctx;
+
+ public void setUp() throws NamingException
+ {
+ super.setUp();
+
+ ctx = this.createContext();
+ ctx = (DirContext) ctx.lookup(this.getTestContainerRdn());
+ }
+
+ public void tearDown() throws NamingException
+ {
+ ctx.close();
+ ctx = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Just checks whether creation of a simple entry succeeds.
+ *
+ * @throws NamingException
+ */
+ public void testAddEntry() throws NamingException
+ {
+ // Add a person
+ Attributes attributes = AttributesFactory.createPersonAttributes(PERSON_CN_VALUE, PERSON_SN_VALUE);
+ DirContext person = ctx.createSubcontext(PERSON_RDN, attributes);
+
+ // Check wether person looks fine
+ person = (DirContext) ctx.lookup(PERSON_RDN);
+ assertNotNull(person);
+ attributes = person.getAttributes("");
+
+ // objectclasses
+ // TODO: Move this useful algorithm to a tool class
+ Attribute ocls = attributes.get("objectClass");
+ String[] expectedOcls = { "top", "person" };
+ for (int i = 0; i < expectedOcls.length; i++) {
+ boolean found = false;
+ String name = expectedOcls[i].toLowerCase();
+ for (int j = 0; j < ocls.size(); j++) {
+ if (name.equalsIgnoreCase(ocls.get(j).toString())) {
+ found = true;
+ }
+ }
+ assertTrue("object class " + name + " is not present", found);
+ }
+
+ // Other attributes
+ Attribute cn = attributes.get("cn");
+ assertTrue("cn value", cn.contains(PERSON_CN_VALUE));
+ Attribute sn = attributes.get("sn");
+ assertTrue("sn value", sn.contains(PERSON_SN_VALUE));
+ }
+
+ /**
+ * Checks whether adding an entry with existing DN causes an error.
+ *
+ * @throws NamingException
+ */
+ public void testAddDuplicateEntry() throws NamingException
+ {
+ Attributes attributes = AttributesFactory.createPersonAttributes(PERSON_CN_VALUE, PERSON_SN_VALUE);
+ ctx.createSubcontext(PERSON_RDN, attributes);
+
+ try {
+ ctx.createSubcontext(PERSON_RDN, attributes);
+ fail("duplicate entry should fail");
+ } catch (NameAlreadyBoundException e) {
+ // Excepted behaviour;
+ assertTrue(true);
+ }
+ }
+
+ /**
+ * Checks whether adding an entry with multi valued attribute succeeds.
+ *
+ * @throws NamingException
+ */
+ public void testAddEntryWithMultipleValues() throws NamingException
+ {
+ // Create a person, description has multiple attributes
+ Attributes attributes = AttributesFactory.createPersonAttributes(PERSON_CN_VALUE, PERSON_SN_VALUE);
+ Attribute descr = new BasicAttribute("description");
+ descr.add("a description for the person");
+ descr.add("another description for this person");
+ attributes.put(descr);
+ int two = descr.size();
+
+ ctx.createSubcontext(PERSON_RDN, attributes);
+
+ DirContext tori = (DirContext) ctx.lookup(PERSON_RDN);
+ attributes = tori.getAttributes("");
+ descr = attributes.get("description");
+
+ assertEquals(two, descr.size());
+ }
+
+ // TODO: Add test for binary data (here, or in an own test case
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BasicAddTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BasicAddTests.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/add/BinaryDataAddTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BinaryDataAddTest.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BinaryDataAddTest.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BinaryDataAddTest.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.add;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Random;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-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;
-
-/**
- * Check whether adding entries with binary data works.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
- */
-public class BinaryDataAddTest extends BaseProtocolTest
-{
-
- private static String PERSON_SN_VALUE = "Amos";
-
- private static String PERSON_CN_VALUE = "Tori Amos";
-
- private static String PERSON_RDN = "cn=" + PERSON_CN_VALUE;
-
- DirContext ctx;
-
- public void setUp() throws NamingException
- {
- super.setUp();
-
- ctx = this.createContext();
- ctx = (DirContext) ctx.lookup(this.getTestContainerRdn());
- }
-
- public void tearDown() throws NamingException
- {
- ctx.close();
- ctx = null;
-
- super.tearDown();
- }
-
- /**
- * Add an inetOrgPerson entry with photo and check whether it can be
- * retrieved back correctly.
- */
- public void testInetOrgPersonWithJpegPhoto() throws NamingException
- {
- Attributes attrs = AttributesFactory.createInetOrgPersonAttributes(PERSON_CN_VALUE, PERSON_SN_VALUE);
-
- // Random data for jpegPhoto, 64k
- byte[] sourceData = new byte[64 * 1024];
- Random r = new Random(0);
- for (int i = 0; i < sourceData.length; i++) {
- sourceData[i] = (byte) r.nextInt();
- }
- attrs.put("jpegPhoto", sourceData);
-
- // Create entry
- ctx.bind(PERSON_RDN, null, attrs);
-
- // Read same entry and compare data bytewise
- Attributes readAttrs = ctx.getAttributes(PERSON_RDN);
- Attribute image = readAttrs.get("jpegPhoto");
- byte[] imageBytes = (byte[]) image.get();
- for (int i = 0; i < imageBytes.length; i++) {
- assertEquals("Byte number " + i, sourceData[i], imageBytes[i]);
- }
- }
-
- /**
- * Add an person entry with userPassword and check whether the value can be
- * retrieved back correctly.
- */
- public void testPersonWithPassword() throws NamingException, UnsupportedEncodingException
- {
- Attributes attrs = AttributesFactory.createPersonAttributes(PERSON_CN_VALUE, PERSON_SN_VALUE);
-
- String password = "MySecret1!";
- attrs.put("userPassword", password.getBytes("UTF-8"));
-
- // Create entry
- ctx.bind(PERSON_RDN, null, attrs);
-
- // Read same entry and compare password value
- Attributes readAttrs = ctx.getAttributes(PERSON_RDN);
- Attribute pwd = readAttrs.get("userPassword");
- byte[] bytes = (byte[]) pwd.get();
- String toTest = new String(bytes, "UTF-8");
- assertEquals(password, toTest);
- }
-
+/*
+ * 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.add;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Random;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+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;
+
+/**
+ * Check whether adding entries with binary data works.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BinaryDataAddTest extends BaseProtocolTest
+{
+
+ private static String PERSON_SN_VALUE = "Amos";
+
+ private static String PERSON_CN_VALUE = "Tori Amos";
+
+ private static String PERSON_RDN = "cn=" + PERSON_CN_VALUE;
+
+ DirContext ctx;
+
+ public void setUp() throws NamingException
+ {
+ super.setUp();
+
+ ctx = this.createContext();
+ ctx = (DirContext) ctx.lookup(this.getTestContainerRdn());
+ }
+
+ public void tearDown() throws NamingException
+ {
+ ctx.close();
+ ctx = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Add an inetOrgPerson entry with photo and check whether it can be
+ * retrieved back correctly.
+ */
+ public void testInetOrgPersonWithJpegPhoto() throws NamingException
+ {
+ Attributes attrs = AttributesFactory.createInetOrgPersonAttributes(PERSON_CN_VALUE, PERSON_SN_VALUE);
+
+ // Random data for jpegPhoto, 64k
+ byte[] sourceData = new byte[64 * 1024];
+ Random r = new Random(0);
+ for (int i = 0; i < sourceData.length; i++) {
+ sourceData[i] = (byte) r.nextInt();
+ }
+ attrs.put("jpegPhoto", sourceData);
+
+ // Create entry
+ ctx.bind(PERSON_RDN, null, attrs);
+
+ // Read same entry and compare data bytewise
+ Attributes readAttrs = ctx.getAttributes(PERSON_RDN);
+ Attribute image = readAttrs.get("jpegPhoto");
+ byte[] imageBytes = (byte[]) image.get();
+ for (int i = 0; i < imageBytes.length; i++) {
+ assertEquals("Byte number " + i, sourceData[i], imageBytes[i]);
+ }
+ }
+
+ /**
+ * Add an person entry with userPassword and check whether the value can be
+ * retrieved back correctly.
+ */
+ public void testPersonWithPassword() throws NamingException, UnsupportedEncodingException
+ {
+ Attributes attrs = AttributesFactory.createPersonAttributes(PERSON_CN_VALUE, PERSON_SN_VALUE);
+
+ String password = "MySecret1!";
+ attrs.put("userPassword", password.getBytes("UTF-8"));
+
+ // Create entry
+ ctx.bind(PERSON_RDN, null, attrs);
+
+ // Read same entry and compare password value
+ Attributes readAttrs = ctx.getAttributes(PERSON_RDN);
+ Attribute pwd = readAttrs.get("userPassword");
+ byte[] bytes = (byte[]) pwd.get();
+ String toTest = new String(bytes, "UTF-8");
+ assertEquals(password, toTest);
+ }
+
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BinaryDataAddTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/BinaryDataAddTest.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/add/SpecialCharacterAddTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.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.add;
-
-import java.io.UnsupportedEncodingException;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-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;
-
-/**
- * Check whether adding entries with special characters (e.g. German umlauts) works.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
- */
-public class SpecialCharacterAddTests extends BaseProtocolTest
-{
-
- DirContext ctx;
-
- public void setUp() throws NamingException
- {
- super.setUp();
-
- ctx = this.createContext();
- ctx = (DirContext) ctx.lookup(this.getTestContainerRdn());
- }
-
- public void tearDown() throws NamingException
- {
- ctx.close();
- ctx = null;
-
- super.tearDown();
- }
-
- /**
- * Checks that an entry with non-ASCII chars can be added
- *
- * @throws NamingException
- */
- public void testAddEntryTurkish() throws NamingException
- {
- // The bytes used are the UTF-8 encoding for turkish characters
- String cn = new String(
- new byte[] { (byte)0xC4, (byte)0xB0, (byte)0xC4, (byte)0xB1,
- (byte)0xC5, (byte)0x9E, (byte)0xC5, (byte)0x9F,
- (byte)0xC3, (byte)0x96, (byte)0xC3, (byte)0xB6,
- (byte)0xC3, (byte)0x9C, (byte)0xC3, (byte)0xBC,
- (byte)0xC4, (byte)0x9E, (byte)0xC4, (byte)0x9F });
- String sn = "baumgarten";
-
- // Add a person
- Attributes attributes = AttributesFactory.createPersonAttributes(cn, sn);
-
- String rdn = "cn=" + cn;
-
- DirContext person = ctx.createSubcontext(rdn, attributes);
-
- // Check whether person looks fine
- person = (DirContext) ctx.lookup(rdn);
- assertNotNull(person);
- attributes = person.getAttributes("");
-
- // objectclasses
- Attribute ocls = attributes.get("objectClass");
- String[] expectedOcls = { "top", "person" };
-
- for (int i = 0; i < expectedOcls.length; i++) {
- String name = expectedOcls[i];
- assertTrue("object class " + name + " is not present", ocls.contains(name));
- }
-
- // Other attributes
- Attribute cnRes = attributes.get("cn");
- assertTrue(cnRes.contains(cn));
- Attribute snRes = attributes.get("sn");
- assertTrue(snRes.contains(sn));
- }
-
- public void testAddEntryWithGermanUmlauts() throws NamingException, UnsupportedEncodingException
- {
-
- // Create a person with german "umlaut". The UTF-8 bytes code for
- // a german o umlaut is C3 B6. Its equivalence in ISO-8859-1 is F6.
- String cnValue = new String(new byte[]{'S', 't', 'e', 'f', 'a', 'n', ' ', 'Z', (byte)0xC3, (byte)0xB6, 'r', 'n', 'e', 'r'}, "UTF-8");
- String snValue = new String(new byte[]{'Z', (byte)0xC3, (byte)0xB6, 'r', 'n', 'e', 'r'}, "UTF-8");
- String rdn = "cn=" + cnValue;
- String allUmlauts = new String(new byte[]{(byte)0xC3, (byte)0x84, (byte)0xC3, (byte)0x96, (byte)0xC3, (byte)0x9C, (byte)0xC3, (byte)0x9F, (byte)0xC3, (byte)0xA4, (byte)0xC3, (byte)0xB6, (byte)0xC3, (byte)0xBC}, "UTF-8");
- Attributes attributes = AttributesFactory.createPersonAttributes(cnValue, snValue);
- attributes.put("description", allUmlauts);
-
- // add entry
- ctx.createSubcontext(rdn, attributes);
-
- // lookup and verify entry
- DirContext stefan = (DirContext) ctx.lookup(rdn);
- attributes = stefan.getAttributes("");
- // cn
- Attribute cn = attributes.get("cn");
- assertNotNull(cn);
- assertEquals("number of cn values", 1, cn.size());
- assertTrue(cn.contains(cnValue));
- // sn
- Attribute sn = attributes.get("sn");
- assertNotNull(sn);
- assertEquals("number of sn values", 1, sn.size());
- assertTrue(sn.contains(snValue));
- // description
- Attribute description = attributes.get("description");
- assertNotNull(description);
- assertEquals("number of description values", 1, description.size());
- assertTrue(description.contains(allUmlauts));
- }
-
- /**
- * Checks that an entry with non-ASCII chars can be added
- *
- * @throws NamingException
- */
- public void testAddEntryNonASCII() throws NamingException
- {
- // The bytes used are the UTF-8 encoding for Jérôme :
- // 0x4A = J
- // 0xC3 0xA9 = é, encoded
- // 0x72 = r
- // 0xC3 0xB4 = ô, encoded
- // 0x6D = m
- // 0x65 = e
- String cn = new String(
- new byte[] { 0x4A, (byte) 0xC3, (byte) 0xA9, 0x72, (byte) 0xC3, (byte) 0xB4, 0x6D, 0x65 });
- String sn = "baumgarten";
-
- // Add a person
- Attributes attributes = AttributesFactory.createPersonAttributes(cn, sn);
-
- String rdn = "cn=" + cn;
-
- DirContext person = ctx.createSubcontext(rdn, attributes);
-
- // Check whether person looks fine
- person = (DirContext) ctx.lookup(rdn);
- assertNotNull(person);
- attributes = person.getAttributes("");
-
- // objectclasses
- Attribute ocls = attributes.get("objectClass");
- String[] expectedOcls = { "top", "person" };
-
- for (int i = 0; i < expectedOcls.length; i++) {
- String name = expectedOcls[i];
- assertTrue("object class " + name + " is not present", ocls.contains(name));
- }
-
- // Other attributes
- Attribute cnRes = attributes.get("cn");
- assertTrue(cnRes.contains(cn));
- Attribute snRes = attributes.get("sn");
- assertTrue(snRes.contains(sn));
- }
-
+/*
+ * 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.add;
+
+import java.io.UnsupportedEncodingException;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+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;
+
+/**
+ * Check whether adding entries with special characters (e.g. German umlauts) works.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SpecialCharacterAddTests extends BaseProtocolTest
+{
+
+ DirContext ctx;
+
+ public void setUp() throws NamingException
+ {
+ super.setUp();
+
+ ctx = this.createContext();
+ ctx = (DirContext) ctx.lookup(this.getTestContainerRdn());
+ }
+
+ public void tearDown() throws NamingException
+ {
+ ctx.close();
+ ctx = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Checks that an entry with non-ASCII chars can be added
+ *
+ * @throws NamingException
+ */
+ public void testAddEntryTurkish() throws NamingException
+ {
+ // The bytes used are the UTF-8 encoding for turkish characters
+ String cn = new String(
+ new byte[] { (byte)0xC4, (byte)0xB0, (byte)0xC4, (byte)0xB1,
+ (byte)0xC5, (byte)0x9E, (byte)0xC5, (byte)0x9F,
+ (byte)0xC3, (byte)0x96, (byte)0xC3, (byte)0xB6,
+ (byte)0xC3, (byte)0x9C, (byte)0xC3, (byte)0xBC,
+ (byte)0xC4, (byte)0x9E, (byte)0xC4, (byte)0x9F });
+ String sn = "baumgarten";
+
+ // Add a person
+ Attributes attributes = AttributesFactory.createPersonAttributes(cn, sn);
+
+ String rdn = "cn=" + cn;
+
+ DirContext person = ctx.createSubcontext(rdn, attributes);
+
+ // Check whether person looks fine
+ person = (DirContext) ctx.lookup(rdn);
+ assertNotNull(person);
+ attributes = person.getAttributes("");
+
+ // objectclasses
+ Attribute ocls = attributes.get("objectClass");
+ String[] expectedOcls = { "top", "person" };
+
+ for (int i = 0; i < expectedOcls.length; i++) {
+ String name = expectedOcls[i];
+ assertTrue("object class " + name + " is not present", ocls.contains(name));
+ }
+
+ // Other attributes
+ Attribute cnRes = attributes.get("cn");
+ assertTrue(cnRes.contains(cn));
+ Attribute snRes = attributes.get("sn");
+ assertTrue(snRes.contains(sn));
+ }
+
+ public void testAddEntryWithGermanUmlauts() throws NamingException, UnsupportedEncodingException
+ {
+
+ // Create a person with german "umlaut". The UTF-8 bytes code for
+ // a german o umlaut is C3 B6. Its equivalence in ISO-8859-1 is F6.
+ String cnValue = new String(new byte[]{'S', 't', 'e', 'f', 'a', 'n', ' ', 'Z', (byte)0xC3, (byte)0xB6, 'r', 'n', 'e', 'r'}, "UTF-8");
+ String snValue = new String(new byte[]{'Z', (byte)0xC3, (byte)0xB6, 'r', 'n', 'e', 'r'}, "UTF-8");
+ String rdn = "cn=" + cnValue;
+ String allUmlauts = new String(new byte[]{(byte)0xC3, (byte)0x84, (byte)0xC3, (byte)0x96, (byte)0xC3, (byte)0x9C, (byte)0xC3, (byte)0x9F, (byte)0xC3, (byte)0xA4, (byte)0xC3, (byte)0xB6, (byte)0xC3, (byte)0xBC}, "UTF-8");
+ Attributes attributes = AttributesFactory.createPersonAttributes(cnValue, snValue);
+ attributes.put("description", allUmlauts);
+
+ // add entry
+ ctx.createSubcontext(rdn, attributes);
+
+ // lookup and verify entry
+ DirContext stefan = (DirContext) ctx.lookup(rdn);
+ attributes = stefan.getAttributes("");
+ // cn
+ Attribute cn = attributes.get("cn");
+ assertNotNull(cn);
+ assertEquals("number of cn values", 1, cn.size());
+ assertTrue(cn.contains(cnValue));
+ // sn
+ Attribute sn = attributes.get("sn");
+ assertNotNull(sn);
+ assertEquals("number of sn values", 1, sn.size());
+ assertTrue(sn.contains(snValue));
+ // description
+ Attribute description = attributes.get("description");
+ assertNotNull(description);
+ assertEquals("number of description values", 1, description.size());
+ assertTrue(description.contains(allUmlauts));
+ }
+
+ /**
+ * Checks that an entry with non-ASCII chars can be added
+ *
+ * @throws NamingException
+ */
+ public void testAddEntryNonASCII() throws NamingException
+ {
+ // The bytes used are the UTF-8 encoding for Jérôme :
+ // 0x4A = J
+ // 0xC3 0xA9 = é, encoded
+ // 0x72 = r
+ // 0xC3 0xB4 = ô, encoded
+ // 0x6D = m
+ // 0x65 = e
+ String cn = new String(
+ new byte[] { 0x4A, (byte) 0xC3, (byte) 0xA9, 0x72, (byte) 0xC3, (byte) 0xB4, 0x6D, 0x65 });
+ String sn = "baumgarten";
+
+ // Add a person
+ Attributes attributes = AttributesFactory.createPersonAttributes(cn, sn);
+
+ String rdn = "cn=" + cn;
+
+ DirContext person = ctx.createSubcontext(rdn, attributes);
+
+ // Check whether person looks fine
+ person = (DirContext) ctx.lookup(rdn);
+ assertNotNull(person);
+ attributes = person.getAttributes("");
+
+ // objectclasses
+ Attribute ocls = attributes.get("objectClass");
+ String[] expectedOcls = { "top", "person" };
+
+ for (int i = 0; i < expectedOcls.length; i++) {
+ String name = expectedOcls[i];
+ assertTrue("object class " + name + " is not present", ocls.contains(name));
+ }
+
+ // Other attributes
+ Attribute cnRes = attributes.get("cn");
+ assertTrue(cnRes.contains(cn));
+ Attribute snRes = attributes.get("sn");
+ assertTrue(snRes.contains(sn));
+ }
+
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.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/compare/AllTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/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/compare/AllTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/AllTests.java Sat Feb 11 21:50:03 2006
@@ -1,39 +1,39 @@
-/*
- * 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.compare;
-
-import junit.framework.TestSuite;
-
-/**
- * Contains the test classes for the LDAP compare 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("Compare");
-
- suite.addTestSuite(BasicCompareTests.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.compare;
+
+import junit.framework.TestSuite;
+
+/**
+ * Contains the test classes for the LDAP compare 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("Compare");
+
+ suite.addTestSuite(BasicCompareTests.class);
+
+ return suite;
+ }
+}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/AllTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/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/compare/BasicCompareTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/BasicCompareTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/BasicCompareTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/BasicCompareTests.java Sat Feb 11 21:50:03 2006
@@ -1,145 +1,145 @@
-/*
- * 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.compare;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.NoSuchAttributeException;
-import javax.naming.directory.SearchControls;
-
-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 BasicCompareTests extends BaseProtocolTest {
-
- DirContext ctx;
- DirContext target;
-
- public static final String RDN = "cn=Tori Amos";
-
- public void setUp() throws NamingException {
- super.setUp();
-
- ctx = this.createContext();
- target = (DirContext) ctx.lookup(this.getTestContainerRdn());
-
- // Create a person
- Attributes attributes = AttributesFactory.createPersonAttributes("Tori Amos", "Amos");
- target.createSubcontext(RDN, attributes);
- }
-
- public void tearDown() throws NamingException {
- target.unbind(RDN);
- target.close();
-
- ctx.close();
- ctx = null;
-
- super.tearDown();
- }
-
- /**
- * Compare an existing attribute.
- *
- * @throws NamingException
- */
- public void testCompareExisting() throws NamingException {
-
- // Setting up search controls
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[0]); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- // search operation, which leads to a compare
- // value is correct
- NamingEnumeration enumeration = target.search(RDN, "sn={0}",
- new String[] { "Amos" }, ctls);
-
- // Check, that result contains exactly one entry
- boolean result = enumeration.hasMore();
- assertTrue(result);
- if (result) {
- enumeration.next();
- assertFalse(enumeration.hasMore());
- }
-
- // search operation, which leads to a compare.
- // value is wrong
- enumeration = target.search(RDN, "sn={0}", new String[] { "Bush" }, ctls);
-
- // Check, that result contains no entry
- assertFalse(enumeration.hasMore());
- }
-
- /**
- * Compare an attribute which does not exist in the entry.
- *
- * @throws NamingException
- */
- public void testCompareNonExisting() throws NamingException {
-
- // Setting up search controls
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[0]); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- // search operation, which leads to a compare.
- // the entry does not have a value for the attribute
- try {
- target.search(RDN, "description={0}",
- new String[] { "a description" }, ctls);
- fail("operation should cause an error");
- } catch (NoSuchAttributeException nsae) {
- // expected behaviour
- }
- }
-
- /**
- * Compare an invalid attribute.
- *
- * @throws NamingException
- */
- public void testCompareInvalidAttribute() throws NamingException {
-
- // Setting up search controls
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[0]); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- // search operation, which leads to a compare
- // attribute does not exist
- try {
- target.search(RDN, "XXX={0}", new String[] { "a value" }, ctls);
- fail("operation should cause an error");
- } catch (NamingException iaie) {
- // expected behaviour
-
- // TODO: add a more detailed Exception here
-
- // I am uncertain, whether Return code 16 or 17 is appropriate here.
- // both values occur, depending on the server you use
- // 16: noSuchAttribute
- // 17: undefinedAttributeType
- }
- }
+/*
+ * 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.compare;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.NoSuchAttributeException;
+import javax.naming.directory.SearchControls;
+
+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 BasicCompareTests extends BaseProtocolTest {
+
+ DirContext ctx;
+ DirContext target;
+
+ public static final String RDN = "cn=Tori Amos";
+
+ public void setUp() throws NamingException {
+ super.setUp();
+
+ ctx = this.createContext();
+ target = (DirContext) ctx.lookup(this.getTestContainerRdn());
+
+ // Create a person
+ Attributes attributes = AttributesFactory.createPersonAttributes("Tori Amos", "Amos");
+ target.createSubcontext(RDN, attributes);
+ }
+
+ public void tearDown() throws NamingException {
+ target.unbind(RDN);
+ target.close();
+
+ ctx.close();
+ ctx = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Compare an existing attribute.
+ *
+ * @throws NamingException
+ */
+ public void testCompareExisting() throws NamingException {
+
+ // Setting up search controls
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[0]); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ // search operation, which leads to a compare
+ // value is correct
+ NamingEnumeration enumeration = target.search(RDN, "sn={0}",
+ new String[] { "Amos" }, ctls);
+
+ // Check, that result contains exactly one entry
+ boolean result = enumeration.hasMore();
+ assertTrue(result);
+ if (result) {
+ enumeration.next();
+ assertFalse(enumeration.hasMore());
+ }
+
+ // search operation, which leads to a compare.
+ // value is wrong
+ enumeration = target.search(RDN, "sn={0}", new String[] { "Bush" }, ctls);
+
+ // Check, that result contains no entry
+ assertFalse(enumeration.hasMore());
+ }
+
+ /**
+ * Compare an attribute which does not exist in the entry.
+ *
+ * @throws NamingException
+ */
+ public void testCompareNonExisting() throws NamingException {
+
+ // Setting up search controls
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[0]); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ // search operation, which leads to a compare.
+ // the entry does not have a value for the attribute
+ try {
+ target.search(RDN, "description={0}",
+ new String[] { "a description" }, ctls);
+ fail("operation should cause an error");
+ } catch (NoSuchAttributeException nsae) {
+ // expected behaviour
+ }
+ }
+
+ /**
+ * Compare an invalid attribute.
+ *
+ * @throws NamingException
+ */
+ public void testCompareInvalidAttribute() throws NamingException {
+
+ // Setting up search controls
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[0]); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ // search operation, which leads to a compare
+ // attribute does not exist
+ try {
+ target.search(RDN, "XXX={0}", new String[] { "a value" }, ctls);
+ fail("operation should cause an error");
+ } catch (NamingException iaie) {
+ // expected behaviour
+
+ // TODO: add a more detailed Exception here
+
+ // I am uncertain, whether Return code 16 or 17 is appropriate here.
+ // both values occur, depending on the server you use
+ // 16: noSuchAttribute
+ // 17: undefinedAttributeType
+ }
+ }
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/BasicCompareTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/BasicCompareTests.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/compare/CompareOperationalAttributesTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/CompareOperationalAttributesTest.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/CompareOperationalAttributesTest.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/CompareOperationalAttributesTest.java Sat Feb 11 21:50:03 2006
@@ -1,235 +1,235 @@
-/*
- * 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.compare;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
-import org.apache.ldap.testsuite.ldaptests.jndi.util.AttributesFactory;
-
-/**
- * Tests with compare operations on the operational attributes createTimestamp,
- * modifyTimestamp, creatorsName, modifiersName.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
- */
-public class CompareOperationalAttributesTest extends BaseProtocolTest {
-
- private LdapContext ctx = null;
-
- public static final String OU_VALUE = "Peoples Front of Judea";
-
- public static final String RDN = "ou="+OU_VALUE;
-
- public void setUp() throws NamingException {
- super.setUp();
-
- ctx = this.createContext();
- ctx = (LdapContext) ctx.lookup(this.getTestContainerRdn());
-
- // Create an organizational Unit
- Attributes attributes = AttributesFactory.createOrganizationalUnitAttributes(OU_VALUE);
- ctx.createSubcontext(RDN, attributes);
- }
-
- public void tearDown() throws NamingException {
- ctx.unbind(RDN);
- ctx.close();
- ctx = null;
-
- super.tearDown();
- }
-
- /**
- * Determine an attribute value with a search op.
- *
- * @param attributeName
- * name of attribute
- * @return attribute value
- * @throws NamingException
- */
- protected Object getAttributeValues(String attributeName)
- throws NamingException {
-
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] { attributeName });
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- NamingEnumeration enumeration = ctx
- .search(RDN, "(objectClass=*)", ctls);
- assertTrue(enumeration.hasMore());
- SearchResult rs = (SearchResult) enumeration.next();
- Attribute attr = rs.getAttributes().get(attributeName);
- assertNotNull(attr);
- Object value = (String) attr.get();
- enumeration.close();
-
- return value;
- }
-
- /**
- * Execute compare operations on the operational attribute createTimestamp.
- *
- * @throws NamingException
- */
- public void testCreateTimestamp() throws NamingException {
- // Determine createTimestamp of entry
- String createTimestamp = (String) this
- .getAttributeValues("createTimestamp");
- assertNotNull(createTimestamp);
-
- System.err.println(createTimestamp);
-
- // Setting up search controls for compare op
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] {}); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- // Compare values and expected results
- String[] values = { createTimestamp, "19710401000000Z" };
- boolean[] expected = { false, true, false };
-
- for (int i = 0; i < values.length; i++) {
- String value = values[i];
- NamingEnumeration enumeration = ctx.search(RDN,
- "createTimestamp={0}", new Object[] { value }, ctls);
- boolean result = enumeration.hasMore();
- assertEquals("compare 'createTimestamp' with '" + value + "'",
- expected[i], result);
- enumeration.close();
- }
- }
-
- /**
- * Execute compare operations on the operational attribute creatorsName.
- *
- * @throws NamingException
- */
- public void testCreatorsName() throws NamingException {
- // Determine creatorsName of entry
- String creatorsName = (String) this.getAttributeValues("creatorsName");
- assertNotNull(creatorsName);
-
- // Setting up search controls for compare op
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] {}); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- // Compare values and expected results
- String[] values = { "", creatorsName, "cn=Not the right value" };
- boolean[] expected = { false, true, false };
-
- for (int i = 0; i < values.length; i++) {
- String value = values[i];
- NamingEnumeration enumeration = ctx.search(RDN, "creatorsName={0}",
- new Object[] { value }, ctls);
- boolean result = enumeration.hasMore();
- assertEquals("compare 'creatorsName' with '" + value + "'",
- expected[i], result);
- enumeration.close();
- }
- }
-
- /**
- * Execute compare operations on the operational attribute modifiersName.
- *
- * @throws NamingException
- */
- public void testModifiersName() throws NamingException {
- // modify entry
- ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE,
- new BasicAttributes("description", "Change this"));
-
- String modifiersName = (String) this
- .getAttributeValues("modifiersName");
-
- // Setting up search controls for compare op
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] {}); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- // Compare values and expected results
- String[] values = { "", modifiersName, "cn=Not the right value" };
- boolean[] expected = { false, true, false };
-
- for (int i = 0; i < values.length; i++) {
- String value = values[i];
-
- NamingEnumeration enumeration = ctx.search(RDN,
- "modifiersName={0}", new Object[] { value }, ctls);
- boolean result = enumeration.hasMore();
- assertEquals("compare 'modifiersName' with '" + value + "'",
- expected[i], result);
- enumeration.close();
- }
- }
-
- /**
- * Execute compare operations on the operational attribute modifyTimestamp.
- *
- * @throws NamingException
- */
- public void testModifyTimestamp() throws NamingException {
- // wait 2s
- try {
- Thread.sleep(2000);
- } catch (InterruptedException ignored) {
- }
-
- // modify entry
- ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE,
- new BasicAttributes("description", "Change this"));
-
- // Determine timestamps of entry
- String modifyTimestamp = (String) this
- .getAttributeValues("modifyTimestamp");
- String createTimestamp = (String) this
- .getAttributeValues("createTimestamp");
-
- assertNotNull(modifyTimestamp);
- assertNotNull(createTimestamp);
-
- // Setting up search controls for compare op
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] {}); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- // Compare values and expected results
- String[] values = { modifyTimestamp, createTimestamp,
- "19710401000000Z" };
- boolean[] expected = { false, true, false, false };
-
- for (int i = 0; i < values.length; i++) {
- String value = values[i];
- NamingEnumeration enumeration = ctx.search(RDN,
- "modifyTimestamp={0}", new Object[] { value }, ctls);
- boolean result = enumeration.hasMore();
- assertEquals("compare 'modifyTimestamp' with '" + value + "'",
- expected[i], result);
- enumeration.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.compare;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
+import org.apache.ldap.testsuite.ldaptests.jndi.util.AttributesFactory;
+
+/**
+ * Tests with compare operations on the operational attributes createTimestamp,
+ * modifyTimestamp, creatorsName, modifiersName.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class CompareOperationalAttributesTest extends BaseProtocolTest {
+
+ private LdapContext ctx = null;
+
+ public static final String OU_VALUE = "Peoples Front of Judea";
+
+ public static final String RDN = "ou="+OU_VALUE;
+
+ public void setUp() throws NamingException {
+ super.setUp();
+
+ ctx = this.createContext();
+ ctx = (LdapContext) ctx.lookup(this.getTestContainerRdn());
+
+ // Create an organizational Unit
+ Attributes attributes = AttributesFactory.createOrganizationalUnitAttributes(OU_VALUE);
+ ctx.createSubcontext(RDN, attributes);
+ }
+
+ public void tearDown() throws NamingException {
+ ctx.unbind(RDN);
+ ctx.close();
+ ctx = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Determine an attribute value with a search op.
+ *
+ * @param attributeName
+ * name of attribute
+ * @return attribute value
+ * @throws NamingException
+ */
+ protected Object getAttributeValues(String attributeName)
+ throws NamingException {
+
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[] { attributeName });
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ NamingEnumeration enumeration = ctx
+ .search(RDN, "(objectClass=*)", ctls);
+ assertTrue(enumeration.hasMore());
+ SearchResult rs = (SearchResult) enumeration.next();
+ Attribute attr = rs.getAttributes().get(attributeName);
+ assertNotNull(attr);
+ Object value = (String) attr.get();
+ enumeration.close();
+
+ return value;
+ }
+
+ /**
+ * Execute compare operations on the operational attribute createTimestamp.
+ *
+ * @throws NamingException
+ */
+ public void testCreateTimestamp() throws NamingException {
+ // Determine createTimestamp of entry
+ String createTimestamp = (String) this
+ .getAttributeValues("createTimestamp");
+ assertNotNull(createTimestamp);
+
+ System.err.println(createTimestamp);
+
+ // Setting up search controls for compare op
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[] {}); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ // Compare values and expected results
+ String[] values = { createTimestamp, "19710401000000Z" };
+ boolean[] expected = { false, true, false };
+
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+ NamingEnumeration enumeration = ctx.search(RDN,
+ "createTimestamp={0}", new Object[] { value }, ctls);
+ boolean result = enumeration.hasMore();
+ assertEquals("compare 'createTimestamp' with '" + value + "'",
+ expected[i], result);
+ enumeration.close();
+ }
+ }
+
+ /**
+ * Execute compare operations on the operational attribute creatorsName.
+ *
+ * @throws NamingException
+ */
+ public void testCreatorsName() throws NamingException {
+ // Determine creatorsName of entry
+ String creatorsName = (String) this.getAttributeValues("creatorsName");
+ assertNotNull(creatorsName);
+
+ // Setting up search controls for compare op
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[] {}); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ // Compare values and expected results
+ String[] values = { "", creatorsName, "cn=Not the right value" };
+ boolean[] expected = { false, true, false };
+
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+ NamingEnumeration enumeration = ctx.search(RDN, "creatorsName={0}",
+ new Object[] { value }, ctls);
+ boolean result = enumeration.hasMore();
+ assertEquals("compare 'creatorsName' with '" + value + "'",
+ expected[i], result);
+ enumeration.close();
+ }
+ }
+
+ /**
+ * Execute compare operations on the operational attribute modifiersName.
+ *
+ * @throws NamingException
+ */
+ public void testModifiersName() throws NamingException {
+ // modify entry
+ ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE,
+ new BasicAttributes("description", "Change this"));
+
+ String modifiersName = (String) this
+ .getAttributeValues("modifiersName");
+
+ // Setting up search controls for compare op
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[] {}); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ // Compare values and expected results
+ String[] values = { "", modifiersName, "cn=Not the right value" };
+ boolean[] expected = { false, true, false };
+
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+
+ NamingEnumeration enumeration = ctx.search(RDN,
+ "modifiersName={0}", new Object[] { value }, ctls);
+ boolean result = enumeration.hasMore();
+ assertEquals("compare 'modifiersName' with '" + value + "'",
+ expected[i], result);
+ enumeration.close();
+ }
+ }
+
+ /**
+ * Execute compare operations on the operational attribute modifyTimestamp.
+ *
+ * @throws NamingException
+ */
+ public void testModifyTimestamp() throws NamingException {
+ // wait 2s
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ignored) {
+ }
+
+ // modify entry
+ ctx.modifyAttributes(RDN, DirContext.ADD_ATTRIBUTE,
+ new BasicAttributes("description", "Change this"));
+
+ // Determine timestamps of entry
+ String modifyTimestamp = (String) this
+ .getAttributeValues("modifyTimestamp");
+ String createTimestamp = (String) this
+ .getAttributeValues("createTimestamp");
+
+ assertNotNull(modifyTimestamp);
+ assertNotNull(createTimestamp);
+
+ // Setting up search controls for compare op
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[] {}); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ // Compare values and expected results
+ String[] values = { modifyTimestamp, createTimestamp,
+ "19710401000000Z" };
+ boolean[] expected = { false, true, false, false };
+
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+ NamingEnumeration enumeration = ctx.search(RDN,
+ "modifyTimestamp={0}", new Object[] { value }, ctls);
+ boolean result = enumeration.hasMore();
+ assertEquals("compare 'modifyTimestamp' with '" + value + "'",
+ expected[i], result);
+ enumeration.close();
+ }
+ }
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/CompareOperationalAttributesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/CompareOperationalAttributesTest.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/compare/MatchingRuleCompareTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/MatchingRuleCompareTests.java?rev=377135&r1=377134&r2=377135&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/MatchingRuleCompareTests.java (original)
+++ directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/MatchingRuleCompareTests.java Sat Feb 11 21:50:03 2006
@@ -1,226 +1,226 @@
-/*
- * 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.compare;
-
-import javax.naming.NamingEnumeration;
-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.SearchControls;
-
-import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
-
-/**
- * Tests for the Compare operation with JNDI.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev: $
- */
-
-public class MatchingRuleCompareTests extends BaseProtocolTest {
-
- DirContext ctx;
-
- public static final String PERSON_CN = "Tori Amos";
-
- public static final String PERSON_SN = "Amos";
-
- public static final String PERSON_RDN = "cn="+PERSON_CN;
-
- public static final String PERSON_TELEPHONE = "1234567890abc";
-
- public static final String PERSON_PWD = "Secret1!";
-
- public static final String GROUP_CN = "Artists";
-
- public static final String GROUP_RDN = "cn=Artists";
-
- 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;
- }
-
- protected Attributes getGroupOfNamesAttributes(String cn, String member) {
- Attributes attributes = new BasicAttributes();
- Attribute attribute = new BasicAttribute("objectClass");
- attribute.add("top");
- attribute.add("groupOfNames");
- attributes.put(attribute);
- attributes.put("cn", cn);
- attributes.put("member", member);
-
- return attributes;
- }
-
- public void setUp() throws NamingException {
- super.setUp();
-
- ctx = this.createContext();
- ctx = (DirContext) ctx.lookup(this.getTestContainerRdn());
-
- // Create a person
- Attributes attributes = this.getPersonAttributes(PERSON_SN, PERSON_CN);
- attributes.put("telephoneNumber", PERSON_TELEPHONE);
- attributes.put("userPassword", PERSON_PWD);
- ctx.createSubcontext(PERSON_RDN, attributes);
-
- // Create a group
- DirContext member = (DirContext) ctx.lookup(PERSON_RDN);
- attributes = this.getGroupOfNamesAttributes(GROUP_CN, member
- .getNameInNamespace());
- ctx.createSubcontext(GROUP_RDN, attributes);
-
- }
-
- public void tearDown() throws NamingException {
-
- ctx.unbind(PERSON_RDN);
- ctx.unbind(GROUP_RDN);
-
- ctx.close();
- ctx = null;
-
- super.tearDown();
- }
-
- /**
- * Compare with caseIgnoreMatch matching rule.
- *
- * @throws NamingException
- */
- public void testCaseIgnoreMatch() throws NamingException {
- // Setting up search controls
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] {}); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- String[] values = { PERSON_SN, PERSON_SN.toUpperCase(), PERSON_SN.toLowerCase(), PERSON_SN+"X" };
- boolean[] expected = { true, true, true, false };
-
- for (int i = 0; i < values.length; i++) {
- String value = values[i];
-
- NamingEnumeration enumeration = ctx.search(PERSON_RDN, "sn={0}",
- new String[] { value }, ctls);
- // Check, that result contains exactly one entry
- boolean result = enumeration.hasMore();
-
- assertEquals("compare sn value '" + PERSON_SN + "' with '" + value + "'", expected[i],
- result);
-
- enumeration.close();
- }
- }
-
- //
-
- /**
- * Compare with telephoneNumberMatch matching rule.
- *
- * @throws NamingException
- */
- public void testTelephoneNumberMatch() throws NamingException {
- // Setting up search controls
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] {}); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- String[] values = { "", "1234567890abc", " 1234567890 A B C",
- "123 456 7890 abc", "123-456-7890 abC", "123456-7890 A bc" };
- boolean[] expected = { false, true, true, true, true, true };
-
- for (int i = 0; i < values.length; i++) {
- String value = values[i];
-
- NamingEnumeration enumeration = ctx.search(PERSON_RDN,
- "telephoneNumber={0}", new String[] { value }, ctls);
- boolean result = enumeration.hasMore();
-
- assertEquals("compare '1234567890' with '" + value + "'",
- expected[i], result);
-
- enumeration.close();
- }
- }
-
- /**
- * Compare with octetStringMatch matching rule.
- *
- * @throws NamingException
- */
- public void testOctetStringMatch() throws NamingException {
- // Setting up search controls
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] {}); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- String[] values = { "", PERSON_PWD, PERSON_PWD.toUpperCase(), PERSON_PWD.toLowerCase(), PERSON_PWD+"X" };
- boolean[] expected = { false, true, false, false, false };
-
- for (int i = 0; i < values.length; i++) {
- String value = values[i];
-
- NamingEnumeration enumeration = ctx.search(PERSON_RDN,
- "userPassword={0}", new String[] { value }, ctls);
- boolean result = enumeration.hasMore();
-
- assertEquals("compare 'Secret1!' with '" + value + "'",
- expected[i], result);
-
- enumeration.close();
- }
- }
-
- public void testDistinguishedNameMatch() throws NamingException {
-
- // determine member DN
- DirContext member = (DirContext) ctx.lookup(PERSON_RDN);
- String memberDN = member.getNameInNamespace();
-
- // Setting up search controls for compare op
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] {}); // no attributes
- ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
-
- String[] values = { "", memberDN, "cn=nobody", memberDN.toLowerCase(),
- PERSON_RDN + " , " + ctx.getNameInNamespace() };
- boolean[] expected = { false, true, false, true, true };
-
- for (int i = 0; i < values.length; i++) {
- String value = values[i];
-
- NamingEnumeration enumeration = ctx.search(GROUP_RDN, "member={0}",
- new Object[] { value }, ctls);
- boolean result = enumeration.hasMore();
-
- assertEquals("compare 'member' with '" + value + "'", expected[i],
- result);
-
- enumeration.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.compare;
+
+import javax.naming.NamingEnumeration;
+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.SearchControls;
+
+import org.apache.ldap.testsuite.ldaptests.jndi.BaseProtocolTest;
+
+/**
+ * Tests for the Compare operation with JNDI.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+
+public class MatchingRuleCompareTests extends BaseProtocolTest {
+
+ DirContext ctx;
+
+ public static final String PERSON_CN = "Tori Amos";
+
+ public static final String PERSON_SN = "Amos";
+
+ public static final String PERSON_RDN = "cn="+PERSON_CN;
+
+ public static final String PERSON_TELEPHONE = "1234567890abc";
+
+ public static final String PERSON_PWD = "Secret1!";
+
+ public static final String GROUP_CN = "Artists";
+
+ public static final String GROUP_RDN = "cn=Artists";
+
+ 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;
+ }
+
+ protected Attributes getGroupOfNamesAttributes(String cn, String member) {
+ Attributes attributes = new BasicAttributes();
+ Attribute attribute = new BasicAttribute("objectClass");
+ attribute.add("top");
+ attribute.add("groupOfNames");
+ attributes.put(attribute);
+ attributes.put("cn", cn);
+ attributes.put("member", member);
+
+ return attributes;
+ }
+
+ public void setUp() throws NamingException {
+ super.setUp();
+
+ ctx = this.createContext();
+ ctx = (DirContext) ctx.lookup(this.getTestContainerRdn());
+
+ // Create a person
+ Attributes attributes = this.getPersonAttributes(PERSON_SN, PERSON_CN);
+ attributes.put("telephoneNumber", PERSON_TELEPHONE);
+ attributes.put("userPassword", PERSON_PWD);
+ ctx.createSubcontext(PERSON_RDN, attributes);
+
+ // Create a group
+ DirContext member = (DirContext) ctx.lookup(PERSON_RDN);
+ attributes = this.getGroupOfNamesAttributes(GROUP_CN, member
+ .getNameInNamespace());
+ ctx.createSubcontext(GROUP_RDN, attributes);
+
+ }
+
+ public void tearDown() throws NamingException {
+
+ ctx.unbind(PERSON_RDN);
+ ctx.unbind(GROUP_RDN);
+
+ ctx.close();
+ ctx = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Compare with caseIgnoreMatch matching rule.
+ *
+ * @throws NamingException
+ */
+ public void testCaseIgnoreMatch() throws NamingException {
+ // Setting up search controls
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[] {}); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ String[] values = { PERSON_SN, PERSON_SN.toUpperCase(), PERSON_SN.toLowerCase(), PERSON_SN+"X" };
+ boolean[] expected = { true, true, true, false };
+
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+
+ NamingEnumeration enumeration = ctx.search(PERSON_RDN, "sn={0}",
+ new String[] { value }, ctls);
+ // Check, that result contains exactly one entry
+ boolean result = enumeration.hasMore();
+
+ assertEquals("compare sn value '" + PERSON_SN + "' with '" + value + "'", expected[i],
+ result);
+
+ enumeration.close();
+ }
+ }
+
+ //
+
+ /**
+ * Compare with telephoneNumberMatch matching rule.
+ *
+ * @throws NamingException
+ */
+ public void testTelephoneNumberMatch() throws NamingException {
+ // Setting up search controls
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[] {}); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ String[] values = { "", "1234567890abc", " 1234567890 A B C",
+ "123 456 7890 abc", "123-456-7890 abC", "123456-7890 A bc" };
+ boolean[] expected = { false, true, true, true, true, true };
+
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+
+ NamingEnumeration enumeration = ctx.search(PERSON_RDN,
+ "telephoneNumber={0}", new String[] { value }, ctls);
+ boolean result = enumeration.hasMore();
+
+ assertEquals("compare '1234567890' with '" + value + "'",
+ expected[i], result);
+
+ enumeration.close();
+ }
+ }
+
+ /**
+ * Compare with octetStringMatch matching rule.
+ *
+ * @throws NamingException
+ */
+ public void testOctetStringMatch() throws NamingException {
+ // Setting up search controls
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[] {}); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ String[] values = { "", PERSON_PWD, PERSON_PWD.toUpperCase(), PERSON_PWD.toLowerCase(), PERSON_PWD+"X" };
+ boolean[] expected = { false, true, false, false, false };
+
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+
+ NamingEnumeration enumeration = ctx.search(PERSON_RDN,
+ "userPassword={0}", new String[] { value }, ctls);
+ boolean result = enumeration.hasMore();
+
+ assertEquals("compare 'Secret1!' with '" + value + "'",
+ expected[i], result);
+
+ enumeration.close();
+ }
+ }
+
+ public void testDistinguishedNameMatch() throws NamingException {
+
+ // determine member DN
+ DirContext member = (DirContext) ctx.lookup(PERSON_RDN);
+ String memberDN = member.getNameInNamespace();
+
+ // Setting up search controls for compare op
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[] {}); // no attributes
+ ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+
+ String[] values = { "", memberDN, "cn=nobody", memberDN.toLowerCase(),
+ PERSON_RDN + " , " + ctx.getNameInNamespace() };
+ boolean[] expected = { false, true, false, true, true };
+
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+
+ NamingEnumeration enumeration = ctx.search(GROUP_RDN, "member={0}",
+ new Object[] { value }, ctls);
+ boolean result = enumeration.hasMore();
+
+ assertEquals("compare 'member' with '" + value + "'", expected[i],
+ result);
+
+ enumeration.close();
+ }
+ }
}
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/MatchingRuleCompareTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/akarasulu/rc1/testsuites/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/compare/MatchingRuleCompareTests.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sat Feb 11 21:50:03 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id