RDF4JProtocolSession extends SPARQLProtocolSession { public void updateRepository(RepositoryConfig config) throws IOException, RepositoryException { String baseURI = Protocol.getRepositoryLocation(serverURL, config.getID()); setRepository(baseURI); Resource ctx = SimpleValueFactory.getInstance().createIRI(baseURI + "#" + config.getID()); Model model = new LinkedHashModel(); config.export(model, ctx); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Rio.write(model, baos, getPreferredRDFFormat()); HttpEntityEnclosingRequestBase method = null; try (InputStream contents = new ByteArrayInputStream(baos.toByteArray())) { HttpEntity entity = new InputStreamEntity(contents, -1, ContentType.parse(getPreferredRDFFormat().getDefaultMIMEType())); method = applyAdditionalHeaders(new HttpPost(Protocol.getRepositoryConfigLocation(baseURI))); method.setEntity(entity); executeNoContent((HttpUriRequest) method); } catch (RepositoryException | RDFParseException e) { throw e; } catch (RDF4JException e) { throw new RepositoryException(e); } finally { if (method != null) { method.reset(); } } } RDF4JProtocolSession(HttpClient client, ScheduledExecutorService executor); void setServerURL(String serverURL); String getServerURL(); String getRepositoryURL(); void setRepository(String repositoryURL); @Override String getUpdateURL(); @Override void close(); TupleQueryResult getRepositoryList(); void getRepositoryList(TupleQueryResultHandler handler); String getServerProtocol(); long size(Resource... contexts); void createRepository(RepositoryConfig config); void updateRepository(RepositoryConfig config); void deleteRepository(String repositoryID); void getRepositoryConfig(StatementCollector statementCollector); TupleQueryResult getNamespaces(); void getNamespaces(TupleQueryResultHandler handler); String getNamespace(String prefix); void setNamespacePrefix(String prefix, String name); void removeNamespacePrefix(String prefix); void clearNamespaces(); TupleQueryResult getContextIDs(); void getContextIDs(TupleQueryResultHandler handler); void getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler,
			Resource... contexts); synchronized void beginTransaction(IsolationLevel isolationLevel); synchronized void beginTransaction(TransactionSetting... transactionSettings); synchronized void commitTransaction(); synchronized void rollbackTransaction(); @Deprecated void sendTransaction(final Iterable<? extends TransactionOperation> txn); void addData(InputStream contents, String baseURI, RDFFormat dataFormat, Resource... contexts); void removeData(InputStream contents, String baseURI, RDFFormat dataFormat, Resource... contexts); void upload(InputStream contents, String baseURI, RDFFormat dataFormat, boolean overwrite,
			boolean preserveNodeIds, Resource... contexts); void upload(final Reader contents, String baseURI, final RDFFormat dataFormat, boolean overwrite,
			boolean preserveNodeIds, Resource... contexts); @Override void setUsernameAndPassword(String username, String password);  }
@Test public void testUpdateRepositoryExecutesPost() throws Exception { RepositoryConfig config = new RepositoryConfig("test"); stubFor(post(urlEqualTo("/rdf4j-server/repositories/test/config")).willReturn(aResponse().withStatus(200))); subject.updateRepository(config); verify(postRequestedFor(urlEqualTo("/rdf4j-server/repositories/test/config"))); verifyHeader("/rdf4j-server/repositories/test/config"); }