ClusterLinkImpl implements ClusterLink { protected void initChannels( Map<String, String> channelLogicNames, Map<String, String> channelPropertiesLocations, Map<String, String> channelNames) throws Exception { _channelCount = channelPropertiesLocations.size(); if ((_channelCount <= 0) || (_channelCount > MAX_CHANNEL_COUNT)) { throw new IllegalArgumentException( "Channel count must be between 1 and " + MAX_CHANNEL_COUNT); } _localAddresses = new ArrayList<>(_channelCount); _clusterChannels = new ArrayList<>(_channelCount); _clusterReceivers = new ArrayList<>(_channelCount); List<String> keys = new ArrayList<>( channelPropertiesLocations.keySet()); Collections.sort(keys); for (String key : keys) { String channelPropertiesLocation = channelPropertiesLocations.get( key); String channelName = channelNames.get(key); if (Validator.isNull(channelPropertiesLocation) || Validator.isNull(channelName)) { continue; } String channelLogicName = channelLogicNames.get(key); ClusterReceiver clusterReceiver = new ClusterForwardReceiver(this); ClusterChannel clusterChannel = _clusterChannelFactory.createClusterChannel( _executorService, channelLogicName, channelPropertiesLocation, channelName, clusterReceiver); _clusterChannels.add(clusterChannel); _clusterReceivers.add(clusterReceiver); _localAddresses.add(clusterChannel.getLocalAddress()); } }  @Override boolean isEnabled(); @Override void sendMulticastMessage(Message message, Priority priority); @Override void sendUnicastMessage(
		Address address, Message message, Priority priority);  }
@Test public void testInitChannels() { try (CaptureHandler captureHandler = JDKLoggerTestUtil.configureJDKLogger( ClusterLinkImpl.class.getName(), Level.OFF)) { List<LogRecord> logRecords = captureHandler.getLogRecords(); try { getClusterLinkImpl(ClusterLinkImpl.MAX_CHANNEL_COUNT + 1); Assert.fail(); } catch (IllegalStateException illegalStateException) { Assert.assertEquals( logRecords.toString(), 0, logRecords.size()); Assert.assertEquals( "java.lang.IllegalArgumentException: Channel count must " + "be between 1 and " + ClusterLinkImpl.MAX_CHANNEL_COUNT, illegalStateException.getMessage()); } logRecords = captureHandler.resetLogLevel(Level.SEVERE); try { getClusterLinkImpl(0); Assert.fail(); } catch (IllegalStateException illegalStateException) { Assert.assertEquals( logRecords.toString(), 1, logRecords.size()); LogRecord logRecord = logRecords.get(0); Assert.assertEquals( "Unable to initialize channels", logRecord.getMessage()); Assert.assertEquals( "java.lang.IllegalArgumentException: Channel count must " + "be between 1 and " + ClusterLinkImpl.MAX_CHANNEL_COUNT, illegalStateException.getMessage()); } } }