public void testMakeTitleDocument() { IndexId iid = IndexId.get("en-titles"); String text = "Some very simple text used for testing\n== Heading 1 ==\nParagraph\n[[Category:Category1]]"; int references = 100; int redirectTargetNamespace = -1; ArrayList<Redirect> redirects = new ArrayList<Redirect>(); redirects.add(new Redirect(0, "Redirect", 2)); ArrayList<RelatedTitle> rel = new ArrayList<RelatedTitle>(); rel.add(new RelatedTitle(new Title(0, "Related test"), 50)); Hashtable<String, Integer> anchors = new Hashtable<String, Integer>(); anchors.put("Anchor", 20); Date date = new Date(); Article article = new Article( 10, 0, "Test page", text, null, references, redirectTargetNamespace, 0, redirects, rel, anchors, date); analyzer = Analyzers.getIndexerAnalyzer(new FieldBuilder(iid)); highlightAnalyzer = Analyzers.getHighlightAnalyzer(iid, false); try { doc = WikiIndexModifier.makeTitleDocument( article, analyzer, highlightAnalyzer, iid, "wiki", "enwiki", false, new HashSet<String>()); assertEquals("1 [test] 1 [page] 255 [redirect]", tokens("alttitle")); assertEquals("wiki:10", value("pageid")); assertEquals("1 [wiki:0:Test page]", tokens("key")); assertEquals("wiki", value("suffix")); assertEquals("1 [enwiki]", tokens("dbname")); assertEquals("0", value("namespace")); assertEquals("Test page", value("title")); } catch (IOException e) { fail(); } }
public void testMakeDocuments() { IndexId iid = IndexId.get("enwiki"); String text = "Some very [[simple]] text used for testing\n== Heading 1 ==\nParagraph\n[[Category:Category1]]"; int references = 100; int redirectTargetNamespace = -1; ArrayList<Redirect> redirects = new ArrayList<Redirect>(); redirects.add(new Redirect(0, "Redirect", 2)); ArrayList<RelatedTitle> rel = new ArrayList<RelatedTitle>(); rel.add(new RelatedTitle(new Title(0, "Related test"), 50)); Hashtable<String, Integer> anchors = new Hashtable<String, Integer>(); anchors.put("Anchor", 20); Date date = new Date(); Article article = new Article( 10, 0, "Test page", text, null, references, redirectTargetNamespace, 0, redirects, rel, anchors, date); analyzer = Analyzers.getIndexerAnalyzer(new FieldBuilder(iid)); try { doc = WikiIndexModifier.makeDocument( article, new FieldBuilder(iid), iid, new HashSet<String>(), analyzer); assertEquals( "1 [test] 1 [page] 3 [some] 1 [very] 1 [simple] 1 [text] 1 [used] 0 [use] 1 [for] 1 [testing] 0 [test] 500 [heading] 1 [1] 1 [paragraph] 1 [category1] 10 [test] 1 [page] 10 [anchor] 10 [redirect]", tokens("contents")); assertEquals("1 [test] 1 [page]", tokens("title")); assertEquals("1 [test] 1 [page] 255 [anchor] 256 [redirect]", tokens("alttitle")); assertEquals("1 [related] 1 [test]", tokens("related")); assertEquals("1 [heading] 1 [1]", tokens("sections")); assertEquals("1 [category1]", tokens("category")); assertEquals("10", value("key")); assertEquals("103", value("rank")); assertEquals("1 [0:test page]", tokens("prefix")); assertEquals("1 [egap] 1 [tset]", tokens("reverse_title")); } catch (IOException e) { fail(); } }