hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Phelps <...@opendns.com>
Subject Re: Writing unit tests against HBase
Date Tue, 25 Jun 2013 01:04:50 GMT
Thansk, that set me on the right path.  For anyone else reading along, I
also needed to add:

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.9.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <scope>test</scope>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <scope>test</scope>
            <version>3.1</version>
        </dependency>

to my pom.xml in order for the tests using FakeHBase to run.

- Adam

On 6/24/13 3:05 PM, Christophe Taton wrote:
> Hey Adam,
> 
> Here is how to use fake-hbase from Java:
> 
> final Configuration conf = new Configuration();
> 
> final FakeHBase fakeHBase = new FakeHBase();
> 
> final HBaseAdmin admin = fakeHBase.getAdminFactory().create(conf);
> 
> final HTableDescriptor desc = new HTableDescriptor("table");
> 
> desc.addFamily(new
> HColumnDescriptor("family").setMaxVersions(HConstants.ALL_VERSIONS));
> 
> admin.createTable(desc);
> 
> final HTableInterface table = fakeHBase.getHTableFactory().create(conf,
> "table");
> 
> mHTable.put(new Put(Bytes.toBytes("row"))
> 
> .add(Bytes.toBytes("family"), Bytes.toBytes("qualifier"),
> Bytes.toBytes("value")));
> 
> ...
> 
> FakeHBase is essentially a factory for fake HBaseAdmin and HTableInterface
> instances.
> Let me know if that works or not for you.
> Thanks,
> C.
> 
> 
> On Mon, Jun 24, 2013 at 2:14 PM, Adam Phelps <amp@opendns.com> wrote:
> 
>> On 6/18/13 4:22 PM, Stack wrote:
>>> On Tue, Jun 18, 2013 at 4:17 PM, Varun Sharma <varun@pinterest.com>
>> wrote:
>>>
>>>> Hi,
>>>>
>>>> If I wanted to write to write a unit test against HTable/HBase, is
>> there an
>>>> already available utility to that for unit testing my application logic.
>>>>
>>>> I don't want to write code that either touches production or requires
>> me to
>>>> mock an HTable. I am looking for a test htable object which behaves
>> pretty
>>>> close to a real HTable.
>>>>
>>>
>>>
>>> Would this help if we included it?
>>> https://github.com/kijiproject/fake-hbase/
>>
>> I figured I'd take a look as I was about to try using Mockito
>> (https://code.google.com/p/mockito/) to try to implement unit testing of
>> some of our code that accesses HBase.  The example tests in there are
>> all Scala, and I'm not having much success using them in Java.  Do you
>> know if there's any example Java tests that make use of fake-hbase?
>>
>> - Adam
>>
>>
> 


Mime
View raw message