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 2013/09/24 19:59:32 UTC
git commit: ACCUMULO-1494 Fix warnings and formatting from patch
Updated Branches:
refs/heads/master d99626072 -> 98fc95216
ACCUMULO-1494 Fix warnings and formatting from patch
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/98fc9521
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/98fc9521
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/98fc9521
Branch: refs/heads/master
Commit: 98fc95216ce9d59ebfba0774d119421e3e00ea0c
Parents: d996260
Author: Christopher Tubbs <ct...@apache.org>
Authored: Tue Sep 24 13:58:42 2013 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Tue Sep 24 13:58:42 2013 -0400
----------------------------------------------------------------------
.../core/security/ColumnVisibilityTest.java | 39 +++++++-------
.../java/org/apache/accumulo/start/Main.java | 11 ++--
.../org/apache/accumulo/start/MainTest.java | 54 ++++++++++++--------
.../accumulo/test/randomwalk/FrameworkTest.java | 19 ++++---
4 files changed, 67 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/98fc9521/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java b/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
index 943317a..1e81b54 100644
--- a/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
@@ -20,14 +20,13 @@ import static org.apache.accumulo.core.security.ColumnVisibility.quote;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import static org.junit.Assert.*;
import org.apache.accumulo.core.security.ColumnVisibility.Node;
import org.apache.accumulo.core.security.ColumnVisibility.NodeType;
import org.junit.Test;
public class ColumnVisibilityTest {
-
+
private void shouldThrow(String... strings) {
for (String s : strings)
try {
@@ -37,45 +36,45 @@ public class ColumnVisibilityTest {
// expected
}
}
-
+
private void shouldNotThrow(String... strings) {
for (String s : strings) {
new ColumnVisibility(s.getBytes());
}
}
-
+
@Test
public void testEmpty() {
// empty visibility is valid
new ColumnVisibility();
new ColumnVisibility(new byte[0]);
}
-
+
@Test
public void testSimple() {
shouldNotThrow("test", "(one)");
}
-
+
@Test
public void testCompound() {
shouldNotThrow("a|b", "a&b", "ab&bc");
shouldNotThrow("A&B&C&D&E", "A|B|C|D|E", "(A|B|C)", "(A)|B|(C)", "A&(B)&(C)", "A&B&(L)");
shouldNotThrow("_&-&:");
}
-
+
@Test
public void testBadCharacters() {
shouldThrow("=", "*", "^", "%", "@");
shouldThrow("a*b");
}
-
+
public void normalized(String... values) {
for (int i = 0; i < values.length; i += 2) {
ColumnVisibility cv = new ColumnVisibility(values[i].getBytes());
assertArrayEquals(cv.flatten(), values[i + 1].getBytes());
}
}
-
+
@Test
public void testComplexCompound() {
shouldNotThrow("(a|b)&(x|y)");
@@ -83,17 +82,17 @@ public class ColumnVisibilityTest {
shouldNotThrow("A&FOO&(L|M)", "(A|B)&FOO&(L|M)", "A&B&(L|M|FOO)", "((A|B|C)|foo)&bar");
shouldNotThrow("(one&two)|(foo&bar)", "(one|foo)&three", "one|foo|bar", "(one|foo)|bar", "((one|foo)|bar)&two");
}
-
+
@Test
public void testNormalization() {
normalized("a", "a", "(a)", "a", "b|a", "a|b", "(b)|a", "a|b", "(b|(a|c))&x", "x&(a|b|c)", "(((a)))", "a");
final String normForm = "a&b&c";
normalized("b&c&a", normForm, "c&b&a", normForm, "a&(b&c)", normForm, "(a&c)&b", normForm);
-
+
// this an expression that's basically `expr | expr`
normalized("(d&c&b&a)|(b&c&a&d)", "a&b&c&d");
}
-
+
@Test
public void testDanglingOperators() {
shouldThrow("a|b&");
@@ -102,23 +101,23 @@ public class ColumnVisibilityTest {
shouldThrow("a|", "|a", "|", "&");
shouldThrow("&(five)", "|(five)", "(five)&", "five|", "a|(b)&", "(&five)", "(five|)");
}
-
+
@Test
public void testMissingSeparators() {
shouldThrow("one(five)", "(five)one", "(one)(two)", "a|(b(c))");
}
-
+
@Test
public void testMismatchedParentheses() {
shouldThrow("(", ")", "(a&b", "b|a)", "A|B)");
}
-
+
@Test
public void testMixedOperators() {
shouldThrow("(A&B)|(C&D)&(E)");
shouldThrow("a|b&c", "A&B&C|D", "(A&B)|(C&D)&(E)");
}
-
+
@Test
public void testQuotes() {
shouldThrow("\"\"");
@@ -131,19 +130,19 @@ public class ColumnVisibilityTest {
shouldThrow("\"B");
shouldThrow("A&\"B");
shouldThrow("A&\"B\\'");
-
+
shouldNotThrow("\"A\"");
shouldNotThrow("(\"A\")");
shouldNotThrow("A&\"B.D\"");
shouldNotThrow("A&\"B\\\\D\"");
shouldNotThrow("A&\"B\\\"D\"");
}
-
+
@Test
public void testToString() {
ColumnVisibility cv = new ColumnVisibility(quote("a"));
assertEquals("[a]", cv.toString());
-
+
// multi-byte
cv = new ColumnVisibility(quote("五"));
assertEquals("[\"五\"]", cv.toString());
@@ -164,6 +163,6 @@ public class ColumnVisibilityTest {
assertEquals(node.type, nodeType);
assertEquals(start, node.start);
assertEquals(end, node.end);
-
+
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/98fc9521/start/src/main/java/org/apache/accumulo/start/Main.java
----------------------------------------------------------------------
diff --git a/start/src/main/java/org/apache/accumulo/start/Main.java b/start/src/main/java/org/apache/accumulo/start/Main.java
index 7a9e76b..1e5a1bc 100644
--- a/start/src/main/java/org/apache/accumulo/start/Main.java
+++ b/start/src/main/java/org/apache/accumulo/start/Main.java
@@ -21,7 +21,6 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
-import java.util.jar.Manifest;
import org.apache.accumulo.start.classloader.AccumuloClassLoader;
@@ -95,8 +94,8 @@ public class Main {
System.out.println("File " + args[1] + " could not be found or read.");
System.exit(1);
} catch (ClassNotFoundException cnfe) {
- System.out.println("Classname " + (args.length > 2 ? args[2] : "in JAR manifest") +
- " not found. Please make sure you use the wholly qualified package name.");
+ System.out.println("Classname " + (args.length > 2 ? args[2] : "in JAR manifest")
+ + " not found. Please make sure you use the wholly qualified package name.");
System.exit(1);
}
} else {
@@ -132,6 +131,7 @@ public class Main {
final Object thisIsJustOneArgument = argsToPass;
final Method finalMain = main;
r = new Runnable() {
+ @Override
public void run() {
try {
finalMain.invoke(null, thisIsJustOneArgument);
@@ -154,7 +154,8 @@ public class Main {
}
private static void printUsage() {
- System.out.println("accumulo init | master | tserver | monitor | shell | admin | gc | classpath | rfile-info | login-info | tracer | minicluster | proxy | zookeeper | create-token | info | version | jar <jar> [<main class>] args | <accumulo class> args");
+ System.out
+ .println("accumulo init | master | tserver | monitor | shell | admin | gc | classpath | rfile-info | login-info | tracer | minicluster | proxy | zookeeper | create-token | info | version | jar <jar> [<main class>] args | <accumulo class> args");
}
// feature: will work even if main class isn't in the JAR
@@ -162,7 +163,7 @@ public class Main {
ClassNotFoundException explicitNotFound = null;
if (args.length >= 3) {
try {
- return cl.loadClass(args[2]); // jar jar-file main-class
+ return cl.loadClass(args[2]); // jar jar-file main-class
} catch (ClassNotFoundException cnfe) {
// assume this is the first argument, look for main class in JAR manifest
explicitNotFound = cnfe;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/98fc9521/start/src/test/java/org/apache/accumulo/start/MainTest.java
----------------------------------------------------------------------
diff --git a/start/src/test/java/org/apache/accumulo/start/MainTest.java b/start/src/test/java/org/apache/accumulo/start/MainTest.java
index 02dc46d..b529dd7 100644
--- a/start/src/test/java/org/apache/accumulo/start/MainTest.java
+++ b/start/src/test/java/org/apache/accumulo/start/MainTest.java
@@ -1,68 +1,81 @@
package org.apache.accumulo.start;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertEquals;
+
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
+
+import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.*;
-import org.easymock.Capture;
-import static org.easymock.EasyMock.*;
public class MainTest {
- private static final Class MAIN_CLASS = String.class; // arbitrary
+ private static final Class<?> MAIN_CLASS = String.class; // arbitrary
private static final String MAIN_CLASS_NAME = MAIN_CLASS.getName();
private JarFile f;
private ClassLoader cl;
- @Before public void setUp() {
+
+ @Before
+ public void setUp() {
f = createMock(JarFile.class);
cl = createMock(ClassLoader.class);
}
- @Test public void testLoadClassFromJar_ExplicitMainClass() throws Exception {
- String[] args = { "jar", "the.jar", "main.class", "arg1", "arg2" };
- expect(cl.loadClass("main.class")).andReturn(MAIN_CLASS);
+
+ @Test
+ public void testLoadClassFromJar_ExplicitMainClass() throws Exception {
+ String[] args = {"jar", "the.jar", "main.class", "arg1", "arg2"};
+ EasyMock.<Class<?>> expect(cl.loadClass("main.class")).andReturn(MAIN_CLASS);
replay(cl);
assertEquals(MAIN_CLASS, Main.loadClassFromJar(args, f, cl));
}
- @Test public void testLoadClassFromJar_ManifestMainClass() throws Exception {
- String[] args = { "jar", "the.jar", "arg1", "arg2" };
+
+ @Test
+ public void testLoadClassFromJar_ManifestMainClass() throws Exception {
+ String[] args = {"jar", "the.jar", "arg1", "arg2"};
expect(cl.loadClass("arg1")).andThrow(new ClassNotFoundException());
- expect(cl.loadClass(MAIN_CLASS_NAME)).andReturn(MAIN_CLASS);
+ EasyMock.<Class<?>> expect(cl.loadClass(MAIN_CLASS_NAME)).andReturn(MAIN_CLASS);
replay(cl);
mockManifestMainClass(f, MAIN_CLASS.getName());
replay(f);
assertEquals(MAIN_CLASS, Main.loadClassFromJar(args, f, cl));
}
- @Test(expected=ClassNotFoundException.class)
+
+ @Test(expected = ClassNotFoundException.class)
public void testLoadClassFromJar_NoMainClass() throws Exception {
- String[] args = { "jar", "the.jar", "arg1", "arg2" };
+ String[] args = {"jar", "the.jar", "arg1", "arg2"};
expect(cl.loadClass("arg1")).andThrow(new ClassNotFoundException());
replay(cl);
mockManifestMainClass(f, null);
replay(f);
Main.loadClassFromJar(args, f, cl);
}
- @Test(expected=ClassNotFoundException.class)
+
+ @Test(expected = ClassNotFoundException.class)
public void testLoadClassFromJar_NoMainClassNoArgs() throws Exception {
- String[] args = { "jar", "the.jar" };
+ String[] args = {"jar", "the.jar"};
mockManifestMainClass(f, null);
replay(f);
Main.loadClassFromJar(args, f, cl);
}
- @Test(expected=ClassNotFoundException.class)
+ @Test(expected = ClassNotFoundException.class)
public void testLoadClassFromJar_ExplicitMainClass_Fail() throws Exception {
- String[] args = { "jar", "the.jar", "main.class", "arg1", "arg2" };
+ String[] args = {"jar", "the.jar", "main.class", "arg1", "arg2"};
expect(cl.loadClass("main.class")).andThrow(new ClassNotFoundException());
replay(cl);
mockManifestMainClass(f, null);
replay(f);
Main.loadClassFromJar(args, f, cl);
}
- @Test(expected=ClassNotFoundException.class)
+
+ @Test(expected = ClassNotFoundException.class)
public void testLoadClassFromJar_ManifestMainClass_Fail() throws Exception {
- String[] args = { "jar", "the.jar", "arg1", "arg2" };
+ String[] args = {"jar", "the.jar", "arg1", "arg2"};
expect(cl.loadClass("arg1")).andThrow(new ClassNotFoundException());
expect(cl.loadClass(MAIN_CLASS_NAME)).andThrow(new ClassNotFoundException());
replay(cl);
@@ -71,8 +84,7 @@ public class MainTest {
Main.loadClassFromJar(args, f, cl);
}
- private void mockManifestMainClass(JarFile f, String mainClassName)
- throws Exception {
+ private void mockManifestMainClass(JarFile f, String mainClassName) throws Exception {
Manifest mf = createMock(Manifest.class);
expect(f.getManifest()).andReturn(mf);
Attributes attrs = createMock(Attributes.class);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/98fc9521/test/src/test/java/org/apache/accumulo/test/randomwalk/FrameworkTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/randomwalk/FrameworkTest.java b/test/src/test/java/org/apache/accumulo/test/randomwalk/FrameworkTest.java
index 7829ac5..d43347e 100644
--- a/test/src/test/java/org/apache/accumulo/test/randomwalk/FrameworkTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/randomwalk/FrameworkTest.java
@@ -17,7 +17,6 @@
package org.apache.accumulo.test.randomwalk;
import java.io.File;
-import java.util.Properties;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
@@ -31,12 +30,12 @@ import org.apache.accumulo.test.randomwalk.unit.CreateTable;
import org.junit.Assert;
public class FrameworkTest extends TestCase {
-
+
public void testXML() {
-
+
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder docbuilder;
-
+
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema moduleSchema = null;
try {
@@ -44,9 +43,9 @@ public class FrameworkTest extends TestCase {
} catch (Exception e) {
Assert.fail("Caught exception: " + e);
}
-
+
dbf.setSchema(moduleSchema);
-
+
try {
File f = new File(this.getClass().getResource("/randomwalk/Basic.xml").toURI());
docbuilder = dbf.newDocumentBuilder();
@@ -55,14 +54,14 @@ public class FrameworkTest extends TestCase {
Assert.fail("Caught exception: " + e);
}
}
-
+
public void testRWTest() {
-
+
Test t1 = new CreateTable();
assertTrue(t1.toString().equals("org.apache.accumulo.test.randomwalk.unit.CreateTable"));
-
+
Test t2 = new CreateTable();
assertTrue(t1.equals(t2));
}
-
+
}