1 17 package org.apache.geronimo.system.configuration.condition; 18 19 import org.apache.geronimo.testsupport.TestSupport; 20 21 26 public class OgnlConditionParserTest 27 extends TestSupport 28 { 29 private OgnlConditionParser parser; 30 31 protected void setUp() throws Exception { 32 parser = new OgnlConditionParser(); 33 } 34 35 protected void tearDown() throws Exception { 36 parser = null; 37 } 38 39 public void testTrue() throws Exception { 40 boolean result = parser.evaluate("true"); 41 assertTrue(result); 42 } 43 44 public void testFalse() throws Exception { 45 boolean result = parser.evaluate("false"); 46 assertTrue(!result); 47 } 48 49 public void testJavaIs1_1() throws Exception { 50 assertTrue(!SystemUtils.IS_JAVA_1_1); 54 boolean result = parser.evaluate("!java.is1_1"); 55 assertTrue(result); 56 } 57 58 public void testJavaIs1_5() throws Exception { 59 boolean result = parser.evaluate("java.is1_5 " + (SystemUtils.IS_JAVA_1_5 ? "==" : "!=") + " true"); 60 assertTrue(result); 61 } 62 63 public void testNonBooleanResult() throws Exception { 64 try { 65 parser.evaluate("java"); 66 fail(); 67 } 68 catch (ConditionParserException e) { 69 } 71 } 72 73 public void testBadSyntax() throws Exception { 74 try { 75 parser.evaluate("a b c d e f"); 76 fail(); 77 } 78 catch (ConditionParserException e) { 79 } 81 } 82 83 public void testInvalidVariableRef() throws Exception { 84 try { 85 parser.evaluate("nosuchvar"); 86 fail(); 87 } 88 catch (ConditionParserException e) { 89 } 91 } 92 } 93 | Popular Tags |