cosmetic: remove training whitespaces
diff --git a/pom.xml b/pom.xml
index 20478fb..602d28a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,7 @@
</scm>
<dependencies>
-
+
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.versioning</artifactId>
@@ -54,7 +54,7 @@
<artifactId>jcr</artifactId>
<scope>compile</scope>
</dependency>
-
+
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
@@ -67,7 +67,7 @@
<version>2.16.0</version>
<scope>compile</scope>
</dependency>
-
+
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
@@ -80,7 +80,7 @@
<version>3.6</version>
<scope>compile</scope>
</dependency>
-
+
<!-- Nullability annotations -->
<dependency>
<groupId>org.jetbrains</groupId>
@@ -93,7 +93,7 @@
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>test</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
@@ -111,12 +111,12 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
-
+
</dependencies>
-
+
<build>
<plugins>
-
+
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
@@ -125,8 +125,8 @@
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-baseline-maven-plugin</artifactId>
</plugin>
-
+
</plugins>
</build>
-
+
</project>
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/AbstractItem.java b/src/main/java/org/apache/sling/testing/mock/jcr/AbstractItem.java
index 4394366..28b4616 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/AbstractItem.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/AbstractItem.java
@@ -69,7 +69,7 @@
public boolean isNew() {
return itemData.isNew();
}
-
+
@Override
public Item getAncestor(final int depth) throws RepositoryException {
if (depth < 0 || depth > getDepth()) {
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/ItemData.java b/src/main/java/org/apache/sling/testing/mock/jcr/ItemData.java
index 1689d6b..6661344 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/ItemData.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/ItemData.java
@@ -29,7 +29,7 @@
* Holds node and property item data independently from session.
*/
class ItemData {
-
+
private final String path;
private final String name;
private final boolean isNode;
@@ -39,7 +39,7 @@
private boolean isMultiple;
private boolean isNew;
private boolean isChanged;
-
+
private ItemData(String path, boolean isNode, String uuid, NodeType nodeType) {
this.path = path;
this.name = ResourceUtil.getName(path);
@@ -49,11 +49,11 @@
this.isNew = true;
this.isChanged = false;
}
-
+
public String getPath() {
return path;
}
-
+
public String getName() {
return name;
}
@@ -61,11 +61,11 @@
public boolean isNode() {
return isNode;
}
-
+
public boolean isProperty() {
return !isNode;
}
-
+
public String getUuid() {
if (!isNode()) {
throw new UnsupportedOperationException();
@@ -109,7 +109,7 @@
this.isMultiple = isMultiple;
this.isChanged = true;
}
-
+
public Item getItem(Session session) {
if (isNode) {
return new MockNode(this, session);
@@ -118,7 +118,7 @@
return new MockProperty(this, session);
}
}
-
+
public boolean isNew() {
return isNew;
}
@@ -152,9 +152,9 @@
public static ItemData newNode(String path, NodeType nodeType) {
return new ItemData(path, true, UUID.randomUUID().toString(), nodeType);
}
-
+
public static ItemData newProperty(String path) {
return new ItemData(path, false, null, null);
}
-
+
}
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockEventListenerIterator.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockEventListenerIterator.java
index a051643..d0859cd 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockEventListenerIterator.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockEventListenerIterator.java
@@ -26,7 +26,7 @@
import org.apache.jackrabbit.commons.iterator.RangeIteratorAdapter;
class MockEventListenerIterator extends RangeIteratorAdapter implements EventListenerIterator {
-
+
public MockEventListenerIterator(Collection collection) {
super(collection);
}
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockJcr.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockJcr.java
index c9fab24..df1cb3c 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockJcr.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockJcr.java
@@ -89,7 +89,7 @@
throw new RuntimeException("Creating mocked JCR session failed.", ex);
}
}
-
+
/**
* Sets the expected result list for all queries executed with the given query manager.
* @param session JCR session
@@ -98,7 +98,7 @@
public static void setQueryResult(@NotNull final Session session, @NotNull final List<Node> resultList) {
setQueryResult(getQueryManager(session), resultList);
}
-
+
/**
* Sets the expected result list for all queries executed with the given query manager.
* @param queryManager Mocked query manager
@@ -124,7 +124,7 @@
@NotNull final String language, @NotNull final List<Node> resultList) {
setQueryResult(getQueryManager(session), statement, language, resultList);
}
-
+
/**
* Sets the expected result list for all queries with the given statement executed with the given query manager.
* @param queryManager Mocked query manager
@@ -156,7 +156,7 @@
public static void addQueryResultHandler(@NotNull final Session session, @NotNull final MockQueryResultHandler resultHandler) {
addQueryResultHandler(getQueryManager(session), resultHandler);
}
-
+
/**
* Adds a query result handler for the given query manager which may return query results for certain queries that are executed.
* @param queryManager Mocked query manager
@@ -165,7 +165,7 @@
public static void addQueryResultHandler(@NotNull final QueryManager queryManager, @NotNull final MockQueryResultHandler resultHandler) {
((MockQueryManager)queryManager).addResultHandler(resultHandler);
}
-
+
private static @NotNull QueryManager getQueryManager(@NotNull Session session) {
try {
return session.getWorkspace().getQueryManager();
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockNode.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockNode.java
index 845221c..6213c09 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockNode.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockNode.java
@@ -67,13 +67,13 @@
Node node = new MockNode(itemData, getSession());
getMockedSession().addItem(itemData);
node.setProperty(JcrConstants.JCR_PRIMARYTYPE, primaryNodeTypeName);
-
+
// special handling for some node types
if (StringUtils.equals(primaryNodeTypeName, JcrConstants.NT_FILE)) {
node.setProperty(JcrConstants.JCR_CREATED, Calendar.getInstance());
node.setProperty("jcr:createdBy", getMockedSession().getUserID());
}
-
+
return node;
}
@@ -298,7 +298,7 @@
addItemOrRemoveIfValueNull(itemData, value);
return property;
}
-
+
/**
* Adds or overwrites an item and marks the item value as changed.
* @param itemData Item data
@@ -351,7 +351,7 @@
throw new ItemNotFoundException();
}
}
-
+
@Override
public int hashCode() {
return itemData.hashCode();
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockNodeDefinition.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockNodeDefinition.java
index d424db5..3311621 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockNodeDefinition.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockNodeDefinition.java
@@ -82,4 +82,4 @@
throw new UnsupportedOperationException();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockNodeType.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockNodeType.java
index 7e5e947..3e25deb 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockNodeType.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockNodeType.java
@@ -33,7 +33,7 @@
class MockNodeType implements NodeType {
private final String name;
-
+
public MockNodeType(final String name) {
this.name = name;
}
@@ -55,7 +55,7 @@
return StringUtils.equals(getName(), JcrConstants.NT_UNSTRUCTURED);
}
-
+
// --- unsupported operations ---
@Override
public boolean canAddChildNode(final String childNodeName) {
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java
index bb15aef..152bb37 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java
@@ -184,7 +184,7 @@
this.itemData.setValues(new Value[] { getSession().getValueFactory().createValue(newValue) });
this.itemData.setMultiple(false);
}
-
+
/**
* Removes the current property (itself) if the given value is null.
* @param value Value to check
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockQuery.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockQuery.java
index cb6b385..566fa39 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockQuery.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockQuery.java
@@ -36,15 +36,15 @@
*/
@ConsumerType
public final class MockQuery implements Query {
-
+
private final MockQueryManager queryManager;
private final String statement;
private final String language;
-
+
private long limit;
private long offset;
private Map<String,Value> variables = new HashMap<String, Value>();
-
+
MockQuery(MockQueryManager queryManager, String statement, String language) {
this.queryManager = queryManager;
this.statement = statement;
@@ -94,11 +94,11 @@
Set<String> variableNames = variables.keySet();
return variableNames.toArray(new String[variableNames.size()]);
}
-
+
public Map<String, Value> getBindVariables() throws RepositoryException {
return Collections.unmodifiableMap(variables);
}
-
+
// --- unsupported operations ---
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryManager.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryManager.java
index 6682321..83bb8a3 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryManager.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryManager.java
@@ -38,9 +38,9 @@
* Mock implementation of {@link QueryManager}.
*/
class MockQueryManager implements QueryManager {
-
+
private List<MockQueryResultHandler> resultHandlers = new ArrayList<MockQueryResultHandler>();
-
+
@SuppressWarnings("deprecation")
private static final List<String> SUPPORTED_QUERY_LANGUAGES = Stream.of(
Query.JCR_SQL2,
@@ -48,7 +48,7 @@
Query.XPATH,
Query.SQL
).collect(Collectors.toList());
-
+
@Override
public Query createQuery(String statement, String language) throws RepositoryException {
if (!SUPPORTED_QUERY_LANGUAGES.contains(StringUtils.defaultString(language))) {
@@ -61,11 +61,11 @@
public String[] getSupportedQueryLanguages() throws RepositoryException {
return SUPPORTED_QUERY_LANGUAGES.toArray(new String[SUPPORTED_QUERY_LANGUAGES.size()]);
}
-
+
void addResultHandler(MockQueryResultHandler resultHandler) {
this.resultHandlers.add(resultHandler);
}
-
+
QueryResult executeQuery(MockQuery query) {
for (MockQueryResultHandler resultHandler : resultHandlers) {
MockQueryResult result = resultHandler.executeQuery(query);
@@ -78,7 +78,7 @@
}
// --- unsupported operations ---
-
+
@Override
public QueryObjectModelFactory getQOMFactory() {
throw new UnsupportedOperationException();
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResult.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResult.java
index 84cd1b9..4306c4b 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResult.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResult.java
@@ -33,15 +33,15 @@
/**
* Mock implementation of {@link QueryResult}.
- * Allows to manually set the expected result, optional with column names
+ * Allows to manually set the expected result, optional with column names
* (which are interpreted as property names of the nodes of the result list).
*/
@ProviderType
public final class MockQueryResult implements QueryResult {
-
+
private final List<Node> nodes;
private final List<String> columnNames;
-
+
public MockQueryResult(List<Node> nodes) {
this(nodes, Collections.emptyList());
}
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResultHandler.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResultHandler.java
index 40572a3..b941804 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResultHandler.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResultHandler.java
@@ -33,5 +33,5 @@
* If not, null is returned and other handlers are asked to provide a result.
*/
MockQueryResult executeQuery(MockQuery query);
-
+
}
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java
index 12c6790..40b2e18 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java
@@ -47,11 +47,11 @@
private final NamespaceRegistry namespaceRegistry = new MockNamespaceRegistry();
private final ObservationManager observationManager = new MockObservationManager();
private final NodeTypeManager nodeTypeManager = new MockNodeTypeManager();
-
+
public MockRepository() {
this.items.put("/", ItemData.newNode("/", MockNodeTypes.NT_UNSTRUCTURED));
}
-
+
@Override
public Session login() throws RepositoryException {
return login(null, null);
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockRow.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockRow.java
index 6f19367..7fc3d6a 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockRow.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockRow.java
@@ -31,10 +31,10 @@
* Mock implementation of {@link Row}.
*/
class MockRow implements Row {
-
+
private final List<String> columnNames;
private final Node node;
-
+
public MockRow(List<String> columnNames, Node node) {
this.columnNames = columnNames;
this.node = node;
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
index 6271c03..0fc994c 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
@@ -226,7 +226,7 @@
}
// Find all items matching the source
- List<ItemData> itemsToMove = new LinkedList<>();
+ List<ItemData> itemsToMove = new LinkedList<>();
for (String key : new ArrayList<>(items.keySet())) {
if (key.startsWith(source.getPath())) {
itemsToMove.add(items.remove(key));
@@ -366,7 +366,7 @@
return new String[0];
}
-
+
// --- unsupported operations ---
@Override
public void addLockToken(final String lt) {
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java
index dad0c6b..c64eaca 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java
@@ -81,7 +81,7 @@
public QueryManager getQueryManager() throws RepositoryException {
return this.queryManager;
}
-
+
// --- unsupported operations ---
@Override
public void copy(final String srcAbsPath, final String destAbsPath) throws RepositoryException {
diff --git a/src/test/java/org/apache/sling/testing/mock/jcr/MockNodeTest.java b/src/test/java/org/apache/sling/testing/mock/jcr/MockNodeTest.java
index 84d3123..3b35470 100644
--- a/src/test/java/org/apache/sling/testing/mock/jcr/MockNodeTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/jcr/MockNodeTest.java
@@ -194,7 +194,7 @@
this.session.save();
assertFalse(foo.isModified());
}
-
+
@Test
public void testOrderBefore() throws RepositoryException {
Node foo = this.session.getRootNode().addNode("foo");
diff --git a/src/test/java/org/apache/sling/testing/mock/jcr/MockPropertyTest.java b/src/test/java/org/apache/sling/testing/mock/jcr/MockPropertyTest.java
index 640ff8c..40a0b13 100644
--- a/src/test/java/org/apache/sling/testing/mock/jcr/MockPropertyTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/jcr/MockPropertyTest.java
@@ -92,17 +92,17 @@
this.node1.setProperty("prop1", "value1");
this.node1.setProperty("prop1", (String)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
-
+
@Test
public void testStringSetNullViaProp() throws RepositoryException {
this.node1.setProperty("prop1", "value1");
this.node1.getProperty("prop1").setValue((String)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
-
+
@Test
public void testStringArray() throws RepositoryException {
String[] value1 = new String[] { "aaa", "bbb" };
@@ -132,7 +132,7 @@
this.node1.setProperty("prop1", value1);
this.node1.setProperty("prop1", (String[])null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -141,7 +141,7 @@
this.node1.setProperty("prop1", value1);
this.node1.getProperty("prop1").setValue((String[])null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -197,7 +197,7 @@
this.node1.setProperty("prop1", new BigDecimal("1.5"));
this.node1.setProperty("prop1", (BigDecimal)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -205,7 +205,7 @@
this.node1.setProperty("prop1", new BigDecimal("1.5"));
this.node1.getProperty("prop1").setValue((BigDecimal)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -231,7 +231,7 @@
this.node1.setProperty("prop1", value1);
this.node1.setProperty("prop1", (Calendar)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -240,7 +240,7 @@
this.node1.setProperty("prop1", value1);
this.node1.getProperty("prop1").setValue((Calendar)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -265,7 +265,7 @@
this.node1.setProperty("prop1", new BinaryValue(value1).getBinary());
this.node1.setProperty("prop1", (BinaryValue)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -274,7 +274,7 @@
this.node1.setProperty("prop1", new BinaryValue(value1).getBinary());
this.node1.getProperty("prop1").setValue((BinaryValue)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@SuppressWarnings("deprecation")
@@ -299,7 +299,7 @@
this.node1.setProperty("prop1", new ByteArrayInputStream(value1));
this.node1.setProperty("prop1", (InputStream)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@SuppressWarnings("deprecation")
@@ -309,7 +309,7 @@
this.node1.setProperty("prop1", new ByteArrayInputStream(value1));
this.node1.getProperty("prop1").setValue((InputStream)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -333,7 +333,7 @@
this.node1.setProperty("prop1", this.session.getValueFactory().createValue("value1"));
this.node1.setProperty("prop1", (Value)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -341,7 +341,7 @@
this.node1.setProperty("prop1", this.session.getValueFactory().createValue("value1"));
this.node1.getProperty("prop1").setValue((Value)null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -375,7 +375,7 @@
this.node1.setProperty("prop1", value1);
this.node1.setProperty("prop1", (Value[])null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -385,7 +385,7 @@
this.node1.setProperty("prop1", value1);
this.node1.getProperty("prop1").setValue((Value[])null);
- assertFalse(this.node1.hasProperty("prop1"));
+ assertFalse(this.node1.hasProperty("prop1"));
}
@Test
@@ -395,7 +395,7 @@
assertTrue(prop1.isMultiple());
assertEquals(PropertyType.UNDEFINED, prop1.getType());
}
-
+
@Test(expected=ValueFormatException.class)
public void testSingleValueAsValueArray() throws RepositoryException {
this.node1.setProperty("prop1", this.session.getValueFactory().createValue("value1"));
@@ -403,5 +403,5 @@
assertFalse(prop1.isMultiple());
assertEquals("value1", prop1.getValues()[0].getString());
}
-
+
}
diff --git a/src/test/java/org/apache/sling/testing/mock/jcr/MockQueryManagerTest.java b/src/test/java/org/apache/sling/testing/mock/jcr/MockQueryManagerTest.java
index 8280ab6..3bc6a31 100644
--- a/src/test/java/org/apache/sling/testing/mock/jcr/MockQueryManagerTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/jcr/MockQueryManagerTest.java
@@ -44,45 +44,45 @@
private Session session;
private QueryManager queryManager;
private List<Node> sampleNodes;
-
+
@Before
public void setUp() throws RepositoryException {
session = MockJcr.newSession();
queryManager = session.getWorkspace().getQueryManager();
-
+
Node rootNode = session.getRootNode();
-
+
sampleNodes = ImmutableList.of(
rootNode.addNode("node1"),
rootNode.addNode("node2"),
rootNode.addNode("node3")
);
-
- for (int i=0; i<sampleNodes.size(); i++) {
+
+ for (int i=0; i<sampleNodes.size(); i++) {
Node node = sampleNodes.get(i);
node.setProperty("stringProp", "value" + (i + 1));
node.setProperty("intProp", i + 1);
}
sampleNodes.get(0).setProperty("optionalStringProp", "optValue1");
}
-
+
@Test
public void testNoQueryResults() throws RepositoryException {
Query query = queryManager.createQuery("dummy", Query.JCR_SQL2);
QueryResult result = query.execute();
assertFalse(result.getNodes().hasNext());
}
-
+
@Test(expected=InvalidQueryException.class)
public void testInvalidQueryLanguage() throws RepositoryException {
queryManager.createQuery("dummy", "wurst");
}
-
+
@SuppressWarnings("unchecked")
@Test
public void testQueryResults_AllQuerys() throws RepositoryException {
MockJcr.setQueryResult(queryManager, sampleNodes);
-
+
Query query = queryManager.createQuery("query1", Query.JCR_SQL2);
QueryResult result = query.execute();
assertEquals(sampleNodes, ImmutableList.copyOf(result.getNodes()));
@@ -91,12 +91,12 @@
result = query.execute();
assertEquals(sampleNodes, ImmutableList.copyOf(result.getNodes()));
}
-
+
@SuppressWarnings("unchecked")
@Test
public void testQueryResults_SpecificQuery() throws RepositoryException {
MockJcr.setQueryResult(queryManager, "query1", Query.JCR_SQL2, sampleNodes);
-
+
Query query = queryManager.createQuery("query1", Query.JCR_SQL2);
QueryResult result = query.execute();
assertEquals(sampleNodes, ImmutableList.copyOf(result.getNodes()));
@@ -105,7 +105,7 @@
result = query.execute();
assertFalse(result.getNodes().hasNext());
}
-
+
@SuppressWarnings("unchecked")
@Test
public void testQueryResults_ResultHandler() throws RepositoryException {
@@ -118,7 +118,7 @@
return null;
}
});
-
+
Query query = queryManager.createQuery("query1", Query.JCR_SQL2);
QueryResult result = query.execute();
assertEquals(sampleNodes, ImmutableList.copyOf(result.getNodes()));
@@ -127,7 +127,7 @@
result = query.execute();
assertFalse(result.getNodes().hasNext());
}
-
+
@SuppressWarnings("unchecked")
@Test
public void testQueryResults_MultipleResultHandlers() throws RepositoryException {
@@ -141,7 +141,7 @@
return null;
}
});
-
+
MockJcr.addQueryResultHandler(session, new MockQueryResultHandler() {
@Override
public MockQueryResult executeQuery(MockQuery query) {
@@ -151,7 +151,7 @@
return null;
}
});
-
+
Query query = queryManager.createQuery("query1", Query.JCR_SQL2);
QueryResult result = query.execute();
assertEquals(sampleNodes, ImmutableList.copyOf(result.getNodes()));
@@ -164,7 +164,7 @@
result = query.execute();
assertFalse(result.getNodes().hasNext());
}
-
+
@SuppressWarnings("unchecked")
@Test
public void testQueryResults_ResultHandler_Rows() throws RepositoryException {
@@ -173,20 +173,20 @@
"intProp",
"optionalStringProp"
);
-
+
MockJcr.addQueryResultHandler(queryManager, new MockQueryResultHandler() {
@Override
public MockQueryResult executeQuery(MockQuery query) {
return new MockQueryResult(sampleNodes, columnNames);
}
});
-
+
Query query = queryManager.createQuery("query1", Query.JCR_SQL2);
QueryResult result = query.execute();
assertEquals(sampleNodes, ImmutableList.copyOf(result.getNodes()));
-
+
assertEquals(columnNames, ImmutableList.copyOf(result.getColumnNames()));
-
+
List<Row> rows = ImmutableList.copyOf(result.getRows());
assertEquals("value1", rows.get(0).getValue("stringProp").getString());
assertEquals(1L, rows.get(0).getValue("intProp").getLong());
@@ -200,5 +200,5 @@
assertEquals(3L, rows.get(2).getValues()[1].getLong());
assertNull(rows.get(2).getValues()[2]);
}
-
+
}
diff --git a/src/test/java/org/apache/sling/testing/mock/jcr/MockRepositoryTest.java b/src/test/java/org/apache/sling/testing/mock/jcr/MockRepositoryTest.java
index b5f2add..7b680c2 100644
--- a/src/test/java/org/apache/sling/testing/mock/jcr/MockRepositoryTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/jcr/MockRepositoryTest.java
@@ -63,7 +63,7 @@
assertFalse(repository.isStandardDescriptor("test"));
assertFalse(repository.isSingleValueDescriptor("test"));
}
-
+
@Test
public void testMultipleSessions() throws RepositoryException {
Session session1 = repository.login();
@@ -73,15 +73,15 @@
Node root = session1.getRootNode();
root.addNode("test");
session1.save();
-
+
// try to get node in session 2
Node testNode2 = session2.getNode("/test");
assertNotNull(testNode2);
-
+
// delete node and make sure it is removed in session 1 as well
testNode2.remove();
session2.save();
-
+
try {
session1.getNode("/test");
fail("Node was not removed");
diff --git a/src/test/java/org/apache/sling/testing/mock/jcr/MockSessionTest.java b/src/test/java/org/apache/sling/testing/mock/jcr/MockSessionTest.java
index 6759639..1e1410e 100644
--- a/src/test/java/org/apache/sling/testing/mock/jcr/MockSessionTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/jcr/MockSessionTest.java
@@ -39,11 +39,11 @@
import com.google.common.collect.ImmutableSet;
public class MockSessionTest {
-
+
@Test
public void testEmptySession() throws RepositoryException {
Session session = MockJcr.newSession();
-
+
Node rootNode = session.getRootNode();
assertNotNull(rootNode);
assertFalse(rootNode.getProperties().hasNext());
@@ -65,11 +65,11 @@
}
assertEquals(2, countChildren);
}
-
+
@Test
public void testNodePropertyCreateRead() throws RepositoryException {
Session session = MockJcr.newSession();
-
+
Node rootNode = session.getNode("/");
assertEquals(rootNode, session.getRootNode());
@@ -305,7 +305,7 @@
session.removeItem("/foo/");
assertFalse("Removing /foo/ should succeed", session.nodeExists("/foo"));
}
-
+
@Test
public void testNewState() throws RepositoryException {
Session session = MockJcr.newSession();
@@ -314,7 +314,7 @@
Property property = node.setProperty("testProp", "value123");
assertTrue(node.isNew());
assertTrue(property.isNew());
-
+
session.save();
assertFalse(node.isNew());
assertFalse(property.isNew());
@@ -328,5 +328,5 @@
session.logout();
assertFalse(session.isLive());
}
-
+
}