src.test.java.com.eva.properties.DataSourceTest Maven / Gradle / Ivy
/*
* $Id: DataSourceTest.java 9 2007-02-06 18:20:13Z max $
*
* Copyright (c) 2006-2007 Maximilian Antoni. All rights reserved.
*
* This software is licensed as described in the file LICENSE.txt, which you
* should have received as part of this distribution. The terms are also
* available at http://www.maxantoni.de/projects/eva-properties/license.txt.
*/
package com.eva.properties;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import junit.framework.TestCase;
/**
* @author Max Antoni
* @version $Revision: 9 $
*/
public class DataSourceTest extends TestCase {
/**
* Test method for
* {@link com.eva.properties.DataSource#DataSource(java.lang.String)}.
* @throws IOException
*/
public void testDataSourceString() throws IOException {
DataSource ds = new DataSource(
"classpath://com/eva/properties/short.eva");
assertNotNull(ds.getReader());
}
/**
* Test method for {@link com.eva.properties.DataSource#getReader()}.
*
* @throws IOException
*/
public void testGetReader() throws IOException {
Reader reader = new DataSource(
"classpath://com/eva/properties/short.eva").getReader();
assertTrue(reader.ready());
char[] chars = new char[10];
reader.read(chars);
assertEquals("very short", new String(chars));
assertFalse(reader.ready());
}
public void testFailClasspathStream() {
try {
new DataSource("classpath://unavailable-file.eva");
fail("Exception expected!");
}
catch(FileNotFoundException e) {
assertTrue(true);
}
}
}