2727import org .apache .lucene .util .TestUtil ;
2828import org .elasticsearch .common .settings .Settings ;
2929import org .elasticsearch .indices .breaker .NoneCircuitBreakerService ;
30- import org .elasticsearch .test .ESSingleNodeTestCase ;
30+ import org .elasticsearch .test .ESTestCase ;
3131
3232import java .util .HashMap ;
3333import java .util .HashSet ;
34- import java .util .Iterator ;
3534import java .util .Map ;
3635import java .util .Map .Entry ;
3736import java .util .Set ;
3837
39- public class BytesRefHashTests extends ESSingleNodeTestCase {
38+ public class BytesRefHashTests extends ESTestCase {
4039
4140 BytesRefHash hash ;
4241
43- private BigArrays randombigArrays () {
42+ private BigArrays randomBigArrays () {
4443 return new MockBigArrays (new MockPageCacheRecycler (Settings .EMPTY ), new NoneCircuitBreakerService ());
4544 }
4645
@@ -50,7 +49,7 @@ private void newHash() {
5049 }
5150 // Test high load factors to make sure that collision resolution works fine
5251 final float maxLoadFactor = 0.6f + randomFloat () * 0.39f ;
53- hash = new BytesRefHash (randomIntBetween (0 , 100 ), maxLoadFactor , randombigArrays ());
52+ hash = new BytesRefHash (randomIntBetween (0 , 100 ), maxLoadFactor , randomBigArrays ());
5453 }
5554
5655 @ Override
@@ -59,7 +58,7 @@ public void setUp() throws Exception {
5958 newHash ();
6059 }
6160
62- public void testDuell () {
61+ public void testDuel () {
6362 final int len = randomIntBetween (1 , 100000 );
6463 final BytesRef [] values = new BytesRef [len ];
6564 for (int i = 0 ; i < values .length ; ++i ) {
@@ -80,8 +79,7 @@ public void testDuell() {
8079 }
8180
8281 assertEquals (valueToId .size (), hash .size ());
83- for (Iterator <ObjectLongCursor <BytesRef >> iterator = valueToId .iterator (); iterator .hasNext (); ) {
84- final ObjectLongCursor <BytesRef > next = iterator .next ();
82+ for (final ObjectLongCursor <BytesRef > next : valueToId ) {
8583 assertEquals (next .value , hash .find (next .key , next .key .hashCode ()));
8684 }
8785
@@ -147,7 +145,7 @@ public void testGet() {
147145 long count = hash .size ();
148146 long key = hash .add (ref .get ());
149147 if (key >= 0 ) {
150- assertNull (strings .put (str , Long . valueOf ( key ) ));
148+ assertNull (strings .put (str , key ));
151149 assertEquals (uniqueCount , key );
152150 uniqueCount ++;
153151 assertEquals (hash .size (), count + 1 );
@@ -158,7 +156,7 @@ public void testGet() {
158156 }
159157 for (Entry <String , Long > entry : strings .entrySet ()) {
160158 ref .copyChars (entry .getKey ());
161- assertEquals (ref .get (), hash .get (entry .getValue (). longValue () , scratch ));
159+ assertEquals (ref .get (), hash .get (entry .getValue (), scratch ));
162160 }
163161 newHash ();
164162 }
@@ -205,7 +203,7 @@ public void testAdd() {
205203 hash .close ();
206204 }
207205
208- public void testFind () throws Exception {
206+ public void testFind () {
209207 BytesRefBuilder ref = new BytesRefBuilder ();
210208 BytesRef scratch = new BytesRef ();
211209 int num = scaledRandomIntBetween (2 , 20 );
0 commit comments