@Test
    public void testOptionChangeListener() {
        final Option<String> option1 = new Option<>("option1", String.class, "abc");
        final Option<String> option2 = new Option<>("option2", String.class, "xyz");
        final OptionManager optionManager = new MemoryOptionManager();
        final int[] counters = new int[2];
        OptionChangeListener<Object> globalListener = new OptionChangeListener<Object>() {
            @Override
            public void optionChanged(OptionChangeEvent<? extends Object> e) {
                counters[0]++;
                Assert.assertEquals(optionManager, e.getOptionManager());
                Option<? extends Object> option = e.getOption();
                if (option.equals(option1)) {
                    Assert.assertEquals("abc", e.getOldValue());
                    Assert.assertEquals("ABC", e.getNewValue());
                } else if (option.equals(option2)) {
                    Assert.assertEquals("xyz", e.getOldValue());
                    Assert.assertEquals("XYZ", e.getNewValue());
                } else {
                    Assert.fail();
                }
            }
        };
        OptionChangeListener<String> specificListener = new OptionChangeListener<String>() {
            @Override
            public void optionChanged(OptionChangeEvent<? extends String> e) {
                counters[1]++;
                Assert.assertEquals(optionManager, e.getOptionManager());
                Assert.assertEquals(option2, e.getOption());
                Assert.assertEquals("xyz", e.getOldValue());
                Assert.assertEquals("XYZ", e.getNewValue());
            }
        };

        optionManager.addOptionChangeListener(globalListener);
        optionManager.addOptionChangeListener(option2, specificListener);
        optionManager.addOptionChangeListener(option2, specificListener);
        optionManager.addOptionChangeListener(option2, specificListener);
        optionManager.removeOptionChangeListener(option2, specificListener);

        optionManager.set(option1, "ABC");
        optionManager.set(option1, "ABC");
        optionManager.set(option2, "XYZ");
        Assert.assertEquals(2, counters[0]);
        Assert.assertEquals(2, counters[1]);
    }