roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r824126 - in /roller/trunk/apps/weblogger: src/java/org/apache/roller/weblogger/business/search/operations/ test/java/org/apache/roller/weblogger/ test/java/org/apache/roller/weblogger/business/
Date Sun, 11 Oct 2009 19:21:13 GMT
Author: snoopdave
Date: Sun Oct 11 19:21:12 2009
New Revision: 824126

URL: http://svn.apache.org/viewvc?rev=824126&view=rev
Log:
Fixing bug cause by upgrading dependencies and specifically, Lucene
   see also https://issues.apache.org/jira/browse/ROL-1840

Didn't notice this before because the IndexManagerTest was not included in the tests, now
it is.

Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java
    roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java
    roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogServicesTestSuite.java
    roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/IndexManagerTest.java

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java?rev=824126&r1=824125&r2=824126&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java
Sun Oct 11 19:21:12 2009
@@ -53,11 +53,20 @@
     private static Log mLogger =
             LogFactory.getFactory().getInstance(SearchOperation.class);
     
-    private static String[] SEARCH_FIELDS = new String[]{
-        FieldConstants.CONTENT, FieldConstants.TITLE,
-        FieldConstants.C_CONTENT, FieldConstants.CATEGORY
+    private static String[] SEARCH_FIELDS = new String[] {
+        FieldConstants.CONTENT,
+        FieldConstants.TITLE,
+        FieldConstants.C_CONTENT,
+        FieldConstants.CATEGORY
     };
-    
+
+    private static BooleanClause.Occur[] SEARCH_FLAGS = new BooleanClause.Occur[] {
+        BooleanClause.Occur.SHOULD,
+        BooleanClause.Occur.SHOULD,
+        BooleanClause.Occur.SHOULD, 
+        BooleanClause.Occur.SHOULD
+    };
+
     private static Sort SORTER = new Sort( new SortField(
             FieldConstants.PUBLISHED, SortField.STRING, true) );
     
@@ -97,13 +106,9 @@
             IndexReader reader = manager.getSharedIndexReader();
             searcher = new IndexSearcher(reader);
 
-            String[] terms = new String[1];
-            terms[0] = term;
-
-            BooleanClause.Occur[] flags = new BooleanClause.Occur[1];
-            flags[1] = BooleanClause.Occur.MUST;
-            Query query = MultiFieldQueryParser.parse(terms,
-                SEARCH_FIELDS, flags, new StandardAnalyzer(Version.LUCENE_CURRENT));
+            Query query = MultiFieldQueryParser.parse(term,
+                SEARCH_FIELDS, SEARCH_FLAGS,
+                new StandardAnalyzer(Version.LUCENE_CURRENT));
             
             Term tUsername =
                 IndexUtil.getTerm(FieldConstants.WEBSITE_HANDLE, websiteHandle);

Modified: roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java?rev=824126&r1=824125&r2=824126&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java (original)
+++ roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java Sun Oct
11 19:21:12 2009
@@ -580,5 +580,12 @@
     public static WeblogEntry getManagedWeblogEntry(WeblogEntry weblogEntry) throws WebloggerException
{
         return WebloggerFactory.getWeblogger().getWeblogEntryManager().getWeblogEntry(weblogEntry.getId());
     }
-    
+
+    /**
+     * Convenience method that returns managed copy of given WeblogEntry.
+     */
+    public static WeblogCategory getManagedWeblogCategory(WeblogCategory cat) throws WebloggerException
{
+        return WebloggerFactory.getWeblogger().getWeblogEntryManager().getWeblogCategory(cat.getId());
+    }
+
 }

Modified: roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogServicesTestSuite.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogServicesTestSuite.java?rev=824126&r1=824125&r2=824126&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogServicesTestSuite.java
(original)
+++ roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogServicesTestSuite.java
Sun Oct 11 19:21:12 2009
@@ -49,6 +49,9 @@
         // test comments
         suite.addTestSuite(CommentTest.class);
 
+        // test search
+        suite.addTestSuite(IndexManagerTest.class);
+
         return suite;
     }
     

Modified: roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/IndexManagerTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/IndexManagerTest.java?rev=824126&r1=824125&r2=824126&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/IndexManagerTest.java
(original)
+++ roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/IndexManagerTest.java
Sun Oct 11 19:21:12 2009
@@ -21,15 +21,15 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
+import org.apache.roller.weblogger.TestUtils;
 import org.apache.roller.weblogger.business.search.IndexManagerImpl;
 import org.apache.roller.weblogger.business.search.operations.AddEntryOperation;
-import org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation;
 import org.apache.roller.weblogger.business.search.operations.SearchOperation;
 import org.apache.roller.weblogger.business.search.IndexManager;
-import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
 import org.apache.roller.weblogger.pojos.Weblog;
+import org.apache.roller.weblogger.pojos.WeblogCategory;
 
 
 /**
@@ -46,41 +46,53 @@
     }
         
     public void testSearch() throws Exception {
-        IndexManager imgr = WebloggerFactory.getWeblogger().getIndexManager();
 
-        Weblog website = new Weblog();
-        website.setHandle("trekker");
+        IndexManager imgr = WebloggerFactory.getWeblogger().getIndexManager();
 
-        User user = new User();
-        user.setUserName("nimoy");
+        User user = TestUtils.setupUser("nimoy");
+        Weblog website = TestUtils.setupWeblog("trekker", user);
+        WeblogCategory cat = TestUtils.setupWeblogCategory(website, "test", null);
+        TestUtils.endSession(true);
 
         WeblogEntry wd1 = new WeblogEntry();            
         wd1.setId("dummy1");
         wd1.setAnchor("dummy1");
+        wd1.setCategory(TestUtils.getManagedWeblogCategory(cat));
         wd1.setCreatorUserName(user.getUserName());
         wd1.setUpdateTime(new Timestamp(System.currentTimeMillis()));
         wd1.setPubTime(new Timestamp(System.currentTimeMillis()));
         wd1.setTitle("The Tholian Web");
-        wd1.setWebsite(website);
+        wd1.setWebsite(TestUtils.getManagedWebsite(website));
         wd1.setText(
          "When the Enterprise attempts to ascertain the fate of the  "
         +"U.S.S. Defiant which vanished 3 weeks ago, the warp engines  "
         +"begin to lose power, and Spock reports strange sensor readings.");
+
+        WebloggerFactory.getWeblogger().getWeblogEntryManager().saveWeblogEntry(wd1);
+        TestUtils.endSession(true);
+        wd1 = TestUtils.getManagedWeblogEntry(wd1);
+
         imgr.executeIndexOperationNow(
             new AddEntryOperation(WebloggerFactory.getWeblogger(), (IndexManagerImpl)imgr,
wd1));
 
         WeblogEntry wd2 = new WeblogEntry();
         wd2.setId("dummy2");
         wd2.setAnchor("dummy2");
+        wd2.setCategory(TestUtils.getManagedWeblogCategory(cat));
         wd2.setCreatorUserName(user.getUserName());
         wd2.setUpdateTime(new Timestamp(System.currentTimeMillis()));
         wd2.setPubTime(new Timestamp(System.currentTimeMillis()));
         wd2.setTitle("A Piece of the Action");
-        wd2.setWebsite(website);
+        wd2.setWebsite(TestUtils.getManagedWebsite(website));
         wd2.setText(
           "The crew of the Enterprise attempts to make contact with "
           +"the inhabitants of planet Sigma Iotia II, and Uhura puts Kirk "
           +"in communication with Boss Oxmyx.");
+
+        WebloggerFactory.getWeblogger().getWeblogEntryManager().saveWeblogEntry(wd2);
+        TestUtils.endSession(true);
+        wd2 = TestUtils.getManagedWeblogEntry(wd2);
+
          imgr.executeIndexOperationNow(
              new AddEntryOperation(WebloggerFactory.getWeblogger(), (IndexManagerImpl)imgr,
wd2));
 



Mime
View raw message