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();
    }
  }
 @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());
 }
 @Before
 public void setUp() throws Exception {
   initMocks(this);
   when(mockRepo.getStartupProblems()).thenReturn(mockProblems);
   when(mockProblems.iterator())
       .thenReturn(new ArrayList<org.modeshape.common.collection.Problem>().iterator());
   when(mockRepo.login()).thenReturn(mockSession);
   testObj = new ModeShapeRepositoryFactoryBean();
   testObj.setRepositoryConfiguration(config);
   when(mockModeShapeEngine.deploy(any(RepositoryConfiguration.class))).thenReturn(mockRepo);
   setField(testObj, "modeShapeEngine", mockModeShapeEngine);
 }
Example #4
0
 /**
  * Obtains the JCR version supported by this repository. This is a JBoss managed readonly
  * property.
  *
  * @param repositoryName (never <code>null</code>)
  * @return String version (never <code>null</code>)
  */
 @ManagementOperation(
     description = "The JCR version supported by this repository",
     impact = Impact.ReadOnly)
 public String getRepositoryVersion(String repositoryName) {
   String version = null;
   JcrRepository repository = getRepository(repositoryName);
   if (repository != null) {
     version =
         repository.getDescriptor(Repository.SPEC_NAME_DESC)
             + " "
             + repository.getDescriptor(Repository.SPEC_VERSION_DESC);
   }
   return version;
 }
Example #5
0
  /**
   * Obtains the managed sequencing service. This is a JBoss managed operation.
   *
   * @param repositoryName
   * @return the sequencing service or <code>null</code> if never started
   */
  @ManagementOperation(
      description = "Obtains the descriptors for a JCRRepository as ManagedProperties",
      impact = Impact.ReadOnly)
  public List<ManagedProperty> getRepositoryProperties(String repositoryName) {
    if (!isRunning()) return null;

    List<ManagedProperty> propertyList = new ArrayList<ManagedProperty>();

    JcrRepository repository = getRepository(repositoryName);

    String[] descriptorKeys = repository.getDescriptorKeys();

    for (String key : descriptorKeys) {
      String value = repository.getDescriptor(key);
      propertyList.add(new ManagedProperty(ManagedUtils.createLabel(key), value));
    }

    return propertyList;
  }
 @Before
 public void beforeEach() throws Exception {
   session = repository.login("default");
 }