Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestRdn.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortControl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortControl.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortControl.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortControl.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,531 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Leonardo Soler
+ * @author Gabriel Miretti
+ * @version 1.0
+ */
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import javax.naming.ldap.SortControl;
+import javax.naming.ldap.SortKey;
+import junit.framework.TestCase;
+
+/**
+ * <p>This Test class is testing the SortControl class.</p>
+ * <p>In the next tables we are gonna see the methods that we test in this class:</p>
+ * <table class="t" cellspacing="0">
+ <tbody><th>Constructors:</th>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="SortControl(SortKey[] sortBy, boolean criticality)" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="SortControl(String[] sortBy, boolean criticality)" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="SortControl(String sortBy, boolean criticality)" id="f10"></td>
+
+ </tr>
+
+ </tbody></table>
+ *
+ */
+public class TestSortControl extends TestCase {
+
+ /**
+ * <p>This method is not implemted.</p>
+ * @param args Possible parameter to help us initiate all tests.
+ */
+ public static void main(String[] args) {
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.SortControl(String, boolean)'</p>
+ * <p>Here we are testing if this method constructs a control to sort on a list of sort keys.</p>
+ * <p>The expected result is a null pointer exception.</p>
+ */
+ public void testSortControlSortKeyArrayBoolean001() {
+
+ SortKey[] t=null;
+ try {
+ SortControl x=new SortControl(t,false);
+ fail("The sort keys should not be null.");
+ } catch (NullPointerException e) {
+
+ } catch (Throwable e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.SortControl(String, boolean)'</p>
+ * <p>Here we are testing if this method constructs a control to sort on a list of sort keys.</p>
+ * <p>The expected result is a not null Sort Control.</p>
+ */
+ public void testSortControlSortKeyArrayBoolean002() {
+
+ SortKey[] t={(SortKey)new SortKey("1"),(SortKey)new SortKey("2")};
+ try {
+ SortControl x=new SortControl(t,false);
+ assertNotNull(x);
+ assertFalse(x.isCritical());
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.SortControl(String[], boolean)'</p>
+ * <p>Here we are testing if this method constructs a control to sort on a list of attributes in ascending order.</p>
+ * <p>The expected result is a null pointer exception.</p>
+ */
+ public void testSortControlStringArrayBoolean001() {
+
+ try {
+ String[] x=null;
+ SortControl sc=new SortControl(x,false);
+ fail("The list of attributes should not be null.");
+ } catch (NullPointerException e) {
+
+ } catch (Throwable e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.SortControl(String[], boolean)'</p>
+ * <p>Here we are testing if this method constructs a control to sort on a list of attributes in ascending order.</p>
+ * <p>The expected result is a not null sort control.</p>
+ */
+ public void testSortControlStringArrayBoolean002() {
+
+ try {
+ String[] x={"1","2"};
+ SortControl sc=new SortControl(x,false);
+ assertNotNull(sc);
+ assertFalse(sc.isCritical());
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.SortControl(String[], boolean)'</p>
+ * <p>Here we are testing if this method constructs a control to sort on a list of attributes in ascending order.</p>
+ * <p>The expected result is a not null sort control.</p>
+ */
+ public void testSortControlStringArrayBoolean003() {
+
+ try {
+ String[] x={"1","2"};
+ SortControl sc=new SortControl(x,true);
+ assertNotNull(sc);
+ assertTrue(sc.isCritical());
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.SortControl(String[], boolean)'</p>
+ * <p>Here we are testing if this method constructs a control to sort on a list of attributes in ascending order.</p>
+ * <p>The expected result is a not null sort control.</p>
+ */
+ public void testSortControlStringArrayBoolean004() {
+
+ try {
+ String[] x={"",""};
+ SortControl sc=new SortControl(x,true);
+ assertNotNull(sc);
+ assertTrue(sc.isCritical());
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.SortControl(SortKey[], boolean)'</p>
+ * <p>Here we are testing if this metho constructs a control to sort on a single attrib.</p>
+ * <p>The expected result is a null pointer exception.</p>
+ */
+ public void testSortControlStringBoolean001() {
+
+ try{
+ String t=null;
+ SortControl sc=new SortControl(t,false);
+ assertNotNull(sc);
+ assertFalse(sc.isCritical());
+ } catch (NullPointerException e) {
+ fail("The attrib can be null."+e);
+ } catch (Throwable e) {
+ fail("Failed with:"+e);
+ }
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.SortControl(SortKey[], boolean)'</p>
+ * <p>Here we are testing if this metho constructs a control to sort on a single attrib.</p>
+ * <p>The expected result is a not null sort control.</p>
+ */
+ public void testSortControlStringBoolean002() {
+
+ try{
+ String t="anything";
+ SortControl sc=new SortControl(t,false);
+ assertNotNull(sc);
+ assertFalse(sc.isCritical());
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.SortControl(SortKey[], boolean)'</p>
+ * <p>Here we are testing if this metho constructs a control to sort on a single attrib.</p>
+ * <p>The expected result is a not null sort control.</p>
+ */
+ public void testSortControlStringBoolean003() {
+
+ try{
+ String t="anything";
+ SortControl sc=new SortControl(t,true);
+ assertNotNull(sc);
+ assertTrue(sc.isCritical());
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of sortkey.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl001(){
+ SortKey[] sk=null;
+ sk=new SortKey[1];
+ sk[0]=new SortKey("pepe",false,"leo");
+ try {
+ SortControl sc=new SortControl(sk,true);
+ assertEquals("30 10 30 0e 04 04 70 65 70 65 80 03 6c 65 6f 81 01 ff",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of sortkey.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl002(){
+ SortKey[] sk=null;
+ sk=new SortKey[1];
+ sk[0]=new SortKey("",false,"");
+ try {
+ SortControl sc=new SortControl(sk,true);
+ assertEquals("30 09 30 07 04 00 80 00 81 01 ff",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of sortkey.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl003(){
+ SortKey[] sk=null;
+ sk=new SortKey[1];
+ sk[0]=new SortKey("",true,"");
+ try {
+ SortControl sc=new SortControl(sk,true);
+ assertEquals("30 06 30 04 04 00 80 00",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of sortkey.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl004(){
+ SortKey[] sk=null;
+ sk=new SortKey[1];
+ sk[0]=new SortKey("pepe",true,"laura");
+ try {
+ SortControl sc=new SortControl(sk,true);
+ assertEquals("30 0f 30 0d 04 04 70 65 70 65 80 05 6c 61 75 72 61",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of sortkey.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl005(){
+ SortKey[] sk=null;
+ sk=new SortKey[1];
+ sk[0]=new SortKey("pepe",true,null);
+ try {
+ SortControl sc=new SortControl(sk,true);
+ assertEquals("30 08 30 06 04 04 70 65 70 65",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of strings.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl006(){
+ String[] sk={""};
+
+ try {
+ SortControl sc=new SortControl(sk,true);
+ assertEquals("30 04 30 02 04 00",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of strings.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl007(){
+ String[] sk={""};
+
+ try {
+ SortControl sc=new SortControl(sk,false);
+ assertEquals("30 04 30 02 04 00",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of strings.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl008(){
+ String[] sk={"pepe"};
+
+ try {
+ SortControl sc=new SortControl(sk,false);
+ assertEquals("30 08 30 06 04 04 70 65 70 65",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of strings.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl009(){
+ String[] sk={"pepe"};
+
+ try {
+ SortControl sc=new SortControl(sk,true);
+ assertEquals("30 08 30 06 04 04 70 65 70 65",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of strings.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl010(){
+ String[] sk={"pepe","","toto"};
+
+ try {
+ SortControl sc=new SortControl(sk,true);
+ assertEquals("30 14 30 06 04 04 70 65 70 65 30 02 04 00 30 06 04 04 74 6f 74 6f",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using an array of strings.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl011(){
+ String[] sk={"pepe","","toto"};
+
+ try {
+ SortControl sc=new SortControl(sk,false);
+ assertEquals("30 14 30 06 04 04 70 65 70 65 30 02 04 00 30 06 04 04 74 6f 74 6f",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using a string.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl012(){
+ String sk=null;
+
+ try {
+ SortControl sc=new SortControl(sk,false);
+ assertEquals("30 04 30 02 04 00",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using a string.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl013(){
+ String sk=null;
+
+ try {
+ SortControl sc=new SortControl(sk,true);
+ assertEquals("30 04 30 02 04 00",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using a string.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl014(){
+ String sk="";
+
+ try {
+ SortControl sc=new SortControl(sk,true);
+ assertEquals("30 04 30 02 04 00",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using a string.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl015(){
+ String sk="";
+
+ try {
+ SortControl sc=new SortControl(sk,false);
+ assertEquals("30 04 30 02 04 00",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the control's ASN.1 BER encoded value. In this case we create a sort
+ * control using a string.</p>
+ * <p>The expecting result is the control's ASN.1 BER encoded value.</p>
+ */
+ public void testEncodedValueOfSortControl016(){
+ String sk="pepe";
+
+ try {
+ SortControl sc=new SortControl(sk,false);
+ assertEquals("30 08 30 06 04 04 70 65 70 65",toHexString(sc.getEncodedValue()));
+ sc=new SortControl(sk,true);
+ assertEquals("30 08 30 06 04 04 70 65 70 65",toHexString(sc.getEncodedValue()));
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+ /*
+ * Method to get the string of a byte array.
+ */
+ private static String toHexString(byte[] data) {
+ BigInteger bi = new BigInteger(data);
+ String s = bi.toString(16);
+ StringBuffer hex = new StringBuffer();
+ if (s.length() % 2 != 0) {
+ s = "0" + s;
+ }
+ for (int i = 0; i < s.length(); i++) {
+ hex.append(s.charAt(i));
+ if (i % 2 != 0 && i < s.length() - 1) {
+ hex.append(" ");
+ }
+ }
+ return hex.toString();
+ }
+
+}
Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortKey.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortKey.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortKey.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortKey.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,263 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Leonardo Soler
+ * @author Gabriel Miretti
+ * @version 1.0
+ */
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import javax.naming.ldap.SortKey;
+import junit.framework.TestCase;
+
+/**
+ * <p>This Test class is testing the SortKey class.</p>
+ * <p>In the next tables we are gonna see the methods that we test in this class:</p>
+ * <table class="t" cellspacing="0">
+ <tbody><th>Constructors:</th>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="SortKey(String attrID)" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="SortKey(String attrID, boolean ascendingOrder, String matchingRuleID)" id="f10"></td>
+
+ </tr>
+ </tbody>
+ <table>
+ <tbody><th>Method Summary:</th>
+ <tr><TD>Return</TD><TD>Method</TD></tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="String" id="f00"></TD>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="getAttributeID()" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="String" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="getMatchingRuleID()" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="boolean" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="isAscending()" id="f10"></td>
+
+ </tr>
+
+ </tbody>
+ </table>
+ *
+ */
+public class TestSortKey extends TestCase {
+
+ /**
+ * <p>This method is not implemted.</p>
+ * @param args Possible parameter to help us initiate all tests.
+ */
+ public static void main(String[] args) {
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.SortKey(String)'</p>
+ * <p>Here we are testing if this method creates the default sort key for an attribute. In this case we send a null ID.</p>
+ * <p>The expected result is a null pointer exception.</p>
+ */
+ public void testSortKeyString001() {
+
+ try{
+ SortKey x=new SortKey(null);
+ fail("The id should not be null.");
+ }catch (NullPointerException e) {
+
+ }
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.SortKey(String)'</p>
+ * <p>Here we are testing if this method creates the default sort key for an attribute. In this case we send a blank ID.</p>
+ * <p>The expected result is a not null sort key.</p>
+ */
+ public void testSortKeyString002() {
+
+ assertNotNull(new SortKey(""));
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.SortKey(String)'</p>
+ * <p>Here we are testing if this method creates the default sort key for an attribute. In this case we send an ID like "anything".</p>
+ * <p>The expected result is a not null sort key.</p>
+ */
+ public void testSortKeyString003() {
+
+ assertNotNull(new SortKey("anything"));
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.SortKey(String, boolean, String)'</p>
+ * <p>Here we are testing if this method creates a sort key for an attribute. In this case we send a null id, a false and another null.</p>
+ * <p>The expected result a null pointer exception.</p>
+ */
+ public void testSortKeyStringBooleanString001() {
+
+ try{
+ SortKey x=new SortKey(null,false,null);
+ fail("The attrID should not be null.");
+ } catch (NullPointerException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.SortKey(String, boolean, String)'</p>
+ * <p>Here we are testing if this method creates a sort key for an attribute. In this case we send a not null id like "", a false and another null.</p>
+ * <p>The expected result a not null sort key.</p>
+ */
+ public void testSortKeyStringBooleanString002() {
+
+ SortKey x=new SortKey("",false,null);
+ assertNotNull(x);
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.SortKey(String, boolean, String)'</p>
+ * <p>Here we are testing if this method creates a sort key for an attribute. In this case we send a not null id like "anything", a
+ * false and another not null like "".</p>
+ * <p>The expected result a not null sort key.</p>
+ */
+ public void testSortKeyStringBooleanString003() {
+
+ SortKey x=new SortKey("anything",false,"");
+ assertNotNull(x);
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.SortKey(String, boolean, String)'</p>
+ * <p>Here we are testing if this method creates a sort key for an attribute. In this case we send a not null id like "anything", a
+ * true and another not null like "anything".</p>
+ * <p>The expected result a not null sort key.</p>
+ */
+ public void testSortKeyStringBooleanString004() {
+
+ SortKey x=new SortKey("anything",true,"anything");
+ assertNotNull(x);
+ }
+
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.getAttributeID()'</p>
+ * <p>Here we are testing if this method retrieves the attribute ID of the sort key.</p>
+ * <p>The expected result is a not null return.</p>
+ */
+ public void testGetAttributeID001() {
+
+ SortKey x=new SortKey("test");
+ assertEquals("test",x.getAttributeID());
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.getAttributeID()'</p>
+ * <p>Here we are testing if this method retrieves the attribute ID of the sort key.</p>
+ * <p>The expected result is a not null return.</p>
+ */
+ public void testGetAttributeID002() {
+
+ SortKey x=new SortKey("");
+ assertEquals("",x.getAttributeID());
+ }
+
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.isAscending()'</p>
+ * <p>Here we are testing if this method determines the sort order.</p>
+ * <p>The expected result is the given sort order.</p>
+ */
+ public void testIsAscending001() {
+
+ SortKey x=new SortKey("",true,"");
+ assertTrue(x.isAscending());
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.isAscending()'</p>
+ * <p>Here we are testing if this method determines the sort order.</p>
+ * <p>The expected result is the given sort order.</p>
+ */
+ public void testIsAscending002() {
+
+ SortKey x=new SortKey("",false,"");
+ assertFalse(x.isAscending());
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.isAscending()'</p>
+ * <p>Here we are testing if this method determines the sort order. In this case we do not give a sort order.</p>
+ * <p>The expected result is true.</p>
+ */
+ public void testIsAscending003() {
+
+ SortKey x=new SortKey("anything");
+ assertTrue(x.isAscending());
+ }
+
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.getMatchingRuleID()'</p>
+ * <p>Here we are testing if this method retrieves the matching rule ID used to order the attribute values.</p>
+ * <p>The expected result is a null.</p>
+ */
+ public void testGetMatchingRuleID001() {
+
+ SortKey x=new SortKey("anything");
+ assertNull(x.getMatchingRuleID());
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.getMatchingRuleID()'</p>
+ * <p>Here we are testing if this method retrieves the matching rule ID used to order the attribute values.</p>
+ * <p>The expected result is a blank Id.</p>
+ */
+ public void testGetMatchingRuleID002() {
+
+ SortKey x=new SortKey("anything",false,"");
+ assertEquals("",x.getMatchingRuleID());
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortKey.getMatchingRuleID()'</p>
+ * <p>Here we are testing if this method retrieves the matching rule ID used to order the attribute values.</p>
+ * <p>The expected result is a blank Id.</p>
+ */
+ public void testGetMatchingRuleID003() {
+
+ SortKey x=new SortKey("anything",false,"anything");
+ assertEquals("anything",x.getMatchingRuleID());
+ }
+
+}
Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,808 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Leonardo Soler
+ * @author Gabriel Miretti
+ * @version 1.0
+ */
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import java.io.IOException;
+import javax.naming.AuthenticationNotSupportedException;
+import javax.naming.LimitExceededException;
+import javax.naming.NamingException;
+import javax.naming.NoPermissionException;
+import javax.naming.OperationNotSupportedException;
+import javax.naming.ServiceUnavailableException;
+import javax.naming.TimeLimitExceededException;
+import javax.naming.directory.InvalidSearchFilterException;
+import javax.naming.directory.NoSuchAttributeException;
+import javax.naming.ldap.SortResponseControl;
+import junit.framework.TestCase;
+
+/**
+ * <p>This Test class is testing the SortControl class.</p>
+ * <p>In the next tables we are gonna see the methods that we test in this class:</p>
+ * <table class="t" cellspacing="0">
+ <tbody><th>Constructors:</th>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="SortResponseControl(String id, boolean criticality, byte[] value)" id="f10"></td>
+
+ </tr>
+
+ </tbody></table>
+ <table class="t" cellspacing="0">
+ <tbody><th>Method Sumary:</th>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="String" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="getAttributeID()" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="NamingException" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="getException()" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="int" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="getResultCode()" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="boolean" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="60" name="sas9nt21" readonly="readonly" value="isSorted()" id="f10"></td>
+
+ </tr>
+
+ </tbody></table>
+
+ *
+ */
+public class TestSortResponseControl extends TestCase {
+
+
+ /**
+ * <p>This method is not implemted.</p>
+ * @param args Possible parameter to help us initiate all tests.
+ */
+ public static void main(String[] args) {
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception like NullPointer.</p>
+ */
+ public void testSortResponseControl001() {
+
+ String Id=null;
+ boolean crit=false;
+ byte[] ber=null;
+ try {
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("Some arguments are null, so an exception must be thrown.");
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ } catch (NullPointerException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception like NullPointer.</p>
+ */
+ public void testSortResponseControl002() {
+
+ String Id=null;
+ boolean crit=true;
+ byte[] ber=null;
+ try {
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("Some arguments are null, so an exception must be thrown.");
+ } catch (IOException e) {
+ fail("Failed with:"+e);
+ } catch (NullPointerException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception like IOException.</p>
+ */
+ public void testSortResponseControl003() {
+
+ String Id=null;
+ boolean crit=true;
+ byte[] ber={};
+ try {
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("Insufficient data.");
+ } catch (IOException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception like IOException.</p>
+ */
+ public void testSortResponseControl004() {
+
+ String Id=null;
+ boolean crit=false;
+ byte[] ber={};
+ try {
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("Insufficient data.");
+ } catch (IOException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception like IOException.</p>
+ */
+ public void testSortResponseControl005() {
+
+ String Id=null;
+ boolean crit=false;
+ byte[] ber=new String("ID").getBytes();
+ try {
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("The bytes are not in the ASN.1 BER.");
+ } catch (IOException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an instance of the class.</p>
+ */
+ public void testSortResponseControl006() {
+
+ String Id=null;
+ boolean crit=false;
+ try {
+ byte[] ber={48,3,10,1,0};
+ assertNotNull(new SortResponseControl(Id,crit,ber));
+
+ } catch (IOException e) {
+ fail("The bytes are in the ASN.1 BER.");
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception.</p>
+ */
+ public void testSortResponseControl007() {
+
+ String Id="";
+ boolean crit=false;
+ try {
+ byte[] ber=null;
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("The bytes are not in the ASN.1 BER.");
+ } catch (IOException e) {
+ fail("Should raise another exception.");
+ } catch (NullPointerException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception.</p>
+ */
+ public void testSortResponseControl008() {
+
+ String Id="";
+ boolean crit=true;
+ try {
+ byte[] ber=null;
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("The bytes are not in the ASN.1 BER.");
+ } catch (IOException e) {
+ fail("Should raise another exception.");
+ } catch (NullPointerException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception.</p>
+ */
+ public void testSortResponseControl010() {
+
+ String Id="";
+ boolean crit=true;
+ try {
+ byte[] ber={};
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("The bytes are not in the ASN.1 BER.");
+ } catch (IOException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception.</p>
+ */
+ public void testSortResponseControl011() {
+
+ String Id="";
+ boolean crit=false;
+ try {
+ byte[] ber={};
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("The bytes are not in the ASN.1 BER.");
+ } catch (IOException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception.</p>
+ */
+ public void testSortResponseControl012() {
+
+ String Id="";
+ boolean crit=true;
+ try {
+ byte[] ber={10,20,12};
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("The bytes are not in the ASN.1 BER.");
+ } catch (IOException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an exception.</p>
+ */
+ public void testSortResponseControl013() {
+
+ String Id="";
+ boolean crit=false;
+ try {
+ byte[] ber={10,20,12};
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("The bytes are not in the ASN.1 BER.");
+ } catch (IOException e) {
+
+ }
+ }
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an instance of the class.</p>
+ */
+ public void testSortResponseControl014() {
+
+ String Id="";
+ boolean crit=false;
+ try {
+ byte[] ber={48,3,10,1,0};
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ assertNotNull(src);
+ } catch (IOException e) {
+ fail("The bytes are in the ASN.1 BER.");
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request.</p>
+ * <p>The expected result is an instance of the class.</p>
+ */
+ public void testSortResponseControl015() {
+
+ String Id="";
+ boolean crit=true;
+ try {
+ byte[] ber={48,3,10,1,0};
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ assertNotNull(src);
+ } catch (IOException e) {
+ fail("The bytes are in the ASN.1 BER.");
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request. With this test
+ * we see that the string Id and the criticality does not matter, olny the BER value.</p>
+ * <p>The expected result is an instance of the class.</p>
+ */
+ public void testSortResponseControl016() {
+
+ String Id="test";
+ boolean crit=true;
+ try {
+ byte[] ber={48,3,10,1,0};
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ assertNotNull(src);
+ } catch (IOException e) {
+ fail("The bytes are in the ASN.1 BER.");
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request. With this test
+ * we see that the string Id and the criticality does not matter, olny the BER value.</p>
+ * <p>The expected result is an exception.</p>
+ */
+ public void testSortResponseControl017() {
+
+ String Id="test";
+ boolean crit=false;
+ try {
+ byte[] ber={3,10,1,0};
+ SortResponseControl src=new SortResponseControl(Id,crit,ber);
+ fail("The bytes are not in the ASN.1 BER.");
+ } catch (IOException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'</p>
+ * <p>Here we are testing if this method constructs a control to indicate the outcome of a sort request. Notice here that
+ * the ber value is not cloned so any change will affect the control.</p>
+ * <p>The expected result is that a change in the ber value affect the control.</p>
+ */
+ public void testSortResponseControl018(){
+
+ String Id="test";
+ boolean crit=false;
+ byte[] ber={48,3,10,1,0};
+ SortResponseControl src=null;
+ byte[] temp=null;
+ try {
+
+ src=new SortResponseControl(Id,crit,ber);
+ temp=src.getEncodedValue();
+ } catch (IOException e) {
+ fail("The bytes are in the ASN.1 BER.");
+ }
+ for(int i=0;i<ber.length;i++){
+ ber[i]=0;
+
+ }
+ for(int i=0;i<ber.length;i++){
+ assertSame(ber[i],src.getEncodedValue()[i]);
+ }
+ }
+
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.isSorted()'</p>
+ * <p>Here we are testing if this method determines if the search results have been successfully sorted.</p>
+ * <p>The expected result in this case is true.</p>
+ */
+ public void testIsSorted001() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,0});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ assertTrue(src.isSorted());
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.isSorted()'</p>
+ * <p>Here we are testing if this method determines if the search results have been successfully sorted.</p>
+ * <p>The expected result in this case is false.</p>
+ */
+ public void testIsSorted002() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",false,new byte[]{48,6,10,1,16,4,1,32});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ assertFalse(src.isSorted());
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getResultCode()'</p>
+ * <p>Here we are testing if this method retrieves the LDAP result code of the sort operation.</p>
+ * <p>The expected result is zero.</p>
+ */
+ public void testGetResultCode001() {
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,0});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ assertEquals(0,src.getResultCode());
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getResultCode()'</p>
+ * <p>Here we are testing if this method retrieves the LDAP result code of the sort operation. Here the sort key does not exist
+ * so the error must be no such attribute.</p>
+ * <p>The expected result is 16.</p>
+ */
+ public void testGetResultCode002() {
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,6,10,1,16,4,1,32});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ assertEquals(16,src.getResultCode());
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getResultCode()'</p>
+ * <p>Here we are testing if this method retrieves the LDAP result code of the sort operation. Here the sort key does exist
+ * but the error must be unwillingToPerform.</p>
+ * <p>The expected result is 53.</p>
+ */
+ public void testGetResultCode003() {
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,7,10,1,53,4,2,67,78});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ assertEquals(53,src.getResultCode());
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getResultCode()'</p>
+ * <p>Here we are testing if this method retrieves the LDAP result code of the sort operation. Here the sort key does exist
+ * but the error must be unwillingToPerform.</p>
+ * <p>The expected result is 100.</p>
+ */
+ public void testGetResultCode004() {
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,7,10,1,100,4,2,67,78});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ assertEquals(100,src.getResultCode());
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getAttributeID()'</p>
+ * <p>Here we are testing if this method retrieves the ID of the attribute that caused the sort to fail.</p>
+ * <p>The expected result is in this case is null because no ID was returned by the server.</p>
+ */
+ public void testGetAttributeID001() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,80});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+ assertEquals(null,src.getAttributeID());
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null naming exception.</p>
+ */
+ public void testGetException001() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,80});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof NamingException){
+
+ }else{
+ fail("The exception must be like NamingException");
+ }
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null NoSuchAttributeException.</p>
+ */
+ public void testGetException002() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,16});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof NoSuchAttributeException){
+
+ }else{
+ fail("The exception must be like NoSuchAttributeException");
+ }
+
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a null exception.</p>
+ */
+ public void testGetException003() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,0});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null)fail("The exception must be null");
+
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null naming exception.</p>
+ */
+ public void testGetException004() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,3});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof TimeLimitExceededException){
+
+ }else{
+ fail("The exception must be like NamingException");
+ }
+
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null naming exception.</p>
+ */
+ public void testGetException005() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,8});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof AuthenticationNotSupportedException){
+
+ }else{
+ fail("The exception must be like NamingException");
+ }
+
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null naming exception.</p>
+ */
+ public void testGetException006() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,11});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof LimitExceededException){
+
+ }else{
+ fail("The exception must be like NamingException");
+ }
+
+
+ }
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null naming exception.</p>
+ */
+ public void testGetException007() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,18});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof InvalidSearchFilterException){
+
+ }else{
+ fail("The exception must be like NamingException");
+ }
+
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null naming exception.</p>
+ */
+ public void testGetException008() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,50});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof NoPermissionException){
+
+ }else{
+ fail("The exception must be like NamingException");
+ }
+
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null naming exception.</p>
+ */
+ public void testGetException009() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,51});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof ServiceUnavailableException){
+
+ }else{
+ fail("The exception must be like NamingException");
+ }
+
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null naming exception.</p>
+ */
+ public void testGetException010() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,53});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof OperationNotSupportedException){
+
+ }else{
+ fail("The exception must be like NamingException");
+ }
+
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null naming exception.</p>
+ */
+ public void testGetException011() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,3,10,1,1});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof NamingException){
+
+ }else{
+ fail("The exception must be like NamingException");
+ }
+
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.SortResponseControl.getException()'</p>
+ * <p>Here we are testing if this method retrieves the NamingException appropriate for the result code.</p>
+ * <p>The expected result is a not null naming exception.</p>
+ */
+ public void testGetException012() {
+
+ SortResponseControl src=null;
+ try{
+ src=new SortResponseControl("test",true,new byte[]{48,7,10,1,100,4,2,67,78});
+ }catch (IOException e) {
+ fail("Failed with:"+e);
+ }
+
+ if(src.getException()!=null&&src.getException() instanceof NamingException){
+
+ }else{
+ fail("The exception must be like NamingException");
+ }
+
+
+ }
+
+}
Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestSortResponseControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestStartTlsRequest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestStartTlsRequest.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestStartTlsRequest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestStartTlsRequest.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,240 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Leonardo Soler
+ * @author Gabriel Miretti
+ * @version 1.0
+ */
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.StartTlsRequest;
+import javax.naming.ldap.StartTlsResponse;
+import junit.framework.TestCase;
+
+/**
+ * <p>This Test class is testing the class StartTlsRequest in the javax.naming.ldap package.</p>
+ * <p>Here in the next tables we are gonna find all methods to be tested:</p>
+ * <table class="t" cellspacing="0">
+ <tbody><th>Constructors:</th>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="StartTlsRequest()" id="f10"></td>
+
+ </tr>
+
+ </tbody>
+ <table>
+ <tbody><th>Method Summary:</th>
+ <tr><TD>Return</TD><TD>Method</TD></tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="ExtendedResponse" id="f00"></TD>
+ <td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="createExtendedResponse(String id, byte[] berValue, int offset, int length)" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="byte[]" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="getEncodedValue()" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="String" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="getID()" id="f10"></td>
+
+ </tr>
+
+
+ </tbody>
+ </table>
+ * <hr>
+ *
+ */
+public class TestStartTlsRequest extends TestCase {
+
+ /**
+ * <p>This method is not implemted.</p>
+ * @param args Possible parameter to help us initiate all tests.
+ */
+ public static void main(String[] args) {
+ }
+
+ /**
+ * <p>Constructor method of the test class.</p>
+ * <p>Here in this case we do not do anything else of initiate the inherited constructor.</p>
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.StartTlsRequest.StartTlsRequest()'</p>
+ * <p>Here we are testing if this method constructs a StartTLS extended request.</p>
+ * <p>The expected return is an object Tls.</p>
+ */
+ public void testStartTlsRequest() {
+
+ assertNotNull(new StartTlsRequest());
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.StartTlsRequest.getID()'</p>
+ * <p>Here we are testing if this method retrieves the StartTLS request's object identifier string.</p>
+ * <p>The expected result is a string : "1.3.6.1.4.1.1466.20037".</p>
+ */
+ public void testGetID() {
+ StartTlsRequest str = new StartTlsRequest();
+ assertEquals("1.3.6.1.4.1.1466.20037",str.getID());
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.StartTlsRequest.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the StartTLS request's ASN.1 BER encoded value.</p>
+ * <p>The expected result is a null value.</p>
+ */
+ public void testGetEncodedValue() {
+
+ StartTlsRequest str = new StartTlsRequest();
+ assertNull(str.getEncodedValue());
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'</p>
+ * <p>Here we are testing if this method creates an extended response object that corresponds to the LDAP StartTLS extended request.</p>
+ * <p>The expected result is NamingException.</p>
+ */
+ public void testCreateExtendedResponse001() {
+ StartTlsRequest str = new StartTlsRequest();
+ String ID="";
+ int t1=0,t2=0;
+ byte[] t0=new byte[] {0,0,0};
+ try {
+ str.createExtendedResponse(ID,t0,t1,t2);
+ } catch (NamingException e) {
+ } catch (Throwable e){
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'</p>
+ * <p>Here we are testing if this method creates an extended response object that corresponds to the LDAP StartTLS extended request.
+ * In this case we are testing the extended response with the argument ID="1.3.6.1.4.1.1466.20037". In this particular case does
+ * not exist an implentation.</p>
+ * <p>Notice here that this package does not have a provider so an implementation does not exist, so this test must fail with a provider
+ * and not fail with no provider.</p>
+ * <p>The expected result is an exception because here does not exist an implemntation.</p>
+ */
+ public void testCreateExtendedResponse002() {
+ StartTlsRequest str = new StartTlsRequest();
+ String ID="1.3.6.1.4.1.1466.20037";
+ int t1=0,t2=0;
+ byte[] t0=null;
+ try {
+ str.createExtendedResponse(ID,t0,t1,t2);
+ fail("Here does not exist an implementation.");
+ } catch (NamingException e) {
+
+ } catch (Throwable e){
+ e.printStackTrace();
+ fail("Failed with:"+e);
+ }
+
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'</p>
+ * <p>Here we are testing if this method creates an extended response object that corresponds to the LDAP StartTLS extended request.
+ * In this case we are testing the extended response with the argument ID="", and the byte array.</p>
+ * <p>Notice here this test is ok because first the class must check the arguments and then search for the implementation.</p>
+ * <p>The expected result is a Naming exception.</p>
+ */
+ public void testCreateExtendedResponse003() {
+
+ StartTlsRequest str = new StartTlsRequest();
+ String ID="";
+ int t1=0,t2=0;
+ byte[] t0=null;
+ try {
+ StartTlsResponse x=(StartTlsResponse) str.createExtendedResponse(ID,t0,t1,t2);
+ fail("Should not be posible use an id distinct of \"1.3.6.1.4.1.1466.20037\"");
+ } catch (NamingException e) {
+
+ } catch (Throwable e){
+ e.printStackTrace();
+ fail("Failed with:"+e);
+ }
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'</p>
+ * <p>Here we are testing if this method creates an extended response object that corresponds to the LDAP StartTLS extended request.
+ * In this case we are testing the extended response with the argument ID="1.3.6.1.4.1.1466.20037" and the others arguments should be ignored.</p>
+ * <p>Notice here that this package does not have a provider so an implementation does not exist, so this test must not fail with a provider
+ * and fail with no provider.</p>
+ * <p>The expected result is a Tls response.</p>
+ */
+ public void testCreateExtendedResponse004() {
+
+ StartTlsRequest str = new StartTlsRequest();
+ String ID="1.3.6.1.4.1.1466.20037";
+ int t1=210,t2=650;
+ byte[] t0=ID.getBytes();
+ try {
+ StartTlsResponse x=(StartTlsResponse) str.createExtendedResponse(ID,t0,t1,t2);
+ assertNotNull(x);
+ assertEquals("1.3.6.1.4.1.1466.20037",x.getID());
+ assertEquals(null,x.getEncodedValue());
+ } catch (NamingException e) {
+ fail("Failed with:"+e);
+ } catch (Throwable e){
+ e.printStackTrace();
+ fail("Failed with:"+e);
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'</p>
+ * <p>Here we are testing if this method creates an extended response object that corresponds to the LDAP StartTLS extended request.
+ * In this case we are testing the extended response with the argument ID=""</p>
+ * <p>The expected result is an exception.</p>
+ */
+ public void testCreateExtendedResponse005() {
+
+ StartTlsRequest str = new StartTlsRequest();
+ String ID="1.a.2.b.3.d.4";
+ int t1=0,t2=0;
+ byte[] t0=null;
+ try {
+ StartTlsResponse tls = (StartTlsResponse) str.createExtendedResponse(ID,t0,t1,t2);
+ fail("Should not be posible use an id distinc of \"1.3.6.1.4.1.1466.20037\"");
+ } catch (NamingException e) {
+ } catch (Throwable e){
+ fail("Failed with:"+e);
+ }
+
+ }
+
+}
Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestStartTlsRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestStartTlsResponse.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestStartTlsResponse.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestStartTlsResponse.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestStartTlsResponse.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Leonardo Soler
+ * @author Gabriel Miretti
+ * @version 1.0
+ */
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockStartTlsResponse;
+import junit.framework.TestCase;
+
+/**
+ * <p>This class has all test for the class TestStartTlsResponse.</p>
+ * <p>Here we are gonna test all its methods as we see in the next table:</p>
+ * <table>
+ <tbody><th>Method Summary:</th>
+ <tr><TD>Return</TD><TD>Method</TD></tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="byte[]" id="f00"></TD>
+ <td class="c0" id="c10"><input class="a0" size="80" name="sas9nt21" readonly="readonly" value="getEncodedValue()" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value=" String" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="80" name="sas9nt21" readonly="readonly" value="getID()" id="f10"></td>
+
+ </tr>
+
+ </tbody>
+ </table>
+ *
+ */
+public class TestStartTlsResponse extends TestCase {
+
+
+ /**
+ * <p>This method is not implemted.</p>
+ * @param args Possible parameter to help us initiate all tests.
+ */
+ public static void main(String[] args) {
+ }
+
+ /**
+ * <p>Constructor method of the test class.</p>
+ * <p>Here in this case we do not do anything else of initiate the inherited constructor.</p>
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.StartTlsResponse.getID()'</p>
+ * <p>Here we are testing if this method retrieves the StartTLS response's object identifier string.</p>
+ * <p>The expected result is "1.3.6.1.4.1.1466.20037".</p>
+ */
+ public void testGetID() {
+
+ MockStartTlsResponse x=new MockStartTlsResponse();
+ assertEquals("1.3.6.1.4.1.1466.20037",x.getID());
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.StartTlsResponse.getEncodedValue()'</p>
+ * <p>Here we are testing if this method retrieves the StartTLS response's ASN.1 BER encoded value.</p>
+ * <p>The expected result is a null value.</p>
+ */
+ public void testGetEncodedValue() {
+
+ MockStartTlsResponse x=new MockStartTlsResponse();
+ assertNull(x.getEncodedValue());
+ }
+
+
+}
Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestStartTlsResponse.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestUnsolicitedNotificationEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestUnsolicitedNotificationEvent.java?view=auto&rev=507703
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestUnsolicitedNotificationEvent.java (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestUnsolicitedNotificationEvent.java Wed Feb 14 13:42:41 2007
@@ -0,0 +1,229 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Leonardo Soler
+ * @author Gabriel Miretti
+ * @version 1.0
+ */
+package org.apache.harmony.jndi.tests.javax.naming.ldap;
+
+import javax.naming.ldap.UnsolicitedNotification;
+import javax.naming.ldap.UnsolicitedNotificationEvent;
+import org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockUnsolicitedNotification;
+import junit.framework.TestCase;
+
+/**
+ * <p>This class has all test for the class UnsolicitedNotificationEvent.</p>
+ * <p>Here we are gonna test all its methods as we see in the next table:</p>
+ * <table class="t" cellspacing="0">
+ <tbody><th>Constructors:</th>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="80" name="sas9nt21" readonly="readonly" value="UnsolicitedNotificationEvent(Object src, UnsolicitedNotification notice)" id="f10"></td>
+
+ </tr>
+
+ </tbody>
+ <table>
+ <tbody><th>Method Summary:</th>
+ <tr><TD>Return</TD><TD>Method</TD></tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="void" id="f00"></TD>
+ <td class="c0" id="c10"><input class="a0" size="80" name="sas9nt21" readonly="readonly" value="dispatch(UnsolicitedNotificationListener listener)" id="f10"></td>
+
+ </tr>
+ <tr>
+ <td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="UnsolicitedNotification" id="f00"></td>
+ <td class="c0" id="c10"><input class="a0" size="80" name="sas9nt21" readonly="readonly" value="getNotification()" id="f10"></td>
+
+ </tr>
+
+ </tbody>
+ </table>
+ *
+ */
+public class TestUnsolicitedNotificationEvent extends TestCase {
+
+ /**
+ * <p>This method is not implemted.</p>
+ * @param args Possible parameter to help us initiate all tests.
+ */
+ public static void main(String[] args) {
+ }
+
+ /**
+ * <p>Constructor method of the test class.</p>
+ * <p>Here in this case we do not do anything else of initiate the inherited constructor.</p>
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'</p>
+ * <p>This is the constructor method that constructs a new instance of UnsolicitedNotificationEvent. In this case we are sending
+ * two null arguments. This is not specified in the API.</p>
+ * <p>The expected result is an Illegal argument exception.</p>
+ */
+ public void testUnsolicitedNotificationEvent001() {
+
+ try{
+ UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(null,null);
+ fail("The arguments could not be null.");
+ } catch (IllegalArgumentException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'</p>
+ * <p>This is the constructor method that constructs a new instance of UnsolicitedNotificationEvent. In this case we are sending
+ * one null arguments. This is not specified in the API.</p>
+ * <p>The expected result is an Illegal Argument exception.</p>
+ */
+ public void testUnsolicitedNotificationEvent002() {
+ try{
+ Object x=new Object();
+ UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,null);
+ fail("The arguments could not be null.");
+ } catch (IllegalArgumentException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'</p>
+ * <p>This is the constructor method that constructs a new instance of UnsolicitedNotificationEvent. In this case we are sending
+ * one null arguments. This is not specified in the API.</p>
+ * <p>The expected result is an Illegal Argument exception.</p>
+ */
+ public void testUnsolicitedNotificationEvent003() {
+
+ try{
+ MockUnsolicitedNotification u=new MockUnsolicitedNotification();
+ UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(null,u);
+ fail("The arguments could not be null.");
+ } catch (IllegalArgumentException e) {
+
+ }
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'</p>
+ * <p>This is the constructor method that constructs a new instance of UnsolicitedNotificationEvent. In this case we are sending
+ * one null arguments. This is not specified in the API.</p>
+ * <p>The expected result is an Illegal Argument exception.</p>
+ */
+ public void testUnsolicitedNotificationEvent004() {
+
+ try{
+ Object x=new Object();
+ MockUnsolicitedNotification u = new MockUnsolicitedNotification();
+ UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,u);
+
+ } catch (Throwable e) {
+ fail("Failed with:"+e);
+ }
+ }
+
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.getNotification()'</p>
+ * <p>Here we are testing if the method returns the unsolicited notification. In this case we create a notification
+ * with an object and a null notification as the parameters.</p>
+ * <p>The expected result is a not null notification.</p>
+ */
+ public void testGetNotification001() {
+
+ try{
+ Object x=new Object();
+ MockUnsolicitedNotification u=null;
+ UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,u);
+ UnsolicitedNotification ret = une.getNotification();//because the notification was null, but see here the error of create a UNE with a null
+ fail("The notification must not be null.");
+ } catch (Throwable e) {
+
+ }
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.getNotification()'</p>
+ * <p>Here we are testing if the method returns the unsolicited notification. In this case we create a notification
+ * with an object and a null notification as the parameters.</p>
+ * <p>The expected result is a not null notification.</p>
+ */
+ public void testGetNotification002() {
+
+ try{
+ Object x=new Object();
+ MockUnsolicitedNotification u = new MockUnsolicitedNotification();
+ UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,u);
+ assertEquals(u,une.getNotification());
+ } catch (Throwable e) {
+ fail("Failed with:"+e);
+ }
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.dispatch(UnsolicitedNotificationListener)'</p>
+ * <p>Here this method invokes the notificationReceived() method on a listener using this event. In this case we are
+ * sending as a parameter a null listener.</p>
+ * <p>The expected result is a null pointer exception.</p>
+ */
+ public void testDispatch001() {
+ Object x=new Object();
+ UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,new MockUnsolicitedNotification());
+ try{
+ une.dispatch(null);
+ fail("Failed notification is null.");
+ } catch (NullPointerException e) {
+
+ } catch (IllegalArgumentException e) {
+ fail("Should not raise IllegalArgument");
+ }
+
+ }
+
+ /**
+ * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.dispatch(UnsolicitedNotificationListener)'</p>
+ * <p>Here this method invokes the notificationReceived() method on a listener using this event. In this case we are
+ * sending as a parameter a non null listener.</p>
+ * <p>The expected result is a null pointer exception.</p>
+ */
+ public void testDispatch002() {
+ try{
+ Object x=new Object();
+ MockUnsolicitedNotification u=new MockUnsolicitedNotification();
+ MockUnsolicitedNotification f=new MockUnsolicitedNotification();
+ UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,u);
+ une.dispatch(f);
+ assertTrue(f.getFlag());
+ } catch (Throwable e) {
+ fail("Failed with:"+e);
+ }
+
+ }
+
+
+}
Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestUnsolicitedNotificationEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
|