|
20 | 20 | import static org.junit.Assert.assertEquals; |
21 | 21 | import static org.junit.Assert.assertFalse; |
22 | 22 | import static org.junit.Assert.assertTrue; |
| 23 | +import static org.junit.Assert.fail; |
23 | 24 | import static org.mockito.Mockito.when; |
24 | 25 |
|
25 | 26 | import com.google.bigtable.v2.BigtableGrpc; |
|
50 | 51 | import java.util.List; |
51 | 52 | import java.util.concurrent.BlockingQueue; |
52 | 53 | import java.util.concurrent.ExecutorService; |
| 54 | +import java.util.concurrent.Executors; |
53 | 55 | import java.util.concurrent.TimeUnit; |
54 | 56 | import java.util.concurrent.atomic.AtomicReference; |
55 | 57 | import org.apache.hadoop.conf.Configuration; |
56 | 58 | import org.apache.hadoop.hbase.HRegionInfo; |
57 | 59 | import org.apache.hadoop.hbase.HRegionLocation; |
58 | 60 | import org.apache.hadoop.hbase.ServerName; |
59 | 61 | import org.apache.hadoop.hbase.TableName; |
| 62 | +import org.apache.hadoop.hbase.security.User; |
60 | 63 | import org.apache.hadoop.hbase.util.Bytes; |
61 | 64 | import org.apache.hadoop.hbase.util.VersionInfo; |
62 | 65 | import org.junit.After; |
@@ -222,12 +225,35 @@ public void testHeaders() throws IOException { |
222 | 225 | } |
223 | 226 | } |
224 | 227 |
|
| 228 | + @Test |
| 229 | + public void testManagedConnectionOverride() throws IOException { |
| 230 | + Configuration configuration = new Configuration(false); |
| 231 | + configuration.set(BigtableOptionsFactory.PROJECT_ID_KEY, PROJECT_ID); |
| 232 | + configuration.set(BigtableOptionsFactory.INSTANCE_ID_KEY, INSTANCE_ID); |
| 233 | + configuration.setBoolean(BigtableOptionsFactory.BIGTABLE_NULL_CREDENTIAL_ENABLE_KEY, true); |
| 234 | + configuration.setInt(BigtableOptionsFactory.BIGTABLE_DATA_CHANNEL_COUNT_KEY, 1); |
| 235 | + configuration.set( |
| 236 | + BigtableOptionsFactory.BIGTABLE_EMULATOR_HOST_KEY, HOST_NAME + ":" + server.getPort()); |
| 237 | + configuration.setBoolean(BigtableOptionsFactory.MANAGED_CONNECTION_WARNING, true); |
| 238 | + try (Connection newConnection = |
| 239 | + new TestBigtableConnectionImpl( |
| 240 | + configuration, true, Executors.newSingleThreadExecutor(), null)) { |
| 241 | + } catch (IllegalArgumentException e) { |
| 242 | + fail("Should not throw IllegalArgumentException"); |
| 243 | + } |
| 244 | + } |
| 245 | + |
225 | 246 | private class TestBigtableConnectionImpl extends AbstractBigtableConnection { |
226 | 247 |
|
227 | 248 | TestBigtableConnectionImpl(Configuration conf) throws IOException { |
228 | 249 | super(conf); |
229 | 250 | } |
230 | 251 |
|
| 252 | + TestBigtableConnectionImpl(Configuration conf, boolean managed, ExecutorService pool, User user) |
| 253 | + throws IOException { |
| 254 | + super(conf, managed, pool, user); |
| 255 | + } |
| 256 | + |
231 | 257 | @Override |
232 | 258 | protected SampledRowKeysAdapter createSampledRowKeysAdapter( |
233 | 259 | TableName tableName, ServerName serverName) { |
|
0 commit comments