### Question:
GOLDParser extends Parser { protected Reduction createInstance() throws ParserException { Reduction currentReduction = getCurrentReduction(); String ruleName = currentReduction.getParent().toString(); return createInstance(ruleName); } GOLDParser();  GOLDParser(GOLDParserBuildContext context);  GOLDParser(File cgtFile, String rulesPackage, boolean trimReductions);  GOLDParser(InputStream cgtFile, String rulesPackage, boolean trimReductions); void clear(); void clearProgramVariables(); void clearProgramVariable(String name); Variable getProgramVariable(String name); void setProgramVariable(String name, Variable value); Map<String, Scope> getScopes(); Scope getCurrentScope(); Scope setCurrentScope(Scope newScope); boolean getGenerateTree(); void setGenerateTree(boolean generateTree); void raiseParserException(String msg); void raiseParserException(String msg, Throwable cause); List<String> getErrorMessages(); String getErrorMessage(); void addErrorMessage(String message); boolean isReady(); boolean isIgnoreCaseOfVariables(); void setIgnoreCaseOfVariables(boolean ignoreCaseOfVariableNames); boolean setup(File grammarFile); boolean parseSourceStatements(String sourceStatements); boolean parseSourceStatements(Reader sourceReader); boolean processInternalError(); String getParseTree(); void loadRuleHandlers(String packageName); void loadRuleHandlers(List<Class> ruleClasses); List<String> validateHandlersExist(); void validateHandlerExists(Production rule); static final String VT_INDENT_DECREASE; static final String VT_INDENT_INCREASE; }### Answer:
@Test public void testCreateInstance() throws Exception { GOLDParserForTesting parser = new GOLDParserForTesting(new File("src/test/resources/parser/Simple2.cgt"), "com.creativewidgetworks.goldparser.simple2", true); Reduction reduction = parser.createInstance("<Value> ::= StringLiteral"); assertEquals("wrong handler", "StringLiteral", reduction.getClass().getSimpleName()); try { reduction = parser.createInstance("<Value> ::= DateLiteral"); fail("expected ParserException"); } catch (ParserException pe) { assertEquals("wrong msg", "No rule handler for rule <Value> ::= DateLiteral", pe.getMessage()); } }