DocumentStorage { public URI addGrammarDocument(final String sessionId, final GrammarDocument document) throws URISyntaxException { Collection<GrammarDocument> currentDocuments = getCurrentSessionDocuments(sessionId); currentDocuments.add(document); final URI localUri = new URI( InternalGrammarDocumentHandler.CONTEXT_PATH + "/" + sessionId + "/" + document.hashCode()); documents.put(localUri, document); final URI serverUri = server.getURI(); final URI uri = new URI(serverUri + InternalGrammarDocumentHandler.CONTEXT_PATH.substring(1) + "/" + sessionId + "/" + document.hashCode()); document.setURI(uri); LOGGER.info("added grammar document at '" + uri + "'"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("added document " + document); } return null; } DocumentStorage(); void setStoragePort(final int port); void setGrammarCreators(final Collection<GrammarCreator> col); void start(); URI resolveBuiltinUri(final URI uri); URI addGrammarDocument(final String sessionId,
            final GrammarDocument document); GrammarDocument getDocument(final URI uri); void clear(final String sessionId); void stop();  }
@Test public void testAddGrammarDocument() throws Exception { final SrgsXmlDocument srgsdocument = new SrgsXmlDocument(); final Grammar grammar = srgsdocument.getGrammar(); final GrammarDocument document = new InternalGrammarDocument(grammar); storage.addGrammarDocument("12345", document); final URI uri = document.getURI(); Assert.assertNotNull(uri); final URI path = new URI(uri.getPath()); Assert.assertEquals(document, storage.getDocument(path)); }