Package

Source Code of MD5OutputStreamTest

import java.io.ByteArrayOutputStream;
import junit.framework.TestCase;
import dijjer.util.MD5OutputStream;

/*
* Dijjer - A Peer to Peer HTTP Cache
* Copyright (C) 2004,2005 Change.Tv, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
public class MD5OutputStreamTest extends TestCase {

  public void testMain() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    MD5OutputStream mos = new MD5OutputStream(baos);
    byte[] toWrite = ("this is a test of md5sum").getBytes();
    mos.write(toWrite);
    mos.close();
    assertEquals(mos.getMD5Sum(), "3aa729600069942b5d4529e1614749b4");
    byte[] written = baos.toByteArray();
    assertEquals(toWrite.length, written.length);
    for (int x=0; x<toWrite.length; x++) {
      assertEquals(toWrite[x], written[x]);
    }
  }
}
TOP

Related Classes of MD5OutputStreamTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.