当前位置: 首页>>代码示例>>Java>>正文


Java Rdn.unescapeValue方法代码示例

本文整理汇总了Java中javax.naming.ldap.Rdn.unescapeValue方法的典型用法代码示例。如果您正苦于以下问题:Java Rdn.unescapeValue方法的具体用法?Java Rdn.unescapeValue怎么用?Java Rdn.unescapeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.naming.ldap.Rdn的用法示例。


在下文中一共展示了Rdn.unescapeValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {

        /**
         * Unescape tests
         */
        String[] invalids = new String[] {"\\", "\\\\\\" };

        String[] valids = new String[] {"\\\\", "\\\\\\\\"};

        String val;
        Object unescVal = null;
        System.out.println("##### Unescape value tests #####");

        for (int i = 0; i < valids.length; i++) {
            unescVal = Rdn.unescapeValue(valids[i]);
            System.out.println("Orig val: " + valids[i] +
                                "       Unescaped val: " + unescVal);
        }

        boolean isExcepThrown = false;
        for (int i = 0; i < invalids.length; i++) {
            val = "Juicy" + invalids[i] + "Fruit";
            try {
                unescVal = Rdn.unescapeValue(val);
            } catch (IllegalArgumentException e) {
                System.out.println("Caught the right exception: " + e);
                isExcepThrown = true;
            }
            if (!isExcepThrown) {
                throw new Exception(
                        "Unescaped successfully an invalid string "
                        + val + " as Rdn: " + unescVal);
            }
            isExcepThrown = false;
        }

        /**
         * Escape tests
         */
        String[] values = new String[] {";", "<<<", "###", "=="};
        System.out.println("##### Escape value tests #####");
        printEscapedVal(values);

        // leading space, trailing space
        values = new String[] {"  leading space", "trailing space  "};
        printEscapedVal(values);

        // binary values
        byte[] bytes = new byte[] {1, 2, 3, 4};
        String escVal = Rdn.escapeValue(bytes);
        System.out.println("Orig val: " + bytes +
                                "       Escaped val: " + escVal);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:54,代码来源:EscapeUnescapeTests.java

示例2: testUnescapedValue002

import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.escapedValue(Object)'
 * </p>
 * <p>
 * Here we are testing if this method can escape some values.
 * </p>
 * <p>
 * The expected result is that the method return the string escaped.
 * </p>
 */
public void testUnescapedValue002() {
    try {
        Rdn.unescapeValue("##fa08");
        fail("An exception must be thrown.");
    } catch (IllegalArgumentException e) {
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:TestRdnWhiteBoxDevelopment.java

示例3: testUnescapeValue006

import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.unescapeValue(String)'
 * </p>
 * <p>
 * Here we are testing if his method returns a correctly unformatted string for
 * the given attribute value. In this case we are testing the special character
 * "\" in the form "this\that".
 * </p>
 * <p>
 * The expected result is an illegal argument ecpetion.
 * </p>
 */
public void testUnescapeValue006() {
    try {
        Rdn.unescapeValue("this\\that");
        fail("The arguments are wrong.");
    } catch (IllegalArgumentException e) {}
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:RdnTest.java

示例4: testUnescapeValue008

import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.unescapeValue(String)'
 * </p>
 * <p>
 * Here we are testing if his method returns a correctly unformatted string for
 * the given attribute value. In this case we are testing with null.
 * </p>
 * <p>
 * The expected result is a NullPointerException.
 * </p>
 */
public void testUnescapeValue008() {
    try {
        Rdn.unescapeValue(null);
        fail("The argument is worng.");
    } catch (NullPointerException e) {

    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:RdnTest.java

示例5: testUnescapeValue010

import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.unescapeValue(String)'
 * </p>
 * <p>
 * Here we are testing if his method returns a correctly unformatted string for
 * the given attribute value. In this case we are testing the special character
 * "#" in the form "#GOFJMOII".
 * </p>
 * <p>
 * The expected result is an exception.
 * </p>
 */
public void testUnescapeValue010() {
    try {
        Rdn.unescapeValue("#GOFJMOII");
        fail("Should raise IllegalArgumentException");
    } catch (IllegalArgumentException e) {}
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:RdnTest.java


注:本文中的javax.naming.ldap.Rdn.unescapeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。