Properties consumerProps() {
        return consumerProps;
    }
@Test
    public void groupIdsProvidedInDifferentPlacesMustMatch() throws IOException {
        Exit.setExitProcedure((code, message) -> {
            throw new IllegalArgumentException(message);
        });

        // different in all three places
        File propsFile = ToolsTestUtils.tempPropertiesFile(Collections.singletonMap("group.id", "group-from-file"));
        final String[] args = new String[]{
            "--bootstrap-server", "localhost:9092",
            "--topic", "test",
            "--group", "group-from-arguments",
            "--consumer-property", "group.id=group-from-properties",
            "--consumer.config", propsFile.getAbsolutePath()
        };

        assertThrows(IllegalArgumentException.class, () -> new ConsoleConsumerOptions(args));

        // the same in all three places
        propsFile = ToolsTestUtils.tempPropertiesFile(Collections.singletonMap("group.id", "test-group"));
        final String[] args1 = new String[]{
            "--bootstrap-server", "localhost:9092",
            "--topic", "test",
            "--group", "test-group",
            "--consumer-property", "group.id=test-group",
            "--consumer.config", propsFile.getAbsolutePath()
        };

        ConsoleConsumerOptions config = new ConsoleConsumerOptions(args1);
        Properties props = config.consumerProps();
        assertEquals("test-group", props.getProperty("group.id"));

        // different via --consumer-property and --consumer.config
        propsFile = ToolsTestUtils.tempPropertiesFile(Collections.singletonMap("group.id", "group-from-file"));
        final String[] args2 = new String[]{
            "--bootstrap-server", "localhost:9092",
            "--topic", "test",
            "--consumer-property", "group.id=group-from-properties",
            "--consumer.config", propsFile.getAbsolutePath()
        };

        assertThrows(IllegalArgumentException.class, () -> new ConsoleConsumerOptions(args2));

        // different via --consumer-property and --group
        final String[] args3 = new String[]{
            "--bootstrap-server", "localhost:9092",
            "--topic", "test",
            "--group", "group-from-arguments",
            "--consumer-property", "group.id=group-from-properties"
        };

        assertThrows(IllegalArgumentException.class, () -> new ConsoleConsumerOptions(args3));

        // different via --group and --consumer.config
        propsFile = ToolsTestUtils.tempPropertiesFile(Collections.singletonMap("group.id", "group-from-file"));
        final String[] args4 = new String[]{
            "--bootstrap-server", "localhost:9092",
            "--topic", "test",
            "--group", "group-from-arguments",
            "--consumer.config", propsFile.getAbsolutePath()
        };
        assertThrows(IllegalArgumentException.class, () -> new ConsoleConsumerOptions(args4));

        // via --group only
        final String[] args5 = new String[]{
            "--bootstrap-server", "localhost:9092",
            "--topic", "test",
            "--group", "group-from-arguments"
        };

        config = new ConsoleConsumerOptions(args5);
        props = config.consumerProps();
        assertEquals("group-from-arguments", props.getProperty("group.id"));

        Exit.resetExitProcedure();
    }