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/10/08 23:05:56 UTC

[1/2] git commit: ACCUMULO-1627 Add equals() and hashCode() for Condition, ConditionalMutation; refine equals() implementation for Mutation and subclasses.

Updated Branches:
  refs/heads/master e70a40dba -> 70031c4dc


ACCUMULO-1627 Add equals() and hashCode() for Condition, ConditionalMutation; refine equals() implementation for Mutation and subclasses.

Signed-off-by: Keith Turner <kt...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/4ac31c3f
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/4ac31c3f
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/4ac31c3f

Branch: refs/heads/master
Commit: 4ac31c3f9df7388f1be3d29865fbb534106bd77d
Parents: e70a40d
Author: Bill Havanki <bh...@cloudera.com>
Authored: Wed Sep 25 15:24:42 2013 -0400
Committer: Keith Turner <kt...@apache.org>
Committed: Tue Oct 8 15:20:44 2013 -0400

----------------------------------------------------------------------
 .../apache/accumulo/core/data/Condition.java    |  43 ++++
 .../accumulo/core/data/ConditionalMutation.java |  21 ++
 .../org/apache/accumulo/core/data/Mutation.java |  21 +-
 .../accumulo/core/data/ConditionTest.java       | 206 +++++++++++++++++++
 .../core/data/ConditionalMutationTest.java      | 146 +++++++++++++
 .../accumulo/server/data/ServerMutation.java    |  22 ++
 6 files changed, 456 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/4ac31c3f/core/src/main/java/org/apache/accumulo/core/data/Condition.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/data/Condition.java b/core/src/main/java/org/apache/accumulo/core/data/Condition.java
index 97df7e0..df20682 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/Condition.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Condition.java
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.core.data;
 
+import java.util.Arrays;
 import java.util.HashSet;
 
 import org.apache.accumulo.core.Constants;
@@ -145,4 +146,46 @@ public class Condition {
     return iterators;
   }
 
+  @Override
+  public boolean equals(Object o) {
+    if (o == this) {
+      return true;
+    }
+    if (o == null || o.getClass() != Condition.class) {
+      return false;
+    }
+    Condition c = (Condition) o;
+    if (!(c.cf.equals(cf))) {
+      return false;
+    }
+    if (!(c.cq.equals(cq))) {
+      return false;
+    }
+    if (!(c.cv.equals(cv))) {
+      return false;
+    }
+    if (!(c.val == null ? val == null : c.val.equals(val))) {
+      return false;
+    }
+    if (!(c.ts == null ? ts == null : c.ts.equals(ts))) {
+      return false;
+    }
+    if (!(Arrays.equals(c.iterators, iterators))) {
+      return false;
+    }
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = 17;
+    result = 31 * result + cf.hashCode();
+    result = 31 * result + cq.hashCode();
+    result = 31 * result + cv.hashCode();
+    result = 31 * result + (val == null ? 0 : val.hashCode());
+    result = 31 * result + (ts == null ? 0 : ts.hashCode());
+    result = 31 * result + Arrays.hashCode(iterators);
+    return result;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4ac31c3f/core/src/main/java/org/apache/accumulo/core/data/ConditionalMutation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/data/ConditionalMutation.java b/core/src/main/java/org/apache/accumulo/core/data/ConditionalMutation.java
index 23bf7d0..510396d 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/ConditionalMutation.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/ConditionalMutation.java
@@ -80,4 +80,25 @@ public class ConditionalMutation extends Mutation {
     return Collections.unmodifiableList(conditions);
   }
 
+  @Override
+  public boolean equals(Object o) {
+    if (o == this) {
+      return true;
+    }
+    if (o == null || o.getClass() != ConditionalMutation.class) {
+      return false;
+    }
+    ConditionalMutation cm = (ConditionalMutation) o;
+    if (!conditions.equals(cm.conditions)) {
+      return false;
+    }
+    return super.equals(o);
+  }
+
+  @Override
+  public int hashCode() {
+    int result = super.hashCode();
+    result = 37 * result + conditions.hashCode();
+    return result;
+  }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4ac31c3f/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/data/Mutation.java b/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
index 161b239..5e281f2 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
@@ -567,8 +567,12 @@ public class Mutation implements Writable {
   
   @Override
   public boolean equals(Object o) {
-    if (o instanceof Mutation)
-      return equals((Mutation) o);
+    if (o == this) {
+      return true;
+    }
+    if (o != null && o.getClass().equals(this.getClass())) {
+      return equalMutation((Mutation) o);
+    }
     return false;
   }
   
@@ -576,8 +580,19 @@ public class Mutation implements Writable {
   public int hashCode() {
     return toThrift().hashCode();
   }
-  
+
+  /**
+   * Checks if this mutation equals another. This method may be removed in a
+   * future API revision in favor of {@link #equals(Object)}. See ACCUMULO-1627
+   * for more information.
+   *
+   * @param m mutation
+   * @return true if the given mutation equals this one, false otehrwise
+   */
   public boolean equals(Mutation m) {
+    return this.equals((Object) m);
+  }
+  private boolean equalMutation(Mutation m) {
     serialize();
     m.serialize();
     if (Arrays.equals(row, m.row) && entries == m.entries && Arrays.equals(data, m.data)) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4ac31c3f/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java b/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
new file mode 100644
index 0000000..37ffea2
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.core.data;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.security.ColumnVisibility;
+import org.apache.hadoop.io.Text;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class ConditionTest {
+  private static final ByteSequence EMPTY = new ArrayByteSequence(new byte[0]);
+  private static final String FAMILY = "family";
+  private static final String QUALIFIER = "qualifier";
+  private static final String VISIBILITY = "visibility";
+  private static final String VALUE = "value";
+  private static final IteratorSetting[] ITERATORS = {new IteratorSetting(1, "first", "someclass"), new IteratorSetting(2, "second", "someotherclass"),
+      new IteratorSetting(3, "third", "yetanotherclass")};
+
+  private String toString(ByteSequence bs) {
+    if (bs == null) {
+      return null;
+    }
+    return new String(bs.toArray(), Constants.UTF8);
+  }
+
+  private Condition c;
+
+  @Before
+  public void setUp() throws Exception {
+    c = new Condition(FAMILY, QUALIFIER);
+  }
+
+  @Test
+  public void testConstruction_CharSequence() {
+    assertEquals(FAMILY, toString(c.getFamily()));
+    assertEquals(QUALIFIER, toString(c.getQualifier()));
+    assertEquals(EMPTY, c.getVisibility());
+  }
+
+  @Test
+  public void testConstruction_ByteArray() {
+    c = new Condition(FAMILY.getBytes(Constants.UTF8), QUALIFIER.getBytes(Constants.UTF8));
+    assertEquals(FAMILY, toString(c.getFamily()));
+    assertEquals(QUALIFIER, toString(c.getQualifier()));
+    assertEquals(EMPTY, c.getVisibility());
+  }
+
+  @Test
+  public void testConstruction_Text() {
+    c = new Condition(new Text(FAMILY), new Text(QUALIFIER));
+    assertEquals(FAMILY, toString(c.getFamily()));
+    assertEquals(QUALIFIER, toString(c.getQualifier()));
+    assertEquals(EMPTY, c.getVisibility());
+  }
+
+  @Test
+  public void testConstruction_ByteSequence() {
+    c = new Condition(new ArrayByteSequence(FAMILY.getBytes(Constants.UTF8)), new ArrayByteSequence(QUALIFIER.getBytes(Constants.UTF8)));
+    assertEquals(FAMILY, toString(c.getFamily()));
+    assertEquals(QUALIFIER, toString(c.getQualifier()));
+    assertEquals(EMPTY, c.getVisibility());
+  }
+
+  @Test
+  public void testGetSetTimestamp() {
+    c.setTimestamp(1234L);
+    assertEquals(Long.valueOf(1234L), c.getTimestamp());
+  }
+
+  @Test
+  public void testSetValue_CharSequence() {
+    c.setValue(VALUE);
+    assertEquals(VALUE, toString(c.getValue()));
+  }
+
+  @Test
+  public void testSetValue_ByteArray() {
+    c.setValue(VALUE.getBytes(Constants.UTF8));
+    assertEquals(VALUE, toString(c.getValue()));
+  }
+
+  @Test
+  public void testSetValue_Text() {
+    c.setValue(new Text(VALUE));
+    assertEquals(VALUE, toString(c.getValue()));
+  }
+
+  @Test
+  public void testSetValue_ByteSequence() {
+    c.setValue(new ArrayByteSequence(VALUE.getBytes(Constants.UTF8)));
+    assertEquals(VALUE, toString(c.getValue()));
+  }
+
+  @Test
+  public void testGetSetVisibility() {
+    ColumnVisibility vis = new ColumnVisibility(VISIBILITY);
+    c.setVisibility(vis);
+    assertEquals(VISIBILITY, toString(c.getVisibility()));
+  }
+
+  @Test
+  public void testGetSetIterators() {
+    c.setIterators(ITERATORS);
+    assertArrayEquals(ITERATORS, c.getIterators());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetIterators_DuplicateName() {
+    IteratorSetting[] iterators = {new IteratorSetting(1, "first", "someclass"), new IteratorSetting(2, "second", "someotherclass"),
+        new IteratorSetting(3, "first", "yetanotherclass")};
+    c.setIterators(iterators);
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetIterators_DuplicatePriority() {
+    IteratorSetting[] iterators = {new IteratorSetting(1, "first", "someclass"), new IteratorSetting(2, "second", "someotherclass"),
+        new IteratorSetting(1, "third", "yetanotherclass")};
+    c.setIterators(iterators);
+  }
+
+  @Test
+  public void testEquals() {
+    ColumnVisibility cvis = new ColumnVisibility(VISIBILITY);
+    c.setVisibility(cvis);
+    c.setValue(VALUE);
+    c.setTimestamp(1234L);
+    c.setIterators(ITERATORS);
+
+    // reflexivity
+    assertTrue(c.equals(c));
+
+    // non-nullity
+    assertFalse(c.equals(null));
+
+    // symmetry
+    Condition c2 = new Condition(FAMILY, QUALIFIER);
+    c2.setVisibility(cvis);
+    c2.setValue(VALUE);
+    c2.setTimestamp(1234L);
+    c2.setIterators(ITERATORS);
+    assertTrue(c.equals(c2));
+    assertTrue(c2.equals(c));
+
+    Condition c3 = new Condition("nope", QUALIFIER);
+    c3.setVisibility(cvis);
+    c3.setValue(VALUE);
+    c3.setTimestamp(1234L);
+    c3.setIterators(ITERATORS);
+    assertFalse(c.equals(c3));
+    c3 = new Condition(FAMILY, "nope");
+    c3.setVisibility(cvis);
+    c3.setValue(VALUE);
+    c3.setTimestamp(1234L);
+    c3.setIterators(ITERATORS);
+    assertFalse(c.equals(c3));
+
+    c2.setVisibility(new ColumnVisibility("sekrit"));
+    assertFalse(c.equals(c2));
+    c2.setVisibility(cvis);
+    c2.setValue(EMPTY);
+    assertFalse(c.equals(c2));
+    c2.setValue(VALUE);
+    c2.setTimestamp(2345L);
+    assertFalse(c.equals(c2));
+    c2.setTimestamp(1234L);
+    c2.setIterators(new IteratorSetting[0]);
+    assertFalse(c.equals(c2));
+    c2.setIterators(ITERATORS);
+    assertTrue(c.equals(c2));
+  }
+
+  @Test
+  public void testHashCode() {
+    ColumnVisibility cvis = new ColumnVisibility(VISIBILITY);
+    c.setVisibility(cvis);
+    c.setValue(VALUE);
+    c.setTimestamp(1234L);
+    c.setIterators(ITERATORS);
+    int hc1 = c.hashCode();
+
+    Condition c2 = new Condition(FAMILY, QUALIFIER);
+    c2.setVisibility(cvis);
+    c2.setValue(VALUE);
+    c2.setTimestamp(1234L);
+    c2.setIterators(ITERATORS);
+    assertTrue(c.equals(c2));
+    assertEquals(hc1, c2.hashCode());
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4ac31c3f/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java b/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
new file mode 100644
index 0000000..1dcee99
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.core.data;
+
+import java.util.List;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.hadoop.io.Text;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class ConditionalMutationTest {
+  private static final byte[] ROW = "row".getBytes(Constants.UTF8);
+  private static final String FAMILY = "family";
+  private static final String QUALIFIER = "qualifier";
+  private static final String QUALIFIER2 = "qualifier2";
+  private static final String QUALIFIER3 = "qualifier3";
+
+  private Condition c1, c2;
+  private ConditionalMutation cm;
+
+  @Before
+  public void setUp() throws Exception {
+    c1 = new Condition(FAMILY, QUALIFIER);
+    c2 = new Condition(FAMILY, QUALIFIER2);
+    assertFalse(c1.equals(c2));
+    cm = new ConditionalMutation(ROW, c1, c2);
+  }
+
+  @Test
+  public void testConstruction_ByteArray() {
+    assertArrayEquals(ROW, cm.getRow());
+    List<Condition> cs = cm.getConditions();
+    assertEquals(2, cs.size());
+    assertEquals(c1, cs.get(0));
+    assertEquals(c2, cs.get(1));
+  }
+
+  @Test
+  public void testConstruction_ByteArray_StartAndLength() {
+    cm = new ConditionalMutation(ROW, 1, 1, c1, c2);
+    assertArrayEquals("o".getBytes(Constants.UTF8), cm.getRow());
+    List<Condition> cs = cm.getConditions();
+    assertEquals(2, cs.size());
+    assertEquals(c1, cs.get(0));
+    assertEquals(c2, cs.get(1));
+  }
+
+  @Test
+  public void testConstruction_Text() {
+    cm = new ConditionalMutation(new Text(ROW), c1, c2);
+    assertArrayEquals(ROW, cm.getRow());
+    List<Condition> cs = cm.getConditions();
+    assertEquals(2, cs.size());
+    assertEquals(c1, cs.get(0));
+    assertEquals(c2, cs.get(1));
+  }
+
+  @Test
+  public void testConstruction_CharSequence() {
+    cm = new ConditionalMutation(new String(ROW, Constants.UTF8), c1, c2);
+    assertArrayEquals(ROW, cm.getRow());
+    List<Condition> cs = cm.getConditions();
+    assertEquals(2, cs.size());
+    assertEquals(c1, cs.get(0));
+    assertEquals(c2, cs.get(1));
+  }
+
+  @Test
+  public void testConstruction_ByteSequence() {
+    cm = new ConditionalMutation(new ArrayByteSequence(ROW), c1, c2);
+    assertArrayEquals(ROW, cm.getRow());
+    List<Condition> cs = cm.getConditions();
+    assertEquals(2, cs.size());
+    assertEquals(c1, cs.get(0));
+    assertEquals(c2, cs.get(1));
+  }
+
+  @Test
+  public void testCopyConstructor() {
+    ConditionalMutation cm2 = new ConditionalMutation(cm);
+    assertArrayEquals(cm.getRow(), cm2.getRow());
+    assertEquals(cm.getConditions(), cm2.getConditions());
+  }
+
+  @Test
+  public void testAddCondition() {
+    Condition c3 = new Condition(FAMILY, QUALIFIER3);
+    cm.addCondition(c3);
+    List<Condition> cs = cm.getConditions();
+    assertEquals(3, cs.size());
+    assertEquals(c1, cs.get(0));
+    assertEquals(c2, cs.get(1));
+    assertEquals(c3, cs.get(2));
+  }
+
+  @Test
+  public void testEquals() {
+    // reflexivity
+    assertTrue(cm.equals(cm));
+
+    // non-nullity
+    assertFalse(cm.equals((Object) null));
+
+    // symmetry
+    ConditionalMutation cm2 = new ConditionalMutation(ROW, c1, c2);
+    assertTrue(cm.equals(cm2));
+    assertTrue(cm2.equals(cm));
+
+    ConditionalMutation cm3 = new ConditionalMutation("row2".getBytes(Constants.UTF8), c1, c2);
+    assertFalse(cm.equals(cm3));
+    cm3 = new ConditionalMutation(ROW, c2, c1);
+    assertFalse(cm.getConditions().equals(cm3.getConditions()));
+    assertFalse(cm.equals(cm3));
+  }
+
+  @Test
+  public void testEquals_Mutation() {
+    Mutation m = new Mutation(ROW);
+    assertFalse(m.equals(cm));
+    assertFalse(cm.equals(m));
+  }
+
+  @Test
+  public void testHashcode() {
+    int hc1 = cm.hashCode();
+    ConditionalMutation cm2 = new ConditionalMutation(ROW, c1, c2);
+    assertTrue(cm.equals(cm2));
+    assertEquals(cm2.hashCode(), cm.hashCode());
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4ac31c3f/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java b/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java
index 28a3515..389cc33 100644
--- a/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java
+++ b/server/src/main/java/org/apache/accumulo/server/data/ServerMutation.java
@@ -78,4 +78,26 @@ public class ServerMutation extends Mutation {
   public long estimatedMemoryUsed() {
     return super.estimatedMemoryUsed() + 8;
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (o == this) {
+      return true;
+    }
+    if (o == null || o.getClass() != ServerMutation.class) {
+      return false;
+    }
+    ServerMutation sm = (ServerMutation) o;
+    if (sm.systemTime != systemTime) {
+      return false;
+    }
+    return super.equals(o);
+  }
+
+  @Override
+  public int hashCode() {
+    int result = super.hashCode();
+    result = 31 * result + (int) (systemTime & 0xffffffff);
+    return result;
+  }
 }


[2/2] git commit: ACCUMULO-1627 increased coverage of Condition unit test

Posted by kt...@apache.org.
ACCUMULO-1627 increased coverage of Condition unit test


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/70031c4d
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/70031c4d
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/70031c4d

Branch: refs/heads/master
Commit: 70031c4dc6f4e8f2448ae888514e3d0b2b811b9c
Parents: 4ac31c3
Author: Keith Turner <kt...@apache.org>
Authored: Tue Oct 8 16:58:23 2013 -0400
Committer: Keith Turner <kt...@apache.org>
Committed: Tue Oct 8 17:04:45 2013 -0400

----------------------------------------------------------------------
 .../accumulo/core/data/ConditionTest.java       | 47 +++++++++++++++++++-
 .../core/data/ConditionalMutationTest.java      |  7 ++-
 2 files changed, 51 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/70031c4d/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java b/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
index 37ffea2..3570610 100644
--- a/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
@@ -16,13 +16,17 @@
  */
 package org.apache.accumulo.core.data;
 
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.hadoop.io.Text;
 import org.junit.Before;
 import org.junit.Test;
-import static org.junit.Assert.*;
 
 public class ConditionTest {
   private static final ByteSequence EMPTY = new ArrayByteSequence(new byte[0]);
@@ -164,26 +168,67 @@ public class ConditionTest {
     c3.setTimestamp(1234L);
     c3.setIterators(ITERATORS);
     assertFalse(c.equals(c3));
+    assertFalse(c3.equals(c));
     c3 = new Condition(FAMILY, "nope");
     c3.setVisibility(cvis);
     c3.setValue(VALUE);
     c3.setTimestamp(1234L);
     c3.setIterators(ITERATORS);
     assertFalse(c.equals(c3));
+    assertFalse(c3.equals(c));
 
     c2.setVisibility(new ColumnVisibility("sekrit"));
     assertFalse(c.equals(c2));
+    assertFalse(c2.equals(c));
     c2.setVisibility(cvis);
     c2.setValue(EMPTY);
     assertFalse(c.equals(c2));
+    assertFalse(c2.equals(c));
     c2.setValue(VALUE);
     c2.setTimestamp(2345L);
     assertFalse(c.equals(c2));
+    assertFalse(c2.equals(c));
     c2.setTimestamp(1234L);
     c2.setIterators(new IteratorSetting[0]);
     assertFalse(c.equals(c2));
+    assertFalse(c2.equals(c));
     c2.setIterators(ITERATORS);
     assertTrue(c.equals(c2));
+    assertTrue(c2.equals(c));
+    
+    // set everything but vis, so its null
+    Condition c4 = new Condition(FAMILY, QUALIFIER);
+    c4.setValue(VALUE);
+    c4.setTimestamp(1234L);
+    c4.setIterators(ITERATORS);
+    
+    assertFalse(c.equals(c4));
+    assertFalse(c4.equals(c));
+    
+    // set everything but timestamp, so its null
+    Condition c5 = new Condition(FAMILY, QUALIFIER);
+    c5.setVisibility(cvis);
+    c5.setValue(VALUE);
+    c5.setIterators(ITERATORS);
+    
+    assertFalse(c.equals(c5));
+    assertFalse(c5.equals(c));
+    
+    // set everything but value
+    Condition c6 = new Condition(FAMILY, QUALIFIER);
+    c6.setVisibility(cvis);
+    c6.setTimestamp(1234L);
+    c6.setIterators(ITERATORS);
+    
+    assertFalse(c.equals(c6));
+    assertFalse(c6.equals(c));
+    
+    // test w/ no optional fields set
+    Condition c7 = new Condition(FAMILY, QUALIFIER);
+    Condition c8 = new Condition(FAMILY, QUALIFIER);
+    assertTrue(c7.equals(c8));
+    assertTrue(c8.equals(c7));
+
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/accumulo/blob/70031c4d/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java b/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
index 1dcee99..47f44f1 100644
--- a/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
@@ -16,13 +16,17 @@
  */
 package org.apache.accumulo.core.data;
 
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.util.List;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.hadoop.io.Text;
 import org.junit.Before;
 import org.junit.Test;
-import static org.junit.Assert.*;
 
 public class ConditionalMutationTest {
   private static final byte[] ROW = "row".getBytes(Constants.UTF8);
@@ -138,7 +142,6 @@ public class ConditionalMutationTest {
 
   @Test
   public void testHashcode() {
-    int hc1 = cm.hashCode();
     ConditionalMutation cm2 = new ConditionalMutation(ROW, c1, c2);
     assertTrue(cm.equals(cm2));
     assertEquals(cm2.hashCode(), cm.hashCode());