Return-Path: X-Original-To: apmail-accumulo-user-archive@www.apache.org Delivered-To: apmail-accumulo-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6C3E2D3AB for ; Tue, 25 Sep 2012 13:30:27 +0000 (UTC) Received: (qmail 12825 invoked by uid 500); 25 Sep 2012 13:30:27 -0000 Delivered-To: apmail-accumulo-user-archive@accumulo.apache.org Received: (qmail 12797 invoked by uid 500); 25 Sep 2012 13:30:27 -0000 Mailing-List: contact user-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@accumulo.apache.org Delivered-To: mailing list user@accumulo.apache.org Received: (qmail 12787 invoked by uid 99); 25 Sep 2012 13:30:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Sep 2012 13:30:27 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of josh.accumulo@gmail.com designates 209.85.161.193 as permitted sender) Received: from [209.85.161.193] (HELO mail-gg0-f193.google.com) (209.85.161.193) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Sep 2012 13:30:19 +0000 Received: by ggnk3 with SMTP id k3so701250ggn.0 for ; Tue, 25 Sep 2012 06:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ZX4PQq3L9oatExAQr2pjScOJbmIOEVMjTGdfQGCiPJs=; b=IKrF0ImVeOegfCU6C3Pd8x+HkllIlviOmlhOblqoOsqqwnBIM1TxNNlCceOSUDHGw/ yKHA9HjEZ7ICvWx+H05saWvXanhPugbsbvQj04l/xserhElqyfURFNOcmeT7GdfQOdQE zNLn6wexk7+pO96dzDYRvp1GJcEJ5T/9PNV6bwkAykzaF/0PVelQEV3VNN4HMI0OAtA5 Yk3Ll/38w70MtpxOCTewC1bXheKhvVf9vgA9sO/Q1kNy2LpQKVVeyP6JzTGg/akKpyv8 FbF11d9HfWNfyYVO810Th+0uY/BKyv6U1PoJ9r+SrwQ9Sf8wEtCnSNVj04As5qRAdzd2 6s1w== MIME-Version: 1.0 Received: by 10.236.173.164 with SMTP id v24mr16040684yhl.60.1348579798852; Tue, 25 Sep 2012 06:29:58 -0700 (PDT) Received: by 10.146.191.2 with HTTP; Tue, 25 Sep 2012 06:29:58 -0700 (PDT) In-Reply-To: References: Date: Tue, 25 Sep 2012 09:29:58 -0400 Message-ID: Subject: Re: Mock classes for JUnit Testing From: Joe Berk To: user@accumulo.apache.org Content-Type: multipart/alternative; boundary=20cf305642dddca52504ca86b318 --20cf305642dddca52504ca86b318 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Thanks for responding, Keith. When I execute the following lines: MockInstance instance =3D new MockInstance(); MockConnector connector =3D (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 wrote: > Did you create the table using mockConn.tableOperations().create()? > > On Tue, Sep 25, 2012 at 8:47 AM, Joe Berk wrote= : > > Hello, > > > > > > > > I am trying to write JUnit tests for Accumulo and I keep running into > > dead-ends with the =93Mock=94 classes. > > > > > > > > /* > > > > * So, the following lines are how I would traditionally establish an > > instance to perform Accumulo reads or writes > > > > */ > > > > > > > > Instance zooInstance =3D new ZooKeeperInstance( InstanceName, > > ZooServers); > > > > Connector connector =3D zooInstance.getConnector(UserName, > > PassWord); > > > > > > > > > > > > > > > > /* > > > > * The following lines would be how I would perform a write to Accumul= o > > > > */ > > > > > > > > BatchWriter batchWriter =3D configuration.getBatchWriter(); > > > > Mutation videoMutation =3D 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 Accumu= lo > > > > */ > > > > > > > > Authorizations authorizations =3D new Authorizations(); > > > > Scanner scanner =3D connector.createScanner(TableName, > > authorizations); > > > > > > > > scanner.setRange(new Range(RowId)); > > > > scanner.fetchColumnFamily(columnFamily); > > > > > > > > Iterator> iterator =3D scanner.iterator(); > > > > > > > > > > > > > > > > > > > > So, I tried to repeat this process, but substituted: > > > > > > > > MockInstance instance =3D new MockInstance() > > > > Or > > > > Instance instance =3D new MockInstance(); > > > > > > > > and everything works great until I attempt to addMutation(videoMutation= ). > > That throws a NullPointerException. > > > > > > > > I=92ve also tried to use the MockConnector & even MockBatchWriter class= es, > but > > have not had any success. > > > > > > > > I would really appreciate any help you could provide. > > > > > > > > > > > > Best Regards, > > > > > > > > Josh > --20cf305642dddca52504ca86b318 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Thanks for responding, Keith.

When I execute the followi= ng lines:


MockInstance =A0 =A0instan= ce =A0=3D new MockInstance();
MockConnector connector =3D (MockCo= nnector) instance.getConnector(UserName, Password);
connector.tableOperations().create("SomeTable");
<= br>
I get a "caused by: java.lang.ClassNotFoundException: or= g/apache/commons/lang/NotImplementedException"

& it throws the Exception on the 3rd line there: connector.tableOp= erations().create("SomeTable");

Best Reg= ards,

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<= br> > dead-ends with the =93Mock=94 classes.
>
>
>
> /*
>
> =A0 * So, the following lines are how I would traditionally establish = an
> instance to perform Accumulo reads or writes
>
> =A0 */
>
>
>
> Instance =A0 =A0 =A0 zooInstance =A0 =A0=3D new ZooKeeperInstance( Ins= tanceName,
> ZooServers);
>
> Connector =A0 =A0 =A0connector =A0 =A0 =A0=3D zooInstance.getConnector= (UserName,
> PassWord);
>
>
>
>
>
>
>
> /*
>
> =A0 * The following lines would be how I would perform a write to Accu= mulo
>
> =A0 */
>
>
>
> BatchWriter batchWriter =A0 =3D configuration.getBatchWriter();
>
> Mutation =A0 =A0videoMutation =3D new Mutation(new Text( RowId ));
>
>
>
> videoMutation.put(ColumnFamily, ColumnQualifer, Value );
>
>
>
> batchWriter.addMutation(videoMutation);
>
> batchWriter.flush();
>
> batchWriter.close();
>
>
>
>
>
>
>
> /*
>
> =A0 * The following lines would be how I would perform a read from Acc= umulo
>
> =A0 */
>
>
>
> Authorizations authorizations =3D new Authorizations();
>
> Scanner =A0 =A0 =A0 =A0scanner =A0 =A0 =A0 =A0=3D connector.createScan= ner(TableName,
> authorizations);
>
>
>
> scanner.setRange(new Range(RowId));
>
> scanner.fetchColumnFamily(columnFamily);
>
>
>
> Iterator<Entry<Key,Value>> iterator =3D scanner.iterator()= ;
>
>
>
>
>
>
>
>
>
> So, I tried to repeat this process, but substituted:
>
>
>
> MockInstance instance =3D new MockInstance()
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Or
>
> Instance =A0 =A0 instance =3D new MockInstance();
>
>
>
> and everything works great until I attempt to addMutation(videoMutatio= n).
> That throws a NullPointerException.
>
>
>
> I=92ve 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

--20cf305642dddca52504ca86b318--