Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ivy.xml update to include lucene #9

Closed
wants to merge 5 commits into from

3 participants

@xiaoyang

I think you likely accidentally deleted it and it won't build out of a clean clone of the repo.

Thanks!

@javasoze javasoze closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 18, 2011
  1. @xiaoyang

    fix ivy dependency

    xiaoyang authored
Commits on May 19, 2011
  1. @xiaoyang
  2. @xiaoyang

    cubertura xml report

    xiaoyang authored
Commits on May 31, 2011
  1. @hyan

    fix the bug of building filter when MultiValueFacetHandler has differ…

    hyan authored
    …ent name and indexfieldname(adaptive filter)
Commits on Jun 2, 2011
  1. @hyan
This page is out of date. Refresh to see the latest.
View
2  .gitignore
@@ -6,6 +6,8 @@ build-test/
dist/
ivy/
doc
+cobertura.ser
+logs
output
lib/gui/
lib/jetty/
View
4 bobo-browse/src/com/browseengine/bobo/facets/impl/MultiValueFacetHandler.java
@@ -173,7 +173,7 @@ public FacetDataCache build(BoboIndexReader reader) {
@Override
public String getName() {
- return _name;
+ return _indexFieldName;
}
}, f, new String[]{value}, false);
@@ -219,7 +219,7 @@ public FacetDataCache build(BoboIndexReader reader) {
@Override
public String getName() {
- return _name;
+ return _indexFieldName;
}
}, f, vals, false);
View
46 build.xml
@@ -30,6 +30,7 @@
<property name="lib.test" location="${lib}/test" />
<property name="test.report.dir" location="${dist}/junit-reports" />
+ <property name="cubertura.report.dir" location="${dist}/cubertura-reports" />
<property name="test.html.dir" location="${test.report.dir}/html" />
@@ -42,7 +43,20 @@
<property name="ivy.install.version" value="2.0.0-beta1"/>
<property name="ivy.jar.dir" value="${basedir}/ivy"/>
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
-
+
+ <property name="cobertura.dir" value="${lib.master}" />
+
+ <path id="cobertura.classpath">
+ <fileset dir="${cobertura.dir}">
+ <include name="cobertura.jar" />
+ <include name="log4j.jar" />
+ <include name="asm*.jar" />
+ <include name="oro.jar" />
+ <include name="lib/**/*.jar" />
+ </fileset>
+ </path>
+
+ <taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<target name="init" depends="resolve">
<mkdir dir="${dist}" />
@@ -290,7 +304,7 @@
</java>
</target>
- <target name="test-build" depends="bobo-browse-jar,bobo-solr-jar">
+ <target name="test-build" depends="bobo-browse-jar,cobertura-instrument,bobo-solr-jar">
<javac destdir="${build.test}">
<src path="${test}"/>
<classpath refid="test.compile.class.path"/>
@@ -298,6 +312,16 @@
<jar destfile="${dist}/bobo-test.jar" basedir="${build.test}" />
</target>
+ <target name="cobertura-instrument" description="instrumentation for cobertura">
+ <delete file="cobertura.ser" />
+ <cobertura-instrument>
+ <ignore regex="org.apache.log4j.*" />
+ <ignore regex="org.objectweb.*" />
+ <fileset dir="${dist}">
+ <include name="bobo-browse-2.5.2-SNAPSHOT.jar" />
+ </fileset>
+ </cobertura-instrument>
+ </target>
<target name="test" description="Runs JUnit Tests" depends="test-build">
<echo>=== Running JUnit Tests ===</echo>
<mkdir dir="${test.report.dir}" />
@@ -309,7 +333,9 @@
<!-- classpath must include all jar dependencies and classes -->
<classpath refid="test.compile.class.path" />
+ <classpath refid="cobertura.classpath" />
+ <sysproperty key="net.sourceforge.cobertura.datafile" file="${basedir}/cobertura.ser" />
<!-- formatter to use for output -->
<formatter type="xml"/>
<batchtest fork="yes" todir="${test.report.dir}">
@@ -325,6 +351,22 @@
<report todir="${test.html.dir}" format="frames" />
</junitreport>
</target>
+ <target name="cobertura-report" description="cobertura-report" depends="test">
+ <cobertura-report format="html" destdir="${cubertura.report.dir}/html">
+ <fileset dir="${basedir}/bobo-browse/src">
+ <include name="com/browseengine/bobo/**/*.java" />
+ <exclude name="com/browseengine/bobo/protobuf/**/*.java" />
+ <exclude name="com/browseengine/bobo/service/**/*.java" />
+ </fileset>
+ </cobertura-report>
+ <cobertura-report format="xml" destdir="${cubertura.report.dir}/xml">
+ <fileset dir="${basedir}/bobo-browse/src">
+ <include name="com/browseengine/bobo/**/*.java" />
+ <exclude name="com/browseengine/bobo/protobuf/**/*.java" />
+ <exclude name="com/browseengine/bobo/service/**/*.java" />
+ </fileset>
+ </cobertura-report>
+ </target>
<target name="lucene-test" description="Lucene-test" depends="test-build">
<echo>=== Running Lucene 2.9 Perf ===</echo>
<java fork="true" classname="com.browseengine.bobo.test.LucenePerfTest">
View
6 ivy.xml
@@ -28,6 +28,8 @@
<dependency org="org.json" name="json" rev="20080701" conf="master"/>
<dependency org="junit" name="junit" rev="4.5" conf="test->master"/>
<dependency org="log4j" name="log4j" rev="1.2.15" conf="master"/>
+ <dependency org="org.apache.lucene" name="lucene-core" rev="2.9.1" conf="master"/>
+ <dependency org="org.apache.lucene" name="lucene-highlighter" rev="2.9.1" conf="master"/>
<dependency org="com.linkedin.kamikaze" name="kamikaze" rev="3.0.4" conf="master"/>
<dependency org="javax.servlet" name="servlet-api" rev="2.5" conf="master"/>
<dependency org="org.springframework" name="spring-webmvc" rev="2.5.5" conf="master"/>
@@ -36,6 +38,10 @@
<dependency org="org.apache.solr" name="solr-core" rev="1.4.0" conf="solr->master"/>
<dependency org="org.apache.solr" name="solr-solrj" rev="1.4.0" conf="solr->master"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.1" conf="solr->master"/>
+ <dependency org="net.sourceforge.cobertura" name="cobertura" rev="1.9.4.1" conf="master"/>
+ <dependency org="asm" name="asm" rev="3.0" conf="master"/>
+ <dependency org="asm" name="asm-tree" rev="3.0" conf="master"/>
+ <dependency org="oro" name="oro" rev="2.0.8" conf="master"/>
<dependency org="commons-codec" name="commons-codec" rev="1.4" conf="solr->master"/>
</dependencies>
</ivy-module>
View
552 test/src/com/browseengine/bobo/test/FacetMaxCountTest.java
@@ -0,0 +1,552 @@
+package com.browseengine.bobo.test;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.apache.log4j.Logger;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Field.Index;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
+
+import com.browseengine.bobo.api.BoboBrowser;
+import com.browseengine.bobo.api.BoboIndexReader;
+import com.browseengine.bobo.api.BrowseException;
+import com.browseengine.bobo.api.BrowseRequest;
+import com.browseengine.bobo.api.BrowseResult;
+import com.browseengine.bobo.api.BrowseSelection;
+import com.browseengine.bobo.api.FacetAccessible;
+import com.browseengine.bobo.api.FacetSpec;
+import com.browseengine.bobo.api.FacetSpec.FacetSortSpec;
+import com.browseengine.bobo.facets.FacetHandler;
+import com.browseengine.bobo.facets.impl.SimpleFacetHandler;
+import com.browseengine.bobo.index.BoboIndexer;
+import com.browseengine.bobo.index.digest.DataDigester;
+
+import junit.framework.TestCase;
+
+/**
+ * This class is to test all kinds of values of FacetSpec.max<0 (which should return all facet values)
+ * @author hyan
+ *
+ */
+public class FacetMaxCountTest extends TestCase {
+ static Logger log = Logger.getLogger(FacetMaxCountTest.class);
+ private List<FacetHandler<?>> _facetHandlers;
+ private int _documentSize;
+
+ private static class TestDataDigester extends DataDigester {
+ private List<FacetHandler<?>> _facetHandlers;
+ private Document[] _data;
+
+ TestDataDigester(List<FacetHandler<?>> facetHandlers,Document[] data){
+ super();
+ _facetHandlers = facetHandlers;
+ _data=data;
+ }
+ @Override
+ public void digest(DataHandler handler) throws IOException {
+ for (int i=0;i<_data.length;++i){
+ handler.handleDocument(_data[i]);
+ }
+ }
+ }
+
+ public FacetMaxCountTest(String testName){
+ super(testName);
+ _facetHandlers = createFacetHandlers();
+
+ _documentSize = 100;
+ String confdir = System.getProperty("conf.dir");
+ if (confdir == null) confdir ="./resource";
+ org.apache.log4j.PropertyConfigurator.configure(confdir+"/log4j.properties");
+ }
+
+ public Document[] createData(){
+ ArrayList<Document> dataList=new ArrayList<Document>();
+ for(int i=0; i<_documentSize; ++i)
+ {
+ String color = null;
+ String make = null;
+ String type = null;
+ if(i<10)
+ {
+ color = "orange";
+ make = "camry";
+ type = "ce";
+ }
+ else if(i<20)
+ {
+ color = "green";
+ make = "yaris";
+ type = "le";
+ }
+ else if(i<30)
+ {
+ color = "blue";
+ make = "yaris";
+ type = "le";
+ }
+ else if(i<40)
+ {
+ color = "yellow";
+ make = "yaris";
+ type = "le";
+ }
+ else if(i<50)
+ {
+ color = "red";
+ make = "yaris";
+ type = "le";
+ }
+ else if(i<60)
+ {
+ color = "red";
+ make = "corrola";
+ type = "le";
+ }
+ else
+ {
+ color = "red";
+ make = "avalon";
+ type = "ce";
+ }
+ String ID = Integer.toString(i);
+ Document d=new Document();
+ d.add(new Field("id",ID,Field.Store.YES,Index.NOT_ANALYZED_NO_NORMS));
+ d.add(new Field("color",color,Field.Store.YES,Index.NOT_ANALYZED_NO_NORMS));
+ d.add(new Field("make",make,Field.Store.YES,Index.NOT_ANALYZED_NO_NORMS));
+ d.add(new Field("type",type,Field.Store.YES,Index.NOT_ANALYZED_NO_NORMS));
+ dataList.add(d);
+ }
+ return dataList.toArray(new Document[dataList.size()]);
+}
+
+ private Directory createIndex(){
+ Directory dir = new RAMDirectory();
+ try {
+ Document[] data= createData();
+
+ TestDataDigester testDigester=new TestDataDigester(_facetHandlers,data);
+ BoboIndexer indexer=new BoboIndexer(testDigester,dir);
+ indexer.index();
+ IndexReader r = IndexReader.open(dir,false);
+ r.close();
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return dir;
+ }
+
+ public static List<FacetHandler<?>> createFacetHandlers(){
+ List<FacetHandler<?>> facetHandlers = new ArrayList<FacetHandler<?>>();
+ facetHandlers.add(new SimpleFacetHandler("id"));
+ facetHandlers.add(new SimpleFacetHandler("make"));
+ facetHandlers.add(new SimpleFacetHandler("color"));
+ facetHandlers.add(new SimpleFacetHandler("type"));
+ return facetHandlers;
+ }
+
+
+ public void testFacetSpecMaxCountGreaterThanFacetValueNum() throws Exception{
+ BrowseRequest br=new BrowseRequest();
+ br.setCount(10);
+ br.setOffset(0);
+
+ BrowseSelection colorSel=new BrowseSelection("color");
+ colorSel.addValue("red");
+ br.addSelection(colorSel);
+
+ FacetSpec spec=new FacetSpec();
+ spec.setExpandSelection(true);
+ spec.setOrderBy(FacetSortSpec.OrderHitsDesc);
+ spec.setMaxCount(15);
+
+ br.setFacetSpec("color", spec);
+ br.setFacetSpec("id", spec);
+ br.setFacetSpec("make", spec);
+ br.setFacetSpec("type", spec);
+
+ BrowseResult result = null;
+ BoboBrowser boboBrowser=null;
+ int expectedHitNum = 60;
+ int expectedPagedHitNum = 10;
+ int expectedFacetNum = 4;
+ try {
+ Directory ramIndexDir = createIndex();
+ IndexReader srcReader=IndexReader.open(ramIndexDir,true);
+ boboBrowser = new BoboBrowser(BoboIndexReader.getInstance(srcReader,_facetHandlers, null));
+ result = boboBrowser.browse(br);
+
+ assertEquals(expectedHitNum,result.getNumHits());
+ assertEquals(expectedPagedHitNum,result.getHits().length);
+ int facetNum = result.getFacetMap().entrySet().size();
+ assertEquals(expectedFacetNum,facetNum);
+
+ } catch (BrowseException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ catch(IOException ioe){
+ fail(ioe.getMessage());
+ }
+ finally{
+ if (boboBrowser!=null){
+ try {
+ if(result!=null) result.close();
+ boboBrowser.close();
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+ }
+
+ }
+
+ public void testFacetSpecMaxCountLessThanFacetNum() throws Exception{
+ BrowseRequest br=new BrowseRequest();
+ br.setCount(10);
+ br.setOffset(0);
+
+ FacetSpec spec=new FacetSpec();
+ spec.setExpandSelection(true);
+ spec.setOrderBy(FacetSortSpec.OrderValueAsc);
+ spec.setMinHitCount(1);
+ spec.setMaxCount(2);
+
+ br.setFacetSpec("color", spec);
+ br.setFacetSpec("id", spec);
+ br.setFacetSpec("make", spec);
+ br.setFacetSpec("type", spec);
+
+ BrowseResult result = null;
+ BoboBrowser boboBrowser=null;
+ int expectedHitNum = 100;
+ int expectedPagedHitNum = 10;
+ int expectedFacetNum = 4;
+ int expectedFacetValueNum_id = 2; // since MaxCount==2
+ int expectedFacetValueNum_make = 2;
+ int expectedFacetValueNum_color = 2;
+ int expectedFacetValueNum_type = 2;
+ try {
+ Directory ramIndexDir = createIndex();
+ IndexReader srcReader=IndexReader.open(ramIndexDir,true);
+ boboBrowser = new BoboBrowser(BoboIndexReader.getInstance(srcReader,_facetHandlers, null));
+ result = boboBrowser.browse(br);
+
+ assertEquals(expectedHitNum,result.getNumHits());
+ assertEquals(expectedPagedHitNum,result.getHits().length);
+ int facetNum = result.getFacetMap().entrySet().size();
+ assertEquals(expectedFacetNum,facetNum);
+
+ int facetValueNum;
+ for(Entry<String, FacetAccessible> entry: result.getFacetMap().entrySet())
+ {
+ if(entry.getKey().equals("id"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(facetValueNum, expectedFacetValueNum_id);
+ }
+ else if(entry.getKey().equals("make"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_make);
+ }
+ else if(entry.getKey().equals("color"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_color);
+ }
+ else //type
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_type);
+ }
+ }
+
+ } catch (BrowseException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ catch(IOException ioe){
+ fail(ioe.getMessage());
+ }
+ finally{
+ if (boboBrowser!=null){
+ try {
+ if(result!=null) result.close();
+ boboBrowser.close();
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+ }
+
+ }
+
+
+ public void testFacetSpecMaxLessThanZero() throws Exception{
+ BrowseRequest br=new BrowseRequest();
+ br.setCount(10);
+ br.setOffset(0);
+
+ FacetSpec spec=new FacetSpec();
+ spec.setExpandSelection(true);
+ spec.setOrderBy(FacetSortSpec.OrderValueAsc);
+ spec.setMinHitCount(1);
+ spec.setMaxCount(-1);
+
+ br.setFacetSpec("color", spec);
+ br.setFacetSpec("id", spec);
+ br.setFacetSpec("make", spec);
+ br.setFacetSpec("type", spec);
+
+ BrowseResult result = null;
+ BoboBrowser boboBrowser=null;
+ int expectedHitNum = 100;
+ int expectedPagedHitNum = 10;
+ int expectedFacetNum = 4;
+ int expectedFacetValueNum_id = 100;
+ int expectedFacetValueNum_make = 4;
+ int expectedFacetValueNum_color = 5;
+ int expectedFacetValueNum_type = 2;
+
+ try {
+ Directory ramIndexDir = createIndex();
+ IndexReader srcReader=IndexReader.open(ramIndexDir,true);
+ boboBrowser = new BoboBrowser(BoboIndexReader.getInstance(srcReader,_facetHandlers, null));
+ result = boboBrowser.browse(br);
+
+ assertEquals(expectedHitNum,result.getNumHits());
+ assertEquals(expectedPagedHitNum,result.getHits().length);
+ int facetNum = result.getFacetMap().entrySet().size();
+ assertEquals(expectedFacetNum,facetNum);
+
+ int facetValueNum;
+ for(Entry<String, FacetAccessible> entry: result.getFacetMap().entrySet())
+ {
+ if(entry.getKey().equals("id"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(facetValueNum, expectedFacetValueNum_id);
+ }
+ else if(entry.getKey().equals("make"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_make);
+ }
+ else if(entry.getKey().equals("color"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_color);
+ }
+ else //type
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_type);
+ }
+ }
+
+ } catch (BrowseException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ catch(IOException ioe){
+ fail(ioe.getMessage());
+ }
+ finally{
+ if (boboBrowser!=null){
+ try {
+ if(result!=null) result.close();
+ boboBrowser.close();
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+ }
+
+ }
+
+ public void testFacetSpecMaxLessThanZeroWithSingleSelection() throws Exception{
+ BrowseRequest br=new BrowseRequest();
+ br.setCount(10);
+ br.setOffset(0);
+
+ BrowseSelection colorSel=new BrowseSelection("color");
+ colorSel.addValue("red");
+ br.addSelection(colorSel);
+
+ FacetSpec spec=new FacetSpec();
+ spec.setExpandSelection(true);
+ spec.setOrderBy(FacetSortSpec.OrderValueAsc);
+ spec.setMaxCount(-1);
+ spec.setMinHitCount(1);
+
+ br.setFacetSpec("color", spec);
+ br.setFacetSpec("id", spec);
+ br.setFacetSpec("make", spec);
+ br.setFacetSpec("type", spec);
+
+ BrowseResult result = null;
+ BoboBrowser boboBrowser=null;
+ int expectedHitNum = 60;
+ int expectedPagedHitNum = 10;
+ int expectedFacetNum = 4;
+ int expectedFacetValueNum_id = 60;
+ int expectedFacetValueNum_make = 3;
+ int expectedFacetValueNum_color = 5;
+ int expectedFacetValueNum_type = 2;
+
+ try {
+ Directory ramIndexDir = createIndex();
+ IndexReader srcReader=IndexReader.open(ramIndexDir,true);
+ boboBrowser = new BoboBrowser(BoboIndexReader.getInstance(srcReader,_facetHandlers, null));
+ result = boboBrowser.browse(br);
+
+ assertEquals(expectedHitNum,result.getNumHits());
+ assertEquals(expectedPagedHitNum,result.getHits().length);
+ int facetNum = result.getFacetMap().entrySet().size();
+ assertEquals(expectedFacetNum,facetNum);
+
+ int facetValueNum;
+ for(Entry<String, FacetAccessible> entry: result.getFacetMap().entrySet())
+ {
+ if(entry.getKey().equals("id"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(facetValueNum, expectedFacetValueNum_id);
+ }
+ else if(entry.getKey().equals("make"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_make);
+ }
+ else if(entry.getKey().equals("color"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_color);
+ }
+ else //type
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_type);
+ }
+ }
+
+ } catch (BrowseException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ catch(IOException ioe){
+ fail(ioe.getMessage());
+ }
+ finally{
+ if (boboBrowser!=null){
+ try {
+ if(result!=null) result.close();
+ boboBrowser.close();
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+ }
+ }
+
+ public void testFacetSpecMaxLessThanZeroWithMultipleSelection() throws Exception{
+ BrowseRequest br=new BrowseRequest();
+ br.setCount(10);
+ br.setOffset(0);
+
+ BrowseSelection makeSel=new BrowseSelection("type");
+ makeSel.addValue("ce");
+ br.addSelection(makeSel);
+
+ BrowseSelection colorSel=new BrowseSelection("color");
+ colorSel.addValue("red");
+ br.addSelection(colorSel);
+
+ FacetSpec spec=new FacetSpec();
+ spec.setExpandSelection(true);
+ spec.setOrderBy(FacetSortSpec.OrderValueAsc);
+ spec.setMaxCount(-1);
+ spec.setMinHitCount(1);
+
+ br.setFacetSpec("make", spec);
+ br.setFacetSpec("color", spec);
+ br.setFacetSpec("id", spec);
+ br.setFacetSpec("type", spec);
+
+ BrowseResult result = null;
+ BoboBrowser boboBrowser=null;
+ int expectedHitNum = 40;
+ int expectedPagedHitNum = 10;
+ int expectedFacetNum = 4;
+ int expectedFacetValueNum_id = 40;
+ int expectedFacetValueNum_make = 1; // the number of make when "color=red" && "type=ce" is 1: avalon
+ int expectedFacetValueNum_color = 2; // the number of color when "type=ce" is 2: orange and red
+ int expectedFacetValueNum_type = 2;// the number of types when "color=red" is 2: le , ce
+
+ try {
+ Directory ramIndexDir = createIndex();
+ IndexReader srcReader=IndexReader.open(ramIndexDir,true);
+ boboBrowser = new BoboBrowser(BoboIndexReader.getInstance(srcReader,_facetHandlers, null));
+ result = boboBrowser.browse(br);
+
+ assertEquals(expectedHitNum,result.getNumHits());
+ assertEquals(expectedPagedHitNum,result.getHits().length);
+ int facetNum = result.getFacetMap().entrySet().size();
+ assertEquals(expectedFacetNum,facetNum);
+
+ int facetValueNum;
+ for(Entry<String, FacetAccessible> entry: result.getFacetMap().entrySet())
+ {
+ if(entry.getKey().equals("id"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(facetValueNum, expectedFacetValueNum_id);
+ }
+ else if(entry.getKey().equals("make"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_make);
+ }
+ else if(entry.getKey().equals("color"))
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_color);
+ }
+ else //type
+ {
+ facetValueNum = entry.getValue().getFacets().size();
+ assertEquals(entry.getValue().getFacets().size(), expectedFacetValueNum_type);
+ }
+
+ }
+
+ } catch (BrowseException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ catch(IOException ioe){
+ fail(ioe.getMessage());
+ }
+ finally{
+ if (boboBrowser!=null){
+ try {
+ if(result!=null) result.close();
+ boboBrowser.close();
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+ }
+
+ }
+}
View
60 test/src/com/browseengine/bobo/test/FacetNameTest.java
@@ -51,6 +51,7 @@
import com.browseengine.bobo.api.FacetSpec;
import com.browseengine.bobo.api.FacetSpec.FacetSortSpec;
import com.browseengine.bobo.facets.FacetHandler;
+import com.browseengine.bobo.facets.impl.MultiValueFacetHandler;
import com.browseengine.bobo.facets.impl.SimpleFacetHandler;
import com.browseengine.bobo.index.BoboIndexer;
import com.browseengine.bobo.index.digest.DataDigester;
@@ -141,8 +142,8 @@ private Directory createIndex(){
List<FacetHandler<?>> facetHandlers = new ArrayList<FacetHandler<?>>();
facetHandlers.add(new SimpleFacetHandler("id"));
facetHandlers.add(new SimpleFacetHandler("make"));
- facetHandlers.add(new SimpleFacetHandler("mycolor", "color"));
-
+ // facetHandlers.add(new SimpleFacetHandler("mycolor", "color"));
+ facetHandlers.add(new MultiValueFacetHandler("multicolor", "color"));
return facetHandlers;
}
@@ -168,6 +169,61 @@ public void testFacetNameForSimpleFacetHandler() throws Exception{
br.setFacetSpec("mycolor", spec);
br.setFacetSpec("id", spec);
br.setFacetSpec("make", spec);
+ br.setFacetSpec("multicolor", spec);
+
+ BrowseResult result = null;
+ BoboBrowser boboBrowser=null;
+ int expectedHitNum = 3;
+ try {
+ Directory ramIndexDir = createIndex();
+ IndexReader srcReader=IndexReader.open(ramIndexDir,true);
+ boboBrowser = new BoboBrowser(BoboIndexReader.getInstance(srcReader,_facetHandlers, null));
+ result = boboBrowser.browse(br);
+
+ assertEquals(expectedHitNum,result.getNumHits());
+ } catch (BrowseException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ catch(IOException ioe){
+ fail(ioe.getMessage());
+ }
+ finally{
+ if (boboBrowser!=null){
+ try {
+ if(result!=null) result.close();
+ boboBrowser.close();
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+ }
+
+ }
+
+
+ public void testFacetNameForMultiValueFacetHandler() throws Exception{
+ BrowseRequest br=new BrowseRequest();
+ br.setCount(20);
+ br.setOffset(0);
+
+ BrowseSelection colorSel=new BrowseSelection("multicolor");
+ colorSel.addValue("yellow");
+ br.addSelection(colorSel);
+
+ BrowseSelection makeSel=new BrowseSelection("make");
+ makeSel.addValue("rav4");
+ br.addSelection(makeSel);
+
+ FacetSpec spec=new FacetSpec();
+ spec.setExpandSelection(true);
+ spec.setOrderBy(FacetSortSpec.OrderHitsDesc);
+ spec.setMaxCount(15);
+
+ br.setFacetSpec("mycolor", spec);
+ br.setFacetSpec("id", spec);
+ br.setFacetSpec("make", spec);
+ br.setFacetSpec("multicolor", spec);
BrowseResult result = null;
BoboBrowser boboBrowser=null;
View
1  test/src/com/browseengine/bobo/test/UnitTestSuite.java
@@ -45,6 +45,7 @@ public static Test suite(){
suite.addTestSuite(BoboFacetIteratorTest.class);
suite.addTestSuite(FacetNotValuesTest.class);
suite.addTestSuite(FacetNameTest.class);
+ suite.addTestSuite(FacetMaxCountTest.class);
return suite;
}
Something went wrong with that request. Please try again.