Refine search
@Test public void namePropertyFromNameValue() throws RepositoryException { PropertyState nameProperty = PropertyStates.createProperty("name", "oak-prefix:value", PropertyType.NAME); Value nameValue = valueFactory.createValue(nameProperty); PropertyState namePropertyFromValue = PropertyStates.createProperty("name", nameValue); assertEquals(nameProperty, namePropertyFromValue); }
@Test public void pathPropertyFromPathValue() throws RepositoryException { PropertyState pathProperty = PropertyStates.createProperty("path", "oak-prefix:a/oak-prefix:b", PropertyType.PATH); Value nameValue = valueFactory.createValue(pathProperty); PropertyState namePropertyFromValue = PropertyStates.createProperty("path", nameValue); assertEquals(pathProperty, namePropertyFromValue); }
@Test public void testGetAggregatedPrivilegeNamesNested() { ImmutableSet<String> values = ImmutableSet.of(JCR_READ, JCR_ADD_CHILD_NODES); when(pTree.getProperty(REP_AGGREGATES)).thenReturn(PropertyStates.createProperty(REP_AGGREGATES, values, Type.NAMES)); when(pTree.exists()).thenReturn(true); when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree); Iterable<String> result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME); ImmutableSet<String> expected = ImmutableSet.of(REP_READ_NODES, REP_READ_PROPERTIES, JCR_ADD_CHILD_NODES); assertEquals(expected, ImmutableSet.copyOf(result)); }
@Test public void testGetPropertiesAfterSet() { secureNodeBuilder.setProperty(PropertyStates.createProperty("another", ImmutableList.of("v", "v2"), Type.STRINGS)); assertEquals(2, Iterables.size(secureNodeBuilder.getProperties())); }
@Test public void testParentNotDefinesProperty() { for (String propName : Iterables.concat(USER_PROPERTY_NAMES, GROUP_PROPERTY_NAMES)) { PropertyState property = PropertyStates.createProperty(propName, "value"); for (String ntName : new String[] {NodeTypeConstants.NT_OAK_UNSTRUCTURED, NT_REP_AUTHORIZABLE_FOLDER}) { assertFalse(ctx.definesProperty(mockTree("anyName", ntName), property)); } } }
@Test public void testNameNotDefinesProperty() { for (String propName : new String[] {"anyName", JcrConstants.JCR_PRIMARYTYPE}) { PropertyState property = PropertyStates.createProperty(propName, "value"); for (String ntName : NT_NAMES) { boolean defines = NT_REP_MEMBERS.equals(ntName); assertEquals(defines, ctx.definesProperty(mockTree("anyName", ntName), property)); } } }
@Test(expected = CommitFailedException.class) public void removeMandatoryProperty() throws CommitFailedException { EffectiveType effective = createControl().createMock(EffectiveType.class); expect(effective.isMandatoryProperty("mandatory")).andReturn(true); expect(effective.getDirectTypeNames()).andReturn(Collections.emptyList()); replay(effective); TypeEditor editor = new TypeEditor(effective); editor.propertyDeleted(PropertyStates.createProperty("mandatory", "")); }
@Test public void sortQueriesWithString_OrderedProps() throws Exception { Tree idx = createIndex("test1", of("foo", "bar")); idx.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("bar"), STRINGS)); idx.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo"), STRINGS)); idx.addChild(PROP_NODE).addChild("foo"); root.commit(); assertSortedString(); }
@Test public void testNameNotDefinesProperty() { for (String propName : new String[] {"anyName", JcrConstants.JCR_PRIMARYTYPE}) { PropertyState property = PropertyStates.createProperty(propName, "value"); for (String ntName : PrivilegeConstants.PRIVILEGE_NODETYPE_NAMES) { assertFalse(ctx.definesProperty(mockTree("anyName", ntName), property)); } } }
@Test public void testDefinesProperty() { for (String propName : PrivilegeConstants.PRIVILEGE_PROPERTY_NAMES) { PropertyState property = PropertyStates.createProperty(propName, "value"); for (String ntName : PrivilegeConstants.PRIVILEGE_NODETYPE_NAMES) { assertTrue(ctx.definesProperty(mockTree("anyName", ntName), property)); } } }
@Test public void testCanReadProperty2() throws Exception { TreePermission tp = getTreePermission(noAccessSession, REPO_POLICY_PATH); assertFalse(tp.canRead(PropertyStates.createProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_ACL))); }
@Test public void removeNonMandatoryProperty() throws CommitFailedException { EffectiveType effective = createControl().createMock(EffectiveType.class); expect(effective.isMandatoryProperty("mandatory")).andReturn(false); replay(effective); TypeEditor editor = new TypeEditor(effective); editor.propertyDeleted(PropertyStates.createProperty("mandatory", "")); }
@Test public void testMatchesTreeProperty() { Tree tree = Mockito.mock(Tree.class); PropertyState property = PropertyStates.createProperty("prop", "value"); assertTrue(alwaysMatching.matches(tree, property)); assertFalse(neverMatching.matches(tree, property)); }
@Test public void sortQueriesWithDouble_OrderedProps() throws Exception { Tree idx = createIndex("test1", of("foo", "bar")); idx.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("bar"), STRINGS)); idx.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo"), STRINGS)); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DOUBLE); root.commit(); assertSortedDouble(); }
@Test public void sortQueriesWithDate_OrderedProps() throws Exception { Tree idx = createIndex("test1", of("foo", "bar")); idx.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("bar"), STRINGS)); idx.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo"), STRINGS)); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE); root.commit(); assertSortedDate(); }
@Test public void sortQueriesWithLong_OrderedProps() throws Exception { Tree idx = createIndex("test1", of("foo", "bar")); idx.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("bar"), STRINGS)); idx.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo"), STRINGS)); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); root.commit(); assertSortedLong(); }
@Test public void testHashCode2() throws IOException { // mixins null vs [] PropertyState primary = createProperty("primary", "primary"); PropertyState mixin = createProperty("mixin", new ArrayList<String>(), Type.STRINGS); PropertyTemplate[] properties = new PropertyTemplate[0]; String childNode = "c"; Template t0 = new Template(store.getReader(), primary, null, properties, childNode); Template t1 = new Template(store.getReader(), primary, mixin, properties, childNode); assertNotEquals(t0.hashCode(), t1.hashCode()); }
@Test public void testCanReadProperty() { PropertyState ps = PropertyStates.createProperty("prop", "val"); assertTrue(allowedTp.canRead(ps)); assertFalse(deniedTp.canRead(ps)); }
@Test public void disabledIgnored() throws Exception{ builder.child("nt:file").setProperty(createProperty(PROP_PATTERN, asList("jcr:content"), STRINGS)); builder.child("nt:file").setProperty(DocumentBundlor.PROP_DISABLED, true); BundledTypesRegistry registry = BundledTypesRegistry.from(builder.getNodeState()); assertTrue(registry.getBundlors().isEmpty()); }
@Test public void testNotMatchesItem() throws Exception { NodeUtil rootTree = new NodeUtil(root.getTree("/")); List<String> notMatching = ImmutableList.of(NodeTypeConstants.NT_OAK_RESOURCE, NodeTypeConstants.NT_OAK_UNSTRUCTURED, JcrConstants.NT_VERSION); for (String ntName : notMatching) { Tree testTree = rootTree.addChild("name", ntName).getTree(); assertFalse(pattern.matches(testTree, null)); assertFalse(pattern.matches(testTree, PropertyStates.createProperty("a", Boolean.FALSE))); assertFalse(pattern.matches(testTree, PropertyStates.createProperty("f", "anyval"))); testTree.remove(); } }