Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 78628 invoked from network); 14 Feb 2007 21:43:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Feb 2007 21:43:37 -0000 Received: (qmail 38840 invoked by uid 500); 14 Feb 2007 21:43:44 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 38804 invoked by uid 500); 14 Feb 2007 21:43:44 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 38737 invoked by uid 99); 14 Feb 2007 21:43:43 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Feb 2007 13:43:43 -0800 X-ASF-Spam-Status: No, hits=-8.2 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME,WEIRD_QUOTING X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Feb 2007 13:43:29 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id B4F481A9829; Wed, 14 Feb 2007 13:42:47 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r507703 [7/9] - in /harmony/enhanced/classlib/trunk/modules: jndi/META-INF/ jndi/make/ jndi/src/main/java/javax/naming/ldap/ jndi/src/main/java/org/apache/harmony/jndi/internal/ jndi/src/main/java/org/apache/harmony/jndi/internal/nls/ jndi/... Date: Wed, 14 Feb 2007 21:42:44 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070214214247.B4F481A9829@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; + +/** + *

This Test class is testing the SortControl class.

+ *

In the next tables we are gonna see the methods that we test in this class:

+ * + + + + + + + + + + + + + + + + + +
Constructors:
+ * + */ +public class TestSortControl extends TestCase { + + /** + *

This method is not implemted.

+ * @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(); + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.SortControl(String, boolean)'

+ *

Here we are testing if this method constructs a control to sort on a list of sort keys.

+ *

The expected result is a null pointer exception.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.SortControl(String, boolean)'

+ *

Here we are testing if this method constructs a control to sort on a list of sort keys.

+ *

The expected result is a not null Sort Control.

+ */ + 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); + } + } + + + /** + *

Test method for 'javax.naming.ldap.SortControl.SortControl(String[], boolean)'

+ *

Here we are testing if this method constructs a control to sort on a list of attributes in ascending order.

+ *

The expected result is a null pointer exception.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.SortControl(String[], boolean)'

+ *

Here we are testing if this method constructs a control to sort on a list of attributes in ascending order.

+ *

The expected result is a not null sort control.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.SortControl(String[], boolean)'

+ *

Here we are testing if this method constructs a control to sort on a list of attributes in ascending order.

+ *

The expected result is a not null sort control.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.SortControl(String[], boolean)'

+ *

Here we are testing if this method constructs a control to sort on a list of attributes in ascending order.

+ *

The expected result is a not null sort control.

+ */ + public void testSortControlStringArrayBoolean004() { + + try { + String[] x={"",""}; + SortControl sc=new SortControl(x,true); + assertNotNull(sc); + assertTrue(sc.isCritical()); + } catch (IOException e) { + fail("Failed with:"+e); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.SortControl(SortKey[], boolean)'

+ *

Here we are testing if this metho constructs a control to sort on a single attrib.

+ *

The expected result is a null pointer exception.

+ */ + 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); + } + + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.SortControl(SortKey[], boolean)'

+ *

Here we are testing if this metho constructs a control to sort on a single attrib.

+ *

The expected result is a not null sort control.

+ */ + 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); + } + + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.SortControl(SortKey[], boolean)'

+ *

Here we are testing if this metho constructs a control to sort on a single attrib.

+ *

The expected result is a not null sort control.

+ */ + 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); + } + + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortControl.getEncodedValue()'

+ *

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.

+ *

The expecting result is the control's ASN.1 BER encoded value.

+ */ + 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; + +/** + *

This Test class is testing the SortKey class.

+ *

In the next tables we are gonna see the methods that we test in this class:

+ * + + + + + + + + + + + + +
Constructors:
+ + + + + + + + + + + + + + + + + + + +
Method Summary:
ReturnMethod
+ * + */ +public class TestSortKey extends TestCase { + + /** + *

This method is not implemted.

+ * @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(); + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.SortKey(String)'

+ *

Here we are testing if this method creates the default sort key for an attribute. In this case we send a null ID.

+ *

The expected result is a null pointer exception.

+ */ + public void testSortKeyString001() { + + try{ + SortKey x=new SortKey(null); + fail("The id should not be null."); + }catch (NullPointerException e) { + + } + + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.SortKey(String)'

+ *

Here we are testing if this method creates the default sort key for an attribute. In this case we send a blank ID.

+ *

The expected result is a not null sort key.

+ */ + public void testSortKeyString002() { + + assertNotNull(new SortKey("")); + + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.SortKey(String)'

+ *

Here we are testing if this method creates the default sort key for an attribute. In this case we send an ID like "anything".

+ *

The expected result is a not null sort key.

+ */ + public void testSortKeyString003() { + + assertNotNull(new SortKey("anything")); + + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.SortKey(String, boolean, String)'

+ *

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.

+ *

The expected result a null pointer exception.

+ */ + public void testSortKeyStringBooleanString001() { + + try{ + SortKey x=new SortKey(null,false,null); + fail("The attrID should not be null."); + } catch (NullPointerException e) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.SortKey(String, boolean, String)'

+ *

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.

+ *

The expected result a not null sort key.

+ */ + public void testSortKeyStringBooleanString002() { + + SortKey x=new SortKey("",false,null); + assertNotNull(x); + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.SortKey(String, boolean, String)'

+ *

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 "".

+ *

The expected result a not null sort key.

+ */ + public void testSortKeyStringBooleanString003() { + + SortKey x=new SortKey("anything",false,""); + assertNotNull(x); + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.SortKey(String, boolean, String)'

+ *

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".

+ *

The expected result a not null sort key.

+ */ + public void testSortKeyStringBooleanString004() { + + SortKey x=new SortKey("anything",true,"anything"); + assertNotNull(x); + } + + + /** + *

Test method for 'javax.naming.ldap.SortKey.getAttributeID()'

+ *

Here we are testing if this method retrieves the attribute ID of the sort key.

+ *

The expected result is a not null return.

+ */ + public void testGetAttributeID001() { + + SortKey x=new SortKey("test"); + assertEquals("test",x.getAttributeID()); + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.getAttributeID()'

+ *

Here we are testing if this method retrieves the attribute ID of the sort key.

+ *

The expected result is a not null return.

+ */ + public void testGetAttributeID002() { + + SortKey x=new SortKey(""); + assertEquals("",x.getAttributeID()); + } + + + /** + *

Test method for 'javax.naming.ldap.SortKey.isAscending()'

+ *

Here we are testing if this method determines the sort order.

+ *

The expected result is the given sort order.

+ */ + public void testIsAscending001() { + + SortKey x=new SortKey("",true,""); + assertTrue(x.isAscending()); + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.isAscending()'

+ *

Here we are testing if this method determines the sort order.

+ *

The expected result is the given sort order.

+ */ + public void testIsAscending002() { + + SortKey x=new SortKey("",false,""); + assertFalse(x.isAscending()); + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.isAscending()'

+ *

Here we are testing if this method determines the sort order. In this case we do not give a sort order.

+ *

The expected result is true.

+ */ + public void testIsAscending003() { + + SortKey x=new SortKey("anything"); + assertTrue(x.isAscending()); + } + + + /** + *

Test method for 'javax.naming.ldap.SortKey.getMatchingRuleID()'

+ *

Here we are testing if this method retrieves the matching rule ID used to order the attribute values.

+ *

The expected result is a null.

+ */ + public void testGetMatchingRuleID001() { + + SortKey x=new SortKey("anything"); + assertNull(x.getMatchingRuleID()); + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.getMatchingRuleID()'

+ *

Here we are testing if this method retrieves the matching rule ID used to order the attribute values.

+ *

The expected result is a blank Id.

+ */ + public void testGetMatchingRuleID002() { + + SortKey x=new SortKey("anything",false,""); + assertEquals("",x.getMatchingRuleID()); + } + + /** + *

Test method for 'javax.naming.ldap.SortKey.getMatchingRuleID()'

+ *

Here we are testing if this method retrieves the matching rule ID used to order the attribute values.

+ *

The expected result is a blank Id.

+ */ + 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; + +/** + *

This Test class is testing the SortControl class.

+ *

In the next tables we are gonna see the methods that we test in this class:

+ * + + + + + + + +
Constructors:
+ + + + + + + + + + + + + + + + + + + + + + + +
Method Sumary:
+ + * + */ +public class TestSortResponseControl extends TestCase { + + + /** + *

This method is not implemted.

+ * @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(); + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception like NullPointer.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception like NullPointer.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception like IOException.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception like IOException.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception like IOException.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an instance of the class.

+ */ + 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."); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an exception.

+ */ + 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) { + + } + } + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an instance of the class.

+ */ + 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."); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

Here we are testing if this method constructs a control to indicate the outcome of a sort request.

+ *

The expected result is an instance of the class.

+ */ + 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."); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

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.

+ *

The expected result is an instance of the class.

+ */ + 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."); + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

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.

+ *

The expected result is an exception.

+ */ + 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) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.SortResponseControl(String, boolean, byte[])'

+ *

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.

+ *

The expected result is that a change in the ber value affect the control.

+ */ + 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;iTest method for 'javax.naming.ldap.SortResponseControl.isSorted()'

+ *

Here we are testing if this method determines if the search results have been successfully sorted.

+ *

The expected result in this case is true.

+ */ + 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()); + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.isSorted()'

+ *

Here we are testing if this method determines if the search results have been successfully sorted.

+ *

The expected result in this case is false.

+ */ + 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()); + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getResultCode()'

+ *

Here we are testing if this method retrieves the LDAP result code of the sort operation.

+ *

The expected result is zero.

+ */ + 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()); + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getResultCode()'

+ *

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.

+ *

The expected result is 16.

+ */ + 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()); + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getResultCode()'

+ *

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.

+ *

The expected result is 53.

+ */ + 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()); + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getResultCode()'

+ *

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.

+ *

The expected result is 100.

+ */ + 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()); + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getAttributeID()'

+ *

Here we are testing if this method retrieves the ID of the attribute that caused the sort to fail.

+ *

The expected result is in this case is null because no ID was returned by the server.

+ */ + 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()); + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null naming exception.

+ */ + 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"); + } + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null NoSuchAttributeException.

+ */ + 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"); + } + + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a null exception.

+ */ + 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"); + + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null naming exception.

+ */ + 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"); + } + + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null naming exception.

+ */ + 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"); + } + + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null naming exception.

+ */ + 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"); + } + + + } + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null naming exception.

+ */ + 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"); + } + + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null naming exception.

+ */ + 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"); + } + + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null naming exception.

+ */ + 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"); + } + + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null naming exception.

+ */ + 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"); + } + + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null naming exception.

+ */ + 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"); + } + + + } + + /** + *

Test method for 'javax.naming.ldap.SortResponseControl.getException()'

+ *

Here we are testing if this method retrieves the NamingException appropriate for the result code.

+ *

The expected result is a not null naming exception.

+ */ + 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; + +/** + *

This Test class is testing the class StartTlsRequest in the javax.naming.ldap package.

+ *

Here in the next tables we are gonna find all methods to be tested:

+ * + + + + + + + + +
Constructors:
+ + + + + + + + + + + + + + + + + + + + +
Method Summary:
ReturnMethod
+ *
+ * + */ +public class TestStartTlsRequest extends TestCase { + + /** + *

This method is not implemted.

+ * @param args Possible parameter to help us initiate all tests. + */ + public static void main(String[] args) { + } + + /** + *

Constructor method of the test class.

+ *

Here in this case we do not do anything else of initiate the inherited constructor.

+ */ + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + *

Test method for 'javax.naming.ldap.StartTlsRequest.StartTlsRequest()'

+ *

Here we are testing if this method constructs a StartTLS extended request.

+ *

The expected return is an object Tls.

+ */ + public void testStartTlsRequest() { + + assertNotNull(new StartTlsRequest()); + + } + + /** + *

Test method for 'javax.naming.ldap.StartTlsRequest.getID()'

+ *

Here we are testing if this method retrieves the StartTLS request's object identifier string.

+ *

The expected result is a string : "1.3.6.1.4.1.1466.20037".

+ */ + public void testGetID() { + StartTlsRequest str = new StartTlsRequest(); + assertEquals("1.3.6.1.4.1.1466.20037",str.getID()); + } + + /** + *

Test method for 'javax.naming.ldap.StartTlsRequest.getEncodedValue()'

+ *

Here we are testing if this method retrieves the StartTLS request's ASN.1 BER encoded value.

+ *

The expected result is a null value.

+ */ + public void testGetEncodedValue() { + + StartTlsRequest str = new StartTlsRequest(); + assertNull(str.getEncodedValue()); + + } + + /** + *

Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'

+ *

Here we are testing if this method creates an extended response object that corresponds to the LDAP StartTLS extended request.

+ *

The expected result is NamingException.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'

+ *

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.

+ *

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.

+ *

The expected result is an exception because here does not exist an implemntation.

+ */ + 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); + } + + + } + + /** + *

Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'

+ *

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.

+ *

Notice here this test is ok because first the class must check the arguments and then search for the implementation.

+ *

The expected result is a Naming exception.

+ */ + 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); + } + + } + + /** + *

Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'

+ *

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.

+ *

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.

+ *

The expected result is a Tls response.

+ */ + 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); + } + } + + /** + *

Test method for 'javax.naming.ldap.StartTlsRequest.createExtendedResponse(String, byte[], int, int)'

+ *

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=""

+ *

The expected result is an exception.

+ */ + 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; + +/** + *

This class has all test for the class TestStartTlsResponse.

+ *

Here we are gonna test all its methods as we see in the next table:

+ * + + + + + + + + + + + + + + +
Method Summary:
ReturnMethod
+ * + */ +public class TestStartTlsResponse extends TestCase { + + + /** + *

This method is not implemted.

+ * @param args Possible parameter to help us initiate all tests. + */ + public static void main(String[] args) { + } + + /** + *

Constructor method of the test class.

+ *

Here in this case we do not do anything else of initiate the inherited constructor.

+ */ + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + *

Test method for 'javax.naming.ldap.StartTlsResponse.getID()'

+ *

Here we are testing if this method retrieves the StartTLS response's object identifier string.

+ *

The expected result is "1.3.6.1.4.1.1466.20037".

+ */ + public void testGetID() { + + MockStartTlsResponse x=new MockStartTlsResponse(); + assertEquals("1.3.6.1.4.1.1466.20037",x.getID()); + } + + /** + *

Test method for 'javax.naming.ldap.StartTlsResponse.getEncodedValue()'

+ *

Here we are testing if this method retrieves the StartTLS response's ASN.1 BER encoded value.

+ *

The expected result is a null value.

+ */ + 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; + +/** + *

This class has all test for the class UnsolicitedNotificationEvent.

+ *

Here we are gonna test all its methods as we see in the next table:

+ * + + + + + + + + +
Constructors:
+ + + + + + + + + + + + + + +
Method Summary:
ReturnMethod
+ * + */ +public class TestUnsolicitedNotificationEvent extends TestCase { + + /** + *

This method is not implemted.

+ * @param args Possible parameter to help us initiate all tests. + */ + public static void main(String[] args) { + } + + /** + *

Constructor method of the test class.

+ *

Here in this case we do not do anything else of initiate the inherited constructor.

+ */ + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + *

Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'

+ *

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.

+ *

The expected result is an Illegal argument exception.

+ */ + public void testUnsolicitedNotificationEvent001() { + + try{ + UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(null,null); + fail("The arguments could not be null."); + } catch (IllegalArgumentException e) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'

+ *

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.

+ *

The expected result is an Illegal Argument exception.

+ */ + public void testUnsolicitedNotificationEvent002() { + try{ + Object x=new Object(); + UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,null); + fail("The arguments could not be null."); + } catch (IllegalArgumentException e) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'

+ *

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.

+ *

The expected result is an Illegal Argument exception.

+ */ + public void testUnsolicitedNotificationEvent003() { + + try{ + MockUnsolicitedNotification u=new MockUnsolicitedNotification(); + UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(null,u); + fail("The arguments could not be null."); + } catch (IllegalArgumentException e) { + + } + } + + /** + *

Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'

+ *

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.

+ *

The expected result is an Illegal Argument exception.

+ */ + 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); + } + } + + + /** + *

Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.getNotification()'

+ *

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.

+ *

The expected result is a not null notification.

+ */ + 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) { + + } + + } + + /** + *

Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.getNotification()'

+ *

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.

+ *

The expected result is a not null notification.

+ */ + 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); + } + + } + + /** + *

Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.dispatch(UnsolicitedNotificationListener)'

+ *

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.

+ *

The expected result is a null pointer exception.

+ */ + 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"); + } + + } + + /** + *

Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.dispatch(UnsolicitedNotificationListener)'

+ *

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.

+ *

The expected result is a null pointer exception.

+ */ + 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