accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject svn commit: r1494797 - in /accumulo/trunk/core/src: main/java/org/apache/accumulo/core/client/IteratorSetting.java test/java/org/apache/accumulo/core/client/IteratorSettingTest.java
Date Wed, 19 Jun 2013 22:58:06 GMT
Author: elserj
Date: Wed Jun 19 22:58:05 2013
New Revision: 1494797

URL: http://svn.apache.org/r1494797
Log:
ACCUMULO-1504 Applying patch from Miguel. Added a few extra tests too.

Added:
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/IteratorSettingTest.java
Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java?rev=1494797&r1=1494796&r2=1494797&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/IteratorSetting.java
Wed Jun 19 22:58:05 2013
@@ -264,6 +264,52 @@ public class IteratorSetting implements 
   }
   
   /**
+   * @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

Added: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/IteratorSettingTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/IteratorSettingTest.java?rev=1494797&view=auto
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/IteratorSettingTest.java
(added)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/IteratorSettingTest.java
Wed Jun 19 22:58:05 2013
@@ -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