// Path: src/test/java/com/linuxense/javadbf/mocks/NullOutputStream.java
// public class NullOutputStream extends OutputStream {
//     
// 	private long count = 0;
// 	
// 
//     /**
//      * Constructor
//      */
//     public NullOutputStream() {
//         super();
//     }
//     /**
//      * Does nothing - output to <code>/dev/null</code>.
//      * @param b The bytes to write
//      * @param off The start offset
//      * @param len The number of bytes to write
//      */
//     @Override
//     public void write(byte[] b, int off, int len) {
//         this.count+= len;
//     }
// 
//     /**
//      * Does nothing - output to <code>/dev/null</code>.
//      * @param b The byte to write
//      */
//     @Override
//     public void write(int b) {
//         this.count++;
//     }
// 
//     /**
//      * Does nothing - output to <code>/dev/null</code>.
//      * @param b The bytes to write
//      * @throws IOException never
//      */
//     @Override
//     public void write(byte[] b) throws IOException {
//         if (b != null) {
//         	this.count += b.length;
//         }
//     }
//     
//     public long getCount() {
//     	return this.count;
//     }
// 
// }


import org.junit.Assert;
import org.junit.Test;
import com.linuxense.javadbf.mocks.NullOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
			ByteArrayInputStream bais = new ByteArrayInputStream(data);
			
			List<String> names = new ArrayList<String>();
			reader = new DBFReader(bais);
			reader.setCharset(StandardCharsets.UTF_8);
			Object[] rowObject;
			while ((rowObject = reader.nextRecord()) != null) {
				names.add((String) rowObject[0]);
			}
			assertNotNull(names.get(0));
			assertEquals("Simón", names.get(0).trim());
			
			assertNotNull(names.get(1));
			assertEquals("Julián", names.get(1).trim());
		}
		finally {
			DBFUtils.close(reader);
			DBFUtils.close(wr);
		}
		
		
	}
	
	@Test
	public void testSetEncoding() throws DBFException {
		DBFWriter writer = null;
		try {
			writer = new DBFWriter(new NullOutputStream());
			writer.setCharset(StandardCharsets.ISO_8859_1);
			Assert.assertEquals(StandardCharsets.ISO_8859_1, writer.getCharset());
// Path: src/test/java/com/linuxense/javadbf/mocks/NullOutputStream.java
// public class NullOutputStream extends OutputStream {
//     
// 	private long count = 0;
// 	
// 
//     /**
//      * Constructor
//      */
//     public NullOutputStream() {
//         super();
//     }
//     /**
//      * Does nothing - output to <code>/dev/null</code>.
//      * @param b The bytes to write
//      * @param off The start offset
//      * @param len The number of bytes to write
//      */
//     @Override
//     public void write(byte[] b, int off, int len) {
//         this.count+= len;
//     }
// 
//     /**
//      * Does nothing - output to <code>/dev/null</code>.
//      * @param b The byte to write
//      */
//     @Override
//     public void write(int b) {
//         this.count++;
//     }
// 
//     /**
//      * Does nothing - output to <code>/dev/null</code>.
//      * @param b The bytes to write
//      * @throws IOException never
//      */
//     @Override
//     public void write(byte[] b) throws IOException {
//         if (b != null) {
//         	this.count += b.length;
//         }
//     }
//     
//     public long getCount() {
//     	return this.count;
//     }
// 
// }


// Path: src/test/java/com/linuxense/javadbf/EncodingTest.java
import org.junit.Assert;
import org.junit.Test;
import com.linuxense.javadbf.mocks.NullOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

			ByteArrayInputStream bais = new ByteArrayInputStream(data);
			
			List<String> names = new ArrayList<String>();
			reader = new DBFReader(bais);
			reader.setCharset(StandardCharsets.UTF_8);
			Object[] rowObject;
			while ((rowObject = reader.nextRecord()) != null) {
				names.add((String) rowObject[0]);
			}
			assertNotNull(names.get(0));
			assertEquals("Simón", names.get(0).trim());
			
			assertNotNull(names.get(1));
			assertEquals("Julián", names.get(1).trim());
		}
		finally {
			DBFUtils.close(reader);
			DBFUtils.close(wr);
		}
		
		
	}
	
	@Test
	public void testSetEncoding() throws DBFException {
		DBFWriter writer = null;
		try {
			writer = new DBFWriter(new NullOutputStream());
			writer.setCharset(StandardCharsets.ISO_8859_1);
			Assert.assertEquals(StandardCharsets.ISO_8859_1, writer.getCharset());
			Assert.assertEquals(StandardCharsets.ISO_8859_1.displayName(), writer.getCharset().displayName());