diff --git src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java index 82a183f..ac8bc4d 100644 --- src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java +++ src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java @@ -58,7 +58,6 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.mockito.Matchers; import org.mockito.Mockito; /** @@ -336,29 +335,10 @@ public class TestCatalogTracker { // Mock an HConnection and a HRegionInterface implementation. Have the // HConnection return the HRI. Have the HRI return a few mocked up responses // to make our test work. - HConnection connection = - HConnectionTestingUtility.getMockedConnection(UTIL.getConfiguration()); + // Mock an HRegionInterface. + final HRegionInterface implementation = Mockito.mock(HRegionInterface.class); + HConnection connection = mockConnection(implementation); try { - // Mock an HRegionInterface. - - final HRegionInterface implementation = Mockito.mock(HRegionInterface.class); - // Make it so our implementation is returned when we do a connection. - // Need to fake out the location lookup stuff first. - ServerName sn = new ServerName("example.com", 1234, System.currentTimeMillis()); - final HRegionLocation anyLocation = - new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, sn.getHostname(), - sn.getPort()); - Mockito.when(connection.getRegionLocation((byte[]) Mockito.any(), - (byte[]) Mockito.any(), Mockito.anyBoolean())). - thenReturn(anyLocation); - // Have implementation returned which ever way getHRegionConnection is called. - Mockito.when(connection.getHRegionConnection(Mockito.anyString(), - Mockito.anyInt(), Matchers.anyBoolean())). - thenReturn(implementation); - Mockito.when(connection.getHRegionConnection(Mockito.anyString(), - Mockito.anyInt())). - thenReturn(implementation); - final CatalogTracker ct = constructAndStartCatalogTracker(connection); ServerName hsa = ct.getMetaLocation(); Assert.assertNull(hsa); @@ -416,6 +396,7 @@ public class TestCatalogTracker { throws IOException { HConnection connection = HConnectionTestingUtility.getMockedConnection(UTIL.getConfiguration()); + Mockito.doNothing().when(connection).close(); // Make it so we return any old location when asked. final HRegionLocation anyLocation = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, SN.getHostname(), @@ -423,6 +404,8 @@ public class TestCatalogTracker { Mockito.when(connection.getRegionLocation((byte[]) Mockito.any(), (byte[]) Mockito.any(), Mockito.anyBoolean())). thenReturn(anyLocation); + Mockito.when(connection.locateRegion((byte[]) Mockito.any(), (byte[]) Mockito.any())). + thenReturn(anyLocation); if (implementation != null) { // If a call to getHRegionConnection, return this implementation. Mockito.when(connection.getHRegionConnection(Mockito.anyString(), Mockito.anyInt())). @@ -494,4 +477,4 @@ public class TestCatalogTracker { this.ct.waitForRoot(); } } -} \ No newline at end of file +}