大名鼎鼎的java动态脚本语言。已经通过了sun的认证

源代码在线查看: trycatchtest.groovy

软件大小: 1630 K
上传用户: hjf
关键词: java sun 动态 脚本
下载地址: 免注册下载 普通下载 VIP

相关代码

				class TryCatchTest extends GroovyTestCase {								    def exceptionCalled				    def finallyCalled									    void testTryCatch() {				        try {				            failingMethod()				        }				        catch (AssertionError e) {				            onException(e)				        }				        finally {				            onFinally()				        }				        afterTryCatch()				        assert exceptionCalled , "should have invoked the catch clause"				        assert finallyCalled , "should have invoked the finally clause"				        println("After try/catch")				     }												     void testTryFinally() {				         Boolean touched = false;				         				         try {				         }				         finally {				             touched = true;				         }								         assert touched , "finally not called with empty try"				     }																     void testWorkingMethod() {				         /** @todo causes inconsistent stack height				          assert exceptionCalled == false , "should not invoked the catch clause"				          */				         				         try {					    	 workingMethod()					     }					     catch (AssertionError e) {						     onException(e)					     }					     finally {						     onFinally()					     }					     assert exceptionCalled == false , "should not invoked the catch clause"					     assert finallyCalled , "should have invoked the finally clause"					     println("After try/catch")				    }				    				    void failingMethod() {				        assert false , "Failing on purpose"					}									    void workingMethod() {				        assert true , "Should never fail"				    }				    				    void onException(e) {					    assert e != null					    exceptionCalled = true					}									    void onFinally() {				        finallyCalled = true					}								    void afterTryCatch() {				        assert exceptionCalled , "should have invoked the catch clause"        				        assert finallyCalled , "should have invoked the finally clause"				        println("After try/catch")				    }				    				    protected void setUp() {				        exceptionCalled = false				        finallyCalled = false				    }				}							

相关资源