Log4JConfigurationMXBeanSingleton implements Log4JConfigurationMXBean { @Override public final void pollConfigurationFile(String file, long updateFrequencyMS) { if (file == null) { throw new IllegalArgumentException("file may not be null"); } if (updateFrequencyMS <= 0) { throw new IllegalArgumentException("updateFrequencyMS must be positive (tried to pass in " + updateFrequencyMS + ')'); } synchronized (MONITOR) { if (this.updateFrequency != null) { throw new IllegalStateException("Can't set config file or polling frequency after polling has started"); } this.configFile = file; this.updateFrequency = updateFrequencyMS; } configureAndWatch(file, updateFrequencyMS); } Log4JConfigurationMXBeanSingleton(); static Log4JConfigurationMXBean instance(); @Override final String getConfigurationFile(); @Override final void setConfigurationFile(String configFile); @Override final Long getUpdateFrequencyMS(); @Override final void pollConfigurationFile(String file, long updateFrequencyMS); @Override final void pollConfigurationFile(long updateFrequencyMS); @Override final void updateConfigurationFile();  }
@Test public void pollWithoutConfiguring() { final TestConfigurator test = new TestConfigurator(); expectException(IllegalStateException.class, new Runnable() { @Override public void run() { test.bean().pollConfigurationFile(4); } }); test.assertAll(null, null); }
@Test public void nullConfigWithPoll() { final TestConfigurator test = new TestConfigurator(); expectException(IllegalArgumentException.class, new Runnable() { @Override public void run() { test.bean().pollConfigurationFile(null, 4); } }); test.assertAll(null, null); }