hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-18768 Move TestTableName to hbase-common from hbase-server
Date Thu, 07 Sep 2017 01:11:39 GMT
Repository: hbase
Updated Branches:
  refs/heads/master fd49a9826 -> 3a9dc8fbd


HBASE-18768 Move TestTableName to hbase-common from hbase-server

Signed-off-by: Michael Stack <stack@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3a9dc8fb
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3a9dc8fb
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3a9dc8fb

Branch: refs/heads/master
Commit: 3a9dc8fbd58ab6dc4a895cbcf9644422fb5b8223
Parents: fd49a98
Author: Michael Stack <stack@apache.org>
Authored: Wed Sep 6 13:25:26 2017 -0700
Committer: Michael Stack <stack@apache.org>
Committed: Wed Sep 6 18:11:32 2017 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/TestTableName.java  | 191 +++++++++++++++++++
 .../TestCorruptedRegionStoreFile.java           |   2 +-
 .../TestScannerRetriableFailure.java            |   2 +-
 .../security/access/TestAccessController2.java  |   2 +-
 .../access/TestCellACLWithMultipleVersions.java |   2 +-
 .../hbase/security/access/TestCellACLs.java     |   2 +-
 .../access/TestScanEarlyTermination.java        |   2 +-
 .../access/TestWithDisabledAuthorization.java   |   2 +-
 .../snapshot/TestSnapshotClientRetries.java     |   2 +-
 .../apache/hadoop/hbase/util/TestTableName.java | 190 ------------------
 10 files changed, 199 insertions(+), 198 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/3a9dc8fb/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java
new file mode 100644
index 0000000..54e25e8
--- /dev/null
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java
@@ -0,0 +1,191 @@
+/**
+ * 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.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
+import org.apache.hadoop.hbase.testclassification.MiscTests;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+/**
+ * Returns a {@code byte[]} containing the name of the currently running test method.
+ */
+@Category({MiscTests.class, MediumTests.class})
+public class TestTableName extends TestWatcher {
+  private TableName tableName;
+
+  /**
+   * Invoked when a test is about to start
+   */
+  @Override
+  protected void starting(Description description) {
+    tableName = TableName.valueOf(description.getMethodName());
+  }
+
+  public TableName getTableName() {
+    return tableName;
+  }
+
+  String emptyNames[] ={"", " "};
+  String invalidNamespace[] = {":a", "%:a"};
+  String legalTableNames[] = { "foo", "with-dash_under.dot", "_under_start_ok",
+      "with-dash.with_underscore", "02-01-2012.my_table_01-02", "xyz._mytable_", "9_9_0.table_02"
+      , "dot1.dot2.table", "new.-mytable", "with-dash.with.dot", "legal..t2", "legal..legal.t2",
+      "trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02"};
+  String illegalTableNames[] = { ".dot_start_illegal", "-dash_start_illegal", "spaces not
ok",
+      "-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
+      "new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2"};
+
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testInvalidNamespace() {
+    for (String tn : invalidNamespace) {
+      TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn));
+      fail("invalid namespace " + tn + " should have failed with IllegalArgumentException
for namespace");
+    }
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testEmptyNamespaceName() {
+    for (String nn : emptyNames) {
+      TableName.isLegalNamespaceName(Bytes.toBytes(nn));
+      fail("invalid Namespace name " + nn + " should have failed with IllegalArgumentException");
+    }
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testEmptyTableName() {
+    for (String tn : emptyNames) {
+      TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn));
+      fail("invalid tablename " + tn + " should have failed with IllegalArgumentException");
+    }
+  }
+
+  @Test
+  public void testLegalHTableNames() {
+    for (String tn : legalTableNames) {
+      TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn));
+    }
+  }
+
+  @Test
+  public void testIllegalHTableNames() {
+    for (String tn : illegalTableNames) {
+      try {
+        TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn));
+        fail("invalid tablename " + tn + " should have failed");
+      } catch (Exception e) {
+        // expected
+      }
+    }
+  }
+
+  class Names {
+    String ns;
+    byte[] nsb;
+    String tn;
+    byte[] tnb;
+    String nn;
+    byte[] nnb;
+
+    Names(String ns, String tn) {
+      this.ns = ns;
+      nsb = ns.getBytes();
+      this.tn = tn;
+      tnb = tn.getBytes();
+      nn = this.ns + ":" + this.tn;
+      nnb = nn.getBytes();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      Names names = (Names) o;
+
+      if (!ns.equals(names.ns)) return false;
+      if (!tn.equals(names.tn)) return false;
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int result = ns.hashCode();
+      result = 31 * result + tn.hashCode();
+      return result;
+    }
+  }
+
+  Names[] names = new Names[] {
+      new Names("n1", "n1"),
+      new Names("n2", "n2"),
+      new Names("table1", "table1"),
+      new Names("table2", "table2"),
+      new Names("table2", "table1"),
+      new Names("table1", "table2"),
+      new Names("n1", "table1"),
+      new Names("n1", "table1"),
+      new Names("n2", "table2"),
+      new Names("n2", "table2")
+  };
+
+  @Test
+  public void testValueOf() {
+
+    Map<String, TableName> inCache = new HashMap<>();
+    // fill cache
+    for (Names name : names) {
+      inCache.put(name.nn, TableName.valueOf(name.ns, name.tn));
+    }
+    for (Names name : names) {
+      assertSame(inCache.get(name.nn), validateNames(TableName.valueOf(name.ns, name.tn),
name));
+      assertSame(inCache.get(name.nn), validateNames(TableName.valueOf(name.nsb, name.tnb),
name));
+      assertSame(inCache.get(name.nn), validateNames(TableName.valueOf(name.nn), name));
+      assertSame(inCache.get(name.nn), validateNames(TableName.valueOf(name.nnb), name));
+      assertSame(inCache.get(name.nn), validateNames(TableName.valueOf(
+          ByteBuffer.wrap(name.nsb), ByteBuffer.wrap(name.tnb)), name));
+    }
+
+  }
+
+  private TableName validateNames(TableName expected, Names names) {
+    assertEquals(expected.getNameAsString(), names.nn);
+    assertArrayEquals(expected.getName(), names.nnb);
+    assertEquals(expected.getQualifierAsString(), names.tn);
+    assertArrayEquals(expected.getQualifier(), names.tnb);
+    assertEquals(expected.getNamespaceAsString(), names.ns);
+    assertArrayEquals(expected.getNamespace(), names.nsb);
+    return expected;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a9dc8fb/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCorruptedRegionStoreFile.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCorruptedRegionStoreFile.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCorruptedRegionStoreFile.java
index 430aef5..a06d40c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCorruptedRegionStoreFile.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCorruptedRegionStoreFile.java
@@ -43,7 +43,7 @@ import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hbase.util.FSVisitor;
-import org.apache.hadoop.hbase.util.TestTableName;
+import org.apache.hadoop.hbase.TestTableName;
 
 import org.junit.After;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a9dc8fb/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerRetriableFailure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerRetriableFailure.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerRetriableFailure.java
index 9bda019..67796d1 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerRetriableFailure.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerRetriableFailure.java
@@ -42,7 +42,7 @@ import org.apache.hadoop.hbase.coprocessor.RegionObserver;
 import org.apache.hadoop.hbase.testclassification.RegionServerTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.TestTableName;
+import org.apache.hadoop.hbase.TestTableName;
 
 import org.junit.AfterClass;
 import org.junit.BeforeClass;

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a9dc8fb/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
index 6e1e09c..c39e119 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java
@@ -54,7 +54,7 @@ import org.apache.hadoop.hbase.security.access.Permission.Action;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.SecurityTests;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.TestTableName;
+import org.apache.hadoop.hbase.TestTableName;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.junit.After;

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a9dc8fb/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java
index 88cdf1d..ef4f82b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java
@@ -50,7 +50,7 @@ import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.testclassification.SecurityTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.apache.hadoop.hbase.util.TestTableName;
+import org.apache.hadoop.hbase.TestTableName;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a9dc8fb/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java
index 155ce57..01a73ba 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java
@@ -52,7 +52,7 @@ import org.apache.hadoop.hbase.security.access.Permission.Action;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.SecurityTests;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.TestTableName;
+import org.apache.hadoop.hbase.TestTableName;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a9dc8fb/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java
index c39a84b..a1def95 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java
@@ -44,7 +44,7 @@ import org.apache.hadoop.hbase.security.access.Permission.Action;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.testclassification.SecurityTests;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.TestTableName;
+import org.apache.hadoop.hbase.TestTableName;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.junit.After;

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a9dc8fb/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java
index bfd9c1a..180faec 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java
@@ -71,7 +71,7 @@ import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.SecurityTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Pair;
-import org.apache.hadoop.hbase.util.TestTableName;
+import org.apache.hadoop.hbase.TestTableName;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.junit.After;

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a9dc8fb/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java
index 5da0d94..949915c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java
@@ -34,7 +34,7 @@ import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
 import org.apache.hadoop.hbase.coprocessor.ObserverContext;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.apache.hadoop.hbase.util.TestTableName;
+import org.apache.hadoop.hbase.TestTableName;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a9dc8fb/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestTableName.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestTableName.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestTableName.java
deleted file mode 100644
index f585f47..0000000
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestTableName.java
+++ /dev/null
@@ -1,190 +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.util;
-
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-
-import org.apache.hadoop.hbase.testclassification.MiscTests;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.apache.hadoop.hbase.TableName;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-
-/**
- * Returns a {@code byte[]} containing the name of the currently running test method.
- */
-@Category({MiscTests.class, MediumTests.class})
-public class TestTableName extends TestWatcher {
-  private TableName tableName;
-
-  /**
-   * Invoked when a test is about to start
-   */
-  @Override
-  protected void starting(Description description) {
-    tableName = TableName.valueOf(description.getMethodName());
-  }
-
-  public TableName getTableName() {
-    return tableName;
-  }
-
-  String emptyNames[] ={"", " "};
-  String invalidNamespace[] = {":a", "%:a"};
-  String legalTableNames[] = { "foo", "with-dash_under.dot", "_under_start_ok",
-      "with-dash.with_underscore", "02-01-2012.my_table_01-02", "xyz._mytable_", "9_9_0.table_02"
-      , "dot1.dot2.table", "new.-mytable", "with-dash.with.dot", "legal..t2", "legal..legal.t2",
-      "trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02"};
-  String illegalTableNames[] = { ".dot_start_illegal", "-dash_start_illegal", "spaces not
ok",
-      "-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash",
-      "new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2"};
-
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testInvalidNamespace() {
-    for (String tn : invalidNamespace) {
-      TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn));
-      fail("invalid namespace " + tn + " should have failed with IllegalArgumentException
for namespace");
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testEmptyNamespaceName() {
-    for (String nn : emptyNames) {
-      TableName.isLegalNamespaceName(Bytes.toBytes(nn));
-      fail("invalid Namespace name " + nn + " should have failed with IllegalArgumentException");
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testEmptyTableName() {
-    for (String tn : emptyNames) {
-      TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn));
-      fail("invalid tablename " + tn + " should have failed with IllegalArgumentException");
-    }
-  }
-
-  @Test
-  public void testLegalHTableNames() {
-    for (String tn : legalTableNames) {
-      TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn));
-    }
-  }
-
-  @Test
-  public void testIllegalHTableNames() {
-    for (String tn : illegalTableNames) {
-      try {
-        TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn));
-        fail("invalid tablename " + tn + " should have failed");
-      } catch (Exception e) {
-        // expected
-      }
-    }
-  }
-
-  class Names {
-    String ns;
-    byte[] nsb;
-    String tn;
-    byte[] tnb;
-    String nn;
-    byte[] nnb;
-
-    Names(String ns, String tn) {
-      this.ns = ns;
-      nsb = ns.getBytes();
-      this.tn = tn;
-      tnb = tn.getBytes();
-      nn = this.ns + ":" + this.tn;
-      nnb = nn.getBytes();
-    }
-
-    @Override
-    public boolean equals(Object o) {
-      if (this == o) return true;
-      if (o == null || getClass() != o.getClass()) return false;
-
-      Names names = (Names) o;
-
-      if (!ns.equals(names.ns)) return false;
-      if (!tn.equals(names.tn)) return false;
-
-      return true;
-    }
-
-    @Override
-    public int hashCode() {
-      int result = ns.hashCode();
-      result = 31 * result + tn.hashCode();
-      return result;
-    }
-  }
-
-  Names[] names = new Names[] {
-      new Names("n1", "n1"),
-      new Names("n2", "n2"),
-      new Names("table1", "table1"),
-      new Names("table2", "table2"),
-      new Names("table2", "table1"),
-      new Names("table1", "table2"),
-      new Names("n1", "table1"),
-      new Names("n1", "table1"),
-      new Names("n2", "table2"),
-      new Names("n2", "table2")
-  };
-
-  @Test
-  public void testValueOf() {
-
-    Map<String, TableName> inCache = new HashMap<>();
-    // fill cache
-    for (Names name : names) {
-      inCache.put(name.nn, TableName.valueOf(name.ns, name.tn));
-    }
-    for (Names name : names) {
-      assertSame(inCache.get(name.nn), validateNames(TableName.valueOf(name.ns, name.tn),
name));
-      assertSame(inCache.get(name.nn), validateNames(TableName.valueOf(name.nsb, name.tnb),
name));
-      assertSame(inCache.get(name.nn), validateNames(TableName.valueOf(name.nn), name));
-      assertSame(inCache.get(name.nn), validateNames(TableName.valueOf(name.nnb), name));
-      assertSame(inCache.get(name.nn), validateNames(TableName.valueOf(
-          ByteBuffer.wrap(name.nsb), ByteBuffer.wrap(name.tnb)), name));
-    }
-
-  }
-
-  private TableName validateNames(TableName expected, Names names) {
-    assertEquals(expected.getNameAsString(), names.nn);
-    assertArrayEquals(expected.getName(), names.nnb);
-    assertEquals(expected.getQualifierAsString(), names.tn);
-    assertArrayEquals(expected.getQualifier(), names.tnb);
-    assertEquals(expected.getNamespaceAsString(), names.ns);
-    assertArrayEquals(expected.getNamespace(), names.nsb);
-    return expected;
-  }
-
-}


Mime
View raw message