GrammarLoader { public GrammarDocument loadGrammarDocument( final VoiceXmlInterpreterContext context, final FetchAttributes attributes, final Grammar grammar, final Locale language) throws UnsupportedFormatError, BadFetchError, SemanticError { try { if (grammar.isExternalGrammar()) { return loadExternalGrammar(context, attributes, grammar); } else { final Session session = context.getSession(); final String sessionId = session.getSessionId(); final DocumentServer server = context.getDocumentServer(); return loadInternalGrammar(sessionId, server, grammar, language); } } catch (IllegalAttributeException | URISyntaxException e) { throw new BadFetchError(e.getMessage(), e); } }  GrammarDocument loadGrammarDocument(
            final VoiceXmlInterpreterContext context,
            final FetchAttributes attributes, final Grammar grammar,
            final Locale language);  }
@Test public void testLoadGrammarDocument() throws Exception, JVoiceXMLEvent { final String cr = System.getProperty("line.separator"); final VoiceXmlDocument document = new VoiceXmlDocument(); final Vxml vxml = document.getVxml(); vxml.setXmlLang(Locale.US); final Form form = vxml.appendChild(Form.class); final Grammar grammar = form.appendChild(Grammar.class); grammar.setType(GrammarType.JSGF); final StringBuilder str = new StringBuilder(); str.append("#JSGF V1.0;" + cr); str.append("grammar jvoicexml;" + cr); str.append("public <boolean> = yes{true}|no{false};"); grammar.addCData(str.toString()); final GrammarDocument grammarDocument = loader.loadGrammarDocument( context, null, grammar, Locale.US); Assert.assertEquals(grammar.toString(), grammarDocument.getDocument()); }