### Question:
WireFileDistribution { public WireFileDistribution(final FileDistribution fileDistribution, ConsoleProperties properties, Timer timer) { timer.schedule(new TimerTask() { public void run() { fileDistribution.scanDistributionFiles(); } }, properties.getScanDistributionFilesPeriod(), properties.getScanDistributionFilesPeriod()); properties.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { final String propertyName = e.getPropertyName(); if (propertyName.equals( ConsoleProperties.DISTRIBUTION_DIRECTORY_PROPERTY)) { fileDistribution.setDirectory((Directory)e.getNewValue()); } else if (propertyName.equals( ConsoleProperties.DISTRIBUTION_FILE_FILTER_EXPRESSION_PROPERTY)) { fileDistribution.setFileFilterPattern((Pattern) e.getNewValue()); } } }); } WireFileDistribution(final FileDistribution fileDistribution,
                              ConsoleProperties properties,
                              Timer timer);   }### Answer:
@Test public void testWireFileDistribution() throws Exception { final FileDistribution fileDistribution = mock(FileDistribution.class); final ConsoleProperties consoleProperties = new ConsoleProperties(m_resources, new File(getDirectory(), "props")); final StubTimer timer = new StubTimer(); new WireFileDistribution(fileDistribution, consoleProperties, timer); assertEquals(6000, timer.getLastDelay()); assertEquals(6000, timer.getLastPeriod()); final TimerTask scanFileTask = timer.getLastScheduledTimerTask(); scanFileTask.run(); verify(fileDistribution).scanDistributionFiles(); consoleProperties.setDistributionFileFilterExpression(".*"); final ArgumentCaptor<Pattern> patternCaptor = ArgumentCaptor.forClass(Pattern.class); verify(fileDistribution).setFileFilterPattern(patternCaptor.capture()); assertEquals(".*", patternCaptor.getValue().pattern()); final ArgumentCaptor<Directory> directoryCaptor = ArgumentCaptor.forClass(Directory.class); final Directory directory = new Directory(new File(getDirectory(), "foo")); consoleProperties.setAndSaveDistributionDirectory(directory); verify(fileDistribution).setDirectory(directoryCaptor.capture()); assertSame(directory, directoryCaptor.getValue()); consoleProperties.setConsolePort(999); verifyNoMoreInteractions(fileDistribution); }