### Question:
Interpreter implements AutoCloseable { public Command parseCommand(final String commandString) throws ParsingException { final InputStream inputStream = new ByteArrayInputStream(commandString.getBytes(StandardCharsets.UTF_8)); final JavaCCParser localParser = new JavaCCParser(inputStream, "UTF-8"); localParser.setParserConfiguration(this.parserConfiguration); try { localParser.getPrefixDeclarationRegistry().setBaseIri(this.reasoner.getKnowledgeBase().getBaseIri()); for (final Entry<String, String> prefix : this.reasoner.getKnowledgeBase().getPrefixDeclarationRegistry()) { localParser.getPrefixDeclarationRegistry().setPrefixIri(prefix.getKey(), prefix.getValue()); } } catch (final PrefixDeclarationException e) { throw new RuntimeException(e); } Command result; try { result = localParser.command(); localParser.ensureEndOfInput(); } catch (ParseException | PrefixDeclarationException | TokenMgrError | RuntimeException e) { throw new ParsingException("failed to parse command \"\"\"" + commandString + "\"\"\"", e); } return result; } Interpreter(final KnowledgeBaseProvider knowledgeBaseProvider, final ReasonerProvider reasonerProvider,
			final StyledPrinter printer, final ParserConfiguration parserConfiguration); void registerCommandInterpreter(final String command, final CommandInterpreter commandInterpreter); Set<String> getRegisteredCommands(); void runCommands(final List<Command> commands); void runCommand(final Command command); Command parseCommand(final String commandString); Reasoner getReasoner(); KnowledgeBase getKnowledgeBase(); ParserConfiguration getParserConfiguration(); Writer getWriter(); void printNormal(final String string); void printSection(final String string); void printEmph(final String string); void printCode(final String string); void printImportant(final String string); static void validateArgumentCount(final Command command, final int number); static String extractStringArgument(final Command command, final int index, final String parameterName); static String extractNameArgument(final Command command, final int index, final String parameterName); static PositiveLiteral extractPositiveLiteralArgument(final Command command, final int index,
			final String parameterName); Writer getFileWriter(final String fileName); InputStream getFileInputStream(final String fileName); void clearReasonerAndKnowledgeBase(); @Override void close(); final static KnowledgeBaseProvider EMPTY_KNOWLEDGE_BASE_PROVIDER; }### Answer:
@Test(expected = ParsingException.class) public void malformedCommand_fails() throws ParsingException { StringWriter writer = new StringWriter(); try (Interpreter interpreter = getMockInterpreter(writer)) { interpreter.parseCommand("malformed ."); } }