teststacktrace.java
来自「一个关于java 的常用工具包」· Java 代码 · 共 57 行
JAVA
57 行
package org.jutiltest.java.throwable;import org.jutil.junit.JutilTest;import org.jutil.java.throwable.StackTrace;import org.jutil.junit.CVSRevision;import org.jutil.java.collections.Visitor;import junit.framework.*;import java.util.List;import java.util.Vector;/** * @path $Source: /cvsroot/org-jutil/jutil.org/src/org/jutiltest/java/throwable/TestStackTrace.java,v $ * @date $Date: 2002/07/20 19:11:33 $ * @state $State: Exp $ * @author Marko van Dooren * @release $Name: $ */public class TestStackTrace extends JutilTest { public TestStackTrace(String name) { super(name, new CVSRevision("1.6")); } public void setUp() { } public void testStrackTrace() { try { throw new IllegalArgumentException(); } catch(Exception exc) { List myList = StackTrace.asList(exc); Vector vector = new Vector(myList); // first method is main(). assertTrue(((String)vector.elementAt(0)).indexOf("main") != -1); // the method throwing the exception is testStrackTrace(). assertTrue(((String)vector.elementAt(vector.size() - 1)).indexOf("testStrackTrace") != -1); } }}/*<copyright>Copyright (C) 1997-2001. This software is copyrighted by the people and entities mentioned after the "@author" tags above, on behalf of the JUTIL.ORG Project. The copyright is dated by the dates after the "@date" tags above. All rights reserved.This software is published under the terms of the JUTIL.ORG SoftwareLicense version 1.1 or later, a copy of which has been included withthis distribution in the LICENSE file, which can also be found athttp://org-jutil.sourceforge.net/LICENSE. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the JUTIL.ORG Software License for more details.For more information, please see http://org-jutil.sourceforge.net/</copyright>*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?