/** * Get a Mocked {@link ClusterConnection} that goes with the passed <code>conf</code> * configuration instance. Minimally the mock will return * <code>conf</conf> when {@link ClusterConnection#getConfiguration()} is invoked. * Be sure to shutdown the connection when done by calling * {@link Connection#close()} else it will stick around; this is probably not what you want. * @param conf configuration * @return ClusterConnection object for <code>conf</code> * @throws ZooKeeperConnectionException */ public static ClusterConnection getMockedConnection(final Configuration conf) throws ZooKeeperConnectionException { ConnectionImplementation connection = Mockito.mock(ConnectionImplementation.class); Mockito.when(connection.getConfiguration()).thenReturn(conf); Mockito.when(connection.getRpcControllerFactory()).thenReturn( Mockito.mock(RpcControllerFactory.class)); // we need a real retrying caller RpcRetryingCallerFactory callerFactory = new RpcRetryingCallerFactory(conf); Mockito.when(connection.getRpcRetryingCallerFactory()).thenReturn(callerFactory); return connection; }
throws IOException { ConnectionImplementation c = Mockito.mock(ConnectionImplementation.class); Mockito.when(c.getConfiguration()).thenReturn(conf); Mockito.doNothing().when(c).close();
Mockito.when(mockConnection.getConfiguration()).thenReturn(conf); Mockito.when(mockConnection.getMaster()).thenReturn(mockMaster);
.mock(ConnectionImplementation.class); Configuration conf = HBaseConfiguration.create(); Mockito.when(mockConnection.getConfiguration()).thenReturn(conf);
params.pool(HTable.getDefaultExecutor(getConfiguration()));
final ExecutorService pool) { this.connection = Preconditions.checkNotNull(connection, "connection is null"); this.configuration = connection.getConfiguration(); this.connConfiguration = connection.getConnectionConfiguration(); if (pool == null) {
Mockito.when(mockConnection.getConfiguration()).thenReturn(conf); Mockito.when(mockConnection.getMaster()).thenReturn(mockMaster);
.mock(ConnectionImplementation.class); Configuration conf = HBaseConfiguration.create(); Mockito.when(mockConnection.getConfiguration()).thenReturn(conf);
params.pool(HTable.getDefaultExecutor(getConfiguration()));
return sn; VHostMapListener vhostMap = VHostMapListener.getInstance(root, getConfiguration()); if (vhostMap != null && vhostMap.getVhost(sn.getHostname()) != null) { vsn = ServerName.valueOf(vhostMap.getVhost(sn.getHostname()), sn.getPort(), sn.getStartcode());
/** * Get a Mocked {@link ClusterConnection} that goes with the passed <code>conf</code> * configuration instance. Minimally the mock will return * <code>conf</conf> when {@link ClusterConnection#getConfiguration()} is invoked. * Be sure to shutdown the connection when done by calling * {@link Connection#close()} else it will stick around; this is probably not what you want. * @param conf configuration * @return ClusterConnection object for <code>conf</code> * @throws ZooKeeperConnectionException */ public static ClusterConnection getMockedConnection(final Configuration conf) throws ZooKeeperConnectionException { ConnectionImplementation connection = Mockito.mock(ConnectionImplementation.class); Mockito.when(connection.getConfiguration()).thenReturn(conf); Mockito.when(connection.getRpcControllerFactory()).thenReturn( Mockito.mock(RpcControllerFactory.class)); // we need a real retrying caller RpcRetryingCallerFactory callerFactory = new RpcRetryingCallerFactory(conf); Mockito.when(connection.getRpcRetryingCallerFactory()).thenReturn(callerFactory); return connection; }
throws IOException { ConnectionImplementation c = Mockito.mock(ConnectionImplementation.class); Mockito.when(c.getConfiguration()).thenReturn(conf); Mockito.doNothing().when(c).close();
params.pool(HTable.getDefaultExecutor(getConfiguration()));