[Jiemamy-notify] commit [2138] [CORE-81] ValueCheckUtilTest追加。

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2008年 11月 13日 (木) 01:04:23 JST


Revision: 2138
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=2138
Author:   daisuke_m
Date:     2008-11-13 01:04:23 +0900 (Thu, 13 Nov 2008)

Log Message:
-----------
[CORE-81] ValueCheckUtilTest追加。

Modified Paths:
--------------
    artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/ValueCheckUtil.java

Added Paths:
-----------
    artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/ValueCheckUtilTest.java


-------------- next part --------------
Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/ValueCheckUtil.java
===================================================================
--- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/ValueCheckUtil.java	2008-11-12 15:57:43 UTC (rev 2137)
+++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/ValueCheckUtil.java	2008-11-12 16:04:23 UTC (rev 2138)
@@ -28,8 +28,10 @@
 public final class ValueCheckUtil {
 	
 	/**
-	 * TODO for daisuke
-	 * @param jiemamyModel
+	 * 初期化チェックを行う。
+	 * 
+	 * @param jiemamyModel 検査対象オブジェクト
+	 * @throws NotInitializedException 与えられたモデルが未初期化だった場合
 	 */
 	public static void assertInitialized(JiemamyModel jiemamyModel) {
 		if (jiemamyModel.isInitialized() == false) {
@@ -40,9 +42,8 @@
 	/**
 	 * NULLチェックを行う。
 	 * 
-	 * <p>与えられた値が <code>null</code> だった場合、NullPointerExceptionをスローする。</p>
-	 * 
 	 * @param obj 検査対象オブジェクト
+	 * @throws NullPointerException 与えられた値が <code>null</code> だった場合
 	 */
 	public static void assertNotNull(Object obj) {
 		if (obj == null) {
@@ -50,6 +51,10 @@
 		}
 	}
 	
+	/**
+	 * ユーティリティクラス。
+	 * @category instance creation
+	 */
 	private ValueCheckUtil() {
 	}
 }

Added: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/ValueCheckUtilTest.java
===================================================================
--- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/ValueCheckUtilTest.java	                        (rev 0)
+++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/ValueCheckUtilTest.java	2008-11-12 16:04:23 UTC (rev 2138)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others.
+ * Created on 2008/11/13
+ *
+ * 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.core.utils;
+
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
+import org.jiemamy.core.S2FactoryStrategy;
+import org.jiemamy.creator.JiemamyModelFactory;
+import org.jiemamy.spec.exception.NotInitializedException;
+import org.jiemamy.spec.model.RootModel;
+
+/**
+ * TODO for daisuke
+ * @author daisuke
+ */
+public class ValueCheckUtilTest {
+	
+	/**
+	 * nullチェックが行われる。
+	 * @throws Exception 
+	 */
+	@Test
+	public void test01_nullチェックが行われる() throws Exception {
+		ValueCheckUtil.assertNotNull(new Object());
+		
+		try {
+			ValueCheckUtil.assertNotNull(null);
+			fail();
+		} catch (NullPointerException e) {
+			// success
+		}
+	}
+	
+	/**
+	 * 初期化チェックが行われる。
+	 * @throws Exception 
+	 */
+	@Test
+	public void test02_初期化チェックが行われる() throws Exception {
+		JiemamyModelFactory.init(new S2FactoryStrategy("jiemamy-core.dicon"));
+		RootModel rootModel = JiemamyModelFactory.createRoot();
+		
+		try {
+			ValueCheckUtil.assertInitialized(rootModel);
+			fail();
+		} catch (NotInitializedException e) {
+			// success
+		}
+		rootModel.init();
+		ValueCheckUtil.assertInitialized(rootModel);
+	}
+}


Property changes on: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/ValueCheckUtilTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain


Jiemamy-notify メーリングリストの案内
Zurück zum Archiv-Index