亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? quotedprintablecodectest.java

?? 一個(gè)很實(shí)用的東東
?? JAVA
字號(hào):
/*
 * Copyright 2001-2004 The Apache Software Foundation.
 * 
 * Licensed 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.
 */ 

package org.apache.commons.codec.net;

import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.EncoderException;

import junit.framework.TestCase;

/**
 * Quoted-printable codec test cases
 * 
 * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
 */
public class QuotedPrintableCodecTest extends TestCase {
    
    static final int SWISS_GERMAN_STUFF_UNICODE [] = {
        0x47, 0x72, 0xFC, 0x65, 0x7A, 0x69, 0x5F, 0x7A, 0xE4, 0x6D, 0xE4
    };
    
    static final int RUSSIAN_STUFF_UNICODE [] = {
        0x412, 0x441, 0x435, 0x43C, 0x5F, 0x43F, 0x440, 0x438, 
        0x432, 0x435, 0x442 
    }; 

    public QuotedPrintableCodecTest(String name) {
        super(name);
    }

    private String constructString(int [] unicodeChars) {
        StringBuffer buffer = new StringBuffer();
        if (unicodeChars != null) {
            for (int i = 0; i < unicodeChars.length; i++) {
                buffer.append((char)unicodeChars[i]); 
            }
        }
        return buffer.toString();
    }

    public void testUTF8RoundTrip() throws Exception {

        String ru_msg = constructString(RUSSIAN_STUFF_UNICODE); 
        String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE); 
        
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        
        assertEquals(
            "=D0=92=D1=81=D0=B5=D0=BC_=D0=BF=D1=80=D0=B8=D0=B2=D0=B5=D1=82", 
        qpcodec.encode(ru_msg, "UTF-8")
        );
        assertEquals("Gr=C3=BCezi_z=C3=A4m=C3=A4", qpcodec.encode(ch_msg, "UTF-8"));
        
        assertEquals(ru_msg, qpcodec.decode(qpcodec.encode(ru_msg, "UTF-8"), "UTF-8"));
        assertEquals(ch_msg, qpcodec.decode(qpcodec.encode(ch_msg, "UTF-8"), "UTF-8"));
    }

    public void testBasicEncodeDecode() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        String plain = "= Hello there =\r\n";
        String encoded = qpcodec.encode(plain);
        assertEquals("Basic quoted-printable encoding test", 
            "=3D Hello there =3D=0D=0A", encoded);
        assertEquals("Basic quoted-printable decoding test", 
            plain, qpcodec.decode(encoded));
    }

    public void testSafeCharEncodeDecode() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        String plain = "abc123_-.*~!@#$%^&()+{}\"\\;:`,/[]";
        String encoded = qpcodec.encode(plain);
        assertEquals("Safe chars quoted-printable encoding test", 
            plain, encoded);
        assertEquals("Safe chars quoted-printable decoding test", 
            plain, qpcodec.decode(encoded));
    }


    public void testUnsafeEncodeDecode() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        String plain = "=\r\n";
        String encoded = qpcodec.encode(plain);
        assertEquals("Unsafe chars quoted-printable encoding test", 
            "=3D=0D=0A", encoded);
        assertEquals("Unsafe chars quoted-printable decoding test", 
            plain, qpcodec.decode(encoded));
    }

    public void testEncodeDecodeNull() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        assertNull("Null string quoted-printable encoding test", 
            qpcodec.encode((String)null));
        assertNull("Null string quoted-printable decoding test", 
            qpcodec.decode((String)null));
    }


    public void testDecodeInvalid() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        try {
            qpcodec.decode("=");
            fail("DecoderException should have been thrown");
        } catch(DecoderException e) {
            // Expected. Move on
        }
        try {
            qpcodec.decode("=A");
            fail("DecoderException should have been thrown");
        } catch(DecoderException e) {
            // Expected. Move on
        }
        try {
            qpcodec.decode("=WW");
            fail("DecoderException should have been thrown");
        } catch(DecoderException e) {
            // Expected. Move on
        }
    }

    public void testEncodeNull() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        byte[] plain = null;
        byte[] encoded = qpcodec.encode(plain);
        assertEquals("Encoding a null string should return null", 
            null, encoded);
    }
    
    public void testEncodeUrlWithNullBitSet() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        String plain = "1+1 = 2";
        String encoded = new String(QuotedPrintableCodec.
            encodeQuotedPrintable(null, plain.getBytes()));
        assertEquals("Basic quoted-printable encoding test", 
            "1+1 =3D 2", encoded);
        assertEquals("Basic quoted-printable decoding test", 
            plain, qpcodec.decode(encoded));
        
    }

    public void testDecodeWithNullArray() throws Exception {
        byte[] plain = null;
        byte[] result = QuotedPrintableCodec.decodeQuotedPrintable( plain );
        assertEquals("Result should be null", null, result);
    }

    public void testEncodeStringWithNull() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        String test = null;
        String result = qpcodec.encode( test, "charset" );
        assertEquals("Result should be null", null, result);
    }

    public void testDecodeStringWithNull() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        String test = null;
        String result = qpcodec.decode( test, "charset" );
        assertEquals("Result should be null", null, result);
    }
    
    public void testEncodeObjects() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        String plain = "1+1 = 2";
        String encoded = (String) qpcodec.encode((Object) plain);
        assertEquals("Basic quoted-printable encoding test", 
            "1+1 =3D 2", encoded);

        byte[] plainBA = plain.getBytes();
        byte[] encodedBA = (byte[]) qpcodec.encode((Object) plainBA);
        encoded = new String(encodedBA);
        assertEquals("Basic quoted-printable encoding test", 
            "1+1 =3D 2", encoded);
            
        Object result = qpcodec.encode((Object) null);
        assertEquals( "Encoding a null Object should return null", null, result);
        
        try {
            Object dObj = new Double(3.0);
            qpcodec.encode( dObj );
            fail( "Trying to url encode a Double object should cause an exception.");
        } catch( EncoderException ee ) {
            // Exception expected, test segment passes.
        }
    }
    
    public void testInvalidEncoding() {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec("NONSENSE");
           String plain = "Hello there!";
            try {
               qpcodec.encode(plain);
                fail( "We set the encoding to a bogus NONSENSE vlaue, this shouldn't have worked.");
            } catch( EncoderException ee ) {
                // Exception expected, test segment passes.
            }
            try {
               qpcodec.decode(plain);
                fail( "We set the encoding to a bogus NONSENSE vlaue, this shouldn't have worked.");
            } catch( DecoderException ee ) {
                // Exception expected, test segment passes.
            }
    }

    public void testDecodeObjects() throws Exception {
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
        String plain = "1+1 =3D 2";
        String decoded = (String) qpcodec.decode((Object) plain);
        assertEquals("Basic quoted-printable decoding test", 
            "1+1 = 2", decoded);

        byte[] plainBA = plain.getBytes();
        byte[] decodedBA = (byte[]) qpcodec.decode((Object) plainBA);
        decoded = new String(decodedBA);
        assertEquals("Basic quoted-printable decoding test", 
            "1+1 = 2", decoded);
            
        Object result = qpcodec.decode((Object) null);
        assertEquals( "Decoding a null Object should return null", null, result);
        
        try {
            Object dObj = new Double(3.0);
            qpcodec.decode( dObj );
            fail( "Trying to url encode a Double object should cause an exception.");
        } catch( DecoderException ee ) {
            // Exception expected, test segment passes.
        }
    }

    public void testDefaultEncoding() throws Exception {
        String plain = "Hello there!";
        QuotedPrintableCodec qpcodec = new QuotedPrintableCodec("UnicodeBig");
        qpcodec.encode(plain); // To work around a weird quirk in Java 1.2.2
        String encoded1 = qpcodec.encode(plain, "UnicodeBig");
        String encoded2 = qpcodec.encode(plain);
        assertEquals(encoded1, encoded2);
    }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人在线网站| 一区二区三区.www| 亚洲最新视频在线播放| 午夜精品福利一区二区蜜股av| 精品在线播放免费| 99在线热播精品免费| 欧美狂野另类xxxxoooo| 久久婷婷久久一区二区三区| 亚洲色图在线播放| 精品一区二区日韩| 97精品国产97久久久久久久久久久久| 91超碰这里只有精品国产| 久久精品综合网| 亚洲国产精品久久艾草纯爱| 国产精品乡下勾搭老头1| 日本久久一区二区| 久久久欧美精品sm网站| 亚洲高清中文字幕| 不卡av电影在线播放| 欧美美女黄视频| 中文字幕一区在线观看| 美女任你摸久久| 欧美综合天天夜夜久久| 国产午夜精品美女毛片视频| 午夜精品在线看| 91性感美女视频| 2017欧美狠狠色| 亚洲电影一级黄| youjizz国产精品| 精品粉嫩超白一线天av| 亚洲大型综合色站| 91网站最新地址| 国产亚洲精品超碰| 免费国产亚洲视频| 欧美日韩一区高清| 亚洲青青青在线视频| 粉嫩aⅴ一区二区三区四区五区| 欧美一卡二卡三卡| 亚洲一区二区三区视频在线播放| av成人免费在线观看| 久久影院午夜论| 麻豆成人久久精品二区三区红 | 一区二区视频免费在线观看| 国产成人高清在线| www一区二区| 免费国产亚洲视频| 91精品欧美综合在线观看最新| 亚洲综合色噜噜狠狠| 成人动漫一区二区| 亚洲国产精品黑人久久久| 久久99精品久久久久久| 欧美电影影音先锋| 午夜精品福利在线| 欧美色图第一页| 亚洲图片欧美一区| 在线观看中文字幕不卡| 亚洲欧美日韩精品久久久久| www.色综合.com| 国产精品卡一卡二| 99精品国产99久久久久久白柏| 国产精品国产自产拍高清av | 亚洲免费在线视频| 99精品视频在线观看| 中文字幕日韩一区| 99久久国产免费看| 国产精品久久久久影院| 北岛玲一区二区三区四区| 国产精品女主播av| 不卡的av电影| 亚洲欧美日韩国产一区二区三区| 北条麻妃国产九九精品视频| 亚洲天堂a在线| 色丁香久综合在线久综合在线观看| 综合av第一页| 成人免费观看男女羞羞视频| 亚洲欧洲一区二区三区| 91麻豆免费视频| 一卡二卡三卡日韩欧美| 欧美日韩一区国产| 麻豆成人免费电影| 久久久噜噜噜久久人人看 | 亚洲六月丁香色婷婷综合久久| 91在线观看一区二区| 一区二区在线看| 欧美三级日韩在线| 蜜芽一区二区三区| 久久免费午夜影院| av成人老司机| 亚洲成人自拍一区| 欧美成人一区二区| 丰满白嫩尤物一区二区| 亚洲日本在线天堂| 3atv一区二区三区| 国产一区二区三区四| 最好看的中文字幕久久| 欧美日韩中文字幕一区| 麻豆国产91在线播放| 国产精品免费视频网站| 色狠狠色狠狠综合| 久久成人免费网站| 中文字幕一区在线观看| 欧美精品日韩精品| 国产麻豆成人精品| 亚洲精品成人a在线观看| 欧美一区二区高清| www.亚洲色图.com| 天天色综合天天| 久久嫩草精品久久久久| 日本韩国欧美国产| 麻豆久久一区二区| 亚洲欧洲日韩综合一区二区| 欧美日韩一卡二卡| 国产成人自拍网| 亚洲不卡av一区二区三区| 欧美精品一区二区在线播放 | 午夜影院久久久| 国产视频一区在线观看| 欧美日韩三级一区| 国产乱妇无码大片在线观看| 一区二区在线免费| 久久久久久久久伊人| 欧美日韩美女一区二区| 国产精品一区二区在线观看不卡| 亚洲影视在线观看| 久久精品亚洲乱码伦伦中文| 欧美日韩高清一区二区三区| 粉嫩高潮美女一区二区三区| 婷婷久久综合九色综合绿巨人| 国产视频在线观看一区二区三区 | 久久99久久99精品免视看婷婷| 一区免费观看视频| 精品国产一区二区三区久久影院 | 日韩和欧美一区二区| 国产精品日韩成人| 欧美大度的电影原声| 一本色道久久综合亚洲aⅴ蜜桃 | 亚洲欧美国产三级| 精品福利视频一区二区三区| 欧美三级韩国三级日本一级| 国产99久久久久久免费看农村| 午夜激情一区二区| 亚洲久草在线视频| 国产三级欧美三级日产三级99| 91精品综合久久久久久| 91麻豆国产福利精品| 午夜精品久久久久久不卡8050| 91精品国产综合久久久久久漫画| 成人激情视频网站| 韩国三级电影一区二区| 日韩主播视频在线| 一区二区三区四区蜜桃| 国产精品伦一区| 久久综合99re88久久爱| 91精品国产高清一区二区三区 | av电影在线不卡| 极品美女销魂一区二区三区| 五月婷婷另类国产| 亚洲一卡二卡三卡四卡无卡久久 | 欧美色图12p| 色综合咪咪久久| 99久久精品国产精品久久| 国产91对白在线观看九色| 黑人巨大精品欧美黑白配亚洲| 日韩成人dvd| 视频一区视频二区在线观看| 亚洲无人区一区| 亚洲午夜久久久久久久久电影网| 亚洲人成网站精品片在线观看| 国产精品成人一区二区三区夜夜夜| 国产日产欧美一区二区视频| 久久久久国产精品麻豆| 久久无码av三级| 久久综合九色综合久久久精品综合| 日韩欧美的一区二区| 日韩精品中文字幕在线不卡尤物 | 国产精品一二三在| 国产乱对白刺激视频不卡| 国产一区二区视频在线播放| 激情五月激情综合网| 国产又粗又猛又爽又黄91精品| 国产精品一区二区久激情瑜伽| 国产一区在线不卡| 成人夜色视频网站在线观看| 成人av影院在线| 91香蕉视频mp4| 欧美亚洲国产一区二区三区va| 在线日韩av片| 欧美片网站yy| 日韩一区二区视频| 久久久久久**毛片大全| 国产欧美日韩精品一区| 中文字幕一区二区三区蜜月| 亚洲另类中文字| 性欧美大战久久久久久久久| 日韩电影一二三区| 狠狠色丁香婷综合久久| 成人一二三区视频| 在线一区二区三区| 欧美一区在线视频| 久久精品亚洲一区二区三区浴池|