1 18 package org.objectweb.speedo; 19 20 import org.objectweb.medor.expression.api.Expression; 21 import org.objectweb.medor.expression.lib.BasicOperand; 22 import org.objectweb.medor.expression.lib.BasicVariableOperand; 23 import org.objectweb.medor.expression.lib.ConditionalAnd; 24 import org.objectweb.medor.expression.lib.Equal; 25 import org.objectweb.medor.expression.lib.Greater; 26 import org.objectweb.medor.expression.lib.GreaterEqual; 27 import org.objectweb.medor.expression.lib.Lower; 28 import org.objectweb.medor.expression.lib.LowerEqual; 29 import org.objectweb.medor.expression.lib.NotEqual; 30 import org.objectweb.medor.filter.TestExpressionHelper; 31 import org.objectweb.speedo.api.ExceptionHelper; 32 import org.objectweb.speedo.generation.jorm.rdb.FilterManager; 33 import org.objectweb.util.monolog.Monolog; 34 import org.objectweb.util.monolog.api.BasicLevel; 35 import org.objectweb.util.monolog.api.Logger; 36 37 import junit.framework.TestCase; 38 39 43 public class TestParsingInheritanceFilter extends TestCase { 44 45 private static final String [] filters = { 46 "(col1 == 12)", 47 "(col1 == \"AZERTY\")", 48 "(col1 != 12)", 49 "(col1 > 12)", 50 "(col1 >= 12)", 51 "(col1 < 12)", 52 "(col1 <= 12)", 53 "((col1 <= 12) && (col1 >= 3))", 54 "((col1 <= 12) && (col1 >= 3) && (col2 == 3)) ", 55 }; 56 57 private static final Expression[] expressions = { 58 new Equal(new BasicVariableOperand("col1"), new BasicOperand(12)), 59 new Equal(new BasicVariableOperand("col1"), new BasicOperand("AZERTY")), 60 new NotEqual(new BasicVariableOperand("col1"), new BasicOperand(12)), 61 new Greater(new BasicVariableOperand("col1"), new BasicOperand(12)), 62 new GreaterEqual(new BasicVariableOperand("col1"), new BasicOperand(12)), 63 new Lower(new BasicVariableOperand("col1"), new BasicOperand(12)), 64 new LowerEqual(new BasicVariableOperand("col1"), new BasicOperand(12)), 65 new ConditionalAnd( 66 new LowerEqual(new BasicVariableOperand("col1"), new BasicOperand(12)), 67 new GreaterEqual(new BasicVariableOperand("col1"), new BasicOperand(3))), 68 new ConditionalAnd( 69 new LowerEqual(new BasicVariableOperand("col1"), new BasicOperand(12)), 70 new ConditionalAnd( 71 new GreaterEqual(new BasicVariableOperand("col1"), new BasicOperand(3)), 72 new Equal(new BasicVariableOperand("col2"), new BasicOperand(3)))) 73 }; 74 75 private static Logger logger = null; 76 77 78 public TestParsingInheritanceFilter(String s) { 79 super(s); 80 if (logger == null) { 81 logger = Monolog.initialize().getLogger(getClass().getName()); 82 } 83 } 84 85 public void testA() { 86 FilterManager parser = new FilterManager(logger); 87 for(int i=0; i<filters.length; i++) { 88 logger.log(BasicLevel.DEBUG, "Parsing of filter: " + filters[i]); 89 try { 90 Expression exp = parser.getParser().parse(filters[i]); 91 TestExpressionHelper.equals("", expressions[i], exp, logger); 92 } catch (Error e) { 93 fail(e.getMessage()); 94 } catch (Exception e) { 95 Exception ie = ExceptionHelper.getNested(e); 96 logger.log(BasicLevel.ERROR, "Error during the parsing of filter: " + filters[i], ie); 97 fail(e.getMessage()); 98 } 99 } 100 } 101 } 102 | Popular Tags |