svnno****@sourc*****
svnno****@sourc*****
2009年 9月 19日 (土) 03:36:21 JST
Revision: 3614 http://sourceforge.jp/projects/jiemamy/svn/view?view=rev&revision=3614 Author: daisuke_m Date: 2009-09-19 03:36:21 +0900 (Sat, 19 Sep 2009) Log Message: ----------- 実験クラス削除。 Removed Paths: ------------- hercules/trunk/jiemamy-integration-test/src/test/java/org/jiemamy/sandbox/daisuke/Factory.java hercules/trunk/jiemamy-integration-test/src/test/java/org/jiemamy/sandbox/daisuke/FactoryTest.java Deleted: hercules/trunk/jiemamy-integration-test/src/test/java/org/jiemamy/sandbox/daisuke/Factory.java =================================================================== --- hercules/trunk/jiemamy-integration-test/src/test/java/org/jiemamy/sandbox/daisuke/Factory.java 2009-09-18 17:37:11 UTC (rev 3613) +++ hercules/trunk/jiemamy-integration-test/src/test/java/org/jiemamy/sandbox/daisuke/Factory.java 2009-09-18 18:36:21 UTC (rev 3614) @@ -1,61 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/16 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.sandbox.daisuke; - -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; - -/** - * 問題のファクトリ。 - * - * テストを壊さず、コンパイラ警告を解消して実装してください。 - * - * @author daisuke - */ -public class Factory { - - private Map<Class<?>, Comparator<?>> map = new HashMap<Class<?>, Comparator<?>>(); - - - /** - * 指定した型のコンパレータを取得する。 - * - * <p>登録されていない場合は{@code null}を返す。</p> - * - * @param <T> キーとなるクラスの型 - * @param clazz キーとなるクラス - * @return コンパレータ - */ - public <T>Comparator<T> getComparator(Class<T> clazz) { - return (Comparator<T>) map.get(clazz); // コンパイラ警告 - // Type safety: Unchecked cast from Comparator<capture#1-of ?> to Comparator<T> - } - - /** - * 指定した型に対応するコンパレータを登録する。 - * - * @param <T> 比較するクラスの型 - * @param clazz 比較するクラス - * @param comparator コンパレータ - */ - public <T>void put(Class<T> clazz, Comparator<T> comparator) { - map.put(clazz, comparator); - } -} Deleted: hercules/trunk/jiemamy-integration-test/src/test/java/org/jiemamy/sandbox/daisuke/FactoryTest.java =================================================================== --- hercules/trunk/jiemamy-integration-test/src/test/java/org/jiemamy/sandbox/daisuke/FactoryTest.java 2009-09-18 17:37:11 UTC (rev 3613) +++ hercules/trunk/jiemamy-integration-test/src/test/java/org/jiemamy/sandbox/daisuke/FactoryTest.java 2009-09-18 18:36:21 UTC (rev 3614) @@ -1,95 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/09/16 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.sandbox.daisuke; - -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - -import java.util.Comparator; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * {@link Factory}のテストクラス。 - * - * @author daisuke - */ -public class FactoryTest { - - static final Comparator<String> COMPARATOR = new StringComparator(); - - private Factory factory; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - factory = new Factory(); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - factory = null; - } - - /** - * 登録されていない型を指定すると{@code null}が返る。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test1() throws Exception { - assertThat(factory.getComparator(String.class), is(nullValue())); - assertThat(factory.getComparator(Number.class), is(nullValue())); - } - - /** - * 登録した型を指定すると、登録したコンパレータが返る。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test2() throws Exception { - factory.put(String.class, COMPARATOR); - - assertThat(factory.getComparator(String.class), is(COMPARATOR)); - assertThat(factory.getComparator(Number.class), is(nullValue())); - } - - - static class StringComparator implements Comparator<String> { - - public int compare(String o1, String o2) { - return 0; - } - - } -}