Author: michiel
Date: 2010-03-23 15:12:07 +0100 (Tue, 23 Mar 2010)
New Revision: 41572
Added:
mmbase/trunk/contributions/lucene/src/test/
mmbase/trunk/contributions/lucene/src/test/java/
mmbase/trunk/contributions/lucene/src/test/java/org/
mmbase/trunk/contributions/lucene/src/test/webapp/
mmbase/trunk/contributions/lucene/src/test/webapp/WEB-INF/
mmbase/trunk/contributions/lucene/src/test/webapp/WEB-INF/web.xml
Modified:
mmbase/trunk/contributions/lucene/src/test/java/org/mmbase/module/lucene/LuceneTest.java
Log:
made cloud not static
Copied: mmbase/trunk/contributions/lucene/src/test/java/org (from rev 40160,
mmbase/trunk/contributions/lucene/tests/org)
Modified:
mmbase/trunk/contributions/lucene/src/test/java/org/mmbase/module/lucene/LuceneTest.java
===================================================================
---
mmbase/trunk/contributions/lucene/tests/org/mmbase/module/lucene/LuceneTest.java
2009-12-08 16:44:17 UTC (rev 40160)
+++
mmbase/trunk/contributions/lucene/src/test/java/org/mmbase/module/lucene/LuceneTest.java
2010-03-23 14:12:07 UTC (rev 41572)
@@ -9,51 +9,57 @@
*/
package org.mmbase.module.lucene;
-import org.mmbase.tests.BridgeTest;
import org.mmbase.bridge.*;
+import org.mmbase.bridge.mock.*;
import java.util.*;
-import junit.framework.TestCase;
+import org.junit.*;
+import static org.junit.Assert.*;
+import static org.junit.Assume.*;
+
/**
*
* @author Michiel Meeuwissen
* @verion $Id$
*/
-public class LuceneTest extends BridgeTest {
+public class LuceneTest {
private static Lucene lucene;
private static int articleNumber;
- private static Cloud cloud;
- public void setUp() throws Exception {
- if (cloud == null) {
- System.out.println("Starting mmbase");
- startMMBase(true);
- lucene = org.mmbase.module.Module.getModule(Lucene.class);
- Thread.sleep(15000); // make sure mynew is deployed. (should
perhaps implemented some wait
- // functionality too).
- System.out.println("" + lucene.listFunction.getFunctionValue());
- System.out.println("NOW DOING FULL INDICES");
- lucene.fullIndexFunction.getFunctionValue("mynews_magazine");
- lucene.fullIndexFunction.getFunctionValue("mynews_news");
- cloud = getCloud();
- System.out.println("Found cloud " + cloud + " and lucene " +
lucene);
- }
+ public MockCloudContext getCloudContext() {
+ return MockCloudContext.getInstance();
}
+ @BeforeClass
+ public static void setup() throws Exception {
+ MockCloudContext.getInstance().addCore();
+
MockCloudContext.getInstance().addNodeManagers(MockBuilderReader.getBuilderLoader().getChildResourceLoader("mynews"));
+ lucene = org.mmbase.module.Module.getModule(Lucene.class, false);
+ assertTrue(lucene != null);
+ lucene.fullIndexFunction.getFunctionValueWithArgs("mynews_magazine");
+ lucene.fullIndexFunction.getFunctionValueWithArgs("mynews_news");
+ System.out.println("Found cloud " + getCloud() + " and lucene " +
lucene);
+ }
+
+ private static Cloud getCloud () {
+ return MockCloudContext.getInstance().getCloud("mmbase", "class",
null);
+ }
+
private Node getArticle() {
- return cloud.getNode(articleNumber);
+ return getCloud().getNode(articleNumber);
}
private void testSize(String index, String value, int expected) throws
Exception {
+ Cloud cloud = getCloud();
int searchSize = lucene.getSearcher(index).searchSize(cloud, value);
assertTrue ("Search size is not " + expected + " but " + searchSize,
searchSize == expected);
}
private void waitForIndicesUpToDate() throws Exception {
- lucene.waitFunction.getFunctionValue();
+ lucene.waitFunction.getFunctionValueWithArgs();
}
- /**
- */
+
+ @Test
public void testIndex() throws Exception {
waitForIndicesUpToDate();
@@ -65,6 +71,7 @@
}
public void testChange() throws Exception {
+ Cloud cloud = getCloud();
Node article = cloud.getNode("anewsarticle");
article.setStringValue("title", "something else");
article.setStringValue("subtitle", "something else");
@@ -77,6 +84,7 @@
}
public void testChangeStillInCondition() throws Exception {
+ Cloud cloud = getCloud();
Node article = cloud.getNode("anewsarticle");
article.setStringValue("title", "Again with XML");
article.commit();
@@ -86,6 +94,7 @@
}
public void testCreateInConditionNotInIndex() throws Exception {
+ Cloud cloud = getCloud();
Node article = cloud.getNodeManager("news").createNode();
article.setStringValue("title", "Also with XML");
article.commit();
@@ -96,6 +105,7 @@
}
public static int rel1Number;
public void testRelateIntoIndex() throws Exception {
+ Cloud cloud = getCloud();
Node mag = cloud.getNode("default.mags");
RelationManager rm = cloud.getRelationManager("mags", "news",
"posrel");
Relation r = rm.createRelation(mag, getArticle());
@@ -127,6 +137,7 @@
}
public void testChangeStartNode() throws Exception {
+ Cloud cloud = getCloud();
Node mag = cloud.getNode("default.mags");
mag.setStringValue("subtitle", "test test");
mag.commit();
@@ -138,6 +149,7 @@
public static int rel2Number;
public void testRelateIntoIndexTwice() throws Exception {
+ Cloud cloud = getCloud();
Node mag = cloud.getNode("nondefault.mags");
RelationManager rm = cloud.getRelationManager("mags", "news",
"posrel");
Relation r = rm.createRelation(mag, getArticle());
@@ -162,12 +174,14 @@
}
public void testUnRelateFromStartNodeButStilInIndex() throws Exception {
+ Cloud cloud = getCloud();
Node r = cloud.getNode(rel1Number);
r.delete();
waitForIndicesUpToDate();
testSize("mynews_magazine", "xml", 4);
}
public void testUnRelateFromLastStartNode() throws Exception {
+ Cloud cloud = getCloud();
Node r = cloud.getNode(rel2Number);
r.delete();
waitForIndicesUpToDate();
Added: mmbase/trunk/contributions/lucene/src/test/webapp/WEB-INF/web.xml
===================================================================
--- mmbase/trunk/contributions/lucene/src/test/webapp/WEB-INF/web.xml
(rev 0)
+++ mmbase/trunk/contributions/lucene/src/test/webapp/WEB-INF/web.xml
2010-03-23 14:12:07 UTC (rev 41572)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee "
+ version="2.4">
+ <description>
+
+ </description>
+
+ <display-name>MMBase lucene tests</display-name>
+
+ <listener>
+ <listener-class>org.mmbase.bridge.mock.MockSetup</listener-class>
+ </listener>
+
+</web-app>
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs