src/main/java/org/apache/sling/testing/mock/jcr/MockJcr.java
public static @NotNull Session newSession(@Nullable String userId, @Nullable String workspaceName) {
        try {
            return newRepository().login(
                    new SimpleCredentials(StringUtils.defaultString(userId, DEFAULT_USER_ID), new char[0]),
                    StringUtils.defaultString(workspaceName, DEFAULT_WORKSPACE)
            );
        } catch (RepositoryException ex) {
            throw new RuntimeException("Creating mocked JCR session failed.", ex);
        }
    }
/**
     * Create a new mocked in-memory JCR session. It contains only the root
     * node. All data of the session is thrown away if it gets garbage
     * collected.
     * @param userId User id for the mock environment. If null a dummy value is used.
     * @param workspaceName Workspace name for the mock environment. If null a dummy value is used.
     * @return JCR session
     */
Create a new mocked in-memory JCR session. It contains only the root
node. All data of the session is thrown away if it gets garbage
collected.
@param userId User id for the mock environment. If null a dummy value is used.
@param workspaceName Workspace name for the mock environment. If null a dummy value is used.
@return JCR session
Create a new mocked in - memory JCR session . It contains only the root node . All data of the session is thrown away if it gets garbage collected . @param userId User id for the mock environment . If null a dummy value is used . @param workspaceName Workspace name for the mock environment . If null a dummy value is used . @return JCR session
public static @NotNull Session newSession(@Nullable String userId, @Nullable String workspaceName) {
        try {
            return newRepository().login(
                    new SimpleCredentials(StringUtils.defaultString(userId, DEFAULT_USER_ID), new char[0]),
                    StringUtils.defaultString(workspaceName, DEFAULT_WORKSPACE)
            );
        } catch (RepositoryException ex) {
            throw new RuntimeException("Creating mocked JCR session failed.", ex);
        }
    }
public static @ NotNull Session newSession ( @ Nullable String userId , @ Nullable String workspaceName ) { try { return newRepository ( ) . login ( new SimpleCredentials ( StringUtils . defaultString ( userId , DEFAULT_USER_ID ) , new char [ 0 ] ) , StringUtils . defaultString ( workspaceName , DEFAULT_WORKSPACE ) ) ; } catch ( RepositoryException ex ) { throw new RuntimeException ( "Creating mocked JCR session failed." , ex ) ; } }
Create a new mocked in-memory JCR session.
Create a new mocked in - memory JCR session .