@Test public void testEvenSplitKeysFailures()throws Exception { TableName tableName = sharedTestEnv.newTestTableName(); byte[] startKey = Bytes.toBytes("AAA"); byte[] endKey = Bytes.toBytes("ZZZ"); try { createTable(tableName, startKey, endKey, 2); Assert.fail(); } catch (IllegalArgumentException e) { } try { createTable(tableName, endKey, startKey, 5); Assert.fail(); } catch (IllegalArgumentException e) { } }
@Test public void testAlreadyExists()throws Exception { thrown.expect(TableExistsException.class); createTable(sharedTestEnv.getDefaultTableName()); }
@Test public void testGetRegionLocation() throws Exception{ TableName tableName = sharedTestEnv.newTestTableName(); createTable(tableName); List<HRegionLocation> regions = getRegions(tableName); Assert.assertEquals(1, regions.size()); }
boolean failed = false; try { createTable(TableName.valueOf(badName)); } catch (Exception ex) {
private void createTable(String goodName, TableName[] tableNames)throws Exception { logger.info("Try create table for: %s", goodName); TableName tableName = TableName.valueOf(goodName); try { if (contains(tableNames, tableName)) { logger.warn("Not creating the table since it exists: %s", tableName); } else { logger.info("Do create table for: %s", goodName); createTable(tableName); } } finally { deleteTable(tableName); } }
@Test public void testAsyncGetRegions() throws Exception{ TableName tableName = sharedTestEnv.newTestTableName(); createTable(tableName); Assert.assertEquals(true, asyncGetRegions(tableName)); }
@Test public void testSplitKeys()throws Exception { byte[][] splits = new byte[][] { Bytes.toBytes("AAA"), Bytes.toBytes("BBB"), Bytes.toBytes("CCC"), }; TableName tableName = sharedTestEnv.newTestTableName(); try { createTable(tableName, splits); List<HRegionLocation> regions = null; try (RegionLocator locator = getConnection().getRegionLocator(tableName)) { regions = locator.getAllRegionLocations(); } // The number of regions should be the number of splits + 1. Assert.assertEquals(splits.length + 1, regions.size()); assertSplitsAndRegionsMatch(splits, regions); } finally { deleteTable(tableName); } }
createTable(tableName, startKey, endKey, 3); List<HRegionLocation> regions = null; try (RegionLocator locator =
createTable(tableName, startKey, endKey, 5); List<HRegionLocation> regions = null; try (RegionLocator locator =
@Test public void testCreate()throws Exception { TableName tableName = sharedTestEnv.newTestTableName(); createTable(tableName); Assert.assertTrue(tableExists(tableName)); deleteTable(tableName); Assert.assertFalse(tableExists(tableName)); }