|
43 | 43 | import java.util.Arrays; |
44 | 44 | import java.util.HashMap; |
45 | 45 | import java.util.List; |
| 46 | +import java.util.Map; |
46 | 47 |
|
47 | 48 | import static com.starrocks.connector.iceberg.IcebergCatalogProperties.ICEBERG_CUSTOM_PROPERTIES_PREFIX; |
48 | 49 | import static com.starrocks.connector.iceberg.IcebergMetadata.LOCATION_PROPERTY; |
@@ -284,4 +285,62 @@ public void testDeleteUncommittedDataFiles(@Mocked JdbcCatalog jdbcCatalog, @Moc |
284 | 285 | Arrays.asList("/tmp/iceberg/db/table/part-00000", "/tmp/iceberg/db/table/part-00001")); |
285 | 286 | } |
286 | 287 |
|
| 288 | + @Test |
| 289 | + public void testJdbcCatalogNameDefaultToStarRocksCatalogName(@Mocked JdbcCatalog jdbcCatalog) { |
| 290 | + final String[] capturedName = new String[1]; |
| 291 | + final Map<String, String>[] capturedProps = new Map[1]; |
| 292 | + |
| 293 | + new Expectations() { |
| 294 | + { |
| 295 | + jdbcCatalog.initialize(anyString, (Map<String, String>) any); |
| 296 | + result = new mockit.Delegate<Void>() { |
| 297 | + @SuppressWarnings("unused") |
| 298 | + void initialize(String name, Map<String, String> props) { |
| 299 | + capturedName[0] = name; |
| 300 | + capturedProps[0] = props; |
| 301 | + } |
| 302 | + }; |
| 303 | + minTimes = 0; |
| 304 | + } |
| 305 | + }; |
| 306 | + |
| 307 | + new IcebergJdbcCatalog("sr_catalog", new Configuration(), |
| 308 | + ImmutableMap.of("iceberg.catalog.warehouse", LOCATION, |
| 309 | + "iceberg.catalog.uri", URI)); |
| 310 | + |
| 311 | + assertEquals("sr_catalog", capturedName[0]); |
| 312 | + Assertions.assertNotNull(capturedProps[0]); |
| 313 | + Assertions.assertFalse(capturedProps[0].containsKey("jdbc.catalog-name")); |
| 314 | + } |
| 315 | + |
| 316 | + @Test |
| 317 | + public void testJdbcCatalogNameOverride(@Mocked JdbcCatalog jdbcCatalog) { |
| 318 | + final String[] capturedName = new String[1]; |
| 319 | + final Map<String, String>[] capturedProps = new Map[1]; |
| 320 | + |
| 321 | + new Expectations() { |
| 322 | + { |
| 323 | + jdbcCatalog.initialize(anyString, (Map<String, String>) any); |
| 324 | + result = new mockit.Delegate<Void>() { |
| 325 | + @SuppressWarnings("unused") |
| 326 | + void initialize(String name, java.util.Map<String, String> props) { |
| 327 | + capturedName[0] = name; |
| 328 | + capturedProps[0] = props; |
| 329 | + } |
| 330 | + }; |
| 331 | + minTimes = 0; |
| 332 | + } |
| 333 | + }; |
| 334 | + |
| 335 | + new IcebergJdbcCatalog("sr_side_view", new Configuration(), |
| 336 | + ImmutableMap.of( |
| 337 | + "iceberg.catalog.warehouse", LOCATION, |
| 338 | + "iceberg.catalog.uri", URI, |
| 339 | + "iceberg.catalog.jdbc.catalog-name", "spark_ice")); |
| 340 | + |
| 341 | + assertEquals("spark_ice", capturedName[0]); |
| 342 | + Assertions.assertNotNull(capturedProps[0]); |
| 343 | + Assertions.assertFalse(capturedProps[0].containsKey("jdbc.catalog-name")); |
| 344 | + } |
| 345 | + |
287 | 346 | } |
0 commit comments