From c026e446883ddab5353e8b935b3c8d653ca98104 Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Fri, 9 Oct 2009 08:23:35 +0000 Subject: [PATCH] testcase for flatten=true git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@823451 13f79535-47bb-0310-9956-ffa450edef68 --- .../dataimport/TestXPathEntityProcessor.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathEntityProcessor.java b/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathEntityProcessor.java index 91963e8c66f..8a446b1aff1 100644 --- a/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathEntityProcessor.java +++ b/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathEntityProcessor.java @@ -88,6 +88,26 @@ public class TestXPathEntityProcessor { Assert.assertEquals(2, ((List)result.get(0).get("a")).size()); } + @Test + public void testMultiValuedFlatten() throws Exception { + Map entityAttrs = createMap("name", "e", "url", "testdata.xml", + XPathEntityProcessor.FOR_EACH, "/root"); + List fields = new ArrayList(); + fields.add(createMap("column", "a", "xpath", "/root/a" ,"flatten","true")); + Context c = AbstractDataImportHandlerTest.getContext(null, + new VariableResolverImpl(), getDataSource(testXmlFlatten), Context.FULL_DUMP, fields, entityAttrs); + XPathEntityProcessor xPathEntityProcessor = new XPathEntityProcessor(); + xPathEntityProcessor.init(c); + Map result = null; + while (true) { + Map row = xPathEntityProcessor.nextRow(); + if (row == null) + break; + result = row; + } + Assert.assertEquals("1B2", result.get("a")); + } + @Test public void withFieldsAndXpathStream() throws Exception { Map entityAttrs = createMap("name", "e", "url", "cd.xml", @@ -204,4 +224,6 @@ public class TestXPathEntityProcessor { + "\t\t1982\n" + "\t\n" + "\t"; private static final String testXml = "12"; + + private static final String testXmlFlatten = "1B2"; }