/*
 * LOGICAL-PARADOX.ORG
 * Copyright (C)2005 satoshi akabane(akabane@logical-paradox.org)
 * $Id: DacConfigTest.java,v 1.2 2005/09/07 13:38:07 rampil Exp $
 */
package org.logical_paradox.vsan.dac;

import java.io.FileNotFoundException;
import java.io.IOException;

import org.logical_paradox.vsan.ConfigException;

import junit.framework.TestCase;

/**
 * DacConfigのテストケース
 * @author satoshi akabane@logical-paradox.org
 * @version $Revision: 1.2 $
 */
public class DacConfigTest extends TestCase {

	/**
	 * Constructor for DacConfigTest.
	 * @param arg0
	 */
	public DacConfigTest(String arg0) {
		super(arg0);
	}
	/**
	 * 完全なコンフィグレーションで正しく稼動するかどうかテスト
	 */
	public void testCompleteConfig() throws FileNotFoundException, ConfigException, IOException {
		String[] args = new String[]{"-config=conf\\dac.conf"};

		DacConfig config = new DacConfig(args);
		assertEquals("conf\\dac.conf", config.getConfigFilename());
	}
	/**
	 * 引数指定なしの場合
	 */
	public void testWithoutAnyArgument() throws FileNotFoundException, ConfigException, IOException {
		DacConfig config = new DacConfig(new String[]{});
		assertEquals(DacConfig.DEFAULT_CONFIG_FILENAME, config.getConfigFilename());
	}
	/**
	 * 不正なオプションをつけて起動した場合
	 */
	public void testWithIllegalOption() throws FileNotFoundException, IOException {
		try {
			new DacConfig(new String[]{"-configration=test"});
			fail();
		} catch(ConfigException e) {
			// OK
		}
	}
	/**
	 * 正しい引数と余計なオプションを指定して起動した場合
	 */
	public void testWithCompleteOptionAndIllegalValue() throws FileNotFoundException, IOException {
		try {
			new DacConfig(new String[]{"-config=sample.conf","test","aaa","bbb"});
			fail();
		} catch(ConfigException e) {
			// OK
		}
	}
}
