cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1525891 - in /cxf/trunk/rt/rs/extensions/search/src: main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
Date Tue, 24 Sep 2013 14:17:30 GMT
Author: sergeyb
Date: Tue Sep 24 14:17:29 2013
New Revision: 1525891

URL: http://svn.apache.org/r1525891
Log:
[CXF-5299] SearchBean can not capture properties with dots, patch from Nikolay Blindov applied

Modified:
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/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?rev=1525891&r1=1525890&r2=1525891&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
Tue Sep 24 14:17:29 2013
@@ -324,7 +324,7 @@ public class FiqlParser<T> implements Se
         boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(valueType);
         Class<?> actualType = isCollection ? InjectionUtils.getActualType(typeInfo.getGenericType())
: valueType;
         
-        int index = setter.indexOf(".");
+        int index = getDotIndex(setter);
         if (index == -1) {
             Object castedValue = value;
             if (Date.class.isAssignableFrom(valueType)) {
@@ -478,8 +478,12 @@ public class FiqlParser<T> implements Se
         }
     }
     
+    private int getDotIndex(String setter) {
+        return this.conditionClass == SearchBean.class ? -1 : setter.indexOf(".");
+    }
+    
     private String getSetter(String setter) {
-        int index = setter.indexOf(".");
+        int index = getDotIndex(setter);
         if (index != -1) {
             return setter.substring(0, index).toLowerCase();
         } else {

Modified: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java?rev=1525891&r1=1525890&r2=1525891&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
Tue Sep 24 14:17:29 2013
@@ -173,7 +173,7 @@ public class SearchContextImplTest exten
     }
     
     @Test
-    public void testPrimitiveStatement() {
+    public void testPrimitiveStatementSearchBean() {
         Message m = new MessageImpl();
         m.put(Message.QUERY_STRING, "_s=name==CXF");
         SearchContext context = new SearchContextImpl(m);
@@ -190,6 +190,23 @@ public class SearchContextImplTest exten
     }
     
     @Test
+    public void testPrimitiveStatementSearchBeanComlexName() {
+        Message m = new MessageImpl();
+        m.put(Message.QUERY_STRING, "_s=complex.name==CXF");
+        SearchContext context = new SearchContextImpl(m);
+        SearchCondition<SearchBean> sc = context.getCondition(SearchBean.class);
+        assertNotNull(sc);
+        
+        PrimitiveStatement ps = sc.getStatement();
+        assertNotNull(ps);
+        
+        assertEquals("complex.name", ps.getProperty());
+        assertEquals("CXF", ps.getValue());
+        assertEquals(ConditionType.EQUALS, ps.getCondition());
+        assertEquals(String.class, ps.getValueType());
+    }
+    
+    @Test
     public void testSingleEquals() {
         Message m = new MessageImpl();
         m.put(Message.QUERY_STRING, "_s=name=CXF");



Mime
View raw message