You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2013/05/30 23:44:22 UTC

svn commit: r1488024 - in /accumulo/contrib/instamo-archetype/branches/1.5: ./ src/main/resources/META-INF/maven/ src/main/resources/archetype-resources/ src/main/resources/archetype-resources/src/main/java/ src/main/resources/archetype-resources/src/t...

Author: kturner
Date: Thu May 30 21:44:22 2013
New Revision: 1488024

URL: http://svn.apache.org/r1488024
Log:
ACCUMULO-1166 improved instamo example unit test

Removed:
    accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/src/main/java/AccumuloApp.java
Modified:
    accumulo/contrib/instamo-archetype/branches/1.5/README.md   (contents, props changed)
    accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/META-INF/maven/archetype-metadata.xml   (contents, props changed)
    accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/README.md   (contents, props changed)
    accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/pom.xml   (contents, props changed)
    accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/src/test/java/ExampleAccumuloUnitTest.java   (contents, props changed)

Modified: accumulo/contrib/instamo-archetype/branches/1.5/README.md
URL: http://svn.apache.org/viewvc/accumulo/contrib/instamo-archetype/branches/1.5/README.md?rev=1488024&r1=1488023&r2=1488024&view=diff
==============================================================================
--- accumulo/contrib/instamo-archetype/branches/1.5/README.md (original)
+++ accumulo/contrib/instamo-archetype/branches/1.5/README.md Thu May 30 21:44:22 2013
@@ -15,7 +15,7 @@ to your local repository.
 
 Then, change to a new directory and run 
 
-`mvn archetype:generate -DarchetypeGroupId=org.apache.accumulo -DarchetypeArtifactId=instamo-archetype`
+`mvn archetype:generate -DarchetypeGroupId=org.apache.accumulo -DarchetypeArtifactId=instamo-archetype -DinteractiveMode=false`
 
 Maven will prompt you to enter the rest of the necessary configuration
 parameters (e.g. groupId, artifactId, version and Java package)

Propchange: accumulo/contrib/instamo-archetype/branches/1.5/README.md
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/META-INF/maven/archetype-metadata.xml
URL: http://svn.apache.org/viewvc/accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/META-INF/maven/archetype-metadata.xml?rev=1488024&r1=1488023&r2=1488024&view=diff
==============================================================================
Binary files - no diff available.

Propchange: accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/META-INF/maven/archetype-metadata.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/META-INF/maven/archetype-metadata.xml
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Thu May 30 21:44:22 2013
@@ -1 +1 @@
-application/xml
+text/xml

Modified: accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/README.md
URL: http://svn.apache.org/viewvc/accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/README.md?rev=1488024&r1=1488023&r2=1488024&view=diff
==============================================================================
--- accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/README.md (original)
+++ accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/README.md Thu May 30 21:44:22 2013
@@ -10,11 +10,12 @@ installation is required.  This is possi
 installed by following the steps below.
 
 ```
-vim src/main/java/${package}/AccumuloApp.java
+vim src/test/java/${package}/ExampleAccumuloUnitTest.java
 mvn package
 ```
 
-After packing the code, you can run one of the below applications.
+The maven package command will run the unit test.  After packing the code, you
+can also run one of the below applications.
 
 Map Reduce
 ----------

Propchange: accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/README.md
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/pom.xml?rev=1488024&r1=1488023&r2=1488024&view=diff
==============================================================================
Binary files - no diff available.

Propchange: accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/pom.xml
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Thu May 30 21:44:22 2013
@@ -1 +1 @@
-application/xml
+text/xml

Modified: accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/src/test/java/ExampleAccumuloUnitTest.java
URL: http://svn.apache.org/viewvc/accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/src/test/java/ExampleAccumuloUnitTest.java?rev=1488024&r1=1488023&r2=1488024&view=diff
==============================================================================
--- accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/src/test/java/ExampleAccumuloUnitTest.java (original)
+++ accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/src/test/java/ExampleAccumuloUnitTest.java Thu May 30 21:44:22 2013
@@ -19,8 +19,21 @@
  */
 package ${package};
 
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.ZooKeeperInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.minicluster.MiniAccumuloCluster;
+
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -49,7 +62,54 @@ public class ExampleAccumuloUnitTest {
 
   @Test(timeout = 30000)
   public void test() throws Exception {
-    AccumuloApp.run(accumulo.getInstanceName(), accumulo.getZooKeepers(), new PasswordToken("superSecret"), new String[0]);
+    // edit this method to play with Accumulo
+
+    Instance instance = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers());
+    
+    Connector conn = instance.getConnector("root", new PasswordToken("superSecret"));
+    
+    conn.tableOperations().create("foo");
+    
+    BatchWriter bw = conn.createBatchWriter("foo", new BatchWriterConfig());
+    Mutation m = new Mutation("1234");
+    m.put("name", "first", "Alice");
+    m.put("friend", "5678", "");
+    m.put("enemy", "5555", "");
+    m.put("enemy", "9999", "");
+    bw.addMutation(m);
+
+    m = new Mutation("5678");
+    m.put("name", "first", "Bob");
+    m.put("friend", "1234", "");
+    m.put("enemy", "5555", "");
+    m.put("enemy", "9999", "");
+    bw.addMutation(m);
+
+    m = new Mutation("9999");
+    m.put("name", "first", "Eve");
+    m.put("friend", "5555", "");
+    m.put("enemy", "1234", "");
+    m.put("enemy", "5678", "");
+    bw.addMutation(m);
+
+    m = new Mutation("5555");
+    m.put("name", "first", "Mallory");
+    m.put("friend", "9999", "");
+    m.put("enemy", "1234", "");
+    m.put("enemy", "5678", "");
+    bw.addMutation(m);
+
+    bw.close();
+    
+    Scanner scanner = conn.createScanner("foo", Constants.NO_AUTHS);
+    for (Entry<Key,Value> entry : scanner) {
+      System.out.println(entry.getKey() + " " + entry.getValue());
+    }
+   
+    //TODO use scanner to find common enemie ids between Alice and Bob, then
+    //use BatchScanner to look up their names
+ 
+    conn.tableOperations().delete("foo");
   }
   
   @AfterClass
@@ -57,5 +117,4 @@ public class ExampleAccumuloUnitTest {
     accumulo.stop();
     folder.delete();
   }
-  
 }

Propchange: accumulo/contrib/instamo-archetype/branches/1.5/src/main/resources/archetype-resources/src/test/java/ExampleAccumuloUnitTest.java
------------------------------------------------------------------------------
    svn:eol-style = native