Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Accumulo >> mail # user >> Mock classes for JUnit Testing


+
Joe Berk 2012-09-25, 12:47
+
Keith Turner 2012-09-25, 12:54
+
Joe Berk 2012-09-25, 13:29
+
Adam Fuchs 2012-09-25, 13:46
+
Joe Berk 2012-09-25, 13:53
+
Keith Turner 2012-09-25, 13:55
+
Adam Fuchs 2012-09-25, 14:03
+
Keith Turner 2012-09-25, 14:07
+
John Armstrong 2012-09-25, 14:12
+
Joe Berk 2012-09-25, 14:17
+
Jim Klucar 2012-09-25, 14:17
+
Keith Turner 2012-09-25, 14:20
+
Joe Berk 2012-09-25, 14:22
+
Billie Rinaldi 2012-09-25, 15:04
Copy link to this message
-
Re: Mock classes for JUnit Testing
Josh,

Can you post the stack trace that came with the NPE?

Adam
On Sep 25, 2012 8:47 AM, "Joe Berk" <[EMAIL PROTECTED]> wrote:

> Hello,
>
>
>
> I am trying to write JUnit tests for Accumulo and I keep running into
> dead-ends with the “Mock” classes.
>
>
>
> /*
>
>   * So, the following lines are how I would traditionally establish an
> instance to perform Accumulo reads or writes
>
>   */
>
>
>
> Instance       zooInstance    = new ZooKeeperInstance( *InstanceName*, *
> ZooServers*);
>
> Connector      connector      = zooInstance.getConnector(*UserName*, *
> PassWord*);
>
>
>
>
>
>
>
> /*
>
>   * The following lines would be how I would perform a write to Accumulo
>
>   */
>
>
>
> BatchWriter batchWriter   = configuration.getBatchWriter();
>
> Mutation    videoMutation = *new* Mutation(*new* Text( *RowId *));
>
>
>
> videoMutation.put(*ColumnFamily*, *ColumnQualifer*, *Value *);
>
>
>
> batchWriter.addMutation(videoMutation);
>
> batchWriter.flush();
>
> batchWriter.close();
>
>
>
>
>
>
>
> /*
>
>   * The following lines would be how I would perform a read from Accumulo
>
>   */
>
>
>
> Authorizations authorizations = new Authorizations();
>
> Scanner        scanner        = connector.createScanner(*TableName*,
> authorizations);
>
>
>
> scanner.setRange(*new* Range(*RowId*));
>
> scanner.fetchColumnFamily(*columnFamily*);
>
>
>
> Iterator<Entry<Key,Value>> iterator = scanner.iterator();
>
>
>
>
>
>
>
>
>
> So, I tried to repeat this process, but substituted:
>
>
>
> MockInstance instance = new MockInstance()
>
>                    Or
>
> Instance     instance = new MockInstance();
>
>
>
> and everything works great until I attempt to addMutation(videoMutation).
> That throws a NullPointerException.
>
>
>
> I’ve also tried to use the MockConnector & even MockBatchWriter classes,
> but have not had any success.
>
>
>
> I would really appreciate any help you could provide.
>
>
>
>
>
> Best Regards,
>
>
>
> Josh
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB