Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/misc/Encode/DecodeBuffer.java
38840 views
/*1* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 415955426* @summary Problem with UUDecoder27*28*/2930import sun.misc.*;31import java.io.*;3233public class DecodeBuffer {3435public static void main(String[] args) throws Exception {36String encoded;37// text to encode and decode38String originalText = "Hi There, please encode and decode me";39UUDecoder uuD = new UUDecoder();4041encoded = "begin 644 encoder.buf\r\n" +42"E2&D@5&AE<F4L('!L96%S92!E;F-O9&4@86YD(&1E8V]D92!M90$!\r\n"+43" \r\nend\r\n";44check (uuD, encoded, originalText);4546encoded = "begin 644 encoder.buf\n" +47"E2&D@5&AE<F4L('!L96%S92!E;F-O9&4@86YD(&1E8V]D92!M90$!\n"+48" \nend\n";49check (uuD, encoded, originalText);5051encoded = "begin 644 encoder.buf\r" +52"E2&D@5&AE<F4L('!L96%S92!E;F-O9&4@86YD(&1E8V]D92!M90$!\r"+53" \rend\r";54check (uuD, encoded, originalText);5556// Multi-line Unix text file5758String s1 = "begin 644 f\n"+59"M3W)I9VYL(\"I(:2!4:&5R92P@<&QE87-E(&5N8V]D92!A;F0@9&5C;V1E(&UE\n"+60"M*@IA;F0@;64@06YD($UE(&%N1\"!M92!!;F0@344@04Y$($U%(%I80U8@,3(S\n"+61"-97)T\"E5)3U @45=%\"DUE\n"+62" \nend\n";6364String s2 = "Orignl *Hi There, please encode and decode me*\n"+65"and me And Me anD me And ME AND ME ZXCV 123ert\n"+66"UIOP QWE\n";67check (uuD, s1, s2);6869// Multi-line Windows text file7071s1 = "begin 644 f\n"+72"M2&5L;&\\@22!A;2!A(&UU;'1I;&EN92!F:6QE#0IC<F5A=&5D(&]N(%=I;F1O\r\n"+73"M=W,L('1O('1E<W0@=&AE(%5516YC;V1E<@T*86YD(%551&5C;V1E<B!C;&%S\r\n"+74"$<V5S+G1O\r\n"+ " \r\nend\r\n";75s2="Hello I am a multiline file\r\n"+76"created on Windows, to test the UUEncoder\r\n"+77"and UUDecoder classes.";78check (uuD, s1, s2);79}8081public static void check (UUDecoder uuD, String s, String original) throws Exception {82String decoded;83// do UU stuff84decoded = new String(uuD.decodeBuffer(s));85if (!decoded.equals (original)) {86throw new Exception ("decoded text not same as original");87}88}89}909192