All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.test.java.com.eva.properties.DataSourceTest Maven / Gradle / Ivy

Go to download

Advanced properties with object factories, references and inheritance.

There is a newer version: 0.3
Show newest version
/*
 * $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);
        }
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy