accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith Turner <ke...@deenlo.com>
Subject Re: Mock classes for JUnit Testing
Date Tue, 25 Sep 2012 14:07:43 GMT
I blame Christopher... I was having a discussion w/ him about the
search space of solving a rubicks cube while typing the email :)  So
when I started there was no response... then I took a long type to
type... then I sent and saw your response.



On Tue, Sep 25, 2012 at 10:03 AM, Adam Fuchs <afuchs@apache.org> wrote:
> Too slow, Keith!  :)
>
> Adam
>
> On Sep 25, 2012 9:55 AM, "Keith Turner" <keith@deenlo.com> wrote:
>>
>> What I think is going is that the class MockTableOperations references
>> org.apache.commons.lang.NotImplementedException.  When you try to load
>> the class MockTableOperations, it tries to load the dependency
>> NotImplementedException which is not on your class path.
>>
>> On Tue, Sep 25, 2012 at 9:29 AM, Joe Berk <josh.accumulo@gmail.com> wrote:
>> > Thanks for responding, Keith.
>> >
>> > When I execute the following lines:
>> >
>> >
>> > MockInstance    instance  = new MockInstance();
>> > MockConnector connector = (MockConnector)
>> > instance.getConnector(UserName,
>> > Password);
>> > connector.tableOperations().create("SomeTable");
>> >
>> > I get a "caused by: java.lang.ClassNotFoundException:
>> > org/apache/commons/lang/NotImplementedException"
>> >
>> > & it throws the Exception on the 3rd line there:
>> > connector.tableOperations().create("SomeTable");
>> >
>> > Best Regards,
>> >
>> > Josh
>> >
>> >
>> >
>> >
>> > On Tue, Sep 25, 2012 at 8:54 AM, Keith Turner <keith@deenlo.com> wrote:
>> >>
>> >> Did you create the table using mockConn.tableOperations().create()?
>> >>
>> >> On Tue, Sep 25, 2012 at 8:47 AM, Joe Berk <josh.accumulo@gmail.com>
>> >> 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
>> >
>> >

Mime
View raw message