ShardingDataSourceGroupBroadcastRoutingEngine implements ShardingRouteEngine { @Override public void route(final RouteContext routeContext, final ShardingRule shardingRule) { Collection<Set<String>> broadcastDataSourceGroup = getBroadcastDataSourceGroup(getDataSourceGroup(shardingRule)); for (Set<String> each : broadcastDataSourceGroup) { String dataSourceName = getRandomDataSourceName(each); routeContext.getRouteUnits().add(new RouteUnit(new RouteMapper(dataSourceName, dataSourceName), Collections.emptyList())); } }  @Override void route(final RouteContext routeContext, final ShardingRule shardingRule);  }
@Test public void assertRoute() { List<List<String>> shards = new LinkedList<>(); shards.add(Arrays.asList("ds1", "ds2", "ds3")); shards.add(Arrays.asList("ds1", "ds2", "ds3")); shards.add(Arrays.asList("ds1", "ds2", "ds3")); List<TableRule> tableRules = mockTableRules(shards); when(shardingRule.getTableRules()).thenReturn(tableRules); RouteContext routeContext = new RouteContext(); shardingDataSourceGroupBroadcastRoutingEngine.route(routeContext, shardingRule); assertThat(routeContext.getRouteUnits().size(), is(1)); Iterator<RouteUnit> iterator = routeContext.getRouteUnits().iterator(); assertThat(Arrays.asList("ds1", "ds2", "ds3"), hasItems(iterator.next().getDataSourceMapper().getActualName())); }