0N/A/*
2362N/A * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 4159554
0N/A * @summary Problem with UUDecoder
0N/A *
0N/A */
0N/A
0N/Aimport sun.misc.*;
0N/Aimport java.io.*;
0N/A
0N/Apublic class DecodeBuffer {
0N/A
0N/A public static void main(String[] args) throws Exception {
0N/A String encoded;
0N/A // text to encode and decode
0N/A String originalText = "Hi There, please encode and decode me";
0N/A UUDecoder uuD = new UUDecoder();
0N/A
0N/A encoded = "begin 644 encoder.buf\r\n" +
0N/A "E2&D@5&AE<F4L('!L96%S92!E;F-O9&4@86YD(&1E8V]D92!M90$!\r\n"+
0N/A " \r\nend\r\n";
0N/A check (uuD, encoded, originalText);
0N/A
0N/A encoded = "begin 644 encoder.buf\n" +
0N/A "E2&D@5&AE<F4L('!L96%S92!E;F-O9&4@86YD(&1E8V]D92!M90$!\n"+
0N/A " \nend\n";
0N/A check (uuD, encoded, originalText);
0N/A
0N/A encoded = "begin 644 encoder.buf\r" +
0N/A "E2&D@5&AE<F4L('!L96%S92!E;F-O9&4@86YD(&1E8V]D92!M90$!\r"+
0N/A " \rend\r";
0N/A check (uuD, encoded, originalText);
0N/A
0N/A // Multi-line Unix text file
0N/A
0N/A String s1 = "begin 644 f\n"+
0N/A "M3W)I9VYL(\"I(:2!4:&5R92P@<&QE87-E(&5N8V]D92!A;F0@9&5C;V1E(&UE\n"+
0N/A "M*@IA;F0@;64@06YD($UE(&%N1\"!M92!!;F0@344@04Y$($U%(%I80U8@,3(S\n"+
0N/A "-97)T\"E5)3U @45=%\"DUE\n"+
0N/A " \nend\n";
0N/A
0N/A String s2 = "Orignl *Hi There, please encode and decode me*\n"+
0N/A "and me And Me anD me And ME AND ME ZXCV 123ert\n"+
0N/A "UIOP QWE\n";
0N/A check (uuD, s1, s2);
0N/A
0N/A // Multi-line Windows text file
0N/A
0N/A s1 = "begin 644 f\n"+
0N/A "M2&5L;&\\@22!A;2!A(&UU;'1I;&EN92!F:6QE#0IC<F5A=&5D(&]N(%=I;F1O\r\n"+
0N/A "M=W,L('1O('1E<W0@=&AE(%5516YC;V1E<@T*86YD(%551&5C;V1E<B!C;&%S\r\n"+
0N/A "$<V5S+G1O\r\n"+ " \r\nend\r\n";
0N/A s2="Hello I am a multiline file\r\n"+
0N/A "created on Windows, to test the UUEncoder\r\n"+
0N/A "and UUDecoder classes.";
0N/A check (uuD, s1, s2);
0N/A }
0N/A
0N/A public static void check (UUDecoder uuD, String s, String original) throws Exception {
0N/A String decoded;
0N/A // do UU stuff
0N/A decoded = new String(uuD.decodeBuffer(s));
0N/A if (!decoded.equals (original)) {
0N/A throw new Exception ("decoded text not same as original");
0N/A }
0N/A }
0N/A}