accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [29/50] [abbrv] git commit: ACCUMULO-1504 Pulling back Miguel's changes for IteratorSetting from trunk to 1.4
Date Wed, 31 Jul 2013 01:59:49 GMT
ACCUMULO-1504 Pulling back Miguel's changes for IteratorSetting from trunk to 1.4


git-svn-id: https://svn.apache.org/repos/asf/accumulo/branches/1.4@1494816 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/1.5.1-SNAPSHOT
Commit: a91173bcbb71052f730961e842cbc5b713d58104
Parents: 9b2a56b
Author: Josh Elser <elserj@apache.org>
Authored: Thu Jun 20 00:16:14 2013 +0000
Committer: Josh Elser <elserj@apache.org>
Committed: Thu Jun 20 00:16:14 2013 +0000

----------------------------------------------------------------------
 .../accumulo/core/client/IteratorSetting.java   | 46 ++++++++++++
 .../core/client/IteratorSettingTest.java        | 76 ++++++++++++++++++++
 2 files changed, 122 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a91173bc/src/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
----------------------------------------------------------------------
diff --git a/src/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java b/src/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
index a3ea003..e815072 100644
--- a/src/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
+++ b/src/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
@@ -251,6 +251,52 @@ public class IteratorSetting {
   }
   
   /**
+   * @see java.lang.Object#hashCode()
+   */
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((iteratorClass == null) ? 0 : iteratorClass.hashCode());
+    result = prime * result + ((name == null) ? 0 : name.hashCode());
+    result = prime * result + priority;
+    result = prime * result + ((properties == null) ? 0 : properties.hashCode());
+    return result;
+  }
+  
+  /**
+   * @see java.lang.Object#equals()
+   */
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (!(obj instanceof IteratorSetting))
+      return false;
+    IteratorSetting other = (IteratorSetting) obj;
+    if (iteratorClass == null) {
+      if (other.iteratorClass != null)
+        return false;
+    } else if (!iteratorClass.equals(other.iteratorClass))
+      return false;
+    if (name == null) {
+      if (other.name != null)
+        return false;
+    } else if (!name.equals(other.name))
+      return false;
+    if (priority != other.priority)
+      return false;
+    if (properties == null) {
+      if (other.properties != null)
+        return false;
+    } else if (!properties.equals(other.properties))
+      return false;
+    return true;
+  }
+
+  /**
    * @see java.lang.Object#toString()
    */
   @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a91173bc/src/core/src/test/java/org/apache/accumulo/core/client/IteratorSettingTest.java
----------------------------------------------------------------------
diff --git a/src/core/src/test/java/org/apache/accumulo/core/client/IteratorSettingTest.java
b/src/core/src/test/java/org/apache/accumulo/core/client/IteratorSettingTest.java
new file mode 100644
index 0000000..69bf1b5
--- /dev/null
+++ b/src/core/src/test/java/org/apache/accumulo/core/client/IteratorSettingTest.java
@@ -0,0 +1,76 @@
+package org.apache.accumulo.core.client;
+
+import static org.junit.Assert.*;
+
+import org.apache.accumulo.core.iterators.Combiner;
+import org.apache.accumulo.core.iterators.DevNull;
+import org.apache.hadoop.io.Writable;
+import org.junit.Test;
+
+/**
+ * Test cases for the IteratorSetting class
+ */
+public class IteratorSettingTest {
+  
+  IteratorSetting setting1 = new IteratorSetting(500, "combiner", Combiner.class.getName());
+  IteratorSetting setting2 = new IteratorSetting(500, "combiner", Combiner.class.getName());
+  IteratorSetting setting3 = new IteratorSetting(500, "combiner", Combiner.class.getName());
+  IteratorSetting devnull = new IteratorSetting(500, "devNull", DevNull.class.getName());
+  IteratorSetting nullsetting = null;
+  IteratorSetting setting4 = new IteratorSetting(300, "combiner", Combiner.class.getName());
+  IteratorSetting setting5 = new IteratorSetting(500, "foocombiner", Combiner.class.getName());
+  IteratorSetting setting6 = new IteratorSetting(500, "combiner", "MySuperCombiner");
+  
+  @Test
+  public final void testHashCodeSameObject() {
+    assertEquals(setting1.hashCode(), setting1.hashCode());
+  }
+  
+  @Test
+  public final void testHashCodeEqualObjects() {
+    assertEquals(setting1.hashCode(), setting2.hashCode());
+  }
+  
+  @Test
+  public final void testEqualsObjectReflexive() {
+    assertEquals(setting1, setting1);
+  }
+  
+  @Test
+  public final void testEqualsObjectSymmetric() {
+    assertEquals(setting1, setting2);
+    assertEquals(setting2, setting1);
+  }
+  
+  @Test
+  public final void testEqualsObjectTransitive() {
+    assertEquals(setting1, setting2);
+    assertEquals(setting2, setting3);
+    assertEquals(setting1, setting3);
+  }
+  
+  @Test
+  public final void testEqualsNullSetting() {
+    assertNotEquals(setting1, nullsetting);
+  }
+  
+  @Test
+  public final void testEqualsObjectNotEqual() {
+    assertNotEquals(setting1, devnull);
+  }
+  
+  @Test
+  public final void testEqualsObjectProperties() {
+    IteratorSetting mysettings = new IteratorSetting(500, "combiner", Combiner.class.getName());
+    assertEquals(setting1, mysettings);
+    mysettings.addOption("myoption1", "myvalue1");
+    assertNotEquals(setting1, mysettings);
+  }
+  
+  @Test
+  public final void testEqualsDifferentMembers() {
+    assertNotEquals(setting1, setting4);
+    assertNotEquals(setting1, setting5);
+    assertNotEquals(setting1, setting6);
+  }
+}


Mime
View raw message