コード例 #1
0
  private void persistBinaryContent(JcrRepository repository)
      throws RepositoryException, IOException {
    assertNotNull(repository);

    long minimumBinarySize =
        repository.getConfiguration().getBinaryStorage().getMinimumBinarySizeInBytes();
    long binarySize = minimumBinarySize + 1;

    Session session = repository.login();
    InputStream binaryValueStream = null;
    try {
      byte[] content = new byte[(int) binarySize];
      new Random().nextBytes(content);
      JCR_TOOLS.uploadFile(session, "folder/file", new ByteArrayInputStream(content));
      session.save();

      Node nodeWithBinaryContent = session.getNode("/folder/file/jcr:content");
      Binary binaryValue = nodeWithBinaryContent.getProperty("jcr:data").getBinary();
      binaryValueStream = binaryValue.getStream();
      byte[] retrievedContent = IoUtil.readBytes(binaryValueStream);
      assertArrayEquals(content, retrievedContent);
    } finally {
      if (binaryValueStream != null) {
        binaryValueStream.close();
      }
      session.logout();
    }
  }
コード例 #2
0
 @Test
 public void shouldAllowCustomReindexingConfiguration() throws Exception {
   // do a login to force the repo to start
   reindexingRepository.login();
   RepositoryConfiguration.Reindexing reindexing =
       reindexingRepository.getConfiguration().getReindexing();
   assertFalse(reindexing.isAsync());
   assertEquals(RepositoryConfiguration.ReindexingMode.INCREMENTAL, reindexing.mode());
 }