[28/30] hbase git commit: HBASE-19873 Add a CategoryBasedTimeout ClassRule for all UTs

2018-01-29 Thread stack
http://git-wip-us.apache.org/repos/asf/hbase/blob/bbf3bae7/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZNodePaths.java
--
diff --git 
a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZNodePaths.java
 
b/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZNodePaths.java
index 102dde1..1a45379 100644
--- 
a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZNodePaths.java
+++ 
b/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZNodePaths.java
@@ -20,15 +20,21 @@ package org.apache.hadoop.hbase.zookeeper;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.testclassification.SmallTests;
 import org.apache.hadoop.hbase.testclassification.ZKTests;
+import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 @Category({ ZKTests.class, SmallTests.class })
 public class TestZNodePaths {
 
+  @ClassRule
+  public static final HBaseClassTestRule CLASS_RULE =
+  HBaseClassTestRule.forClass(TestZNodePaths.class);
+
   @Test
   public void testIsClientReadable() {
 ZNodePaths znodePaths = new ZNodePaths(HBaseConfiguration.create());

http://git-wip-us.apache.org/repos/asf/hbase/blob/bbf3bae7/hbase-common/pom.xml
--
diff --git a/hbase-common/pom.xml b/hbase-common/pom.xml
index 3284440..f5fa8ed 100644
--- a/hbase-common/pom.xml
+++ b/hbase-common/pom.xml
@@ -129,17 +129,6 @@
 
 
 
-
-maven-surefire-plugin
-
-  
-
-  listener
-  
org.apache.hadoop.hbase.ResourceCheckerJUnitListener
-
-  
-
-  
 
 
   org.apache.maven.plugins

http://git-wip-us.apache.org/repos/asf/hbase/blob/bbf3bae7/hbase-common/src/test/java/org/apache/hadoop/hbase/CategoryBasedTimeout.java
--
diff --git 
a/hbase-common/src/test/java/org/apache/hadoop/hbase/CategoryBasedTimeout.java 
b/hbase-common/src/test/java/org/apache/hadoop/hbase/CategoryBasedTimeout.java
deleted file mode 100644
index 8a31ff3..000
--- 
a/hbase-common/src/test/java/org/apache/hadoop/hbase/CategoryBasedTimeout.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.hbase;
-
-import java.lang.annotation.Annotation;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.Timeout;
-
-/**
- * Set a test method timeout based off the test categories small, medium, 
large.
- * Based on junit Timeout TestRule; see 
https://github.com/junit-team/junit/wiki/Rules
- */
-public class CategoryBasedTimeout extends Timeout {
-
-  public static Timeout forClass(Class clazz) {
-return 
CategoryBasedTimeout.builder().withTimeout(clazz).withLookingForStuckThread(true)
-.build();
-  }
-
-  public static Builder builder() {
-return new CategoryBasedTimeout.Builder();
-  }
-
-  @Deprecated
-  public CategoryBasedTimeout(int millis) {
-super(millis);
-  }
-
-  public CategoryBasedTimeout(long timeout, TimeUnit timeUnit) {
-super(timeout, timeUnit);
-  }
-
-  protected CategoryBasedTimeout(Builder builder) {
-super(builder);
-  }
-
-  public static class Builder extends Timeout.Builder {
-public Timeout.Builder withTimeout(Class clazz) {
-  Annotation annotation = clazz.getAnnotation(Category.class);
-  if (annotation != null) {
-Category category = (Category)annotation;
-for (Class c: category.value()) {
-  if (c == SmallTests.class) {
-// See SmallTests. 

[28/30] hbase git commit: HBASE-19873 Add a CategoryBasedTimeout ClassRule for all UTs

2018-01-28 Thread zhangduo
http://git-wip-us.apache.org/repos/asf/hbase/blob/918599ef/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java
--
diff --git 
a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java 
b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java
index 6a2bb39..f566223 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestGet.java
@@ -1,5 +1,4 @@
 /**
- *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -16,7 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.hadoop.hbase.client;
 
 import static org.junit.Assert.assertEquals;
@@ -27,20 +25,18 @@ import static org.junit.Assert.fail;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.nio.ByteBuffer;
 import java.lang.reflect.InvocationTargetException;
+import java.nio.ByteBuffer;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
-
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.exceptions.DeserializationException;
 import org.apache.hadoop.hbase.filter.Filter;
 import org.apache.hadoop.hbase.filter.FilterList;
 import org.apache.hadoop.hbase.filter.KeyOnlyFilter;
-import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
-import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
 import org.apache.hadoop.hbase.security.access.Permission;
 import org.apache.hadoop.hbase.security.visibility.Authorizations;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
@@ -48,12 +44,21 @@ import 
org.apache.hadoop.hbase.testclassification.SmallTests;
 import org.apache.hadoop.hbase.util.Base64;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.junit.Assert;
+import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
+
 // TODO: cover more test cases
 @Category({ClientTests.class, SmallTests.class})
 public class TestGet {
+
+  @ClassRule
+  public static final HBaseClassTestRule CLASS_RULE =
+  HBaseClassTestRule.forClass(TestGet.class);
+
   private static final byte [] ROW = new byte [] {'r'};
 
   private static final String PB_GET = 
"CgNyb3ciEwoPdGVzdC5Nb2NrRmlsdGVyEgAwATgB";

http://git-wip-us.apache.org/repos/asf/hbase/blob/918599ef/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestHTableMultiplexerViaMocks.java
--
diff --git 
a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestHTableMultiplexerViaMocks.java
 
b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestHTableMultiplexerViaMocks.java
index ef59eed..cce4939 100644
--- 
a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestHTableMultiplexerViaMocks.java
+++ 
b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestHTableMultiplexerViaMocks.java
@@ -1,12 +1,13 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,14 +17,6 @@
  */
 package org.apache.hadoop.hbase.client;
 
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.IOException;
-
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;