You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Priya Ch <le...@gmail.com> on 2015/10/29 12:27:47 UTC

Mock Cassandra DB Connection in Unit Testing

Hi All,

  For my  Spark Streaming code, which writes the results to Cassandra DB, I
need to write Unit test cases. what are the available test frameworks to
mock the connection to Cassandra DB ?

Re: Mock Cassandra DB Connection in Unit Testing

Posted by Adrian Tanase <at...@adobe.com>.
Does it need to be a mock? Can you use sc.parallelize(data)?

From: Priya Ch
Date: Thursday, October 29, 2015 at 2:00 PM
To: Василец Дмитрий
Cc: "user@spark.apache.org<ma...@spark.apache.org>", "spark-connector-user@lists.datastax.com<ma...@lists.datastax.com>"
Subject: Re: Mock Cassandra DB Connection in Unit Testing

One more question, if i have a function which takes RDD as a parameter, how do we mock an RDD ??

On Thu, Oct 29, 2015 at 5:20 PM, Priya Ch <le...@gmail.com>> wrote:
How do we do it for Cassandra..can we use the same Mocking ? EmbeddedCassandra Server is available with CassandraUnit. Can this be used in Spark Code as well ? I mean with Scala code ?

On Thu, Oct 29, 2015 at 5:03 PM, Василец Дмитрий <pr...@gmail.com>> wrote:
there is example how i mock mysql
import org.scalamock.scalatest.MockFactory
 val connectionMock = mock[java.sql.Connection]
 val statementMock = mock[PreparedStatement]
    (conMock.prepareStatement(_: String)).expects(sql.toString).returning(statementMock)
    (statementMock.executeUpdate _).expects()


On Thu, Oct 29, 2015 at 12:27 PM, Priya Ch <le...@gmail.com>> wrote:
Hi All,

  For my  Spark Streaming code, which writes the results to Cassandra DB, I need to write Unit test cases. what are the available test frameworks to mock the connection to Cassandra DB ?




Re: Mock Cassandra DB Connection in Unit Testing

Posted by Priya Ch <le...@gmail.com>.
One more question, if i have a function which takes RDD as a parameter, how
do we mock an RDD ??

On Thu, Oct 29, 2015 at 5:20 PM, Priya Ch <le...@gmail.com>
wrote:

> How do we do it for Cassandra..can we use the same Mocking ?
> EmbeddedCassandra Server is available with CassandraUnit. Can this be used
> in Spark Code as well ? I mean with Scala code ?
>
> On Thu, Oct 29, 2015 at 5:03 PM, Василец Дмитрий <pronix.service@gmail.com
> > wrote:
>
>> there is example how i mock mysql
>> import org.scalamock.scalatest.MockFactory
>>  val connectionMock = mock[java.sql.Connection]
>>  val statementMock = mock[PreparedStatement]
>>     (conMock.prepareStatement(_:
>> String)).expects(sql.toString).returning(statementMock)
>>     (statementMock.executeUpdate _).expects()
>>
>>
>> On Thu, Oct 29, 2015 at 12:27 PM, Priya Ch <le...@gmail.com>
>> wrote:
>>
>>> Hi All,
>>>
>>>   For my  Spark Streaming code, which writes the results to Cassandra
>>> DB, I need to write Unit test cases. what are the available test frameworks
>>> to mock the connection to Cassandra DB ?
>>>
>>
>>
>

Re: Mock Cassandra DB Connection in Unit Testing

Posted by Priya Ch <le...@gmail.com>.
How do we do it for Cassandra..can we use the same Mocking ?
EmbeddedCassandra Server is available with CassandraUnit. Can this be used
in Spark Code as well ? I mean with Scala code ?

On Thu, Oct 29, 2015 at 5:03 PM, Василец Дмитрий <pr...@gmail.com>
wrote:

> there is example how i mock mysql
> import org.scalamock.scalatest.MockFactory
>  val connectionMock = mock[java.sql.Connection]
>  val statementMock = mock[PreparedStatement]
>     (conMock.prepareStatement(_:
> String)).expects(sql.toString).returning(statementMock)
>     (statementMock.executeUpdate _).expects()
>
>
> On Thu, Oct 29, 2015 at 12:27 PM, Priya Ch <le...@gmail.com>
> wrote:
>
>> Hi All,
>>
>>   For my  Spark Streaming code, which writes the results to Cassandra DB,
>> I need to write Unit test cases. what are the available test frameworks to
>> mock the connection to Cassandra DB ?
>>
>
>

Re: Mock Cassandra DB Connection in Unit Testing

Posted by Василец Дмитрий <pr...@gmail.com>.
there is example how i mock mysql
import org.scalamock.scalatest.MockFactory
 val connectionMock = mock[java.sql.Connection]
 val statementMock = mock[PreparedStatement]
    (conMock.prepareStatement(_:
String)).expects(sql.toString).returning(statementMock)
    (statementMock.executeUpdate _).expects()


On Thu, Oct 29, 2015 at 12:27 PM, Priya Ch <le...@gmail.com>
wrote:

> Hi All,
>
>   For my  Spark Streaming code, which writes the results to Cassandra DB,
> I need to write Unit test cases. what are the available test frameworks to
> mock the connection to Cassandra DB ?
>