cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: CXF-5549: Introduce Tika Search Visitor. Added contextual property systest and fixed NPE (DefaultParamConverterProvider)
Date Mon, 14 Jul 2014 23:43:59 GMT
Repository: cxf
Updated Branches:
  refs/heads/master ebd537875 -> 32caf7fef


CXF-5549: Introduce Tika Search Visitor. Added contextual property systest and fixed NPE (DefaultParamConverterProvider)


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/32caf7fe
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/32caf7fe
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/32caf7fe

Branch: refs/heads/master
Commit: 32caf7feff3b8730d797f428be5d0d80148be062
Parents: ebd5378
Author: reta <drreta@gmail.com>
Authored: Mon Jul 14 19:43:40 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Mon Jul 14 19:43:40 2014 -0400

----------------------------------------------------------------------
 .../search/DefaultParamConverterProvider.java   |  2 +-
 .../systest/jaxrs/extraction/BookCatalog.java   | 15 ++++++++++++
 .../extraction/JAXRSClientServerTikaTest.java   | 24 +++++++++++++++++++-
 3 files changed, 39 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/32caf7fe/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/DefaultParamConverterProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/DefaultParamConverterProvider.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/DefaultParamConverterProvider.java
index db3cfaf..67b01ed 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/DefaultParamConverterProvider.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/DefaultParamConverterProvider.java
@@ -48,7 +48,7 @@ public class DefaultParamConverterProvider implements ParamConverterProvider
{
         
         @Override
         public String toString(final Date value) {
-            return DateTools.dateToString(value, Resolution.MILLISECOND);
+            return value != null ? DateTools.dateToString(value, Resolution.MILLISECOND)
: null;
         }
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/32caf7fe/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
index 8ff5113..76785d5 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
@@ -29,6 +29,7 @@ import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
@@ -113,6 +114,20 @@ public class BookCatalog {
             reader.close();
         }
     }
+    
+    @DELETE
+    public Response delete() throws IOException {
+        final IndexWriter writer = new IndexWriter(directory, config);
+        
+        try {
+            writer.deleteAll();
+            writer.commit();
+        } finally {
+            writer.close();
+        }  
+        
+        return Response.ok().build();
+    }
 }
 
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/32caf7fe/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/JAXRSClientServerTikaTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/JAXRSClientServerTikaTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/JAXRSClientServerTikaTest.java
index 63698f8..2cb7e24 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/JAXRSClientServerTikaTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/JAXRSClientServerTikaTest.java
@@ -35,6 +35,7 @@ import org.apache.cxf.jaxrs.ext.multipart.ContentDisposition;
 import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
 import org.apache.cxf.jaxrs.ext.search.SearchBean;
 import org.apache.cxf.jaxrs.ext.search.SearchContextProvider;
+import org.apache.cxf.jaxrs.ext.search.SearchUtils;
 import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
@@ -43,6 +44,7 @@ import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.lucene.search.ScoreDoc;
 import org.junit.BeforeClass;
+import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -57,6 +59,7 @@ public class JAXRSClientServerTikaTest extends AbstractBusClientServerTestBase
{
             final Map< String, Object > properties = new HashMap< String, Object
>();        
             properties.put("search.query.parameter.name", "$filter");
             properties.put("search.parser", new FiqlParser< SearchBean >(SearchBean.class));
+            properties.put(SearchUtils.DATE_FORMAT_PROPERTY, "yyyy/MM/dd");
             
             sf.setResourceClasses(BookCatalog.class);
             sf.setResourceProvider(BookCatalog.class, new SingletonResourceProvider(new BookCatalog()));
@@ -90,6 +93,11 @@ public class JAXRSClientServerTikaTest extends AbstractBusClientServerTestBase
{
         createStaticBus();
     }
     
+    @Before
+    public void setUp() {
+        createWebClient("/catalog").delete();        
+    }
+    
     @Test
     public void testUploadIndexAndSearchPdfFile() {
         final WebClient wc = createWebClient("/catalog").type(MediaType.MULTIPART_FORM_DATA);
@@ -99,9 +107,23 @@ public class JAXRSClientServerTikaTest extends AbstractBusClientServerTestBase
{
             getClass().getResourceAsStream("/files/testPDF.pdf"), disposition);
         wc.post(new MultipartBody(attachment));
         
-        final Collection<ScoreDoc> hits = search("modified=le=2007-09-16");       

+        final Collection<ScoreDoc> hits = search("modified=le=2007-09-16T09:00:00");
       
         assertEquals(hits.size(), 1);
     }
+    
+    @Test
+    public void testUploadIndexAndSearchPdfFileUsingUserDefinedDatePattern() {
+        final WebClient wc = createWebClient("/catalog").type(MediaType.MULTIPART_FORM_DATA);
+        
+        final ContentDisposition disposition = new ContentDisposition("attachment;filename=testPDF.pdf");
+        final Attachment attachment = new Attachment("root", 
+            getClass().getResourceAsStream("/files/testPDF.pdf"), disposition);
+        wc.post(new MultipartBody(attachment));
+        
+        // Use user-defined date pattern
+        final Collection<ScoreDoc> custom = search("modified=le=2007/09/16");     
  
+        assertEquals(custom.size(), 1);
+    }
 
     @SuppressWarnings("unchecked")
     private Collection<ScoreDoc> search(final String expression) {


Mime
View raw message