Search in sources :

Example 16 with AccessResultDataImpl

use of org.codelibs.fess.crawler.entity.AccessResultDataImpl in project fess-crawler by codelibs.

the class XmlTransformerTest method test_getData.

public void test_getData() throws Exception {
    final String value = // 
    "<?xml version=\"1.0\"?>\n" + // 
    "<doc>\n" + // 
    "<field name=\"title\">タイトル</field>\n" + // 
    "<field name=\"body\">第一章 第一節 ほげほげふがふが LINK 第2章 第2節</field>\n" + // 
    "<field name=\"list\"><list><item>リスト1</item><item>リスト2</item><item>リスト3</item></list></field>\n" + "</doc>";
    final AccessResultDataImpl accessResultDataImpl = new AccessResultDataImpl();
    accessResultDataImpl.setData(value.getBytes(Constants.UTF_8));
    accessResultDataImpl.setEncoding(Constants.UTF_8);
    accessResultDataImpl.setTransformerName("xmlTransformer");
    final Object obj = xmlTransformer.getData(accessResultDataImpl);
    assertEquals(value, obj);
}
Also used : AccessResultDataImpl(org.codelibs.fess.crawler.entity.AccessResultDataImpl)

Example 17 with AccessResultDataImpl

use of org.codelibs.fess.crawler.entity.AccessResultDataImpl in project fess-crawler by codelibs.

the class XmlTransformerTest method test_getData_nullData.

public void test_getData_nullData() throws Exception {
    final String value = // 
    "<?xml version=\"1.0\"?>\n" + // 
    "<doc>\n" + // 
    "<field name=\"title\">タイトル</field>\n" + // 
    "<field name=\"body\">第一章 第一節 ほげほげふがふが LINK 第2章 第2節</field>\n" + "</doc>";
    final AccessResultDataImpl accessResultDataImpl = new AccessResultDataImpl();
    accessResultDataImpl.setData(null);
    accessResultDataImpl.setEncoding(Constants.UTF_8);
    accessResultDataImpl.setTransformerName("xmlTransformer");
    final Object obj = xmlTransformer.getData(accessResultDataImpl);
    assertNull(obj);
}
Also used : AccessResultDataImpl(org.codelibs.fess.crawler.entity.AccessResultDataImpl)

Example 18 with AccessResultDataImpl

use of org.codelibs.fess.crawler.entity.AccessResultDataImpl in project fess-crawler by codelibs.

the class XmlTransformerTest method test_getData_dataMap_entity.

public void test_getData_dataMap_entity() throws Exception {
    final String value = // 
    "<?xml version=\"1.0\"?>\n" + // 
    "<doc>\n" + // 
    "<field name=\"title\">タイトル</field>\n" + // 
    "<field name=\"body\">第一章 第一節 ほげほげふがふが LINK 第2章 第2節</field>\n" + // 
    "<field name=\"list\"><list><item>リスト1</item><item>リスト2</item><item>リスト3</item></list></field>\n" + "</doc>";
    final AccessResultDataImpl accessResultDataImpl = new AccessResultDataImpl();
    accessResultDataImpl.setData(value.getBytes(Constants.UTF_8));
    accessResultDataImpl.setEncoding(Constants.UTF_8);
    accessResultDataImpl.setTransformerName("xmlEntityTransformer");
    final Object obj = xmlEntityTransformer.getData(accessResultDataImpl);
    assertTrue(obj instanceof TestEntity);
    final TestEntity entity = (TestEntity) obj;
    assertEquals("タイトル", entity.getTitle());
    assertEquals("第一章 第一節 ほげほげふがふが LINK 第2章 第2節", entity.getBody());
    final List<String> list = new ArrayList<String>();
    list.add("リスト1");
    list.add("リスト2");
    list.add("リスト3");
    assertEquals(list, entity.getList());
}
Also used : TestEntity(org.codelibs.fess.crawler.entity.TestEntity) ArrayList(java.util.ArrayList) AccessResultDataImpl(org.codelibs.fess.crawler.entity.AccessResultDataImpl)

Example 19 with AccessResultDataImpl

use of org.codelibs.fess.crawler.entity.AccessResultDataImpl in project fess-crawler by codelibs.

the class XmlTransformerTest method test_getData_dataMap_entity_emptyList.

public void test_getData_dataMap_entity_emptyList() throws Exception {
    final String value = // 
    "<?xml version=\"1.0\"?>\n" + // 
    "<doc>\n" + // 
    "<field name=\"title\">タイトル</field>\n" + // 
    "<field name=\"body\">第一章 第一節 ほげほげふがふが LINK 第2章 第2節</field>\n" + // 
    "<field name=\"list\"><list></list></field>\n" + "</doc>";
    final AccessResultDataImpl accessResultDataImpl = new AccessResultDataImpl();
    accessResultDataImpl.setData(value.getBytes(Constants.UTF_8));
    accessResultDataImpl.setEncoding(Constants.UTF_8);
    accessResultDataImpl.setTransformerName("xmlEntityTransformer");
    final Object obj = xmlEntityTransformer.getData(accessResultDataImpl);
    assertTrue(obj instanceof TestEntity);
    final TestEntity entity = (TestEntity) obj;
    assertEquals("タイトル", entity.getTitle());
    assertEquals("第一章 第一節 ほげほげふがふが LINK 第2章 第2節", entity.getBody());
    final List<String> list = new ArrayList<String>();
    assertEquals(list, entity.getList());
}
Also used : TestEntity(org.codelibs.fess.crawler.entity.TestEntity) ArrayList(java.util.ArrayList) AccessResultDataImpl(org.codelibs.fess.crawler.entity.AccessResultDataImpl)

Example 20 with AccessResultDataImpl

use of org.codelibs.fess.crawler.entity.AccessResultDataImpl in project fess-crawler by codelibs.

the class XpathTransformerTest method test_getData_dataMap_entity_emptyList.

public void test_getData_dataMap_entity_emptyList() throws Exception {
    final String value = // 
    "<?xml version=\"1.0\"?>\n" + // 
    "<doc>\n" + // 
    "<field name=\"title\">タイトル</field>\n" + // 
    "<field name=\"body\">第一章 第一節 ほげほげふがふが LINK 第2章 第2節</field>\n" + // 
    "<field name=\"list\"><list></list></field>\n" + "</doc>";
    final AccessResultDataImpl accessResultDataImpl = new AccessResultDataImpl();
    accessResultDataImpl.setData(value.getBytes(Constants.UTF_8));
    accessResultDataImpl.setEncoding(Constants.UTF_8);
    accessResultDataImpl.setTransformerName("xpathEntityTransformer");
    final Object obj = xpathEntityTransformer.getData(accessResultDataImpl);
    assertTrue(obj instanceof TestEntity);
    final TestEntity entity = (TestEntity) obj;
    assertEquals("タイトル", entity.getTitle());
    assertEquals("第一章 第一節 ほげほげふがふが LINK 第2章 第2節", entity.getBody());
    final List<String> list = new ArrayList<String>();
    assertEquals(list, entity.getList());
}
Also used : TestEntity(org.codelibs.fess.crawler.entity.TestEntity) ArrayList(java.util.ArrayList) AccessResultDataImpl(org.codelibs.fess.crawler.entity.AccessResultDataImpl)

Aggregations

AccessResultDataImpl (org.codelibs.fess.crawler.entity.AccessResultDataImpl)24 ArrayList (java.util.ArrayList)6 CrawlerSystemException (org.codelibs.fess.crawler.exception.CrawlerSystemException)6 TestEntity (org.codelibs.fess.crawler.entity.TestEntity)4 Map (java.util.Map)2 File (java.io.File)1 InputStream (java.io.InputStream)1