You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2014/04/17 00:01:38 UTC
[1/2] git commit: ACCUMULO-1362 Ensure resources are closed and
warnings removed
Repository: accumulo
Updated Branches:
refs/heads/master 121cb5f1d -> ecfdf8d7c
ACCUMULO-1362 Ensure resources are closed and warnings removed
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/082d43d6
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/082d43d6
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/082d43d6
Branch: refs/heads/master
Commit: 082d43d690ef30dee79d3230ec5eba4ac795a361
Parents: 121cb5f
Author: Christopher Tubbs <ct...@apache.org>
Authored: Wed Apr 16 17:44:57 2014 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Wed Apr 16 18:01:25 2014 -0400
----------------------------------------------------------------------
.../client/mapreduce/lib/impl/ConfiguratorBase.java | 8 +-------
.../apache/accumulo/minicluster/MiniAccumuloRunner.java | 5 +++--
.../minicluster/impl/MiniAccumuloClusterImpl.java | 12 ++++++------
.../start/classloader/vfs/AccumuloVFSClassLoader.java | 3 +--
4 files changed, 11 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/082d43d6/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
index c86623a..4610556 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
@@ -250,8 +250,7 @@ public class ConfiguratorBase {
} catch (IOException e) {
throw new IllegalArgumentException("Couldn't open password file called \"" + tokenFile + "\".");
}
- java.util.Scanner fileScanner = new java.util.Scanner(in);
- try {
+ try (java.util.Scanner fileScanner = new java.util.Scanner(in)) {
while (fileScanner.hasNextLine()) {
Credentials creds = Credentials.deserialize(fileScanner.nextLine());
if (principal.equals(creds.getPrincipal())) {
@@ -259,11 +258,6 @@ public class ConfiguratorBase {
}
}
throw new IllegalArgumentException("Couldn't find token for user \"" + principal + "\" in file \"" + tokenFile + "\"");
- } finally {
- if (fileScanner != null && fileScanner.ioException() == null)
- fileScanner.close();
- else if (fileScanner.ioException() != null)
- throw new RuntimeException(fileScanner.ioException());
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/082d43d6/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
index ab84d37..a7e2a3c 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
@@ -203,8 +203,9 @@ public class MiniAccumuloRunner {
printInfo(accumulo, shutdownPort);
// start a socket on the shutdown port and block- anything connected to this port will activate the shutdown
- ServerSocket shutdownServer = new ServerSocket(shutdownPort);
- shutdownServer.accept();
+ try (ServerSocket shutdownServer = new ServerSocket(shutdownPort)) {
+ shutdownServer.accept();
+ }
System.exit(0);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/082d43d6/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
index d054718..6934a1b 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
@@ -131,7 +131,7 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
}
}
- private static final long ZOOKEEPER_STARTUP_WAIT = 20*1000;
+ private static final long ZOOKEEPER_STARTUP_WAIT = 20 * 1000;
private boolean initialized = false;
private Process zooKeeperProcess = null;
@@ -210,9 +210,7 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
if (classLoader instanceof URLClassLoader) {
- URLClassLoader ucl = (URLClassLoader) classLoader;
-
- for (URL u : ucl.getURLs()) {
+ for (URL u : ((URLClassLoader) classLoader).getURLs()) {
append(classpathBuilder, u);
}
@@ -251,7 +249,8 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
for (Entry<String,String> sysProp : config.getSystemProperties().entrySet()) {
argList.add(String.format("-D%s=%s", sysProp.getKey(), sysProp.getValue()));
}
- argList.addAll(Arrays.asList("-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75", "-Dapple.awt.UIElement=true", Main.class.getName(), className));
+ argList.addAll(Arrays.asList("-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75", "-Dapple.awt.UIElement=true", Main.class.getName(),
+ className));
argList.addAll(Arrays.asList(args));
ProcessBuilder builder = new ProcessBuilder(argList);
@@ -457,7 +456,8 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
break;
} catch (Exception e) {
if (System.currentTimeMillis() - startTime >= ZOOKEEPER_STARTUP_WAIT) {
- throw new RuntimeException("Zookeeper did not start within " + (ZOOKEEPER_STARTUP_WAIT/1000) + " seconds. Check the logs in " + config.getLogDir() + " for errors. Last exception: " + e);
+ throw new RuntimeException("Zookeeper did not start within " + (ZOOKEEPER_STARTUP_WAIT / 1000) + " seconds. Check the logs in "
+ + config.getLogDir() + " for errors. Last exception: " + e);
}
UtilWaitThread.sleep(250);
} finally {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/082d43d6/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
----------------------------------------------------------------------
diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
index fa20725..ccd27b1 100644
--- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
+++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
@@ -322,10 +322,9 @@ public class AccumuloVFSClassLoader {
if (classLoader instanceof URLClassLoader) {
// If VFS class loader enabled, but no contexts defined.
- URLClassLoader ucl = (URLClassLoader) classLoader;
out.print("Level " + classLoaderDescription + " URL classpath items are:");
- for (URL u : ucl.getURLs()) {
+ for (URL u : ((URLClassLoader) classLoader).getURLs()) {
out.print("\t" + u.toExternalForm());
}
[2/2] git commit: ACCUMULO-2683 Fix type safety with generics/varargs
in lexicoder tests
Posted by ct...@apache.org.
ACCUMULO-2683 Fix type safety with generics/varargs in lexicoder tests
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/ecfdf8d7
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/ecfdf8d7
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/ecfdf8d7
Branch: refs/heads/master
Commit: ecfdf8d7c7f07b773edabf9de79ac1d60b33bd9c
Parents: 082d43d
Author: Christopher Tubbs <ct...@apache.org>
Authored: Wed Apr 16 17:50:50 2014 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Wed Apr 16 18:01:35 2014 -0400
----------------------------------------------------------------------
.../lexicoder/BigIntegerLexicoderTest.java | 17 ++++++------
.../client/lexicoder/DoubleLexicoderTest.java | 10 ++++---
.../client/lexicoder/IntegerLexicoderTest.java | 6 ++--
.../core/client/lexicoder/LexicoderTest.java | 24 ++++++++--------
.../client/lexicoder/LongLexicoderTest.java | 8 ++++--
.../client/lexicoder/PairLexicoderTest.java | 19 +++++++------
.../client/lexicoder/ReverseLexicoderTest.java | 29 ++++++++++----------
.../client/lexicoder/ULongLexicoderTest.java | 18 ++++++------
.../client/lexicoder/UUIDLexicoderTest.java | 14 ++++++----
9 files changed, 79 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ecfdf8d7/core/src/test/java/org/apache/accumulo/core/client/lexicoder/BigIntegerLexicoderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/BigIntegerLexicoderTest.java b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/BigIntegerLexicoderTest.java
index 587ceca..347649c 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/BigIntegerLexicoderTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/BigIntegerLexicoderTest.java
@@ -17,19 +17,20 @@
package org.apache.accumulo.core.client.lexicoder;
import java.math.BigInteger;
+import java.util.Arrays;
/**
*
*/
public class BigIntegerLexicoderTest extends LexicoderTest {
public void testSortOrder() {
- assertSortOrder(new BigIntegerLexicoder(), new BigInteger("-1"), new BigInteger("0"), new BigInteger("1"), new BigInteger("-257"), new BigInteger("-256"),
- new BigInteger("-255"), new BigInteger("255"), new BigInteger("256"), new BigInteger("257"), new BigInteger("65534"), new BigInteger("65535"),
- new BigInteger("65536"), new BigInteger("65537"), new BigInteger("-65534"), new BigInteger("-65535"), new BigInteger("-65536"),
- new BigInteger("-65537"), new BigInteger("2147483648"), new BigInteger("2147483647"), new BigInteger("2147483649"), new BigInteger("-2147483648"),
- new BigInteger("-2147483647"), new BigInteger("-2147483649"), new BigInteger("32768"), new BigInteger("32769"), new BigInteger("32767"),
- new BigInteger("-32768"), new BigInteger("-32769"), new BigInteger("-32767"), new BigInteger("126"), new BigInteger("127"), new BigInteger("128"),
- new BigInteger("129"), new BigInteger("-126"), new BigInteger("-127"), new BigInteger("-128"), new BigInteger("-129"));
-
+ assertSortOrder(new BigIntegerLexicoder(), Arrays.asList(new BigInteger("-1"), new BigInteger("0"), new BigInteger("1"), new BigInteger("-257"),
+ new BigInteger("-256"), new BigInteger("-255"), new BigInteger("255"), new BigInteger("256"), new BigInteger("257"), new BigInteger("65534"),
+ new BigInteger("65535"), new BigInteger("65536"), new BigInteger("65537"), new BigInteger("-65534"), new BigInteger("-65535"),
+ new BigInteger("-65536"), new BigInteger("-65537"), new BigInteger("2147483648"), new BigInteger("2147483647"), new BigInteger("2147483649"),
+ new BigInteger("-2147483648"), new BigInteger("-2147483647"), new BigInteger("-2147483649"), new BigInteger("32768"), new BigInteger("32769"),
+ new BigInteger("32767"), new BigInteger("-32768"), new BigInteger("-32769"), new BigInteger("-32767"), new BigInteger("126"), new BigInteger("127"),
+ new BigInteger("128"), new BigInteger("129"), new BigInteger("-126"), new BigInteger("-127"), new BigInteger("-128"), new BigInteger("-129")));
+
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ecfdf8d7/core/src/test/java/org/apache/accumulo/core/client/lexicoder/DoubleLexicoderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/DoubleLexicoderTest.java b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/DoubleLexicoderTest.java
index 6eb871e..b299896 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/DoubleLexicoderTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/DoubleLexicoderTest.java
@@ -16,15 +16,17 @@
*/
package org.apache.accumulo.core.client.lexicoder;
+import java.util.Arrays;
+
/**
*
*/
public class DoubleLexicoderTest extends LexicoderTest {
public void testSortOrder() {
- assertSortOrder(new DoubleLexicoder(), Double.MIN_VALUE, Double.MAX_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 0.0, 0.01, 0.001, 1.0, -1.0,
- -1.1, -1.01, Math.nextUp(Double.NEGATIVE_INFINITY), Math.nextAfter(0.0, Double.NEGATIVE_INFINITY),
+ assertSortOrder(new DoubleLexicoder(), Arrays.asList(Double.MIN_VALUE, Double.MAX_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 0.0, 0.01,
+ 0.001, 1.0, -1.0, -1.1, -1.01, Math.nextUp(Double.NEGATIVE_INFINITY), Math.nextAfter(0.0, Double.NEGATIVE_INFINITY),
Math.nextAfter(Double.MAX_VALUE, Double.NEGATIVE_INFINITY), Math.pow(10.0, 30.0) * -1.0, Math.pow(10.0, 30.0), Math.pow(10.0, -30.0) * -1.0,
- Math.pow(10.0, -30.0));
-
+ Math.pow(10.0, -30.0)));
+
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ecfdf8d7/core/src/test/java/org/apache/accumulo/core/client/lexicoder/IntegerLexicoderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/IntegerLexicoderTest.java b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/IntegerLexicoderTest.java
index f289aaf..0af4792 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/IntegerLexicoderTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/IntegerLexicoderTest.java
@@ -16,9 +16,11 @@
*/
package org.apache.accumulo.core.client.lexicoder;
+import java.util.Arrays;
+
public class IntegerLexicoderTest extends LexicoderTest {
public void testSortOrder() {
- assertSortOrder(new IntegerLexicoder(), Integer.MIN_VALUE, 0xff123456, 0xffff3456, 0xffffff56, -1, 0, 1, 0x12, 0x1234, 0x123456, 0x1234678,
- Integer.MAX_VALUE);
+ assertSortOrder(new IntegerLexicoder(),
+ Arrays.asList(Integer.MIN_VALUE, 0xff123456, 0xffff3456, 0xffffff56, -1, 0, 1, 0x12, 0x1234, 0x123456, 0x1234678, Integer.MAX_VALUE));
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ecfdf8d7/core/src/test/java/org/apache/accumulo/core/client/lexicoder/LexicoderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/LexicoderTest.java b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/LexicoderTest.java
index 2654560..4b798b6 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/LexicoderTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/LexicoderTest.java
@@ -27,38 +27,38 @@ import org.apache.accumulo.core.util.TextUtil;
import org.apache.hadoop.io.Text;
public abstract class LexicoderTest extends TestCase {
-
+
void assertEqualsB(byte[] ba1, byte[] ba2) {
assertEquals(new Text(ba2), new Text(ba1));
}
-
- public <T extends Comparable<T>> void assertSortOrder(Lexicoder<T> lexicoder, Comparator<T> comp, T... data) {
+
+ public <T extends Comparable<T>> void assertSortOrder(Lexicoder<T> lexicoder, Comparator<T> comp, List<T> data) {
List<T> list = new ArrayList<T>();
List<Text> encList = new ArrayList<Text>();
-
+
for (T d : data) {
list.add(d);
encList.add(new Text(lexicoder.encode(d)));
}
-
+
if (comp != null)
Collections.sort(list, comp);
else
Collections.sort(list);
-
+
Collections.sort(encList);
-
+
List<T> decodedList = new ArrayList<T>();
-
+
for (Text t : encList) {
decodedList.add(lexicoder.decode(TextUtil.getBytes(t)));
}
-
+
assertEquals(list, decodedList);
}
-
- public <T extends Comparable<T>> void assertSortOrder(Lexicoder<T> lexicoder, T... data) {
+
+ public <T extends Comparable<T>> void assertSortOrder(Lexicoder<T> lexicoder, List<T> data) {
assertSortOrder(lexicoder, null, data);
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ecfdf8d7/core/src/test/java/org/apache/accumulo/core/client/lexicoder/LongLexicoderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/LongLexicoderTest.java b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/LongLexicoderTest.java
index 88a48e3..bf9a3a7 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/LongLexicoderTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/LongLexicoderTest.java
@@ -16,11 +16,13 @@
*/
package org.apache.accumulo.core.client.lexicoder;
+import java.util.Arrays;
+
public class LongLexicoderTest extends LexicoderTest {
public void testSortOrder() {
-
- assertSortOrder(new LongLexicoder(), Long.MIN_VALUE, 0xff1234567890abcdl, 0xffff1234567890abl, 0xffffff567890abcdl, 0xffffffff7890abcdl,
+
+ assertSortOrder(new LongLexicoder(), Arrays.asList(Long.MIN_VALUE, 0xff1234567890abcdl, 0xffff1234567890abl, 0xffffff567890abcdl, 0xffffffff7890abcdl,
0xffffffffff90abcdl, 0xffffffffffffabcdl, 0xffffffffffffffcdl, -1l, 0l, 0x01l, 0x1234l, 0x123456l, 0x12345678l, 0x1234567890l, 0x1234567890abl,
- 0x1234567890abcdl, 0x1234567890abcdefl, Long.MAX_VALUE);
+ 0x1234567890abcdl, 0x1234567890abcdefl, Long.MAX_VALUE));
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ecfdf8d7/core/src/test/java/org/apache/accumulo/core/client/lexicoder/PairLexicoderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/PairLexicoderTest.java b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/PairLexicoderTest.java
index a59781e..a653259 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/PairLexicoderTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/PairLexicoderTest.java
@@ -16,23 +16,24 @@
*/
package org.apache.accumulo.core.client.lexicoder;
+import java.util.Arrays;
+
import org.apache.accumulo.core.util.ComparablePair;
/**
*
*/
public class PairLexicoderTest extends LexicoderTest {
- @SuppressWarnings("unchecked")
public void testSortOrder() {
PairLexicoder<String,String> plexc = new PairLexicoder<String,String>(new StringLexicoder(), new StringLexicoder());
-
- assertSortOrder(plexc, new ComparablePair<String,String>("a", "b"), new ComparablePair<String,String>("a", "bc"), new ComparablePair<String,String>("a",
- "c"), new ComparablePair<String,String>("ab", "c"), new ComparablePair<String,String>("ab", ""), new ComparablePair<String,String>("ab", "d"),
- new ComparablePair<String,String>("b", "f"), new ComparablePair<String,String>("b", "a"));
-
+
+ assertSortOrder(plexc, Arrays.asList(new ComparablePair<String,String>("a", "b"), new ComparablePair<String,String>("a", "bc"),
+ new ComparablePair<String,String>("a", "c"), new ComparablePair<String,String>("ab", "c"), new ComparablePair<String,String>("ab", ""),
+ new ComparablePair<String,String>("ab", "d"), new ComparablePair<String,String>("b", "f"), new ComparablePair<String,String>("b", "a")));
+
PairLexicoder<Long,String> plexc2 = new PairLexicoder<Long,String>(new LongLexicoder(), new StringLexicoder());
-
- assertSortOrder(plexc2, new ComparablePair<Long,String>(0x100l, "a"), new ComparablePair<Long,String>(0x100l, "ab"), new ComparablePair<Long,String>(0xf0l,
- "a"), new ComparablePair<Long,String>(0xf0l, "ab"));
+
+ assertSortOrder(plexc2, Arrays.asList(new ComparablePair<Long,String>(0x100l, "a"), new ComparablePair<Long,String>(0x100l, "ab"),
+ new ComparablePair<Long,String>(0xf0l, "a"), new ComparablePair<Long,String>(0xf0l, "ab")));
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ecfdf8d7/core/src/test/java/org/apache/accumulo/core/client/lexicoder/ReverseLexicoderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/ReverseLexicoderTest.java b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/ReverseLexicoderTest.java
index e6bfca8..6e594be 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/ReverseLexicoderTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/ReverseLexicoderTest.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.core.client.lexicoder;
import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
@@ -26,35 +27,35 @@ import org.junit.Test;
public class ReverseLexicoderTest extends LexicoderTest {
public void testSortOrder() {
Comparator<Long> comp = Collections.reverseOrder();
- assertSortOrder(new ReverseLexicoder<Long>(new LongLexicoder()), comp, Long.MIN_VALUE, 0xff1234567890abcdl, 0xffff1234567890abl, 0xffffff567890abcdl,
- 0xffffffff7890abcdl, 0xffffffffff90abcdl, 0xffffffffffffabcdl, 0xffffffffffffffcdl, -1l, 0l, 0x01l, 0x1234l, 0x123456l, 0x12345678l, 0x1234567890l,
- 0x1234567890abl, 0x1234567890abcdl, 0x1234567890abcdefl, Long.MAX_VALUE);
-
+ assertSortOrder(new ReverseLexicoder<Long>(new LongLexicoder()), comp, Arrays.asList(Long.MIN_VALUE, 0xff1234567890abcdl, 0xffff1234567890abl,
+ 0xffffff567890abcdl, 0xffffffff7890abcdl, 0xffffffffff90abcdl, 0xffffffffffffabcdl, 0xffffffffffffffcdl, -1l, 0l, 0x01l, 0x1234l, 0x123456l,
+ 0x12345678l, 0x1234567890l, 0x1234567890abl, 0x1234567890abcdl, 0x1234567890abcdefl, Long.MAX_VALUE));
+
Comparator<String> comp2 = Collections.reverseOrder();
- assertSortOrder(new ReverseLexicoder<String>(new StringLexicoder()), comp2, "a", "aa", "ab", "b", "aab");
-
+ assertSortOrder(new ReverseLexicoder<String>(new StringLexicoder()), comp2, Arrays.asList("a", "aa", "ab", "b", "aab"));
+
}
-
+
/**
* Just a simple test verifying reverse indexed dates
*/
@Test
public void testReverseSortDates() throws UnsupportedEncodingException {
-
+
ReverseLexicoder<Date> revLex = new ReverseLexicoder<Date>(new DateLexicoder());
-
+
Date date1 = new Date();
Date date2 = new Date(System.currentTimeMillis() + 10000);
Date date3 = new Date(System.currentTimeMillis() + 500);
-
+
Comparator<Date> comparator = Collections.reverseOrder();
- assertSortOrder(revLex, comparator, date1, date2, date3);
-
+ assertSortOrder(revLex, comparator, Arrays.asList(date1, date2, date3));
+
// truncate date to hours
long time = System.currentTimeMillis() - (System.currentTimeMillis() % 3600000);
Date date = new Date(time);
-
+
System.out.println(date);
-
+
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ecfdf8d7/core/src/test/java/org/apache/accumulo/core/client/lexicoder/ULongLexicoderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/ULongLexicoderTest.java b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/ULongLexicoderTest.java
index 30f9638..acf0fb3 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/ULongLexicoderTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/ULongLexicoderTest.java
@@ -16,11 +16,13 @@
*/
package org.apache.accumulo.core.client.lexicoder;
+import java.util.Arrays;
+
public class ULongLexicoderTest extends LexicoderTest {
-
+
public void testEncoding() {
ULongLexicoder ull = new ULongLexicoder();
-
+
assertEqualsB(ull.encode(0l), new byte[] {0x00});
assertEqualsB(ull.encode(0x01l), new byte[] {0x01, 0x01});
assertEqualsB(ull.encode(0x1234l), new byte[] {0x02, 0x12, 0x34});
@@ -30,7 +32,7 @@ public class ULongLexicoderTest extends LexicoderTest {
assertEqualsB(ull.encode(0x1234567890abl), new byte[] {0x06, 0x12, 0x34, 0x56, 0x78, (byte) 0x90, (byte) 0xab});
assertEqualsB(ull.encode(0x1234567890abcdl), new byte[] {0x07, 0x12, 0x34, 0x56, 0x78, (byte) 0x90, (byte) 0xab, (byte) 0xcd});
assertEqualsB(ull.encode(0x1234567890abcdefl), new byte[] {0x08, 0x12, 0x34, 0x56, 0x78, (byte) 0x90, (byte) 0xab, (byte) 0xcd, (byte) 0xef});
-
+
assertEqualsB(ull.encode(0xff34567890abcdefl), new byte[] {0x09, 0x34, 0x56, 0x78, (byte) 0x90, (byte) 0xab, (byte) 0xcd, (byte) 0xef});
assertEqualsB(ull.encode(0xffff567890abcdefl), new byte[] {0x0a, 0x56, 0x78, (byte) 0x90, (byte) 0xab, (byte) 0xcd, (byte) 0xef});
assertEqualsB(ull.encode(0xffffff7890abcdefl), new byte[] {0x0b, 0x78, (byte) 0x90, (byte) 0xab, (byte) 0xcd, (byte) 0xef});
@@ -38,14 +40,14 @@ public class ULongLexicoderTest extends LexicoderTest {
assertEqualsB(ull.encode(0xffffffffffabcdefl), new byte[] {0x0d, (byte) 0xab, (byte) 0xcd, (byte) 0xef});
assertEqualsB(ull.encode(0xffffffffffffcdefl), new byte[] {0x0e, (byte) 0xcd, (byte) 0xef});
assertEqualsB(ull.encode(0xffffffffffffffefl), new byte[] {0x0f, (byte) 0xef});
-
+
assertEqualsB(ull.encode(-1l), new byte[] {16});
}
-
+
public void testSortOrder() {
// only testing non negative
- assertSortOrder(new ULongLexicoder(), 0l, 0x01l, 0x1234l, 0x123456l, 0x12345678l, 0x1234567890l, 0x1234567890abl, 0x1234567890abcdl, 0x1234567890abcdefl,
- Long.MAX_VALUE);
+ assertSortOrder(new ULongLexicoder(),
+ Arrays.asList(0l, 0x01l, 0x1234l, 0x123456l, 0x12345678l, 0x1234567890l, 0x1234567890abl, 0x1234567890abcdl, 0x1234567890abcdefl, Long.MAX_VALUE));
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ecfdf8d7/core/src/test/java/org/apache/accumulo/core/client/lexicoder/UUIDLexicoderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/UUIDLexicoderTest.java b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/UUIDLexicoderTest.java
index bd3047d..26c1476 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/lexicoder/UUIDLexicoderTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/lexicoder/UUIDLexicoderTest.java
@@ -17,21 +17,23 @@
package org.apache.accumulo.core.client.lexicoder;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.UUID;
public class UUIDLexicoderTest extends LexicoderTest {
public void testSortOrder() {
-
- assertSortOrder(new UUIDLexicoder(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID());
-
+
+ assertSortOrder(new UUIDLexicoder(),
+ Arrays.asList(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()));
+
ArrayList<UUID> uuids = new ArrayList<UUID>();
-
+
for (long ms = -260l; ms < 260l; ms++) {
for (long ls = -2l; ls < 2; ls++) {
uuids.add(new UUID(ms, ls));
}
}
-
- assertSortOrder(new UUIDLexicoder(), uuids.toArray(new UUID[0]));
+
+ assertSortOrder(new UUIDLexicoder(), uuids);
}
}