How to debug Solr test cases in Eclipse?

瘦欲@ 提交于 2019-12-25 03:24:11

问题


When I try to run a Solr test case from Eclipse (Right-Click > Run As > JUnit Test), I get the following printed to the Eclipse console:

Feb 27, 2012 5:21:06 PM org.apache.solr.SolrTestCaseJ4 deleteCore
INFO: ###deleteCore

The whole process runs and exits very quickly without running the actual test case.

I have tried to set my working directory according to the instructions at http://wiki.apache.org/solr/TestingSolr to no avail. Those instructions refer to a directory that doesn't actually exist any more (src/test/test-files), so I tried setting it to solr/core/src/test-files without any luck. I'm using the latest SOLR trunk (as of Feb 27,2012)

What am I missing?


回答1:


From your own answer looks like you're adding to the classpath a jar which contains the code which should already be in your workspace, thus in your classpath. The Solr build file has a really handy eclipse target which generates the eclipse project, so you can import it in one click. Just run ant eclipse from the root directory and you shouldn't have problems with classpath.




回答2:


I hadn't noticed it before, but the test case was throwing an exception saying

A SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene40' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: []

I solved the problem by adding lucene/build/core/lucene-core-4.0-SNAPSHOT.jar to the classpath in the test case's Run Configuration. It feels like I shouldn't have to do this, but I don't have time to investigate further.

If anyone else can tell me how to remove this dependency, I'll attribute the answer to you.

I also had to set the working directory in my Run Configuration to solr/core/src/test-files



来源:https://stackoverflow.com/questions/9474625/how-to-debug-solr-test-cases-in-eclipse

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!