Package org.apache.sling.testing.mock.jcr

# Klasse MockJcr

java.lang.Object
org.apache.sling.testing.mock.jcr.MockJcr

@ConsumerType public final class MockJcr extends Object
Factory for mock JCR objects.

## Feldübersicht

Felder
Modifizierer und Typ
Feld
Beschreibung
`static final String`
`DEFAULT_USER_ID`
Default user id
`static final String`
`DEFAULT_WORKSPACE`
Default workspace name

## Methodenübersicht

Modifizierer und Typ
Methode
Beschreibung
`static void`
`addQueryResultHandler(@NotNull javax.jcr.Session session, @NotNull MockQueryResultHandler resultHandler)`
Adds a query result handler for the given query manager which may return query results for certain queries that are executed.
`static void`
`addQueryResultHandler(@NotNull javax.jcr.query.QueryManager queryManager, @NotNull MockQueryResultHandler resultHandler)`
Adds a query result handler for the given query manager which may return query results for certain queries that are executed.
`static void`
`loadNodeTypeDefs(@NotNull javax.jcr.Session session, @NotNull Reader reader)`
Reads and registers the node types from the reader that supplies the content in the compact node type definition format.
`static @NotNull javax.jcr.Repository`
`newRepository()`
Create a new mocked in-memory JCR repository.
`static @NotNull javax.jcr.Session`
`newSession()`
Create a new mocked in-memory JCR session.
`static @NotNull javax.jcr.Session`
`newSession(@Nullable String userId, @Nullable String workspaceName)`
Create a new mocked in-memory JCR session.
`static void`
`setAccessControlManager(@NotNull javax.jcr.Session session, @Nullable javax.jcr.security.AccessControlManager acm)`
Use the supplied AccessControlManager for the session
`static void`
`setQueryResult(@NotNull javax.jcr.Session session, @NotNull String statement, @NotNull String language, @NotNull List<javax.jcr.Node> resultList)`
Sets the expected result list for all queries with the given statement executed with the given query manager.
`static void`
`setQueryResult(@NotNull javax.jcr.Session session, @NotNull String statement, @NotNull String language, @NotNull List<javax.jcr.Node> resultList, boolean simulateUnknownSize)`
Sets the expected result list for all queries with the given statement executed with the given query manager.
`static void`
`setQueryResult(@NotNull javax.jcr.Session session, @NotNull List<javax.jcr.Node> resultList)`
Sets the expected result list for all queries executed with the given query manager.
`static void`
`setQueryResult(@NotNull javax.jcr.Session session, @NotNull List<javax.jcr.Node> resultList, boolean simulateUnknownSize)`
Sets the expected result list for all queries executed with the given query manager.
`static void`
`setQueryResult(@NotNull javax.jcr.query.QueryManager queryManager, @NotNull String statement, @NotNull String language, @NotNull List<javax.jcr.Node> resultList)`
Sets the expected result list for all queries with the given statement executed with the given query manager.
`static void`
`setQueryResult(@NotNull javax.jcr.query.QueryManager queryManager, @NotNull String statement, @NotNull String language, @NotNull List<javax.jcr.Node> resultList, boolean simulateUnknownSize)`
Sets the expected result list for all queries with the given statement executed with the given query manager.
`static void`
`setQueryResult(@NotNull javax.jcr.query.QueryManager queryManager, @NotNull List<javax.jcr.Node> resultList)`
Sets the expected result list for all queries executed with the given query manager.
`static void`
`setQueryResult(@NotNull javax.jcr.query.QueryManager queryManager, @NotNull List<javax.jcr.Node> resultList, boolean simulateUnknownSize)`
Sets the expected result list for all queries executed with the given query manager.

### Von Klasse geerbte Methoden java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Felddetails

### DEFAULT_WORKSPACE

public static final String DEFAULT_WORKSPACE
Default workspace name

Siehe auch:
  - Konstantenfeldwerte

### DEFAULT_USER_ID

public static final String DEFAULT_USER_ID
Default user id

Siehe auch:
  - Konstantenfeldwerte

## Methodendetails

### newRepository

@NotNull public static @NotNull javax.jcr.Repository newRepository()
Create a new mocked in-memory JCR repository. Beware: each session has its own data store.

Gibt zurück:
  JCR repository

### newSession

@NotNull public static @NotNull javax.jcr.Session newSession()
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.

Gibt zurück:
  JCR session

### newSession

@NotNull public static @NotNull javax.jcr.Session newSession(@Nullable @Nullable String userId, @Nullable @Nullable String workspaceName)
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.

Parameter:
  `userId` - User id for the mock environment. If null a dummy value is used.
  `workspaceName` - Workspace name for the mock environment. If null a dummy value is used.
Gibt zurück:
  JCR session

### setQueryResult

public static void setQueryResult(@NotNull @NotNull javax.jcr.Session session, @NotNull @NotNull List<javax.jcr.Node> resultList)
Sets the expected result list for all queries executed with the given query manager.

Parameter:
  `session` - JCR session
  `resultList` - Result list

### setQueryResult

public static void setQueryResult(@NotNull @NotNull javax.jcr.Session session, @NotNull @NotNull List<javax.jcr.Node> resultList, boolean simulateUnknownSize)
Sets the expected result list for all queries executed with the given query manager.

Parameter:
  `session` - JCR session
  `resultList` - Result list
  `simulateUnknownSize` - true to simulate the result iterator having an unknown size

### setQueryResult

public static void setQueryResult(@NotNull @NotNull javax.jcr.query.QueryManager queryManager, @NotNull @NotNull List<javax.jcr.Node> resultList)
Sets the expected result list for all queries executed with the given query manager.

Parameter:
  `queryManager` - Mocked query manager
  `resultList` - Result list

### setQueryResult

public static void setQueryResult(@NotNull @NotNull javax.jcr.query.QueryManager queryManager, @NotNull @NotNull List<javax.jcr.Node> resultList, boolean simulateUnknownSize)
Sets the expected result list for all queries executed with the given query manager.

Parameter:
  `queryManager` - Mocked query manager
  `resultList` - Result list
  `simulateUnknownSize` - true to simulate the result iterator having an unknown size

### setQueryResult

public static void setQueryResult(@NotNull @NotNull javax.jcr.Session session, @NotNull @NotNull String statement, @NotNull @NotNull String language, @NotNull @NotNull List<javax.jcr.Node> resultList)
Sets the expected result list for all queries with the given statement executed with the given query manager.

Parameter:
  `session` - JCR session
  `statement` - Query statement
  `language` - Query language
  `resultList` - Result list

### setQueryResult

public static void setQueryResult(@NotNull @NotNull javax.jcr.Session session, @NotNull @NotNull String statement, @NotNull @NotNull String language, @NotNull @NotNull List<javax.jcr.Node> resultList, boolean simulateUnknownSize)
Sets the expected result list for all queries with the given statement executed with the given query manager.

Parameter:
  `session` - JCR session
  `statement` - Query statement
  `language` - Query language
  `resultList` - Result list
  `simulateUnknownSize` - true to simulate the result iterator having an unknown size

### setQueryResult

public static void setQueryResult(@NotNull @NotNull javax.jcr.query.QueryManager queryManager, @NotNull @NotNull String statement, @NotNull @NotNull String language, @NotNull @NotNull List<javax.jcr.Node> resultList)
Sets the expected result list for all queries with the given statement executed with the given query manager.

Parameter:
  `queryManager` - Mocked query manager
  `statement` - Query statement
  `language` - Query language
  `resultList` - Result list

### setQueryResult

public static void setQueryResult(@NotNull @NotNull javax.jcr.query.QueryManager queryManager, @NotNull @NotNull String statement, @NotNull @NotNull String language, @NotNull @NotNull List<javax.jcr.Node> resultList, boolean simulateUnknownSize)
Sets the expected result list for all queries with the given statement executed with the given query manager.

Parameter:
  `queryManager` - Mocked query manager
  `statement` - Query statement
  `language` - Query language
  `resultList` - Result list
  `simulateUnknownSize` - true to simulate the result iterator having an unknown size

### addQueryResultHandler

public static void addQueryResultHandler(@NotNull @NotNull javax.jcr.Session session, @NotNull @NotNull MockQueryResultHandler resultHandler)
Adds a query result handler for the given query manager which may return query results for certain queries that are executed.

Parameter:
  `session` - JCR session
  `resultHandler` - Mock query result handler

### addQueryResultHandler

public static void addQueryResultHandler(@NotNull @NotNull javax.jcr.query.QueryManager queryManager, @NotNull @NotNull MockQueryResultHandler resultHandler)
Adds a query result handler for the given query manager which may return query results for certain queries that are executed.

Parameter:
  `queryManager` - Mocked query manager
  `resultHandler` - Mock query result handler

### loadNodeTypeDefs

public static void loadNodeTypeDefs(@NotNull @NotNull javax.jcr.Session session, @NotNull @NotNull Reader reader) throws org.apache.jackrabbit.commons.cnd.ParseException, javax.jcr.RepositoryException
Reads and registers the node types from the reader that supplies the content in the compact node type definition format. This will also change the mode of the MockNodeTypeManager to consider only the registered node types.

Parameter:
  `session` - session to load the node types into
  `reader` - reader supplying the compact node type definition data
Löst aus:
  `org.apache.jackrabbit.commons.cnd.ParseException` - Parse exception
  `javax.jcr.RepositoryException` - Repository exception

### setAccessControlManager

public static void setAccessControlManager(@NotNull @NotNull javax.jcr.Session session, @Nullable @Nullable javax.jcr.security.AccessControlManager acm)
Use the supplied AccessControlManager for the session

Parameter:
  `session` - the session to modify
  `acm` - the access control manager to use for the session