@Test
public void testGetDocument() throws URISyntaxException, BadFetchError {

    final URI uri = new URI("http://localhost:8080/testgrammar");
    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());
}