RDF4JProtocolSession extends SPARQLProtocolSession { public long size(Resource... contexts) throws IOException, RepositoryException, UnauthorizedException { checkRepositoryURL(); try { String transactionURL = getTransactionURL(); final boolean useTransaction = transactionURL != null; String baseLocation = useTransaction ? appendAction(transactionURL, Action.SIZE) : Protocol.getSizeLocation(getQueryURL()); URIBuilder url = new URIBuilder(baseLocation); String[] encodedContexts = Protocol.encodeContexts(contexts); for (int i = 0; i < encodedContexts.length; i++) { url.addParameter(Protocol.CONTEXT_PARAM_NAME, encodedContexts[i]); } HttpRequestBase method = useTransaction ? new HttpPut(url.build()) : new HttpGet(url.build()); applyAdditionalHeaders(method); try { String response = EntityUtils.toString(executeOK(method).getEntity()); pingTransaction(); try { return Long.parseLong(response); } catch (NumberFormatException e) { throw new RepositoryException("Server responded with invalid size value: " + response); } } finally { method.reset(); } } catch (URISyntaxException e) { throw new AssertionError(e); } catch (RepositoryException e) { throw e; } catch (RDF4JException e) { throw new RepositoryException(e); } } 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 testSize() throws Exception { stubFor(get(urlEqualTo("/rdf4j-server/repositories/test/size")) .willReturn(aResponse().withStatus(200).withBody("8"))); assertThat(subject.size()).isEqualTo(8); verifyHeader("/rdf4j-server/repositories/test/size"); }