@Override public Node addNode(final String relPath, final String primaryNodeTypeName) throws RepositoryException { String path = makeAbsolutePath(relPath); Node node = new MockNode(path, getSession(), new MockNodeType(primaryNodeTypeName)); getMockedSession().addItem(node); return node; }
/** * Create a new mocked in-memory JCR repository. * Beware: each session has its own data store. * @return JCR repository */ public static Repository newRepository() { return new MockRepository(); }
@Override public boolean propertyExists(final String absPath) throws RepositoryException { try { getProperty(absPath); return true; } catch (PathNotFoundException ex) { return false; } }
@Override public Property setProperty(final String name, final Value value) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(value); getMockedSession().addItem(property); return property; }
public MockSession(final Repository repository) { this.repository = repository; this.workspace = new MockWorkspace(this); this.items.put("/", new MockNode("/", this, MockNodeTypes.NT_UNSTRUCTURED)); }
@Override public NodeType getNodeType(String nodeTypeName) { // accept all node types and return a mock return new MockNodeType(nodeTypeName); }
@Override public boolean nodeExists(final String absPath) throws RepositoryException { try { getNode(absPath); return true; } catch (PathNotFoundException ex) { return false; } }
@Override public Session login(final String workspaceName) { return login(); }
@Override public String getUUID() { return getIdentifier(); }
@Override public Property setProperty(final String name, final String value) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(value); getMockedSession().addItem(property); return property; }
@Override public Property setProperty(final String name, final Calendar value) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(value); getMockedSession().addItem(property); return property; }
@Override public Property setProperty(final String name, final String[] values) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(values); getMockedSession().addItem(property); return property; }
@Override @SuppressWarnings("deprecation") public Property setProperty(final String name, final InputStream value) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(value); getMockedSession().addItem(property); return property; }
@Override public Property setProperty(final String name, final boolean value) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(value); getMockedSession().addItem(property); return property; }
@Override public Property setProperty(final String name, final double value) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(value); getMockedSession().addItem(property); return property; }
@Override public Property setProperty(final String name, final Binary value) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(value); getMockedSession().addItem(property); return property; }
@Override public Property setProperty(final String name, final BigDecimal value) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(value); getMockedSession().addItem(property); return property; }
@Override public Property setProperty(final String name, final Value[] values) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(values); getMockedSession().addItem(property); return property; }
@Override public Property setProperty(final String name, final long value) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(value); getMockedSession().addItem(property); return property; }
@Override public Property setProperty(final String name, final Node value) throws RepositoryException { Property property = new MockProperty(getPath() + "/" + name, getSession()); property.setValue(value); getMockedSession().addItem(property); return property; }