gpt4 book ai didi

unit-testing - Grails - Apache Tika 插件测试应用失败

转载 作者:行者123 更新时间:2023-12-02 15:21:20 26 4
gpt4 key购买 nike

我正在学习如何使用 Apache Tika plugin .我刚刚从 github 复制了代码并且在单元测试时出现失败错误。

这是unit test

import grails.test.mixin.TestFor
import spock.lang.Specification

/**
* Test for tikaService: try to parse test data.
*/
@TestFor(TikaService)
class TikaServiceSpec extends Specification {

def 'Parse a word file to XML'() {
given:
def file = new File('parserTest.doc')

when:
def xml = service.parseFile(file)

then:
def doc = new XmlSlurper().parseText(xml)
doc.body.p.find{
it.text() == 'This is a simple test document'
}
}
}

这是我得到的错误。
Running 5 unit tests... 8 of 8
| Failure: Parse a word file to XML(com.myApp.TikaServiceSpec)
| Condition not satisfied:
doc.body.p.find{ it.text() == 'This is a simple test document' }
| | | |
| | | groovy.util.slurpersupport.NoChildren@4c2a4e84
| | Tika Parser Test
| | This is a simple test document
| Tika Parser Test
| This is a simple test document
Tika Parser Test
This is a simple test document
at com.myApp.TikaServiceSpec.Parse a word file to XML(TikaServiceSpec.groovy:21)

我究竟做错了什么?
dependencies {
compile('org.apache.tika:tika-core:0.7')
compile('org.apache.tika:tika-parsers:0.7') { excludes "xercesImpl", "xmlParserAPIs", "xml-apis", "log4j" }
}

最佳答案

感谢@Gagravarr,问题已经解决。我使用了 1.12 版本,它工作正常。

repo 是https://repo1.maven.org/maven2/org/apache/tika/

关于unit-testing - Grails - Apache Tika 插件测试应用失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35492921/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com