cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1550182 - in /cxf/branches/2.7.x-fixes: ./ rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/ rt/rs/extensions/search/src/test/java/org/apache/...
Date Wed, 11 Dec 2013 16:22:58 GMT
Author: sergeyb
Date: Wed Dec 11 16:22:58 2013
New Revision: 1550182

URL: http://svn.apache.org/r1550182
Log:
Merged revisions 1550181 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1550181 | sergeyb | 2013-12-11 16:19:30 +0000 (Wed, 11 Dec 2013) | 1 line
  
  [CXF-5453] Support for beans with interfaces
........

Added:
    cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/InterfaceProxy.java
      - copied unchanged from r1550181, cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/InterfaceProxy.java
Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
    cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
    cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1550181

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java?rev=1550182&r1=1550181&r2=1550182&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
Wed Dec 11 16:22:58 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.jaxrs.ext.search.fiql;
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.util.ArrayList;
@@ -37,6 +38,7 @@ import org.apache.cxf.jaxrs.ext.search.A
 import org.apache.cxf.jaxrs.ext.search.Beanspector;
 import org.apache.cxf.jaxrs.ext.search.Beanspector.TypeInfo;
 import org.apache.cxf.jaxrs.ext.search.ConditionType;
+import org.apache.cxf.jaxrs.ext.search.InterfaceProxy;
 import org.apache.cxf.jaxrs.ext.search.OrSearchCondition;
 import org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException;
 import org.apache.cxf.jaxrs.ext.search.SearchBean;
@@ -381,7 +383,12 @@ public class FiqlParser<T> implements Se
                 boolean lastTry = names.length == 2 
                     && (isPrimitive || returnType == Date.class || returnCollection);
                 
-                Object valueObject = lastTry && ownerBean != null ? ownerBean : actualType.newInstance();
+                Object valueObject = lastTry && ownerBean != null ? ownerBean 
+                    : actualType.isInterface() 
+                    ? Proxy.newProxyInstance(this.getClass().getClassLoader(), 
+                                             new Class[]{actualType}, 
+                                             new InterfaceProxy())
+                    : actualType.newInstance();
                 Object nextObject;
                 
                 if (lastTry) {

Modified: cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java?rev=1550182&r1=1550181&r2=1550182&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
Wed Dec 11 16:22:58 2013
@@ -19,8 +19,10 @@
 package org.apache.cxf.jaxrs.ext.search;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
+import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 
@@ -238,4 +240,76 @@ public class SearchContextImplTest exten
         assertEquals(ConditionType.EQUALS, ps.getCondition());
         assertEquals(String.class, ps.getValueType());
     }
+    
+    @Test
+    public void testIsMetCompositeObject() throws Exception {
+        SearchCondition<TheBook> filter = 
+            new FiqlParser<TheBook>(TheBook.class,
+                null,                          
+                Collections.singletonMap("address", "address.street")).parse("address==Street1");
+        
+        TheBook b = new TheBook();
+        b.setAddress(new TheOwnerAddress("Street1"));
+        assertTrue(filter.isMet(b));
+        
+        b.setAddress(new TheOwnerAddress("Street2"));
+        assertFalse(filter.isMet(b));
+    }
+    @Test
+    public void testIsMetCompositeInterface() throws Exception {
+        SearchCondition<TheBook> filter = 
+            new FiqlParser<TheBook>(TheBook.class,
+                null,                          
+                Collections.singletonMap("address", "addressInterface.street"))
+                    .parse("address==Street1");
+        
+        TheBook b = new TheBook();
+        b.setAddress(new TheOwnerAddress("Street1"));
+        assertTrue(filter.isMet(b));
+        
+        b.setAddress(new TheOwnerAddress("Street2"));
+        assertFalse(filter.isMet(b));
+    }
+        
+    public static class TheBook {
+        private TheOwnerAddressInterface address;
+
+        public TheOwnerAddress getAddress() {
+            return (TheOwnerAddress)address;
+        }
+
+        public void setAddress(TheOwnerAddress a) {
+            this.address = a;
+        }
+        
+        public TheOwnerAddressInterface getAddressInterface() {
+            return address;
+        }
+
+        public void setAddressInterface(TheOwnerAddressInterface a) {
+            this.address = a;
+        }
+    }
+    public interface TheOwnerAddressInterface {
+        String getStreet();
+        void setStreet(String street);
+    }
+    public static class TheOwnerAddress implements TheOwnerAddressInterface {
+        private String street;
+
+        public TheOwnerAddress() {
+            
+        }
+        public TheOwnerAddress(String s) {
+            this.street = s;
+        }
+        
+        public String getStreet() {
+            return street;
+        }
+
+        public void setStreet(String street) {
+            this.street = street;
+        }
+    }
 }

Modified: cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java?rev=1550182&r1=1550181&r2=1550182&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
Wed Dec 11 16:22:58 2013
@@ -337,21 +337,6 @@ public class JPATypedQueryVisitorTest ex
     }
     
     @Test
-    public void testIsMet() throws Exception {
-        SearchCondition<Book> filter = 
-            new FiqlParser<Book>(Book.class,
-                null,                          
-                Collections.singletonMap("address", "address.street")).parse("address==Street1");
-        
-        Book b = new Book();
-        b.setAddress(new OwnerAddress("Street1"));
-        assertTrue(filter.isMet(b));
-        
-        b.setAddress(new OwnerAddress("Street2"));
-        assertFalse(filter.isMet(b));
-    }
-    
-    @Test
     public void testEqualsAddressQuery2() throws Exception {
         List<Book> books = queryBooks("street==Street1",
             null,                          



Mime
View raw message