/*
 * ElementNameEmptyExceptionTest class.
 *
 * Copyright (C) 2007 SATOH Takayuki All Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
package ts.util.resource;

import ts.tester.function.coverage.FunctionTester;
import ts.tester.function.print.*;

/**
 * {@link ts.util.resource.ElementNameEmptyException ElementNameEmptyException}クラスの機能試験クラス。
 *
 * @author  佐藤隆之.
 * @version $Revision: 1.1.1.1 $, $Date: 2010-10-16 00:03:49 $
 */
public class ElementNameEmptyExceptionTest extends FunctionTester
{
  public static void main(String[] args)
  {
    try {
      PrinterGroup group = new PrinterGroup();
      group.addPrinter(new ConsolePrinter());
      group.addPrinter(new HtmlPrinter("SATOH Takayuki"));
      setPrinter(group);

      run(ElementNameEmptyExceptionTest.class, (args.length == 0) ? null : args[0]);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  protected void preTesting()
  {
    MSG("ElementNameEmptyException クラスの機能試験を実行する。");
  }
  

  /* -- test case -- */

  public void constructor_key()
  {
    MSG("キーを引数にとるコンストラクタ。");

    try {
      throw new ElementNameEmptyException("aaa.bbb");
    } catch (ElementNameEmptyException e) {
      TRUE(e instanceof IllegalKeyException);
      EQUAL(e.getKey(), "aaa.bbb");
      NULL(e.getMessage());
      NULL(e.getCause());
    }
  }

  public void constructor_key_1()
  {
    MSG("引数がヌルの場合。");

    try {
      throw new ElementNameEmptyException(null);
    } catch (ElementNameEmptyException e) {
      TRUE(e instanceof IllegalKeyException);
      EQUAL(e.getKey(), "");
      NULL(e.getMessage());
      NULL(e.getCause());
    }
  }

  public void constructor_key_msg()
  {
    MSG("キーとメッセージを引数にとるコンストラクタ。");

    try {
      throw new ElementNameEmptyException("aaa.bbb", "あいうえお");
    } catch (ElementNameEmptyException e) {
      EQUAL(e.getKey(), "aaa.bbb");
      EQUAL(e.getMessage(), "あいうえお");
      NULL(e.getCause());
    }
  }

  public void constructor_key_msg_1()
  {
    MSG("引数がヌルの場合。");

    try {
      throw new ElementNameEmptyException(null, (String) null);
    } catch (ElementNameEmptyException e) {
      EQUAL(e.getKey(), "");
      NULL(e.getMessage());
      NULL(e.getCause());
    }
  }

  public void constructor_key_msg_cause()
  {
    MSG("キーとメッセージと原因を引数にとるコンストラクタ。");

    Exception e0 = new Exception();

    try {
      throw new ElementNameEmptyException("aaa.bbb", "あいうえお", e0);
    } catch (ElementNameEmptyException e) {
      EQUAL(e.getKey(), "aaa.bbb");
      EQUAL(e.getMessage(), "あいうえお");
      EQUAL(e.getCause(), e0);
    }
  }

  public void constructor_key_msg_cause_1()
  {
    MSG("引数がヌルの場合。");

    try {
      throw new ElementNameEmptyException(null, null, null);
    } catch (ElementNameEmptyException e) {
      EQUAL(e.getKey(), "");
      NULL(e.getMessage());
      NULL(e.getCause());
    }
  }

  public void constructor_key_cause()
  {
    MSG("キーと原因を引数にとるコンストラクタ。");

    Exception e0 = new Exception();

    try {
      throw new ElementNameEmptyException("aaa.bbb", e0);
    } catch (ElementNameEmptyException e) {
      EQUAL(e.getKey(), "aaa.bbb");
      EQUAL(e.getMessage(), e0.getClass().getName());
      EQUAL(e.getCause(), e0);
    }
  }

  public void constructor_key_cause_1()
  {
    MSG("引数がヌルの場合。");

    try {
      throw new ElementNameEmptyException(null, (Throwable) null);
    } catch (ElementNameEmptyException e) {
      EQUAL(e.getKey(), "");
      NULL(e.getMessage());
      NULL(e.getCause());
    }
  }
}

