package eu.dnetlib.miscutils.encoding;


import static org.junit.Assert.*;

import java.io.StringWriter;

import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;

import com.sun.xml.internal.messaging.saaj.util.Base64;

/**
 * This test reproduces bug #502.
 *
 * @author marko
 *
 */
public class Base64Test {

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testEncoding() throws Exception {
		StringWriter buffer = new StringWriter();
		IOUtils.copy(getClass().getResourceAsStream("testSource.xml"), buffer);

		final byte[] barr = Base64.encode(buffer.toString().getBytes());

		boolean foundZero = false;
		for(byte ch : barr)
			if(ch == 0)
				foundZero = true;

		assertTrue("found zero", foundZero);
	}

}
