@Override public Property getProperty(String absPath) throws RepositoryException { Property internal = delegate.getProperty(absPath); return new PropertyFacade<>(internal, this); }
/** {@inheritDoc} */ public RemoteProperty getProperty(String path) throws RepositoryException, RemoteException { try { return (RemoteProperty) getRemoteItem(session.getProperty(path)); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
@Override public Property getProperty(final String relPath) throws RepositoryException { String path = makeAbsolutePath(relPath); return getSession().getProperty(path); }
public Long call() throws Exception { String path = propertyPaths.get(rnd.nextInt(propertyPaths.size())); long t1 = System.currentTimeMillis(); Property property = session.getProperty(path); long t2 = System.currentTimeMillis(); items.add(property); return t2 - t1; }
@Test public void testGetProperty() throws Exception { sessionWrapper.getProperty("/included/excludeChannels"); try { sessionWrapper.getProperty("/excluded/excludeChannels"); fail(); } catch (PathNotFoundException expected) { } }
/** * Asserts that a property at the given path as the expected value. */ protected void assertConfig(String expectedValue, String path) throws RepositoryException { assertEquals(expectedValue, MgnlContext.getJCRSession("config").getProperty(path).getString()); }
@Test public void getPropertyWithRelativePath() throws RepositoryException { Session s = getAdminSession(); try { s.getProperty("some-relative-path"); fail("Session.getProperty() with relative path must throw a RepositoryException"); } catch (RepositoryException e) { // expected } }
@Test public void setPropertyAgain() throws RepositoryException { Session session = getAdminSession(); Property p1 = session.getProperty("/foo/stringProp"); Property p2 = p1.getParent().setProperty("stringProp", "newValue"); Property p3 = session.getProperty("/foo/stringProp"); assertEquals("newValue", p1.getString()); assertEquals("newValue", p2.getString()); assertEquals("newValue", p3.getString()); }
@Test public void doNotOverride() throws Exception { // GIVEN sessionConfig.getRootNode().addNode("someSrcNode").setProperty("someProperty", "somePropertyValue"); sessionConfig.getRootNode().addNode("someDestNode").setProperty("someProperty", "someOldValue"); Task task = new CopyPropertyTask("name", RepositoryConstants.CONFIG, "/someSrcNode", "/someDestNode", "someProperty", false); // WHEN task.execute(installContext); // THEN assertTrue(sessionConfig.propertyExists("/someSrcNode/someProperty")); assertEquals("someOldValue", sessionConfig.getProperty("/someDestNode/someProperty").getString()); }
@Test public void testDoNotOverride() throws Exception { // GIVEN sessionConfig.getRootNode().addNode("someSrcNode").setProperty("someProperty", "somePropertyValue"); sessionConfig.getRootNode().addNode("someDestNode").setProperty("someProperty", "someOldValue"); Task task = new MovePropertyTask("name", RepositoryConstants.CONFIG, "/someSrcNode/someProperty", "/someDestNode/someProperty", false); // WHEN task.execute(installContext); // THEN assertTrue(sessionConfig.propertyExists("/someSrcNode/someProperty")); assertEquals("someOldValue", sessionConfig.getProperty("/someDestNode/someProperty").getString()); }
@FixFor( "MODE-1005" ) public void testShouldThrowRepositoryExceptionForRelativePathsInSessionGetProperty() throws Exception { try { Node root = getTestRoot(superuser); root.addNode("propertyNodeForRelativePathTest", "nt:unstructured"); superuser.getProperty("propertyNodeForRelativePathTest/jcr:primaryType"); fail("Should throw RepositoryException when attempting to call Session.getProperty(String) with a relative path"); } catch (RepositoryException re) { // Expected } }
public static void verifyBlob(Session session) throws IOException, RepositoryException { Property p = session.getProperty("/sling-logo.png/jcr:content/jcr:data"); InputStream is = p.getValue().getBinary().getStream(); String expectedMD5 = "35504d8c59455ab12a31f3d06f139a05"; try { assertEquals(expectedMD5, DigestUtils.md5Hex(is)); } finally { is.close(); } }
@Test public void testDialogsAreAddedModalityLevelProperty() throws ModuleManagementException, RepositoryException { // GIVEN this.setupConfigNode("/modules/ui-framework/dialogs/rename"); this.setupConfigNode("/modules/ui-framework/dialogs/folder"); // WHEN executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("5.2.2")); // THEN assertEquals("light", session.getProperty("/modules/ui-framework/dialogs/rename/modalityLevel").getString()); assertEquals("light", session.getProperty("/modules/ui-framework/dialogs/folder/modalityLevel").getString()); }
@Test public void testExecute() throws RepositoryException, TaskExecutionException { // GIVEN ModuleFilesExtraction task = new ModuleFilesExtraction(); // WHEN task.execute(ctx); // THEN assertTrue(new File("docroot/moduleName/avatar.jpg").exists()); assertTrue(session.propertyExists("/server/install/mgnl-files/docroot/moduleName/avatar.jpg/md5")); assertEquals("f4b00bf28d5e67083a9721f8fbae6278", session.getProperty("/server/install/mgnl-files/docroot/moduleName/avatar.jpg/md5").getString()); } }
@Test public void updateFrom523ChangesConfigurationAppClass() throws Exception { // GIVEN setupConfigProperty("modules/ui-admincentral/apps/configuration", "class", "info.magnolia.ui.api.app.registry.ConfiguredAppDescriptor"); // WHEN executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("5.2.3")); // THEN assertEquals("info.magnolia.ui.contentapp.ContentAppDescriptor", session.getProperty("/modules/ui-admincentral/apps/configuration/class").getString()); }
@Test public void testSessionGetProperty() throws Exception { Property pp = superuser.getProperty(p.getPath()); assertTrue(p.isSame(pp)); }
@Test public void setDoubleNaNProperty() throws RepositoryException, IOException { Node parentNode = getNode(TEST_PATH); addProperty(parentNode, "NaN", getAdminSession().getValueFactory().createValue(Double.NaN)); Session session2 = createAnonymousSession(); try { Property property2 = session2.getProperty(TEST_PATH + "/NaN"); assertTrue(Double.isNaN(property2.getDouble())); } finally { session2.logout(); } }
@Test public void updateFrom521AddsEmptyItemTypesInToParamsOfActivateAction() throws Exception { // GIVEN this.setupConfigNode("/modules/ui-admincentral/apps/configuration/subApps/browser/actions/activate"); // WHEN executeUpdatesAsIfTheCurrentlyInstalledVersionWas(Version.parseVersion("5.2.1")); // THEN assertTrue(session.itemExists("/modules/ui-admincentral/apps/configuration/subApps/browser/actions/activate/params/itemTypes")); assertEquals("", session.getProperty("/modules/ui-admincentral/apps/configuration/subApps/browser/actions/activate/params/itemTypes").getString()); }
@Test public void execute() throws Exception { // GIVEN setUpActivation(); Task task = new SetupModuleRepositoriesTask(); // WHEN task.execute(installContext); // THEN assertTrue(sessionConfig.itemExists("/server/activation/subscribers/someSubscriber/subscriptions")); assertTrue(sessionConfig.propertyExists("/server/activation/subscribers/someSubscriber/subscriptions/config/repository")); assertEquals(RepositoryConstants.CONFIG, sessionConfig.getProperty("/server/activation/subscribers/someSubscriber/subscriptions/config/repository").getString()); assertThat(installContext.getMessages().values(), hasSize(0)); }
@Test public void testSingleValueToMultiValue() throws RepositoryException, NotExecutableException { Value v = superuser.getValueFactory().createValue("testValue"); try { user.setProperty("testProperty", v); superuser.save(); } catch (RepositoryException e) { throw new NotExecutableException("Cannot test 'Authorizable.setProperty'."); } user.setProperty("testProperty", new Value[] {v}); Property p = superuser.getProperty(user.getPath() + "/testProperty"); assertTrue(p.isMultiple()); }