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 4D022D51C for ; Tue, 25 Sep 2012 14:08:11 +0000 (UTC) Received: (qmail 51046 invoked by uid 500); 25 Sep 2012 14:08:11 -0000 Delivered-To: apmail-accumulo-user-archive@accumulo.apache.org Received: (qmail 51012 invoked by uid 500); 25 Sep 2012 14:08:11 -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 51004 invoked by uid 99); 25 Sep 2012 14:08:11 -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 14:08:11 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.212.41] (HELO mail-vb0-f41.google.com) (209.85.212.41) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Sep 2012 14:08:04 +0000 Received: by vbkv13 with SMTP id v13so8204346vbk.0 for ; Tue, 25 Sep 2012 07:07:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding:x-gm-message-state; bh=9KDrVn2cU2ERu8PrApFHekGFkn/BjWH8E5uD+461y6w=; b=l2JVc3b81AUvdnnA3tdbtWM1dn86FbUQtCw2Ufg6XshCvoAsiBynyz1KCkBDRSz+ux T13nAhjb0KkQFwcagANYLr+fA5RdgChanj38INnxSbn2N2Br59MfEqf0ryI3XyBYCiSp 2XwSu0h3RnA72XjYk1UNzYF6o5AVz9Dcdb7sjzTRX+gRPCy4Pq8j/5cLQf36L/8iFXX8 c3om9Uaw63H8B77nm6ziKC043TsRA7HAJhCiELNClW6I43c1AkCUJKrJpsEPqgB2dklj OkRc0oQLVHI7nDypVKJYeLHxtxk8rtMH5u2vNxw9qHQv56aSfObJMS8NonkMMwJUdErZ iwqQ== MIME-Version: 1.0 Received: by 10.52.38.168 with SMTP id h8mr7562046vdk.93.1348582063528; Tue, 25 Sep 2012 07:07:43 -0700 (PDT) Received: by 10.58.74.200 with HTTP; Tue, 25 Sep 2012 07:07:43 -0700 (PDT) In-Reply-To: References: Date: Tue, 25 Sep 2012 10:07:43 -0400 Message-ID: Subject: Re: Mock classes for JUnit Testing From: Keith Turner To: user@accumulo.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQmJtsqHAK9iEDfgTXxiTG4KH/ORokfbX1N7K6e798IjbbuVN6xEUBPdZlNJ66ivOCavYz/Z 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 wrote: > Too slow, Keith! :) > > Adam > > On Sep 25, 2012 9:55 AM, "Keith Turner" 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 wrot= e: >> > 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 in= to >> >> > 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( InstanceNa= me, >> >> > ZooServers); >> >> > >> >> > Connector connector =3D zooInstance.getConnector(UserName= , >> >> > PassWord); >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > /* >> >> > >> >> > * The following lines would be how I would perform a write to >> >> > Accumulo >> >> > >> >> > */ >> >> > >> >> > >> >> > >> >> > 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 >> >> > Accumulo >> >> > >> >> > */ >> >> > >> >> > >> >> > >> >> > 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 >> >> > classes, >> >> > but >> >> > have not had any success. >> >> > >> >> > >> >> > >> >> > I would really appreciate any help you could provide. >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > Best Regards, >> >> > >> >> > >> >> > >> >> > Josh >> > >> >