@Test(expected = ParserException.class) public void getDataModelIncorrectFileTest() throws IOException, ParserException { out.write("module ONOS {\n"); out.write("yang-version 1\n"); out.write("namespace urn:ietf:params:xml:ns:yang:ietf-ospf;\n"); out.write("prefix On;\n"); out.write("}\n"); out.close(); YangNode node = manager.getDataModel("demo.yang"); }
@Override public YangNode getDataModel(String yangFile) throws IOException, ParserException { ANTLRInputStream input; try { input = new ANTLRFileStream(yangFile); } catch (IOException e) { throw new ParserException("YANG file error : YANG file does not exist."); } GeneratedYangLexer lexer = new GeneratedYangLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); GeneratedYangParser parser = new GeneratedYangParser(tokens); parser.removeErrorListeners(); ParseTreeErrorListener parseTreeErrorListener = new ParseTreeErrorListener(); parser.addErrorListener(parseTreeErrorListener); ParseTree tree; try { tree = parser.yangfile(); } catch (ParserException parserException) { parserException.setFileName(yangFile); throw parserException; } ParseTreeWalker walker = new ParseTreeWalker(); TreeWalkListener treeWalker = new TreeWalkListener(); try { walker.walk(treeWalker, tree); } catch (ParserException listenerException) { listenerException.setFileName(yangFile); throw listenerException; } finally { } return treeWalker.getRootNode(); }
YangUtilsParserManager implements YangUtilsParser { @Override public YangNode getDataModel(String yangFile) throws IOException, ParserException { ANTLRInputStream input; try { input = new ANTLRFileStream(yangFile); } catch (IOException e) { throw new ParserException("YANG file error : YANG file does not exist."); } GeneratedYangLexer lexer = new GeneratedYangLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); GeneratedYangParser parser = new GeneratedYangParser(tokens); parser.removeErrorListeners(); ParseTreeErrorListener parseTreeErrorListener = new ParseTreeErrorListener(); parser.addErrorListener(parseTreeErrorListener); ParseTree tree; try { tree = parser.yangfile(); } catch (ParserException parserException) { parserException.setFileName(yangFile); throw parserException; } ParseTreeWalker walker = new ParseTreeWalker(); TreeWalkListener treeWalker = new TreeWalkListener(); try { walker.walk(treeWalker, tree); } catch (ParserException listenerException) { listenerException.setFileName(yangFile); throw listenerException; } finally { } return treeWalker.getRootNode(); } }
YangUtilsParserManager implements YangUtilsParser { @Override public YangNode getDataModel(String yangFile) throws IOException, ParserException { ANTLRInputStream input; try { input = new ANTLRFileStream(yangFile); } catch (IOException e) { throw new ParserException("YANG file error : YANG file does not exist."); } GeneratedYangLexer lexer = new GeneratedYangLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); GeneratedYangParser parser = new GeneratedYangParser(tokens); parser.removeErrorListeners(); ParseTreeErrorListener parseTreeErrorListener = new ParseTreeErrorListener(); parser.addErrorListener(parseTreeErrorListener); ParseTree tree; try { tree = parser.yangfile(); } catch (ParserException parserException) { parserException.setFileName(yangFile); throw parserException; } ParseTreeWalker walker = new ParseTreeWalker(); TreeWalkListener treeWalker = new TreeWalkListener(); try { walker.walk(treeWalker, tree); } catch (ParserException listenerException) { listenerException.setFileName(yangFile); throw listenerException; } finally { } return treeWalker.getRootNode(); }  }
YangUtilsParserManager implements YangUtilsParser { @Override public YangNode getDataModel(String yangFile) throws IOException, ParserException { ANTLRInputStream input; try { input = new ANTLRFileStream(yangFile); } catch (IOException e) { throw new ParserException("YANG file error : YANG file does not exist."); } GeneratedYangLexer lexer = new GeneratedYangLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); GeneratedYangParser parser = new GeneratedYangParser(tokens); parser.removeErrorListeners(); ParseTreeErrorListener parseTreeErrorListener = new ParseTreeErrorListener(); parser.addErrorListener(parseTreeErrorListener); ParseTree tree; try { tree = parser.yangfile(); } catch (ParserException parserException) { parserException.setFileName(yangFile); throw parserException; } ParseTreeWalker walker = new ParseTreeWalker(); TreeWalkListener treeWalker = new TreeWalkListener(); try { walker.walk(treeWalker, tree); } catch (ParserException listenerException) { listenerException.setFileName(yangFile); throw listenerException; } finally { } return treeWalker.getRootNode(); }  @Override YangNode getDataModel(String yangFile); }
YangUtilsParserManager implements YangUtilsParser { @Override public YangNode getDataModel(String yangFile) throws IOException, ParserException { ANTLRInputStream input; try { input = new ANTLRFileStream(yangFile); } catch (IOException e) { throw new ParserException("YANG file error : YANG file does not exist."); } GeneratedYangLexer lexer = new GeneratedYangLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); GeneratedYangParser parser = new GeneratedYangParser(tokens); parser.removeErrorListeners(); ParseTreeErrorListener parseTreeErrorListener = new ParseTreeErrorListener(); parser.addErrorListener(parseTreeErrorListener); ParseTree tree; try { tree = parser.yangfile(); } catch (ParserException parserException) { parserException.setFileName(yangFile); throw parserException; } ParseTreeWalker walker = new ParseTreeWalker(); TreeWalkListener treeWalker = new TreeWalkListener(); try { walker.walk(treeWalker, tree); } catch (ParserException listenerException) { listenerException.setFileName(yangFile); throw listenerException; } finally { } return treeWalker.getRootNode(); }  @Override YangNode getDataModel(String yangFile);  }