Solr(11)Solr Testing

Solr(11)SolrTesting

ErrorMessage:

sbt.ResolveException:unresolveddependency:org.restlet.jee#org.restlet;2.3.0:notfound

unresolveddependency:org.restlet.jee#org.restlet.ext.servlet;2.3.0:notfound

Solution:

resolvers+="RestletRepositories"at"http://maven.restlet.org"

Dependency

libraryDependencies++=Seq(

"com.amazonaws"%"aws-java-sdk"%"1.10.6",//

"org.slf4j"%"slf4j-api"%"1.7.12",//MIT

"org.slf4j"%"slf4j-log4j12"%"1.7.12",

"com.typesafe"%"config"%"1.3.0",

"com.etaty.rediscala"%%"rediscala"%"1.4.2",

"org.msgpack"%"msgpack"%"0.6.12",

"org.apache.solr"%"solr-solrj"%"5.3.0",

"com.thoughtworks.xstream"%"xstream"%"1.4.8",

"commons-lang"%"commons-lang"%"2.6",//htmlescape

"org.joda"%"joda-convert"%"1.7",

"org.scalatest"%%"scalatest"%"2.2.0"%"test",//Apachev2

"org.mockito"%"mockito-all"%"1.9.5"%"test",//MIT

"com.orange.redis-embedded"%"embedded-redis"%"0.6"%"test",

"org.apache.solr"%"solr-core"%"5.3.0"%"test"

)

CoreTestClass

packagecom.sillycat.jobsconsumer.persistence

importjava.io.File

importcom.sillycat.jobsconsumer.models.Job

importcom.sillycat.jobsconsumer.utilities.IncludeConfig

importorg.apache.commons.io.FileUtils

importorg.apache.solr.client.solrj.SolrClient

importorg.apache.solr.client.solrj.embedded.EmbeddedSolrServer

importorg.apache.solr.core.CoreContainer

importorg.scalatest.{BeforeAndAfterAll,Matchers,FunSpec}

importscala.collection.mutable.ListBuffer

importjava.nio.file.{Paths,Path}

/**

*Createdbycarlon8/7/15.

*/

classSolrJDAOSpecextendsFunSpecwithMatcherswithBeforeAndAfterAllwithIncludeConfig{

valsolrHome="/opt/solr/server"

objectSolrJDAOEmbeddedextendsIncludeSolrJDAO{

defgetSolrClient:SolrClient={

newEmbeddedSolrServer(CoreContainer.createAndLoad(solrHome,newFile(solrHome+"/solr/solr.xml")),"jobs")

}

}

overridedefbeforeAll(){

if(config.getString("build.env").equals("test")){

}

}

overridedefafterAll(){

if(config.getString("build.env").equals("test")){

SolrJDAOEmbedded.releaseResource

removeIndexDirectory

}

}

describe("SolrDAO"){

describe("#addandquery"){

it("AddonesinglejobtoSolr"){

valjob1=newJob("id1","title1","http://www.jobs2careers.com","ref1","jobs2careers","desc1","category1")

SolrJDAOEmbedded.addJobs(List(job1))

SolrJDAOEmbedded.commit

}

}

}

defremoveIndexDirectory(){

valindexDir1=newFile(solrHome,"/solr/jobs/data")

FileUtils.deleteDirectory(indexDir1)

valindexDir2=newFile(solrHome,"/solr/collection1/data")

FileUtils.deleteDirectory(indexDir2)

}

}

Butitdoesnotworks.

References:

https://blog.synyx.de/2011/01/integration-tests-for-your-solr-config/

https://wiki.apache.org/solr/TestingSolr

http://stackoverflow.com/questions/10796750/is-there-a-recommended-way-for-solr-3-6-junit-testing

caseclassmapper

https://github.com/takezoe/solr-scala-client/blob/bbebccd3997e5300e7fa69d6873037349721815f/src/main/scala/jp/sf/amateras/solr/scala/CaseClassMapper.scala

BatchRegister

https://github.com/takezoe/solr-scala-client/blob/bbebccd3997e5300e7fa69d6873037349721815f/src/main/scala/jp/sf/amateras/solr/scala/BatchRegister.scala

SolrClient

https://github.com/takezoe/solr-scala-client/blob/bbebccd3997e5300e7fa69d6873037349721815f/src/main/scala/jp/sf/amateras/solr/scala/SolrClient.scala

相关推荐