Package javax.naming.ldap

Examples of javax.naming.ldap.SortKey


  public void testCompareTo002() {
   
    try {
      LdapName ln = new LdapName("t=test,cn=common");
      int i;
      i = ln.compareTo(new SortKey(""));
      fail("The string is null.");
    } catch (ClassCastException e) {
     
    } catch (Throwable e) {
      fail("Failed with: "+e);
View Full Code Here


import junit.framework.TestCase;

public class SortKeyTest extends TestCase {

    public void testAll() {
        new SortKey(null);
        new SortKey(null, true, null);

        SortKey sk = new SortKey("attributeId");
        assertEquals("attributeId", sk.getAttributeID());
        assertTrue(sk.isAscending());
        assertNull(sk.getMatchingRuleID());

        sk = new SortKey("attributeId", false, "matchingRuleId");
        assertEquals("attributeId", sk.getAttributeID());
        assertFalse(sk.isAscending());
        assertEquals("matchingRuleId", sk.getMatchingRuleID());
       
       
        sk = new SortKey("attributeId", true, null);
        assertEquals("attributeId", sk.getAttributeID());
        assertTrue(sk.isAscending());
        assertNull(sk.getMatchingRuleID());
    }
View Full Code Here

  public void testCompareTo002() {
   
    try {
      LdapName ln = new LdapName("t=test,cn=common");
      int i;
      i = ln.compareTo(new SortKey(""));
      fail("The string is null.");
    } catch (ClassCastException e) {
     
    } catch (Throwable e) {
      fail("Failed with: "+e);
View Full Code Here

     * <p>
     * The expecting result is the control's ASN.1 BER encoded value.
     * </p>
     */
    public void testEncodedValueOfSortControl001() throws Exception {
        SortKey[] sk = { new SortKey("pepe", false, "leo") };

        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()));
    }
View Full Code Here

        String[] sk2 = {"pepe", "", "haha" };
        sc = new SortControl(sk2, true);
        assertEquals("30 14 30 06 04 04 70 65 70 65 30 02 04 00 30 06 04 04 68 61 68 61",
                toHexString(sc.getEncodedValue()));
       
        SortKey[] sk3 = {new SortKey("pepe", false, "haha"), null, new SortKey("", true, "haha2"), new SortKey("haah", true, "pepe")};
        try{
            sc = new SortControl(sk3, true);
            fail("should throw NPE");
        }catch(NullPointerException e){
        }
       
        SortKey[] sk4 = {new SortKey("pepe", false, "haha"), new SortKey("", true, "haha2"), new SortKey("haah", true, "pepe")};
        sc = new SortControl(sk4, true);
        assertEquals("30 2a 30 0f 04 04 70 65 70 65 80 04 68 61 68 61 81 01 ff 30 09 04 00 80 05 68 61 68 61 32 30 0c 04 04 68 61 61 68 80 04 70 65 70 65",
                toHexString(sc.getEncodedValue()));

    }
View Full Code Here

     * <p>
     * The expecting result is the control's ASN.1 BER encoded value.
     * </p>
     */
    public void testEncodedValueOfSortControl003() throws Exception {
        SortKey[] sk = { new SortKey("", true, "") };

        SortControl sc = new SortControl(sk, true);
        assertEquals("30 06 30 04 04 00 80 00", toHexString(sc
                .getEncodedValue()));

        SortKey[] sk1 = { new SortKey("pepe", true, "laura") };

        sc = new SortControl(sk1, true);
        assertEquals("30 0f 30 0d 04 04 70 65 70 65 80 05 6c 61 75 72 61",
                toHexString(sc.getEncodedValue()));
    }
View Full Code Here

    }
    if (sorted)
    {
      SortKey[] keys = new SortKey[SORT_ATTRIBUTES.length];
      for (int i=0; i<keys.length; i++) {
        keys[i] = new SortKey(SORT_ATTRIBUTES[i]);
      }
      try
      {
        ctls[0] = new SortControl(keys, false);
      }
View Full Code Here

TOP

Related Classes of javax.naming.ldap.SortKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.