Skip to content

Commit

Permalink
Update search test and add Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
neitomic committed Jun 16, 2017
1 parent d692c6c commit cf70479
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Elasticsearch Java Http client wrapper
> An Elasticsearch RestClient wrapped with entities and async method for Scala
[![Build Status](https://travis-ci.org/thanhtien522/es-http-client.svg?branch=master)](https://travis-ci.org/thanhtien522/es-http-client)
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import org.elasticsearch.client.http.entities.{BasicAuthInfo, NoAuth}
import org.elasticsearch.index.query.QueryBuilders
import org.scalatest.{BeforeAndAfterAllConfigMap, ConfigMap, FunSuite}
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterAllConfigMap, ConfigMap, FunSuite}

import scala.io.Source

class EsHttpClientSearchTest extends FunSuite with BeforeAndAfterAllConfigMap {
class EsHttpClientSearchTest extends FunSuite with BeforeAndAfterAll {

var client: ESHttpClient = null
private val index = "test"
private val `type` = "doc"

val objectMapper = new ObjectMapper().registerModule(DefaultScalaModule)

override def beforeAll(configMap: ConfigMap): Unit = {
val auth = (configMap.getOptional[String]("user"), configMap.getOptional[String]("pass")) match {
override def beforeAll(): Unit = {
val auth = (Option(System.getProperty("auth.user")), Option(System.getProperty("auth.pass"))) match {
case (Some(user), Some(pass)) => BasicAuthInfo(user, pass)
case _ => NoAuth()
}
client = new ESHttpClient(configMap.getWithDefault("servers", Seq("localhost:9200")),auth)
client = new ESHttpClient(System.getProperty("servers", "localhost:9200").split(","), auth)
}

@throws[Exception]
def testDocWithAllTypes(): Unit = {
test("test doc with all types should success") {
val docBody = Source.fromURL(getClass.getResource("/org/elasticsearch/search/query/all-example-document.json")).mkString
val id = "1"
val idxSetting = Source.fromURL(getClass.getResource("/org/elasticsearch/search/query/all-query-index.json")).mkString
Expand Down Expand Up @@ -70,8 +69,8 @@ class EsHttpClientSearchTest extends FunSuite with BeforeAndAfterAllConfigMap {
assert(client.deleteIndies(index).acknowledged)
}

override def afterAll(configMap: ConfigMap): Unit = {
super.afterAll(configMap)
override def afterAll(): Unit = {
super.afterAll()
client.close()
}

Expand Down

0 comments on commit cf70479

Please sign in to comment.