[ 
https://issues.apache.org/jira/browse/GEARPUMP-204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15512294#comment-15512294
 ] 

ASF GitHub Bot commented on GEARPUMP-204:
-----------------------------------------

Github user manuzhang commented on a diff in the pull request:

    https://github.com/apache/incubator-gearpump/pull/86#discussion_r79979548
  
    --- Diff: 
external/hbase/src/test/scala/org/apache/gearpump/external/hbase/HBaseSinkSpec.scala
 ---
    @@ -17,24 +17,52 @@
      */
     package org.apache.gearpump.external.hbase
     
    +import org.apache.gearpump.cluster.UserConfig
    +import org.apache.gearpump.streaming.MockUtil
    +import org.apache.gearpump.streaming.task.TaskContext
    +import org.apache.hadoop.conf.Configuration
    +import org.apache.hadoop.hbase.TableName
    +import org.apache.hadoop.hbase.client._
    +import org.apache.hadoop.hbase.util.Bytes
    +import org.mockito.Mockito._
    +import org.scalatest.mock.MockitoSugar
     import org.scalatest.prop.PropertyChecks
     import org.scalatest.{Matchers, PropSpec}
     
    -class HBaseSinkSpec extends PropSpec with PropertyChecks with Matchers {
    +class HBaseSinkSpec extends PropSpec with PropertyChecks with Matchers 
with MockitoSugar {
     
       property("HBaseSink should insert a row successfully") {
     
    -  //  import Mockito._
    -  //  val htable = Mockito.mock(classOf[HTable])
    -  //  val row = "row"
    -  //  val group = "group"
    -  //  val name = "name"
    -  //  val value = "1.2"
    -  //  val put = new Put(Bytes.toBytes(row))
    -  //  put.add(Bytes.toBytes(group), Bytes.toBytes(name), 
Bytes.toBytes(value))
    -  //  val hbaseSink = HBaseSink(htable)
    -  //  hbaseSink.insert(put)
    -  //  verify(htable).put(put)
    +    val table = mock[Table]
    +    val config = mock[Configuration]
    +    val conn = mock[Connection]
    +    val taskContext = mock[TaskContext]
    +
    +
    +    val map = Map[String, String]("HBASESINK" -> "hbasesink", "TABLE_NAME" 
-> "hbase.table.name",
    +      "COLUMN_FAMILY" -> "hbase.table.column.family", "COLUMN_NAME" -> 
"hbase.table.column.name",
    +      "HBASE_USER" -> "hbase.user", "GEARPUMP_KERBEROS_PRINCIPAL" -> 
"gearpump.kerberos.principal",
    +      "GEARPUMP_KEYTAB_FILE" -> "gearpump.keytab.file"
    +    )
    +    val userconfig = new UserConfig(map)
    +    val tablename = "hbase"
    +    val row = "row"
    +    val group = "group"
    +    val name = "name"
    +    val value = "1.2"
    +
    +    when(conn.getTable(TableName.valueOf(tablename))).thenReturn(table)
    +
    +    val connection = HBaseSink.getConn(conn, true, userconfig, config)
    --- End diff --
    
    simply use mocked `conn` here


> Add unit test for external_hbase module
> ---------------------------------------
>
>                 Key: GEARPUMP-204
>                 URL: https://issues.apache.org/jira/browse/GEARPUMP-204
>             Project: Apache Gearpump
>          Issue Type: Improvement
>            Reporter: Manu Zhang
>            Assignee: Kaifang Bao
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to