cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1351617 - in /cxf/trunk/rt: management-web/src/test/java/org/apache/cxf/management/web/logging/ rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/ ...
Date Tue, 19 Jun 2012 09:37:42 GMT
Author: sergeyb
Date: Tue Jun 19 09:37:41 2012
New Revision: 1351617

URL: http://svn.apache.org/viewvc?rev=1351617&view=rev
Log:
[CXF-4389] Moving FiqlParser to its own package

Added:
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
  (with props)
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchParseException.java
      - copied, changed from r1351408, cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/FiqlParseException.java
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
      - copied, changed from r1351408, cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/FiqlParser.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParserTest.java
      - copied, changed from r1351410, cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/FiqlParserTest.java
Removed:
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/FiqlParseException.java
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/FiqlParser.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/FiqlParserTest.java
Modified:
    cxf/trunk/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/ReadOnlyFileStorageTest.java
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/Beanspector.java
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/BeanspectorTest.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPALanguageVisitorTest.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/sql/SQLPrinterVisitorTest.java

Modified: cxf/trunk/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/ReadOnlyFileStorageTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/ReadOnlyFileStorageTest.java?rev=1351617&r1=1351616&r2=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/ReadOnlyFileStorageTest.java
(original)
+++ cxf/trunk/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/ReadOnlyFileStorageTest.java
Tue Jun 19 09:37:41 2012
@@ -24,10 +24,10 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.cxf.jaxrs.ext.search.ConditionType;
-import org.apache.cxf.jaxrs.ext.search.FiqlParser;
 import org.apache.cxf.jaxrs.ext.search.PrimitiveSearchCondition;
 import org.apache.cxf.jaxrs.ext.search.SearchCondition;
 import org.apache.cxf.jaxrs.ext.search.SearchUtils;
+import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 
 import org.junit.After;
 import org.junit.Assert;

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/Beanspector.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/Beanspector.java?rev=1351617&r1=1351616&r2=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/Beanspector.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/Beanspector.java
Tue Jun 19 09:37:41 2012
@@ -30,7 +30,7 @@ import java.util.Set;
 /**
  * Bean introspection utility.
  */
-class Beanspector<T> {
+public class Beanspector<T> {
 
     private Class<T> tclass;
     private T tobj;

Added: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java?rev=1351617&view=auto
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
(added)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
Tue Jun 19 09:37:41 2012
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.ext.search;
+
+public interface SearchConditionParser<T> {
+    SearchCondition<T> parse(String fiqlExpression) throws SearchParseException;
+}

Propchange: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java?rev=1351617&r1=1351616&r2=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
Tue Jun 19 09:37:41 2012
@@ -26,6 +26,7 @@ import java.util.logging.Logger;
 import javax.ws.rs.core.MultivaluedMap;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
@@ -49,13 +50,13 @@ public class SearchContextImpl implement
             throw new IllegalArgumentException(errorMessage);
         }
         
-        FiqlParser<T> parser = getParser(cls);
+        SearchConditionParser<T> parser = getParser(cls);
         
         String expression = getSearchExpression();
         if (expression != null) {
             try {
                 return parser.parse(expression);
-            } catch (FiqlParseException ex) {
+            } catch (SearchParseException ex) {
                 return null;
             }
         } else {

Copied: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchParseException.java
(from r1351408, cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/FiqlParseException.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchParseException.java?p2=cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchParseException.java&p1=cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/FiqlParseException.java&r1=1351408&r2=1351617&rev=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/FiqlParseException.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchParseException.java
Tue Jun 19 09:37:41 2012
@@ -18,23 +18,23 @@
  */
 package org.apache.cxf.jaxrs.ext.search;
 
-public class FiqlParseException extends Exception {
+public class SearchParseException extends Exception {
 
     private static final long serialVersionUID = 1182999957472822704L;
 
-    public FiqlParseException() {
+    public SearchParseException() {
         super();
     }
 
-    public FiqlParseException(String arg0, Throwable arg1) {
+    public SearchParseException(String arg0, Throwable arg1) {
         super(arg0, arg1);
     }
 
-    public FiqlParseException(String arg0) {
+    public SearchParseException(String arg0) {
         super(arg0);
     }
 
-    public FiqlParseException(Throwable arg0) {
+    public SearchParseException(Throwable arg0) {
         super(arg0);
     }
 

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java?rev=1351617&r1=1351616&r2=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
Tue Jun 19 09:37:41 2012
@@ -25,8 +25,8 @@ import java.util.Map;
 
 import javax.xml.datatype.Duration;
 
-import org.apache.cxf.jaxrs.ext.search.FiqlParser;
 import org.apache.cxf.jaxrs.ext.search.SearchUtils;
+import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 
 /**
  * Builds a FIQL search condition.

Copied: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
(from r1351408, cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/FiqlParser.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java?p2=cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java&p1=cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/FiqlParser.java&r1=1351408&r2=1351617&rev=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/FiqlParser.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
Tue Jun 19 09:37:41 2012
@@ -16,8 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.jaxrs.ext.search;
-
+package org.apache.cxf.jaxrs.ext.search.fiql;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.util.ArrayList;
@@ -33,8 +32,19 @@ import java.util.regex.Pattern;
 import javax.xml.datatype.DatatypeConfigurationException;
 import javax.xml.datatype.DatatypeFactory;
 
+import org.apache.cxf.jaxrs.ext.search.AndSearchCondition;
+import org.apache.cxf.jaxrs.ext.search.Beanspector;
+import org.apache.cxf.jaxrs.ext.search.ConditionType;
+import org.apache.cxf.jaxrs.ext.search.OrSearchCondition;
+import org.apache.cxf.jaxrs.ext.search.SearchBean;
+import org.apache.cxf.jaxrs.ext.search.SearchCondition;
+import org.apache.cxf.jaxrs.ext.search.SearchConditionParser;
+import org.apache.cxf.jaxrs.ext.search.SearchParseException;
+import org.apache.cxf.jaxrs.ext.search.SearchUtils;
+import org.apache.cxf.jaxrs.ext.search.SimpleSearchCondition;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 
+
 /**
  * Parses <a href="http://tools.ietf.org/html/draft-nottingham-atompub-fiql-00">FIQL</a>
expression to
  * construct {@link SearchCondition} structure. Since this class operates on Java type T,
not on XML
@@ -43,7 +53,7 @@ import org.apache.cxf.jaxrs.utils.Inject
  * 
  * @param <T> type of search condition.
  */
-public class FiqlParser<T> {
+public class FiqlParser<T> implements SearchConditionParser<T> {
 
     public static final String OR = ",";
     public static final String AND = ";";
@@ -123,15 +133,15 @@ public class FiqlParser<T> {
      * 
      * @param fiqlExpression expression of filter.
      * @return tree of {@link SearchCondition} objects representing runtime search structure.
-     * @throws FiqlParseException when expression does not follow FIQL grammar
+     * @throws SearchParseException when expression does not follow FIQL grammar
      */
-    public SearchCondition<T> parse(String fiqlExpression) throws FiqlParseException
{
+    public SearchCondition<T> parse(String fiqlExpression) throws SearchParseException
{
         ASTNode<T> ast = parseAndsOrsBrackets(fiqlExpression);
         // System.out.println(ast);
         return ast.build();
     }
 
-    private ASTNode<T> parseAndsOrsBrackets(String expr) throws FiqlParseException
{
+    private ASTNode<T> parseAndsOrsBrackets(String expr) throws SearchParseException
{
         List<String> subexpressions = new ArrayList<String>();
         List<String> operators = new ArrayList<String>();
         int level = 0;
@@ -144,7 +154,7 @@ public class FiqlParser<T> {
             } else if (c == ')') {
                 level--;
                 if (level < 0) {
-                    throw new FiqlParseException(String.format("Unexpected closing bracket
at position %d",
+                    throw new SearchParseException(String.format("Unexpected closing bracket
at position %d",
                                                                idx));
                 }
             }
@@ -166,13 +176,13 @@ public class FiqlParser<T> {
             }
         }
         if (level != 0) {
-            throw new FiqlParseException(String
+            throw new SearchParseException(String
                 .format("Unmatched opening and closing brackets in expression: %s", expr));
         }
         if (operators.get(operators.size() - 1) != null) {
             String op = operators.get(operators.size() - 1);
             String ex = subexpressions.get(subexpressions.size() - 1);
-            throw new FiqlParseException("Dangling operator at the end of expression: ..."
+ ex + op);
+            throw new SearchParseException("Dangling operator at the end of expression: ..."
+ ex + op);
         }
         // looking for adjacent ANDs then group them into ORs
         // Note: in case not ANDs is found (e.g only ORs) every single subexpression is
@@ -209,29 +219,29 @@ public class FiqlParser<T> {
         }
     }
 
-    private Comparison parseComparison(String expr) throws FiqlParseException {
+    private Comparison parseComparison(String expr) throws SearchParseException {
         Matcher m = COMPARATORS_PATTERN.matcher(expr);
         if (m.find()) {
             String name = expr.substring(0, m.start(1));
             String operator = m.group(1);
             String value = expr.substring(m.end(1));
             if ("".equals(value)) {
-                throw new FiqlParseException("Not a comparison expression: " + expr);
+                throw new SearchParseException("Not a comparison expression: " + expr);
             }
             Object castedValue = parseDatatype(name, value);
             return new Comparison(name, operator, castedValue);
         } else {
-            throw new FiqlParseException("Not a comparison expression: " + expr);
+            throw new SearchParseException("Not a comparison expression: " + expr);
         }
     }
 
-    private Object parseDatatype(String setter, String value) throws FiqlParseException {
+    private Object parseDatatype(String setter, String value) throws SearchParseException
{
         Object castedValue = value;
         Class<?> valueType;
         try {
             valueType = beanspector != null ? beanspector.getAccessorType(setter) : String.class;
         } catch (Exception e) {
-            throw new FiqlParseException(e);
+            throw new SearchParseException(e);
         }
         if (Date.class.isAssignableFrom(valueType)) {
             try {
@@ -252,16 +262,16 @@ public class FiqlParser<T> {
                     DatatypeFactory.newInstance().newDuration(value).addTo(now);
                     castedValue = now;
                 } catch (DatatypeConfigurationException e1) {
-                    throw new FiqlParseException(e1);
+                    throw new SearchParseException(e1);
                 } catch (IllegalArgumentException e1) {
-                    throw new FiqlParseException("Can parse " + value + " neither as date
nor duration", e);
+                    throw new SearchParseException("Can parse " + value + " neither as date
nor duration", e);
                 }
             }
         } else {
             try {
                 castedValue = InjectionUtils.convertStringToPrimitive(value, valueType);
             } catch (Exception e) {
-                throw new FiqlParseException("Cannot convert String value \"" + value
+                throw new SearchParseException("Cannot convert String value \"" + value
                                              + "\" to a value of class " + valueType.getName(),
e);
             }
         }
@@ -270,7 +280,7 @@ public class FiqlParser<T> {
 
     // node of abstract syntax tree
     private interface ASTNode<T> {
-        SearchCondition<T> build() throws FiqlParseException;
+        SearchCondition<T> build() throws SearchParseException;
     }
 
     private class SubExpression implements ASTNode<T> {
@@ -303,7 +313,7 @@ public class FiqlParser<T> {
             return s;
         }
 
-        public SearchCondition<T> build() throws FiqlParseException {
+        public SearchCondition<T> build() throws SearchParseException {
             boolean hasSubtree = false;
             for (ASTNode<T> node : subnodes) {
                 if (node instanceof FiqlParser.SubExpression) {
@@ -367,7 +377,7 @@ public class FiqlParser<T> {
             return name + " " + operator + " " + value + " (" + value.getClass().getSimpleName()
+ ")";
         }
 
-        public SearchCondition<T> build() throws FiqlParseException {
+        public SearchCondition<T> build() throws SearchParseException {
             T cond = createTemplate(name, value);
             ConditionType ct = OPERATORS_MAP.get(operator);
             
@@ -384,7 +394,7 @@ public class FiqlParser<T> {
         }
         
         @SuppressWarnings("unchecked")
-        private T createTemplate(String setter, Object val) throws FiqlParseException {
+        private T createTemplate(String setter, Object val) throws SearchParseException {
             try {
                 if (beanspector != null) {
                     beanspector.instantiate().setValue(setter, val);
@@ -395,7 +405,7 @@ public class FiqlParser<T> {
                     return (T)bean;
                 }
             } catch (Throwable e) {
-                throw new FiqlParseException(e);
+                throw new SearchParseException(e);
             }
         }
     }

Modified: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/BeanspectorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/BeanspectorTest.java?rev=1351617&r1=1351616&r2=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/BeanspectorTest.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/BeanspectorTest.java
Tue Jun 19 09:37:41 2012
@@ -28,7 +28,7 @@ import org.junit.Test;
 public class BeanspectorTest extends Assert {
     
     @Test
-    public void testSimpleBean() throws FiqlParseException {
+    public void testSimpleBean() throws SearchParseException {
         Beanspector<SimpleBean> bean = new Beanspector<SimpleBean>(new SimpleBean());
         Set<String> getters = bean.getGettersNames();
         assertEquals(3, getters.size());
@@ -42,7 +42,7 @@ public class BeanspectorTest extends Ass
     }
 
     @Test(expected = IllegalArgumentException.class)
-    public void testMismatchedAccessorTypes() throws FiqlParseException {
+    public void testMismatchedAccessorTypes() throws SearchParseException {
         new Beanspector<MismatchedTypes>(MismatchedTypes.class);
     }
     

Copied: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParserTest.java
(from r1351410, cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/FiqlParserTest.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParserTest.java?p2=cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParserTest.java&p1=cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/FiqlParserTest.java&r1=1351410&r2=1351617&rev=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/FiqlParserTest.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParserTest.java
Tue Jun 19 09:37:41 2012
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.jaxrs.ext.search;
+package org.apache.cxf.jaxrs.ext.search.fiql;
 
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -28,6 +28,12 @@ import java.util.Map;
 
 import javax.xml.datatype.DatatypeFactory;
 
+import org.apache.cxf.jaxrs.ext.search.ConditionType;
+import org.apache.cxf.jaxrs.ext.search.PrimitiveStatement;
+import org.apache.cxf.jaxrs.ext.search.SearchCondition;
+import org.apache.cxf.jaxrs.ext.search.SearchParseException;
+import org.apache.cxf.jaxrs.ext.search.SearchUtils;
+
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -35,93 +41,93 @@ import org.junit.Test;
 public class FiqlParserTest extends Assert {
     private FiqlParser<Condition> parser = new FiqlParser<Condition>(Condition.class);
 
-    @Test(expected = FiqlParseException.class)
-    public void testCompareWrongComparator() throws FiqlParseException {
+    @Test(expected = SearchParseException.class)
+    public void testCompareWrongComparator() throws SearchParseException {
         parser.parse("name>booba");
     }
 
-    @Test(expected = FiqlParseException.class)
-    public void testCompareMissingName() throws FiqlParseException {
+    @Test(expected = SearchParseException.class)
+    public void testCompareMissingName() throws SearchParseException {
         parser.parse("==30");
     }
 
-    @Test(expected = FiqlParseException.class)
-    public void testCompareMissingValue() throws FiqlParseException {
+    @Test(expected = SearchParseException.class)
+    public void testCompareMissingValue() throws SearchParseException {
         parser.parse("name=gt=");
     }
 
     @Test
-    public void testCompareValueTextSpaces() throws FiqlParseException {
+    public void testCompareValueTextSpaces() throws SearchParseException {
         parser.parse("name=gt=some text");
     }
 
-    @Test(expected = FiqlParseException.class)
-    public void testCompareNameTextSpaces() throws FiqlParseException {
+    @Test(expected = SearchParseException.class)
+    public void testCompareNameTextSpaces() throws SearchParseException {
         parser.parse("some name=gt=text");
     }
 
-    @Test(expected = FiqlParseException.class)
-    public void testDanglingOperator() throws FiqlParseException {
+    @Test(expected = SearchParseException.class)
+    public void testDanglingOperator() throws SearchParseException {
         parser.parse("name==a;(level==10;),");
     }
 
     @Test
-    public void testMultilevelExpression() throws FiqlParseException {
+    public void testMultilevelExpression() throws SearchParseException {
         parser.parse("name==a;(level==10,(name!=b;name!=c;(level=gt=10)))");
     }
 
     @Test
-    public void testMultilevelExpression2() throws FiqlParseException {
+    public void testMultilevelExpression2() throws SearchParseException {
         parser.parse("((name==a;level==10),name!=b;name!=c);level=gt=10");
     }
 
     @Test
-    public void testRedundantBrackets() throws FiqlParseException {
+    public void testRedundantBrackets() throws SearchParseException {
         parser.parse("name==a;((((level==10))))");
     }
 
     @Test
-    public void testAndOfOrs() throws FiqlParseException {
+    public void testAndOfOrs() throws SearchParseException {
         parser.parse("(name==a,name==b);(level=gt=0,level=lt=10)");
     }
 
     @Test
-    public void testOrOfAnds() throws FiqlParseException {
+    public void testOrOfAnds() throws SearchParseException {
         parser.parse("(name==a;name==b),(level=gt=0;level=lt=10)");
     }
 
-    @Test(expected = FiqlParseException.class)
-    public void testUnmatchedBracket() throws FiqlParseException {
+    @Test(expected = SearchParseException.class)
+    public void testUnmatchedBracket() throws SearchParseException {
         parser.parse("name==a;(name!=b;(level==10,(name!=b))");
     }
 
-    @Test(expected = FiqlParseException.class)
-    public void testUnmatchedBracket2() throws FiqlParseException {
+    @Test(expected = SearchParseException.class)
+    public void testUnmatchedBracket2() throws SearchParseException {
         parser.parse("name==bbb;))()level==111");
     }
 
-    @Test(expected = FiqlParseException.class)
-    public void testMissingComparison() throws FiqlParseException {
+    @Test(expected = SearchParseException.class)
+    public void testMissingComparison() throws SearchParseException {
         parser.parse("name==bbb;,level==111");
     }
 
-    @Test(expected = FiqlParseException.class)
-    public void testSetterMissing() throws FiqlParseException {
+    @Test(expected = SearchParseException.class)
+    public void testSetterMissing() throws SearchParseException {
         parser.parse("noSuchSetter==xxx");
     }
 
-    @Test(expected = FiqlParseException.class)
-    public void testSetterWrongType() throws FiqlParseException {
+    @Test(expected = SearchParseException.class)
+    public void testSetterWrongType() throws SearchParseException {
         parser.parse("exception==text");
     }
 
     @Test
-    public void testSetterNumericText() throws FiqlParseException {
+    public void testSetterNumericText() throws SearchParseException {
         parser.parse("name==10");
     }
 
     @Test
-    public void testParseName() throws FiqlParseException {
+    public void testParseName() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==king");
         assertTrue(filter.isMet(new Condition("king", 10, new Date())));
         assertTrue(filter.isMet(new Condition("king", 0, null)));
@@ -130,7 +136,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testParseLevel() throws FiqlParseException {
+    public void testParseLevel() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("level=gt=10");
         assertTrue(filter.isMet(new Condition("whatever", 15, new Date())));
         assertTrue(filter.isMet(new Condition(null, 15, null)));
@@ -139,7 +145,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testParseDateWithDefaultFormat() throws FiqlParseException, ParseException
{
+    public void testParseDateWithDefaultFormat() throws SearchParseException, ParseException
{
         SearchCondition<Condition> filter = parser.parse("time=le=2010-03-11T18:00:00.000+00:00");
         DateFormat df = new SimpleDateFormat(FiqlParser.DEFAULT_DATE_FORMAT);
         assertTrue(filter.isMet(new Condition("whatever", 15, df.parse("2010-03-11T18:00:00.000+0000"))));
@@ -149,7 +155,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testParseDateWithCustomFormat() throws FiqlParseException, ParseException
{
+    public void testParseDateWithCustomFormat() throws SearchParseException, ParseException
{
         Map<String, String> props = new HashMap<String, String>();
         props.put(SearchUtils.DATE_FORMAT_PROPERTY, "yyyy-MM-dd'T'HH:mm:ss");
         props.put(SearchUtils.TIMEZONE_SUPPORT_PROPERTY, "false");
@@ -174,7 +180,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testParseComplex1() throws FiqlParseException {
+    public void testParseComplex1() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==ami*;level=gt=10");
         assertEquals(ConditionType.AND, filter.getConditionType());
 
@@ -194,7 +200,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testSQL1() throws FiqlParseException {
+    public void testSQL1() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==ami*;level=gt=10");
         String sql = SearchUtils.toSQL(filter, "table");
         assertTrue("SELECT * FROM table WHERE (name LIKE 'ami%') AND (level > '10')".equals(sql)
@@ -202,7 +208,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testParseComplex2() throws FiqlParseException {
+    public void testParseComplex2() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==ami*,level=gt=10");
         assertEquals(ConditionType.OR, filter.getConditionType());
 
@@ -222,7 +228,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testSQL2() throws FiqlParseException {
+    public void testSQL2() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==ami*,level=gt=10");
         String sql = SearchUtils.toSQL(filter, "table");
         assertTrue("SELECT * FROM table WHERE (name LIKE 'ami%') OR (level > '10')".equals(sql)
@@ -230,7 +236,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testParseComplex3() throws FiqlParseException {
+    public void testParseComplex3() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==foo*;(name!=*bar,level=gt=10)");
         assertTrue(filter.isMet(new Condition("fooooo", 0, null)));
         assertTrue(filter.isMet(new Condition("fooooobar", 20, null)));
@@ -239,7 +245,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testSQL3() throws FiqlParseException {
+    public void testSQL3() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==foo*;(name!=*bar,level=gt=10)");
         String sql = SearchUtils.toSQL(filter, "table");
         assertTrue(("SELECT * FROM table WHERE (name LIKE 'foo%') AND ((name NOT LIKE '%bar')
"
@@ -249,7 +255,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testSQL4() throws FiqlParseException {
+    public void testSQL4() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("(name==test,level==18);(name==test1,level!=19)");
         String sql = SearchUtils.toSQL(filter, "table");
         assertTrue(("SELECT * FROM table WHERE ((name = 'test') OR (level = '18'))"
@@ -259,14 +265,14 @@ public class FiqlParserTest extends Asse
     }
 
     @Test
-    public void testSQL5() throws FiqlParseException {
+    public void testSQL5() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==test");
         String sql = SearchUtils.toSQL(filter, "table");
         assertTrue("SELECT * FROM table WHERE name = 'test'".equals(sql));
     }
 
     @Test
-    public void testParseComplex4() throws FiqlParseException {
+    public void testParseComplex4() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==foo*;name!=*bar,level=gt=10");
         assertTrue(filter.isMet(new Condition("zonk", 20, null)));
         assertTrue(filter.isMet(new Condition("foobaz", 0, null)));
@@ -275,7 +281,7 @@ public class FiqlParserTest extends Asse
     }
 
     @Ignore
-    static class Condition {
+    public static class Condition {
         private String name;
         private Integer level;
         private Date time;

Modified: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPALanguageVisitorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPALanguageVisitorTest.java?rev=1351617&r1=1351616&r2=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPALanguageVisitorTest.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPALanguageVisitorTest.java
Tue Jun 19 09:37:41 2012
@@ -18,8 +18,8 @@
  */
 package org.apache.cxf.jaxrs.ext.search.jpa;
 
-import org.apache.cxf.jaxrs.ext.search.FiqlParser;
 import org.apache.cxf.jaxrs.ext.search.SearchCondition;
+import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 
 import org.junit.Assert;
 import org.junit.Test;

Modified: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java?rev=1351617&r1=1351616&r2=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
Tue Jun 19 09:37:41 2012
@@ -27,8 +27,8 @@ import javax.persistence.EntityManagerFa
 import javax.persistence.Persistence;
 import javax.persistence.TypedQuery;
 
-import org.apache.cxf.jaxrs.ext.search.FiqlParser;
 import org.apache.cxf.jaxrs.ext.search.SearchCondition;
+import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 
 import org.junit.After;
 import org.junit.Assert;

Modified: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/sql/SQLPrinterVisitorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/sql/SQLPrinterVisitorTest.java?rev=1351617&r1=1351616&r2=1351617&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/sql/SQLPrinterVisitorTest.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/sql/SQLPrinterVisitorTest.java
Tue Jun 19 09:37:41 2012
@@ -21,10 +21,10 @@ package org.apache.cxf.jaxrs.ext.search.
 import java.util.Collections;
 import java.util.Date;
 
-import org.apache.cxf.jaxrs.ext.search.FiqlParseException;
-import org.apache.cxf.jaxrs.ext.search.FiqlParser;
 import org.apache.cxf.jaxrs.ext.search.SearchBean;
 import org.apache.cxf.jaxrs.ext.search.SearchCondition;
+import org.apache.cxf.jaxrs.ext.search.SearchParseException;
+import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 
 import org.junit.Assert;
 import org.junit.Ignore;
@@ -35,7 +35,7 @@ public class SQLPrinterVisitorTest exten
     private FiqlParser<Condition> parser = new FiqlParser<Condition>(Condition.class);
 
     @Test
-    public void testSQL1() throws FiqlParseException {
+    public void testSQL1() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==ami*;level=gt=10");
         SQLPrinterVisitor<Condition> visitor = new SQLPrinterVisitor<Condition>("table");
         filter.accept(visitor);
@@ -46,7 +46,7 @@ public class SQLPrinterVisitorTest exten
     }
     
     @Test
-    public void testSQL1WithSearchBean() throws FiqlParseException {
+    public void testSQL1WithSearchBean() throws SearchParseException {
         FiqlParser<SearchBean> beanParser = new FiqlParser<SearchBean>(SearchBean.class);
         SearchCondition<SearchBean> filter = beanParser.parse("name==ami*;level=gt=10");
         SQLPrinterVisitor<SearchBean> visitor = new SQLPrinterVisitor<SearchBean>("table");
@@ -58,7 +58,7 @@ public class SQLPrinterVisitorTest exten
     }
     
     @Test
-    public void testSQL2() throws FiqlParseException {
+    public void testSQL2() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==ami*,level=gt=10");
         SQLPrinterVisitor<Condition> visitor = new SQLPrinterVisitor<Condition>("table");
         filter.accept(visitor);
@@ -68,7 +68,7 @@ public class SQLPrinterVisitorTest exten
     }
     
     @Test
-    public void testSQL3() throws FiqlParseException {
+    public void testSQL3() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==foo*;(name!=*bar,level=gt=10)");
         SQLPrinterVisitor<Condition> visitor = new SQLPrinterVisitor<Condition>("table");
         filter.accept(visitor);
@@ -80,7 +80,7 @@ public class SQLPrinterVisitorTest exten
     }
     
     @Test
-    public void testSQL3WithSearchBean() throws FiqlParseException {
+    public void testSQL3WithSearchBean() throws SearchParseException {
         FiqlParser<SearchBean> beanParser = new FiqlParser<SearchBean>(SearchBean.class);
         SearchCondition<SearchBean> filter = beanParser.parse("name==foo*;(name!=*bar,level=gt=10)");
         SQLPrinterVisitor<SearchBean> visitor = new SQLPrinterVisitor<SearchBean>("table");
@@ -93,7 +93,7 @@ public class SQLPrinterVisitorTest exten
     }
     
     @Test
-    public void testSQL4() throws FiqlParseException {
+    public void testSQL4() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("(name==test,level==18);(name==test1,level!=19)");
         SQLPrinterVisitor<Condition> visitor = new SQLPrinterVisitor<Condition>("table");
         filter.accept(visitor);
@@ -105,7 +105,7 @@ public class SQLPrinterVisitorTest exten
     }
     
     @Test
-    public void testSQL5() throws FiqlParseException {
+    public void testSQL5() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==test");
         SQLPrinterVisitor<Condition> visitor = new SQLPrinterVisitor<Condition>("table");
         filter.accept(visitor);
@@ -114,7 +114,7 @@ public class SQLPrinterVisitorTest exten
     }
     
     @Test
-    public void testSQL5WithColumns() throws FiqlParseException {
+    public void testSQL5WithColumns() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==test");
         SQLPrinterVisitor<Condition> visitor = 
             new SQLPrinterVisitor<Condition>("table", "NAMES");
@@ -124,7 +124,7 @@ public class SQLPrinterVisitorTest exten
     }
     
     @Test
-    public void testSQL5WithFieldMap() throws FiqlParseException {
+    public void testSQL5WithFieldMap() throws SearchParseException {
         SearchCondition<Condition> filter = parser.parse("name==test");
         SQLPrinterVisitor<Condition> visitor = 
             new SQLPrinterVisitor<Condition>(



Mime
View raw message