01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.test.constraints;
13:
14: import net.sf.oval.constraint.AssertCheck;
15:
16: /**
17: * @author Sebastian Thomschke
18: */
19: public class AssertTest extends AbstractContraintsTest {
20: private void testAssert(final String language, final String expr1,
21: final String expr2) {
22: final AssertCheck check = new AssertCheck();
23: super .testCheck(check);
24:
25: check.setLang(language);
26: assertEquals(check.getLang(), language);
27:
28: check.setExpression(expr1);
29: assertEquals(check.getExpression(), expr1);
30: assertFalse(check.isSatisfied(this , null, null, validator));
31: assertTrue(check.isSatisfied(this , "", null, validator));
32:
33: check.setExpression(expr2);
34: assertEquals(check.getExpression(), expr2);
35: assertFalse(check.isSatisfied(null, null, null, validator));
36: assertTrue(check.isSatisfied(this , null, null, validator));
37: }
38:
39: public void testAssertBeanshell() {
40: testAssert("bsh", "_value!=null", "_this!=null");
41: testAssert("beanshell", "_value!=null", "_this!=null");
42: }
43:
44: public void testAssertGroovy() {
45: testAssert("groovy", "_value!=null", "_this!=null");
46: }
47:
48: public void testAssertJavascript() {
49: testAssert("js", "_value!=null", "_this!=null");
50: testAssert("javascript", "_value!=null", "_this!=null");
51: }
52:
53: public void testAssertMVEL() {
54: testAssert("mvel", "_value!=null", "_this!=null");
55: }
56:
57: public void testAssertOGNL() {
58: testAssert("ognl", "_value!=null", "_this!=null");
59: }
60:
61: public void testAssertRuby() {
62: testAssert("ruby", "_value!=nil", "_this!=nil");
63: }
64: }
|