Java Code Examples for sun.net.idn.StringPrep#prepare()

The following examples show how to use sun.net.idn.StringPrep#prepare() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestStringPrep.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 2
Source File: TestStringPrep.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 3
Source File: TestStringPrep.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 4
Source File: TestStringPrep.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 5
Source File: TestStringPrep.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 6
Source File: TestStringPrep.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 7
Source File: TestStringPrep.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getModule()
                                         .getResourceAsStream("sun/net/idn/uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 8
Source File: TestStringPrep.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 9
Source File: TestStringPrep.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 10
Source File: TestStringPrep.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 11
Source File: TestStringPrep.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 12
Source File: TestStringPrep.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void TestNamePrepConformance() throws Exception {
    InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp");
    StringPrep namePrep = new StringPrep(stream);
    stream.close();
    int i;
    for(i=0; i<TestData.conformanceTestCases.length;i++){
        TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
        try{
            UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input);
            StringBuffer output = namePrep.prepare(iter, testCase.flags);
            if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){
                fail("Did not get the expected output. Expected: " + prettify(testCase.output)+
                        " Got: "+ prettify(output.toString()) );
            }
        } catch(ParseException ex) {
            if (testCase.expected == null) {
                fail("get the unexpected exception for source: " +testCase.input +" Got:  "+ ex.toString());
            }
        }
    }
    System.out.println("Nameprep test count: " + i);
}
 
Example 13
Source File: NFS4StringPrep.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] prepare(byte[] src, StringPrep prep)
            throws ParseException, UnsupportedEncodingException{
    String s = new String(src, "UTF-8");
    UCharacterIterator iter =  UCharacterIterator.getInstance(s);
    StringBuffer out = prep.prepare(iter,StringPrep.DEFAULT);
    return out.toString().getBytes("UTF-8");
}
 
Example 14
Source File: NFS4StringPrep.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] prepare(byte[] src, StringPrep prep)
            throws ParseException, UnsupportedEncodingException{
    String s = new String(src, "UTF-8");
    UCharacterIterator iter =  UCharacterIterator.getInstance(s);
    StringBuffer out = prep.prepare(iter,StringPrep.DEFAULT);
    return out.toString().getBytes("UTF-8");
}
 
Example 15
Source File: NFS4StringPrep.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] prepare(byte[] src, StringPrep prep)
            throws ParseException, UnsupportedEncodingException{
    String s = new String(src, "UTF-8");
    UCharacterIterator iter =  UCharacterIterator.getInstance(s);
    StringBuffer out = prep.prepare(iter,StringPrep.DEFAULT);
    return out.toString().getBytes("UTF-8");
}
 
Example 16
Source File: NFS4StringPrep.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] prepare(byte[] src, StringPrep prep)
            throws ParseException, UnsupportedEncodingException{
    String s = new String(src, "UTF-8");
    UCharacterIterator iter =  UCharacterIterator.getInstance(s);
    StringBuffer out = prep.prepare(iter,StringPrep.DEFAULT);
    return out.toString().getBytes("UTF-8");
}
 
Example 17
Source File: NFS4StringPrep.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] prepare(byte[] src, StringPrep prep)
            throws ParseException, UnsupportedEncodingException{
    String s = new String(src, "UTF-8");
    UCharacterIterator iter =  UCharacterIterator.getInstance(s);
    StringBuffer out = prep.prepare(iter,StringPrep.DEFAULT);
    return out.toString().getBytes("UTF-8");
}
 
Example 18
Source File: NFS4StringPrep.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] prepare(byte[] src, StringPrep prep)
            throws ParseException, UnsupportedEncodingException{
    String s = new String(src, "UTF-8");
    UCharacterIterator iter =  UCharacterIterator.getInstance(s);
    StringBuffer out = prep.prepare(iter,StringPrep.DEFAULT);
    return out.toString().getBytes("UTF-8");
}
 
Example 19
Source File: NFS4StringPrep.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] prepare(byte[] src, StringPrep prep)
            throws ParseException, UnsupportedEncodingException{
    String s = new String(src, "UTF-8");
    UCharacterIterator iter =  UCharacterIterator.getInstance(s);
    StringBuffer out = prep.prepare(iter,StringPrep.DEFAULT);
    return out.toString().getBytes("UTF-8");
}
 
Example 20
Source File: NFS4StringPrep.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] prepare(byte[] src, StringPrep prep)
            throws ParseException, UnsupportedEncodingException{
    String s = new String(src, "UTF-8");
    UCharacterIterator iter =  UCharacterIterator.getInstance(s);
    StringBuffer out = prep.prepare(iter,StringPrep.DEFAULT);
    return out.toString().getBytes("UTF-8");
}