### Question:
ParameterTableHandler implements ExtensionHandler { @Override public Extension handle(String tag, String value) throws IOException { if (tag.equals(TAG) == false) { return null; } File file = new File(value); if (file.isFile() == false) { throw new FileNotFoundException(file.getAbsolutePath()); } ParameterTable table = parse(file); File temporary = File.createTempFile("asakusa-iterative-", ".bin"); boolean success = false; try (OutputStream output = new FileOutputStream(temporary)) { LOG.debug("storing parameter table: {}", temporary); IterativeExtensions.save(output, table); success = true; } finally { if (success == false) { if (temporary.delete() == false && temporary.exists()) { LOG.warn(MessageFormat.format( "failed to delete temporary file: {0}", temporary)); } } } return new BasicExtension(IterativeExtensions.EXTENSION_NAME, temporary, true); }  @Override Extension handle(String tag, String value); static final String TAG; }### Answer:
@Test public void handle() throws Exception { File json = json(new String[] { "{ a: 'A', b: 'B', c: 'C' }", }); File f; try (Extension ext = new ParameterTableHandler().handle(ParameterTableHandler.TAG, json.getAbsolutePath())) { assertThat(ext, is(notNullValue())); f = ((BasicExtension) ext).getData().getFile(); try (InputStream in = ext.getData().open()) { ParameterTable table = IterativeExtensions.load(in); assertThat(table.getRowCount(), is(1)); List<ParameterSet> rows = table.getRows(); assertThat(rows.get(0).toMap(), is(map("a", "A", "b", "B", "c", "C"))); } } assertThat("delete on exit", f.exists(), is(false)); }
@Test public void handle_other() throws Exception { File json = json(new String[] { "{ a: 'A', b: 'B', c: 'C' }", }); try (Extension ext = new ParameterTableHandler().handle("UNKNOWN", json.getAbsolutePath())) { assertThat(ext, is(nullValue())); } }