@@ -0,0 +1,2454 @@
+/**%0D%0A * Copyright (c) 2008-2010, http://code.google.com/p/snakeyaml/%0D%0A *%0D%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0D%0A * you may not use this file except in compliance with the License.%0D%0A * You may obtain a copy of the License at%0D%0A *%0D%0A *     http://www.apache.org/licenses/LICENSE-2.0%0D%0A *%0D%0A * Unless required by applicable law or agreed to in writing, software%0D%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0D%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0D%0A * See the License for the specific language governing permissions and%0D%0A * limitations under the License.%0D%0A */%0D%0A%0D%0Apackage biz.source_code.base64Coder;%0D%0A%0D%0Aimport java.io.UnsupportedEncodingException;%0D%0A%0D%0Aimport junit.framework.TestCase;%0D%0A%0D%0Apublic class Base64CoderTest extends TestCase %7B%0D%0A%0D%0A    public void testDecode() throws UnsupportedEncodingException %7B%0D%0A        check(%22Aladdin:open sesame%22, %22QWxhZGRpbjpvcGVuIHNlc2FtZQ==%22);%0D%0A        check(%22a%22, %22YQ==%22);%0D%0A        check(%22aa%22, %22YWE=%22);%0D%0A        check(%22a=%22, %22YT0=%22);%0D%0A        check(%22%22, %22%22);%0D%0A    %7D%0D%0A%0D%0A    public void testFailure1() throws UnsupportedEncodingException %7B%0D%0A        try %7B%0D%0A            Base64Coder.decode(%22YQ=%22.toCharArray());%0D%0A            fail();%0D%0A        %7D catch (Exception e) %7B%0D%0A            assertEquals(%22Length of Base64 encoded input string is not a multiple of 4.%22, e%0D%0A                    .getMessage());%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    public void testFailure2() throws UnsupportedEncodingException %7B%0D%0A        checkInvalid(%22%5CtWE=%22);%0D%0A        checkInvalid(%22Y%5CtE=%22);%0D%0A        checkInvalid(%22YW%5Ct=%22);%0D%0A        checkInvalid(%22YWE%5Ct%22);%0D%0A        //%0D%0A        checkInvalid(%22%C2%A9WE=%22);%0D%0A        checkInvalid(%22Y%C2%A9E=%22);%0D%0A        checkInvalid(%22YW%C2%A9=%22);%0D%0A        checkInvalid(%22YWE%C2%A9%22);%0D%0A    %7D%0D%0A%0D%0A    private void checkInvalid(String encoded) %7B%0D%0A        try %7B%0D%0A            Base64Coder.decode(encoded.toCharArray());%0D%0A            fail(%22Illegal chanracter.%22);%0D%0A        %7D catch (Exception e) %7B%0D%0A            assertEquals(%22Illegal character in Base64 encoded data.%22, e.getMessage());%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    private void check(String text, String encoded) throws UnsupportedEncodingException %7B%0D%0A        char%5B%5D s1 = Base64Coder.encode(text.getBytes(%22UTF-8%22));%0D%0A        String t1 = new String(s1);%0D%0A        assertEquals(encoded, t1);%0D%0A        byte%5B%5D s2 = Base64Coder.decode(encoded.toCharArray());%0D%0A        String t2 = new String(s2, %22UTF-8%22);%0D%0A        assertEquals(text, t2);%0D%0A    %7D%0D%0A%7D%0D%0A

Improve coverage of Base64Coder