You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/10/10 02:55:38 UTC
svn commit: r454578 - in
/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src:
main/java/javax/naming/ldap/
test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/
Author: ndbeyer
Date: Mon Oct 9 17:55:37 2006
New Revision: 454578
URL: http://svn.apache.org/viewvc?view=rev&rev=454578
Log:
Implement SortKey, BasicControl and respective tests.
Added:
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/BasicControl.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortKey.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/BasicControlTest.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/SortKeyTest.java (with props)
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/BasicControl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/BasicControl.java?view=auto&rev=454578
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/BasicControl.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/BasicControl.java Mon Oct 9 17:55:37 2006
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.naming.ldap;
+
+public class BasicControl implements Control {
+ private static final long serialVersionUID = -4233907508771791687L;
+
+ protected String id;
+ protected boolean criticality;
+ protected byte[] value;
+
+ public BasicControl(String id) {
+ super();
+ this.id = id;
+ }
+
+ public BasicControl(String id, boolean criticality, byte[] value) {
+ super();
+ this.id = id;
+ this.criticality = criticality;
+ this.value = value;
+ }
+
+ public byte[] getEncodedValue() {
+ return value;
+ }
+
+ public String getID() {
+ return id;
+ }
+
+ public boolean isCritical() {
+ return criticality;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/BasicControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortKey.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortKey.java?view=auto&rev=454578
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortKey.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortKey.java Mon Oct 9 17:55:37 2006
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.naming.ldap;
+
+public class SortKey {
+ private final String attributeId;
+
+ private final boolean ascending;
+
+ private final String matchingRuleId;
+
+ public SortKey(String attributeId) {
+ super();
+ this.attributeId = attributeId;
+ this.ascending = true;
+ this.matchingRuleId = null;
+ }
+
+ public SortKey(String attributeId, boolean ascending, String matchingRuleId) {
+ super();
+ this.attributeId = attributeId;
+ this.ascending = ascending;
+ this.matchingRuleId = matchingRuleId;
+ }
+
+ public String getAttributeID() {
+ return attributeId;
+ }
+
+ public String getMatchingRuleID() {
+ return matchingRuleId;
+ }
+
+ public boolean isAscending() {
+ return ascending;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/SortKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/BasicControlTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/BasicControlTest.java?view=auto&rev=454578
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/BasicControlTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/BasicControlTest.java Mon Oct 9 17:55:37 2006
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import javax.naming.ldap.BasicControl;
+import javax.naming.ldap.Control;
+import junit.framework.TestCase;
+
+public class BasicControlTest extends TestCase {
+ /**
+ * Test method for
+ * {@link javax.naming.ldap.BasicControl#BasicControl(java.lang.String)}.
+ */
+ public void testBasicControlString() {
+ BasicControl bc = new BasicControl("fixture");
+ assertEquals("fixture", bc.getID());
+ }
+
+ /**
+ * Test method for
+ * {@link javax.naming.ldap.BasicControl#BasicControl(java.lang.String, boolean, byte[])}.
+ */
+ public void testBasicControlStringBooleanByteArray() {
+ byte[] fixture = new byte[] { 0, 1 };
+ BasicControl bc = new BasicControl("fixture", Control.CRITICAL, fixture);
+ assertEquals("fixture", bc.getID());
+ assertEquals(Control.CRITICAL, bc.isCritical());
+ // spec says the byte[] is NOT copied
+ assertSame(fixture, bc.getEncodedValue());
+ }
+
+ /**
+ * Test method for {@link javax.naming.ldap.BasicControl#getEncodedValue()}.
+ */
+ public void testGetEncodedValue() {
+ BasicControl bc = new BasicControl("fixture");
+ assertNull(bc.getEncodedValue());
+ byte[] fixture = new byte[] { 0, 1 };
+ bc = new BasicControl("fixture", Control.CRITICAL, fixture);
+ // spec says the byte[] is NOT copied
+ assertSame(fixture, bc.getEncodedValue());
+
+ // spec says that byte[] isn't copied and can be changed
+ fixture[0] = Byte.MIN_VALUE;
+ fixture[1] = Byte.MAX_VALUE;
+ assertEquals(Byte.MIN_VALUE, bc.getEncodedValue()[0]);
+ assertEquals(Byte.MAX_VALUE, bc.getEncodedValue()[1]);
+ }
+
+ /**
+ * Test method for {@link javax.naming.ldap.BasicControl#getID()}.
+ */
+ public void testGetID() {
+ BasicControl bc = new BasicControl("fixture");
+ assertEquals("fixture", bc.getID());
+
+ bc = new BasicControl(null);
+ assertNull(bc.getID());
+
+ bc = new BasicControl("");
+ assertEquals("", bc.getID());
+
+ bc = new BasicControl(null, false, null);
+ assertNull(bc.getID());
+ }
+
+ /**
+ * Test method for {@link javax.naming.ldap.BasicControl#isCritical()}.
+ */
+ public void testIsCritical() {
+ BasicControl bc = new BasicControl("fixture");
+ assertFalse(bc.isCritical());
+
+ bc = new BasicControl(null, false, null);
+ assertFalse(bc.isCritical());
+
+ bc = new BasicControl(null, true, null);
+ assertTrue(bc.isCritical());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/BasicControlTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/SortKeyTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/SortKeyTest.java?view=auto&rev=454578
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/SortKeyTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/SortKeyTest.java Mon Oct 9 17:55:37 2006
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import javax.naming.ldap.SortKey;
+import junit.framework.TestCase;
+
+public class SortKeyTest extends TestCase {
+
+ public void testAll() {
+ SortKey sk = new SortKey("attributeId");
+ assertEquals("attributeId", sk.getAttributeID());
+ assertTrue(sk.isAscending());
+ assertNull(sk.getMatchingRuleID());
+
+ sk = new SortKey(null);
+ assertNull(sk.getAttributeID());
+
+ sk = new SortKey("attributeId", false, "matchingRuleId");
+ assertEquals("attributeId", sk.getAttributeID());
+ assertFalse(sk.isAscending());
+ assertEquals("matchingRuleId", sk.getMatchingRuleID());
+
+ sk = new SortKey(null, true, null);
+ assertNull(sk.getAttributeID());
+ assertTrue(sk.isAscending());
+ assertNull(sk.getMatchingRuleID());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/SortKeyTest.java
------------------------------------------------------------------------------
svn:eol-style = native