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

📄 valuestacktestcase.java

📁 webwork source
💻 JAVA
字号:
/* * WebWork, Web Application Framework * * Distributable under Apache license. * See terms of license at opensource.org */package webwork.util;import junit.textui.TestRunner;import webwork.action.Action;import webwork.examples.Test;import webwork.TestCaseSupport;/** * @author Maurice C. Parker (maurice@vineyardenterprise.com) */public class ValueStackTestCase extends TestCaseSupport {	ValueStack vs = new ValueStack();	/**	 * @see junit.framework.TestCase#TestCase(java.lang.String)	 */	public ValueStackTestCase(String testName) {		super(testName);	}	/**	 * @see junit.framework.TestCase#setUp()	 */	protected void setUp() throws Exception {		Test testAction = new Test();		try {			assertEquals("action execution failed.", Action.SUCCESS, testAction.execute());		} catch (Exception e) {			fail(e);		}		vs.pushValue(testAction);	}	/**	 * Method testLogicExpressions.	 */	public void testLogicExpressions() {		assertTrue(vs.test("true == true"));		assertTrue(vs.test("'1' == '1'"));		assertTrue(vs.test("(1==1 && 2==2) || (2==2 && 3==2)"));		assertFalse(vs.test("1==2 && 2==2 || (2==2 && 3==2)"));		assertTrue(vs.test("(true && true) || (2==2 && 3==2)"));		assertFalse(vs.test("(1==2 && 2==2)"));		assertFalse(vs.test("(1==2 && 2==2) || (2==2 && 3==2)"));		assertFalse(vs.test("('1'=='2' && 2==2) || (2==2 && 3==2)"));		assertTrue(vs.test("bool('true') == true"));		assertFalse(vs.test("bool('true') == true && bool('false') == true"));		assertTrue(vs.test("settings['foo'] == 'bar'"));		assertTrue(vs.test("bool('false') == true || settings['foo'] == 'bar'"));		assertTrue(vs.test("(bool('false') == true || settings['foo'] == 'bar')"));		assertTrue(vs.test("bool('true') == true && (bool('false') == true || settings['foo'] == 'bar')"));	}  public void testMultiParamMethod() {    assertEquals("abc123", vs.findValue("concat('abc', '123')"));  }	/**	 * Method testValueExpressions.	 */	public void testValueExpressions() {		assertEquals("HelloWorld", vs.findValue("name"));	}  public void testBracketedIfClause() {    Object value = vs.findValue("/stringsEqual(sameString('foo'), 'foo')");    assertEquals("unexpected result from if test", Boolean.TRUE, value);    assertTrue(vs.test("/stringsEqual(sameString('foo'), 'bar')==false"));  }	/**	 * Runs this test case.	 */	public static void main(String[] args) {		TestRunner.run(ValueStackTestCase.class);	}}

⌨️ 快捷键说明

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