⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asserttests.java

📁 spring的源代码
💻 JAVA
字号:
/*
 * Copyright 2004-2005 the original author or authors.
 */

package org.springframework.util;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

import junit.framework.TestCase;

/**
 * Tests for the Assert class.
 *
 * @author Keith Donald
 * @author Erwin Vervaet
 */
public class AssertTests extends TestCase {

	public void testInstanceOf() {
		Set set = new HashSet();
		Assert.isInstanceOf(HashSet.class, set);
		try {
			Assert.isInstanceOf(HashMap.class, set);
			fail("Should have failed - a hash map is not a set");
		}
		catch (IllegalArgumentException ex) {
			// ok
		}
	}

	public void testIsNull() {
		Assert.isNull(null, "Bla");
		try {
			Assert.isNull(new Object(), "Bla");
			fail("Should have failed - object is not null");
		}
		catch (IllegalArgumentException e) {
			assertEquals("Bla", e.getMessage());
		}

		Assert.isNull(null);
		try {
			Assert.isNull(new Object());
			fail("Should have failed - object is not null");
		}
		catch (IllegalArgumentException ex) {
			// ok
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -