1 27 28 package org.objectweb.speedo.runtime.query.parser; 29 30 import junit.framework.TestCase; 31 32 import java.io.CharArrayReader ; 33 34 import org.objectweb.util.monolog.api.Logger; 35 import org.objectweb.util.monolog.api.BasicLevel; 36 import org.objectweb.util.monolog.Monolog; 37 import org.objectweb.speedo.query.parser.SpeedoQL; 38 39 43 public class SpeedoQLTest extends TestCase { 44 final static String filters[] = { 45 "toto.titi", 46 "toto.titi()", 47 "this.toto", 48 "this.titi()", 49 "(+78)", 50 "(-89458.457)", 51 "(~788)", 52 "((~abc)|| tyty)", 53 "(!rere && toto+7)", 54 "((boolean)john)", 55 "(a < b > c <= d >= e | f || g & h && i == j != k + l - m / n * o ^ p.jotp())", 56 "((byte)b && (short)s || (int)i <= (long)l == (char)c * (float)f / (double)d == (true) && (false | null))", 57 "null", 58 "((char)(byte)(short)b || (char)(java.lang.String)s)", 59 "my.toto((q<b) + 9)", 60 "(house.b())", 61 "((((g)a < b.g())))", 62 "(+4 < t)", 63 "((-4+9*8) == toto.titi.titi.ktkt(one))", 64 "((a < b.house()) || (c.name > ((d*4)/100)))", 65 "toto(tutu).titi(tata)", 66 "toto(titi)", 67 "((1 < 5 > 3) || (4 && 5 <= (934 == 4)))", 68 "(((1 < 5) > 3) || ((4 && 5) <= (934 == 4)))", 69 "(true == a)", 70 "true == a", 71 "(a+b).method()", 72 "(salary > 3000)", 73 "(salary > sal)", 74 "(dept.name == dep)", 75 "(emps.contains(emp) & emp.salary > sal)", 76 "(depts.contains(name))", 77 "((getEmpId () >= 1) && (getEmpId () <= 10))", 78 "a == \"Paul\"", 79 "a >= 1 && b <= 10", 80 "x == param", 81 "x == 4", 82 "x == param1 && y == param2", 83 "reviewers.contains(person) && person == Employee", 84 "reviewers.contains(person) && person == person" 85 }; 87 88 private final static String LOGGER_NAME 89 = "org.objectweb.speedo.rt.query.parser.speedoql"; 90 91 private static Logger logger = null; 92 93 static { 94 logger = Monolog.initialize().getLogger(LOGGER_NAME); 95 } 96 97 98 public SpeedoQLTest(String name) { 99 super(name); 100 } 101 102 public void testAll() { 103 logger.log(BasicLevel.DEBUG, "SpeedoQL Test - javacc grammar"); 104 for (int i = 0; i < filters.length; i++) { 105 String filter = filters[i]; 106 logger.log(BasicLevel.DEBUG, "Testing: " + filter); 107 try { 108 filter = '(' + filter + ')'; 109 new SpeedoQL(new CharArrayReader (filter.toCharArray())).SpeedoQL(); 110 } catch (Throwable e) { 111 logger.log(BasicLevel.ERROR, "Parsing of: " + filter, e); 112 fail("Parsing of: " + filter); 113 } 114 115 } 116 } 117 } 118 | Popular Tags |