ContextFreeGrammar extends Grammar { @SuppressWarnings({"UnusedReturnValue", "IOResourceOpenedButNotSafelyClosed"}) boolean readBNFFileFromFilesystem(String file_name) throws MalformedGrammarException { StringBuffer contents = new StringBuffer(); try { final int bufferSize = 1024; String line; File f = new File(file_name); FileReader fr = new FileReader(f); BufferedReader br = new BufferedReader(fr, bufferSize); while( (line = br.readLine()) != null ) { contents.append(line); contents.append(System.getProperty("line.separator")); } br.close(); } catch(FileNotFoundException e) { System.err.println("Grammar File not found: "+file_name); return false; } catch(IOException e) { System.err.println("IOException when opening grammar file: "+file_name); return false; } contents.append("\n"); return readBNFString(contents.toString()); } ContextFreeGrammar();   ContextFreeGrammar(ContextFreeGrammar g); abstract boolean genotype2Phenotype(); abstract boolean phenotype2Genotype(); abstract int getUsedCodons(); abstract int getUsedWraps(); @SuppressWarnings({"UnusedReturnValue", "IOResourceOpenedButNotSafelyClosed"}) boolean readBNFFile(String file_name); Rule findRule(Symbol s); Rule findRule(String s); ArrayList getTerminalRules(); ArrayList getNonTerminalRules();  }
@Test public void testReadBNFFileFromFilesystem() throws MalformedGrammarException { System.out.println("* ContextFreeGrammarTest: readBNFFileFromFilesystem"); String fileName = ""; ContextFreeGrammar instance = new ContextFreeGrammarMock(); boolean result = true; try { result = instance.readBNFFileFromFilesystem(fileName); fail("Expected a Malformed Grammar Exception"); } catch (MalformedGrammarException ex) { } catch (AssertionError e) { assertTrue(true); } catch (NullPointerException e) { assertTrue(true); } assertEquals(false, result); instance = new ContextFreeGrammarMock(); result = false; assertEquals(true, instance.readBNFFileFromFilesystem(this.file_name)); }