### Question:
RouterHandler extends GenericHeapObject implements FileChangeListener, Handler { @Override public void onChanges(final FileChangeSet changes) { write.lock(); try { for (File file : changes.getRemovedFiles()) { onRemovedFile(file); } for (File file : changes.getAddedFiles()) { onAddedFile(file); } for (File file : changes.getModifiedFiles()) { onModifiedFile(file); } } finally { write.unlock(); } } RouterHandler(final RouteBuilder builder, final DirectoryScanner scanner); void setRouteComparator(final Comparator<Route> comparator); void setDefaultHandler(final Handler handler); void start(); void stop(); @Override void onChanges(final FileChangeSet changes); @Override Promise<Response, NeverThrowsException> handle(final Context context, final Request request);  }### Answer:
@Test public void testDuplicatedRouteNamesAreGeneratingErrors() throws Exception { RouterHandler router = new RouterHandler(newRouterBuilder(), scanner); router.setLogger(logger); File first = Files.getRelativeFile(RouterHandlerTest.class, "names/abcd-route.json"); File second = Files.getRelativeFile(RouterHandlerTest.class, "names/another-abcd-route.json"); router.onChanges(new FileChangeSet(null, new HashSet<>(asList(first, second)), Collections.<File>emptySet(), Collections.<File>emptySet())); verify(logger).error(anyString()); }
@Test public void testUncheckedExceptionSupportForAddedFiles() throws Exception { RouteBuilder builder = spy(newRouterBuilder()); RouterHandler router = new RouterHandler(builder, scanner); router.setLogger(logger); doThrow(new NullPointerException()).when(builder).build(any(File.class)); router.onChanges(new FileChangeSet(null, Collections.singleton(new File("/")), Collections.<File>emptySet(), Collections.<File>emptySet())); verify(logger).error(matches("The route defined in file '.*' cannot be added")); }