ACCUMULO-2418 use utility method to count iterables
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/eab028a4 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/eab028a4 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/eab028a4 Branch: refs/heads/1.6.0-SNAPSHOT Commit: eab028a4894c363c112df051ceebbd5584075769 Parents: 948216c Author: Eric Newton <[email protected]> Authored: Thu Feb 27 12:14:42 2014 -0500 Committer: Eric Newton <[email protected]> Committed: Thu Feb 27 12:14:42 2014 -0500 ---------------------------------------------------------------------- .../org/apache/accumulo/test/CleanWalIT.java | 18 ++--------- .../test/ConfigurableMajorCompactionIT.java | 10 ++---- .../test/MasterRepairsDualAssignmentIT.java | 4 +-- .../accumulo/test/NoMutationRecoveryIT.java | 6 ++-- .../org/apache/accumulo/test/ShellServerIT.java | 5 ++- .../apache/accumulo/test/SplitRecoveryIT.java | 7 ++--- .../test/functional/BadIteratorMincIT.java | 13 +++----- .../test/functional/BigRootTabletIT.java | 9 +----- .../accumulo/test/functional/CleanTmpIT.java | 7 +---- .../accumulo/test/functional/CompactionIT.java | 9 +----- .../accumulo/test/functional/ConcurrencyIT.java | 8 +---- .../functional/ConfigurableCompactionIT.java | 10 +----- .../test/functional/DeleteEverythingIT.java | 14 +++------ .../accumulo/test/functional/ExamplesIT.java | 6 +--- .../test/functional/FunctionalTestUtils.java | 4 +-- .../test/functional/GarbageCollectorIT.java | 7 +---- .../accumulo/test/functional/ReadWriteIT.java | 8 ++--- .../accumulo/test/functional/RowDeleteIT.java | 32 +++++--------------- .../accumulo/test/functional/TableIT.java | 17 ++--------- 19 files changed, 41 insertions(+), 153 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java b/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java index 3c0f2ea..7fd60d4 100644 --- a/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java +++ b/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java @@ -18,17 +18,13 @@ package org.apache.accumulo.test; import static org.junit.Assert.assertEquals; -import java.util.Map.Entry; - 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.Scanner; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.conf.Property; -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.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.RootTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema; @@ -38,6 +34,7 @@ import org.apache.accumulo.minicluster.ServerType; import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl; import org.apache.accumulo.minicluster.impl.ProcessReference; import org.apache.accumulo.test.functional.ConfigurableMacIT; +import org.apache.accumulo.test.functional.FunctionalTestUtils; import org.apache.hadoop.conf.Configuration; import org.junit.Test; @@ -90,20 +87,11 @@ public class CleanWalIT extends ConfigurableMacIT { private int countLogs(String tableName, Connector conn) throws TableNotFoundException { Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY); scanner.fetchColumnFamily(MetadataSchema.TabletsSection.LogColumnFamily.NAME); - int count = 0; - for (@SuppressWarnings("unused") Entry<Key,Value> entry : scanner) { - count++; - } - return count; + return FunctionalTestUtils.count(scanner); } int count(String tableName, Connector conn) throws Exception { - Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY); - int result = 0; - for (@SuppressWarnings("unused") Entry<Key,Value> entry : scanner) { - result++; - } - return result; + return FunctionalTestUtils.count(conn.createScanner(tableName, Authorizations.EMPTY)); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/ConfigurableMajorCompactionIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/ConfigurableMajorCompactionIT.java b/test/src/test/java/org/apache/accumulo/test/ConfigurableMajorCompactionIT.java index ef90c3b..8968ea1 100644 --- a/test/src/test/java/org/apache/accumulo/test/ConfigurableMajorCompactionIT.java +++ b/test/src/test/java/org/apache/accumulo/test/ConfigurableMajorCompactionIT.java @@ -22,22 +22,20 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; 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.Scanner; import org.apache.accumulo.core.conf.Property; -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.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.fate.util.UtilWaitThread; import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl; import org.apache.accumulo.test.functional.ConfigurableMacIT; +import org.apache.accumulo.test.functional.FunctionalTestUtils; import org.apache.accumulo.tserver.compaction.CompactionPlan; import org.apache.accumulo.tserver.compaction.CompactionStrategy; import org.apache.accumulo.tserver.compaction.MajorCompactionRequest; @@ -100,11 +98,7 @@ public class ConfigurableMajorCompactionIT extends ConfigurableMacIT { Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY); s.setRange(MetadataSchema.TabletsSection.getRange()); s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME); - int count = 0; - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : s) - count++; - return count; + return FunctionalTestUtils.count(s); } private void writeFile(Connector conn, String tableName) throws Exception { http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/MasterRepairsDualAssignmentIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/MasterRepairsDualAssignmentIT.java b/test/src/test/java/org/apache/accumulo/test/MasterRepairsDualAssignmentIT.java index cc51d63..86c5004 100644 --- a/test/src/test/java/org/apache/accumulo/test/MasterRepairsDualAssignmentIT.java +++ b/test/src/test/java/org/apache/accumulo/test/MasterRepairsDualAssignmentIT.java @@ -44,6 +44,7 @@ import org.apache.accumulo.server.master.state.RootTabletStateStore; import org.apache.accumulo.server.master.state.TServerInstance; import org.apache.accumulo.server.master.state.TabletLocationState; import org.apache.accumulo.test.functional.ConfigurableMacIT; +import org.apache.accumulo.test.functional.FunctionalTestUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Text; import org.junit.Test; @@ -133,8 +134,7 @@ public class MasterRepairsDualAssignmentIT extends ConfigurableMacIT { private void waitForCleanStore(MetaDataStateStore store) { while (true) { try { - for (@SuppressWarnings("unused") TabletLocationState tls : store) - ; + FunctionalTestUtils.count(store); } catch (Exception ex) { System.out.println(ex); UtilWaitThread.sleep(250); http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/NoMutationRecoveryIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/NoMutationRecoveryIT.java b/test/src/test/java/org/apache/accumulo/test/NoMutationRecoveryIT.java index 2d9aafb..65036ab 100644 --- a/test/src/test/java/org/apache/accumulo/test/NoMutationRecoveryIT.java +++ b/test/src/test/java/org/apache/accumulo/test/NoMutationRecoveryIT.java @@ -19,7 +19,6 @@ package org.apache.accumulo.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.util.Map.Entry; @@ -40,6 +39,7 @@ import org.apache.accumulo.minicluster.ServerType; import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl; import org.apache.accumulo.minicluster.impl.ProcessReference; import org.apache.accumulo.test.functional.ConfigurableMacIT; +import org.apache.accumulo.test.functional.FunctionalTestUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Text; import org.junit.Test; @@ -69,9 +69,7 @@ public class NoMutationRecoveryIT extends ConfigurableMacIT { update(conn, TABLE, new Text("row"), new Text("cf"), new Text("cq"), new Value("value".getBytes())); Entry<Key, Value> logRef = getLogRef(conn, MetadataTable.NAME); conn.tableOperations().flush(TABLE, null, null, true); - for (@SuppressWarnings("unused") Entry<Key, Value> refs : getLogRefs(conn, MetadataTable.NAME)) { - fail("should not have any refs"); - } + assertEquals(0, FunctionalTestUtils.count(getLogRefs(conn, MetadataTable.NAME))); conn.securityOperations().grantTablePermission(conn.whoami(), MetadataTable.NAME, TablePermission.WRITE); update(conn, MetadataTable.NAME, logRef); assertTrue(equals(logRef, getLogRef(conn, MetadataTable.NAME))); http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java b/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java index 8b220da..da094e8 100644 --- a/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java +++ b/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java @@ -50,6 +50,7 @@ import org.apache.accumulo.core.metadata.RootTable; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.util.UtilWaitThread; import org.apache.accumulo.core.util.shell.Shell; +import org.apache.accumulo.test.functional.FunctionalTestUtils; import org.apache.accumulo.test.functional.SimpleMacIT; import org.apache.accumulo.tracer.TraceServer; import org.apache.commons.io.FileUtils; @@ -917,9 +918,7 @@ public class ShellServerIT extends SimpleMacIT { try { Connector connector = getConnector(); Scanner s = connector.createScanner(table, Authorizations.EMPTY); - for (@SuppressWarnings("unused") - Entry<Key,Value> kv : s) - ; + FunctionalTestUtils.count(s); } catch (Exception ex) { throw new RuntimeException(ex); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/SplitRecoveryIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/SplitRecoveryIT.java b/test/src/test/java/org/apache/accumulo/test/SplitRecoveryIT.java index b53a724..64762de 100644 --- a/test/src/test/java/org/apache/accumulo/test/SplitRecoveryIT.java +++ b/test/src/test/java/org/apache/accumulo/test/SplitRecoveryIT.java @@ -36,6 +36,7 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.Da import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.security.TablePermission; import org.apache.accumulo.core.util.UtilWaitThread; +import org.apache.accumulo.test.functional.FunctionalTestUtils; import org.apache.accumulo.test.functional.SimpleMacIT; import org.apache.hadoop.io.Text; import org.junit.Test; @@ -53,11 +54,7 @@ public class SplitRecoveryIT extends SimpleMacIT { Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY); scanner.setRange(new Range(new Text(tableId + ";"), new Text(tableId + "<"))); scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME); - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : scanner) { - return false; - } - return true; + return FunctionalTestUtils.count(scanner) == 0; } @Test(timeout = 60000) http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java b/test/src/test/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java index ac425b3..c304b9b 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java @@ -16,6 +16,8 @@ */ package org.apache.accumulo.test.functional; +import static org.junit.Assert.assertEquals; + import java.util.EnumSet; import java.util.Map.Entry; @@ -60,15 +62,8 @@ public class BadIteratorMincIT extends SimpleMacIT { // try to scan table Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY); - - int count = 0; - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : scanner) { - count++; - } - - if (count != 1) - throw new Exception("Did not see expected # entries " + count); + int count = FunctionalTestUtils.count(scanner); + assertEquals("Did not see expected # entries " + count, 1, count); // remove the bad iterator c.tableOperations().removeIterator(tableName, BadIterator.class.getSimpleName(), EnumSet.of(IteratorScope.minc)); http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/BigRootTabletIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BigRootTabletIT.java b/test/src/test/java/org/apache/accumulo/test/functional/BigRootTabletIT.java index 599b0bf..0e0671b 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/BigRootTabletIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/BigRootTabletIT.java @@ -20,12 +20,9 @@ import static org.junit.Assert.assertTrue; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.data.Key; -import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.RootTable; import org.apache.accumulo.core.security.Authorizations; @@ -55,11 +52,7 @@ public class BigRootTabletIT extends ConfigurableMacIT { } cluster.stop(); cluster.start(); - int count = 0; - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : c.createScanner(RootTable.NAME, Authorizations.EMPTY)) - count++; - assertTrue(count > 0); + assertTrue(FunctionalTestUtils.count(c.createScanner(RootTable.NAME, Authorizations.EMPTY)) > 0); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/CleanTmpIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/CleanTmpIT.java b/test/src/test/java/org/apache/accumulo/test/functional/CleanTmpIT.java index d02f041..ec103f2 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/CleanTmpIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/CleanTmpIT.java @@ -20,16 +20,13 @@ import static org.junit.Assert.assertFalse; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; 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.Scanner; import org.apache.accumulo.core.conf.Property; -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.core.security.Authorizations; import org.apache.accumulo.minicluster.ServerType; import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl; @@ -74,9 +71,7 @@ public class CleanTmpIT extends ConfigurableMacIT { getCluster().start(); Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY); - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : scanner) - ; + FunctionalTestUtils.count(scanner); assertFalse(fs.exists(tmp)); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/CompactionIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/CompactionIT.java b/test/src/test/java/org/apache/accumulo/test/functional/CompactionIT.java index 2829533..e7ccdd2 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/CompactionIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/CompactionIT.java @@ -25,15 +25,12 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.accumulo.core.cli.ScannerOpts; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.data.Key; -import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema; import org.apache.accumulo.core.security.Authorizations; @@ -110,11 +107,7 @@ public class CompactionIT extends ConfigurableMacIT { Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY); s.fetchColumnFamily(MetadataSchema.TabletsSection.TabletColumnFamily.NAME); s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME); - int i = 0; - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : s) - i++; - return i; + return FunctionalTestUtils.count(s); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/ConcurrencyIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/ConcurrencyIT.java b/test/src/test/java/org/apache/accumulo/test/functional/ConcurrencyIT.java index 60c530b..b2d16ad 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/ConcurrencyIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/ConcurrencyIT.java @@ -18,7 +18,6 @@ package org.apache.accumulo.test.functional; import java.util.Collections; import java.util.EnumSet; -import java.util.Map.Entry; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.AccumuloException; @@ -32,7 +31,6 @@ import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.TableExistsException; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.conf.Property; -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.core.iterators.IteratorUtil.IteratorScope; @@ -59,11 +57,7 @@ public class ConcurrencyIT extends ConfigurableMacIT { @Override public void run() { - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : scanner) { - count++; - } - + count = FunctionalTestUtils.count(scanner); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/ConfigurableCompactionIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/ConfigurableCompactionIT.java b/test/src/test/java/org/apache/accumulo/test/functional/ConfigurableCompactionIT.java index a208cc0..a465350 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/ConfigurableCompactionIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/ConfigurableCompactionIT.java @@ -21,7 +21,6 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.Collections; import java.util.Map; -import java.util.Map.Entry; import java.util.Random; import org.apache.accumulo.core.client.BatchWriter; @@ -29,9 +28,7 @@ import org.apache.accumulo.core.client.BatchWriterConfig; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.conf.Property; -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.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema; import org.apache.accumulo.core.security.Authorizations; @@ -120,12 +117,7 @@ public class ConfigurableCompactionIT extends ConfigurableMacIT { private int countFiles(Connector c, String tableName) throws Exception { Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY); s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME); - int count = 0; - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : s) { - count++; - } - return count; + return FunctionalTestUtils.count(s); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java b/test/src/test/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java index a0bf118..e251157 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java @@ -16,6 +16,8 @@ */ package org.apache.accumulo.test.functional; +import static org.junit.Assert.*; + import java.util.Collections; import java.util.Map.Entry; @@ -64,16 +66,8 @@ public class DeleteEverythingIT extends ConfigurableMacIT { Scanner scanner = getConnector().createScanner("de", Authorizations.EMPTY); scanner.setRange(new Range()); - - int count = 0; - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : scanner) { - count++; - } - - if (count != 0) - throw new Exception("count == " + count); - + int count = FunctionalTestUtils.count(scanner); + assertEquals("count == " + count, 0, count); getConnector().tableOperations().flush("de", null, null, true); getConnector().tableOperations().setProperty("de", Property.TABLE_MAJC_RATIO.getKey(), "1.0"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java b/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java index 74881b3..824002f 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java @@ -209,11 +209,7 @@ public class ExamplesIT extends AbstractMacIT { bw.addMutation(m); bw.close(); UtilWaitThread.sleep(1000); - int count = 0; - for (@SuppressWarnings("unused") - Entry<Key,Value> line : c.createScanner("filtertest", Authorizations.EMPTY)) - count++; - assertEquals(0, count); + assertEquals(0, FunctionalTestUtils.count(c.createScanner("filtertest", Authorizations.EMPTY))); } @Test(timeout = 60 * 1000) http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java b/test/src/test/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java index 28a1bf2..1246efe 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java @@ -171,9 +171,9 @@ public class FunctionalTestUtils { return result; } - public static int count(Iterable<Entry<Key, Value>> i) { + public static int count(Iterable<?> i) { int count = 0; - for (@SuppressWarnings("unused") Entry<Key,Value> entry : i) + for (@SuppressWarnings("unused") Object entry : i) count++; return count; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java b/test/src/test/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java index 887e55a..3a9b404 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.cli.BatchWriterOpts; @@ -34,7 +33,6 @@ 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.conf.Property; -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.core.metadata.MetadataTable; @@ -163,10 +161,7 @@ public class GarbageCollectorIT extends ConfigurableMacIT { cluster.start(); // did it recover? Scanner scanner = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY); - for (@SuppressWarnings("unused") - Entry<Key,Value> unused : scanner) { - - } + FunctionalTestUtils.count(scanner); } @Test(timeout = 60 * 1000) http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/ReadWriteIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/ReadWriteIT.java b/test/src/test/java/org/apache/accumulo/test/functional/ReadWriteIT.java index 834d3d7..e845d99 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/ReadWriteIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/ReadWriteIT.java @@ -187,16 +187,12 @@ public class ReadWriteIT extends ConfigurableMacIT { long now = System.currentTimeMillis(); Scanner scanner = connector.createScanner("test_ingest", Authorizations.EMPTY); scanner.fetchColumnFamily(new Text("colf")); - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : scanner) - ; + FunctionalTestUtils.count(scanner); long diff = System.currentTimeMillis() - now; now = System.currentTimeMillis(); scanner = connector.createScanner("test_ingest", Authorizations.EMPTY); scanner.fetchColumnFamily(new Text("colf2")); - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : scanner) - ; + FunctionalTestUtils.count(scanner); bw.close(); long diff2 = System.currentTimeMillis() - now; assertTrue(diff2 < diff); http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/RowDeleteIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/RowDeleteIT.java b/test/src/test/java/org/apache/accumulo/test/functional/RowDeleteIT.java index c04be14..886af49 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/RowDeleteIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/RowDeleteIT.java @@ -18,12 +18,12 @@ package org.apache.accumulo.test.functional; import static org.apache.accumulo.test.functional.FunctionalTestUtils.checkRFiles; import static org.apache.accumulo.test.functional.FunctionalTestUtils.nm; +import static org.junit.Assert.assertEquals; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import org.apache.accumulo.core.client.BatchWriter; @@ -32,8 +32,6 @@ import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.data.Key; -import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope; import org.apache.accumulo.core.iterators.user.RowDeletingIterator; import org.apache.accumulo.core.security.Authorizations; @@ -72,14 +70,9 @@ public class RowDeleteIT extends ConfigurableMacIT { checkRFiles(c, "rdel1", 1, 1, 1, 1); - int count = 0; Scanner scanner = c.createScanner("rdel1", Authorizations.EMPTY); - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : scanner) { - count++; - } - if (count != 2) - throw new Exception("1 count=" + count); + int count = FunctionalTestUtils.count(scanner); + assertEquals("count == " + count, 2, count); bw.addMutation(nm("r1", "", "", RowDeletingIterator.DELETE_ROW_VALUE)); @@ -88,28 +81,17 @@ public class RowDeleteIT extends ConfigurableMacIT { checkRFiles(c, "rdel1", 1, 1, 2, 2); - count = 0; scanner = c.createScanner("rdel1", Authorizations.EMPTY); - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : scanner) { - count++; - } - if (count != 3) - throw new Exception("2 count=" + count); + count = FunctionalTestUtils.count(scanner); + assertEquals("count == " + count, 3, count); c.tableOperations().compact("rdel1", null, null, false, true); checkRFiles(c, "rdel1", 1, 1, 0, 0); - count = 0; scanner = c.createScanner("rdel1", Authorizations.EMPTY); - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : scanner) { - count++; - } - if (count != 0) - throw new Exception("3 count=" + count); - + count = FunctionalTestUtils.count(scanner); + assertEquals("count == " + count, 0, count); bw.close(); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/eab028a4/test/src/test/java/org/apache/accumulo/test/functional/TableIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/TableIT.java b/test/src/test/java/org/apache/accumulo/test/functional/TableIT.java index a9e78f8..36c80f6 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/TableIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/TableIT.java @@ -21,16 +21,13 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.FileNotFoundException; -import java.util.Map.Entry; import org.apache.accumulo.core.cli.BatchWriterOpts; import org.apache.accumulo.core.cli.ScannerOpts; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.admin.TableOperations; -import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.KeyExtent; -import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema; import org.apache.accumulo.core.security.Authorizations; @@ -61,21 +58,11 @@ public class TableIT extends SimpleMacIT { Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY); s.setRange(new KeyExtent(new Text(id), null, null).toMetadataRange()); s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME); - int count = 0; - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : s) { - count++; - } - assertTrue(count > 0); + assertTrue(FunctionalTestUtils.count(s) > 0); FileSystem fs = FileSystem.get(CachedConfiguration.getInstance()); assertTrue(fs.listStatus(new Path(rootPath() + "/accumulo/tables/" + id)).length > 0); to.delete(tableName); - count = 0; - for (@SuppressWarnings("unused") - Entry<Key,Value> entry : s) { - count++; - } - assertEquals(0, count); + assertEquals(0, FunctionalTestUtils.count(s)); try { assertEquals(0, fs.listStatus(new Path(rootPath() + "/accumulo/tables/" + id)).length); } catch (FileNotFoundException ex) {
