码迷,mamicode.com
首页 > 其他好文 > 详细

assert.notNull

时间:2017-06-05 10:22:42      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:pre   测试   void   nbsp   spring   throw   sql   sage   stat   

今天我做JUnit关于MySQL测试时发现,类似于assertNull(tu)之类的代码不知道什么意思,因此稍微总结如下。

org.springframework.util.Assert
Assert翻译为中文为"断言".
大概来说,就是断定某一个实际的值就为自己预期想得到的,如果不一样就抛出异常.

 

spring源码如下:

/**
* Assert that an object is not <code>null</code> .
* <pre class="code">Assert.notNull(clazz, "The class must not be null");</pre>
* @param object the object to check
* @param message the exception message to use if the assertion fails
* @throws IllegalArgumentException if the object is <code>null</code>
*/
public static void notNull(Object object, String message) {
if (object == null) {
throw new IllegalArgumentException(message);
}
}

该函数的意思是传入的object必须不能为空。如果为空就抛出异常。

assert.notNull

标签:pre   测试   void   nbsp   spring   throw   sql   sage   stat   

原文地址:http://www.cnblogs.com/qzsoul/p/6943141.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!