HBASE-19566 Fixed Checkstyle errors in hbase-archetypes and enabled Checkstyle to fail on violations

This commit is contained in:
Jan Hentschel 2017-12-20 18:04:56 +01:00
parent 0887cdf1da
commit 3cbe2c331b
3 changed files with 32 additions and 22 deletions

View File

@ -18,7 +18,10 @@
*/ */
package org.apache.hbase.archetypes.exemplars.client; package org.apache.hbase.archetypes.exemplars.client;
import static org.junit.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Admin;
@ -29,7 +32,6 @@ import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass; import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
@ -64,8 +66,7 @@ public class TestHelloHBase {
assertEquals("#namespaceExists failed: found nonexistent namespace.", assertEquals("#namespaceExists failed: found nonexistent namespace.",
false, exists); false, exists);
admin.createNamespace admin.createNamespace(NamespaceDescriptor.create(EXISTING_NAMESPACE).build());
(NamespaceDescriptor.create(EXISTING_NAMESPACE).build());
exists = HelloHBase.namespaceExists(admin, EXISTING_NAMESPACE); exists = HelloHBase.namespaceExists(admin, EXISTING_NAMESPACE);
assertEquals("#namespaceExists failed: did NOT find existing namespace.", assertEquals("#namespaceExists failed: did NOT find existing namespace.",
true, exists); true, exists);
@ -94,11 +95,9 @@ public class TestHelloHBase {
@Test @Test
public void testPutRowToTable() throws IOException { public void testPutRowToTable() throws IOException {
Admin admin = TEST_UTIL.getAdmin(); Admin admin = TEST_UTIL.getAdmin();
admin.createNamespace admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
Table table Table table
= TEST_UTIL.createTable = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
HelloHBase.putRowToTable(table); HelloHBase.putRowToTable(table);
Result row = table.get(new Get(HelloHBase.MY_ROW_ID)); Result row = table.get(new Get(HelloHBase.MY_ROW_ID));
@ -111,11 +110,9 @@ public class TestHelloHBase {
@Test @Test
public void testDeleteRow() throws IOException { public void testDeleteRow() throws IOException {
Admin admin = TEST_UTIL.getAdmin(); Admin admin = TEST_UTIL.getAdmin();
admin.createNamespace admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
Table table Table table
= TEST_UTIL.createTable = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
table.put(new Put(HelloHBase.MY_ROW_ID). table.put(new Put(HelloHBase.MY_ROW_ID).
addColumn(HelloHBase.MY_COLUMN_FAMILY_NAME, addColumn(HelloHBase.MY_COLUMN_FAMILY_NAME,

View File

@ -18,7 +18,10 @@
*/ */
package org.apache.hbase.archetypes.exemplars.shaded_client; package org.apache.hbase.archetypes.exemplars.shaded_client;
import static org.junit.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Admin;
@ -29,7 +32,6 @@ import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass; import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
@ -64,8 +66,7 @@ public class TestHelloHBase {
assertEquals("#namespaceExists failed: found nonexistent namespace.", assertEquals("#namespaceExists failed: found nonexistent namespace.",
false, exists); false, exists);
admin.createNamespace admin.createNamespace(NamespaceDescriptor.create(EXISTING_NAMESPACE).build());
(NamespaceDescriptor.create(EXISTING_NAMESPACE).build());
exists = HelloHBase.namespaceExists(admin, EXISTING_NAMESPACE); exists = HelloHBase.namespaceExists(admin, EXISTING_NAMESPACE);
assertEquals("#namespaceExists failed: did NOT find existing namespace.", assertEquals("#namespaceExists failed: did NOT find existing namespace.",
true, exists); true, exists);
@ -94,11 +95,9 @@ public class TestHelloHBase {
@Test @Test
public void testPutRowToTable() throws IOException { public void testPutRowToTable() throws IOException {
Admin admin = TEST_UTIL.getAdmin(); Admin admin = TEST_UTIL.getAdmin();
admin.createNamespace admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
Table table Table table
= TEST_UTIL.createTable = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
HelloHBase.putRowToTable(table); HelloHBase.putRowToTable(table);
Result row = table.get(new Get(HelloHBase.MY_ROW_ID)); Result row = table.get(new Get(HelloHBase.MY_ROW_ID));
@ -111,11 +110,9 @@ public class TestHelloHBase {
@Test @Test
public void testDeleteRow() throws IOException { public void testDeleteRow() throws IOException {
Admin admin = TEST_UTIL.getAdmin(); Admin admin = TEST_UTIL.getAdmin();
admin.createNamespace admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
Table table Table table
= TEST_UTIL.createTable = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
table.put(new Put(HelloHBase.MY_ROW_ID). table.put(new Put(HelloHBase.MY_ROW_ID).
addColumn(HelloHBase.MY_COLUMN_FAMILY_NAME, addColumn(HelloHBase.MY_COLUMN_FAMILY_NAME,

View File

@ -78,6 +78,22 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>