Author: bdelacretaz
Date: Wed Jul 6 14:26:51 2016
New Revision: 1751689
URL: http://svn.apache.org/viewvc?rev=1751689&view=rev
Log:
SLING-5682 - additional integration test
Added:
sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
sling/trunk/bundles/jcr/contentloader/src/test/resources/initial-content/ordered-content.ordered-json
Modified:
sling/trunk/bundles/jcr/contentloader/pom.xml
Modified: sling/trunk/bundles/jcr/contentloader/pom.xml
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/pom.xml?rev=1751689&r1=1751688&r2=1751689&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/pom.xml (original)
+++ sling/trunk/bundles/jcr/contentloader/pom.xml Wed Jul 6 14:26:51 2016
@@ -88,6 +88,7 @@
<excludes>
<exclude>**/*.json</exclude>
<exclude>src/test/resources/reader/testfile.txt</exclude>
+
<exclude>src/test/resources/initial-content/ordered-content.ordered-json</exclude>
<exclude>jackrabbit/**</exclude>
<exclude>derby.log</exclude>
</excludes>
Added:
sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java?rev=1751689&view=auto
==============================================================================
---
sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
(added)
+++
sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
Wed Jul 6 14:26:51 2016
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.contentloader.it;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.commons.testing.junit.Retry;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.osgi.framework.Bundle;
+
+/** Test the SLING-5682 ordered content loading */
+@RunWith(PaxExam.class)
+public class OrderedInitialContentIT extends ContentBundleTestBase {
+
+ protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
+ b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:="
+ contentRootPath);
+ addContent(b, DEFAULT_PATH_IN_BUNDLE, "ordered-content.ordered-json");
+ return b;
+ }
+
+ @Test
+ @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
+ public void bundleStarted() {
+ final Bundle b = PaxExamUtilities.findBundle(bundleContext,
bundleSymbolicName);
+ assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
+ assertEquals("Expecting bundle to be active:" + bundleSymbolicName,
Bundle.ACTIVE, b.getState());
+ }
+
+ private void assertProperty(Session session, String path, String expected)
throws RepositoryException {
+ assertTrue("Expecting property " + path, session.itemExists(path));
+ final String actual = session.getProperty(path).getString();
+ assertEquals("Expecting correct value at " + path, expected, actual);
+ }
+
+ @Test
+ @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
+ public void initialContentInstalled() throws RepositoryException {
+ assertProperty(session, contentRootPath +
"/ordered-content/first/title", "This comes first");
+ assertProperty(session, contentRootPath +
"/ordered-content/second/title", "This comes second");
+ }
+}
\ No newline at end of file
Added:
sling/trunk/bundles/jcr/contentloader/src/test/resources/initial-content/ordered-content.ordered-json
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/test/resources/initial-content/ordered-content.ordered-json?rev=1751689&view=auto
==============================================================================
---
sling/trunk/bundles/jcr/contentloader/src/test/resources/initial-content/ordered-content.ordered-json
(added)
+++
sling/trunk/bundles/jcr/contentloader/src/test/resources/initial-content/ordered-content.ordered-json
Wed Jul 6 14:26:51 2016
@@ -0,0 +1,10 @@
+{
+ "title": "The parent node",
+ "SLING:ordered": [{
+ "SLING:name": "first",
+ "title": "This comes first"
+ }, {
+ "SLING:name": "second",
+ "title": "This comes second"
+ }]
+}
\ No newline at end of file