LazyLoadingGrammarDocument implements GrammarDocument { @Override public String getDocument() { try { final GrammarDocument doc = retrieveDocument(); return doc.getDocument(); } catch (BadFetchError e) { LOGGER.warn(e.getMessage(), e); return null; } } LazyLoadingGrammarDocument(final String sessionId,
            final DocumentServer documentServer, 
            final URI source, final FetchAttributes attrs); @Override boolean isCacheable(); @Override void setURI(final URI source); @Override URI getURI(); @Override void setMediaType(final GrammarType gramamrType); @Override GrammarType getMediaType(); @Override void setModeType(final ModeType modeType); @Override ModeType getModeType(); @Override boolean isAscii(); @Override String getDocument(); @Override String getTextContent(); @Override byte[] getBuffer(); @Override int hashCode(); @Override boolean equals(Object obj); @Override boolean equals(GrammarDocument obj); @Override String toString();  }
@Test public void testGetDocument() throws URISyntaxException, BadFetchError { final URI uri = new URI("http: final FetchAttributes attributes = new FetchAttributes(); attributes.setFetchHint(FetchAttributes.HINT_SAFE); final String sessionId = "4242"; final DocumentServer server = Mockito.mock(DocumentServer.class); final GrammarDocument doc = new ExternalGrammarDocument(uri, "test".getBytes(), "UTF-8", true); Mockito.when(server.getGrammarDocument(Mockito.anyString(), Mockito.any(), Mockito.any())).thenReturn(doc); final LazyLoadingGrammarDocument document = new LazyLoadingGrammarDocument( sessionId, server, uri, attributes); Assert.assertEquals(doc.getBuffer(), document.getBuffer()); }