You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2017/05/03 16:33:57 UTC
svn commit: r1793674 - in /sling/trunk/bundles/jcr/contentloader/src/test:
java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
resources/i18n-content/ resources/initial-content/i18n/
Author: sseifert
Date: Wed May 3 16:33:56 2017
New Revision: 1793674
URL: http://svn.apache.org/viewvc?rev=1793674&view=rev
Log:
SLING-6825 add unit tests for file with descriptor
Added:
sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java (with props)
sling/trunk/bundles/jcr/contentloader/src/test/resources/initial-content/i18n/
- copied from r1793673, sling/trunk/bundles/jcr/contentloader/src/test/resources/i18n-content/
Removed:
sling/trunk/bundles/jcr/contentloader/src/test/resources/i18n-content/
Added: sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java?rev=1793674&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java (added)
+++ sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java Wed May 3 16:33:56 2017
@@ -0,0 +1,79 @@
+/*
+ * 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+
+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;
+
+/** Basic test of a bundle that provides initial content */
+@RunWith(PaxExam.class)
+public class I18nInitialContentIT extends ContentBundleTestBase {
+
+ protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
+ b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";ignoreImportProviders:=json;path:=" + contentRootPath);
+ addContent(b, DEFAULT_PATH_IN_BUNDLE, "i18n/en.json");
+ addContent(b, DEFAULT_PATH_IN_BUNDLE, "i18n/en.json.xml");
+ 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());
+ }
+
+ @Test
+ @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
+ public void i18nJsonFile() throws RepositoryException {
+ final String filePath = contentRootPath + "/i18n/en.json";
+ assertTrue("file node " + filePath + " exists", session.itemExists(filePath));
+ Node node = session.getNode(filePath);
+ assertEquals("file has node type 'nt:file'", "nt:file", node.getPrimaryNodeType().getName());
+
+ boolean mixLanguageFound = false;
+ for (NodeType mixin : node.getMixinNodeTypes()) {
+ if ("mix:language".equals(mixin.getName())) {
+ mixLanguageFound = true;
+ }
+ }
+ assertTrue("file has mixin 'mix:language'", mixLanguageFound);
+ assertEquals("file has property 'en'", "en", node.getProperty("jcr:language").getString());
+
+ final String descriptorPath = contentRootPath + "/i18n/en.json.xml";
+ assertFalse("descriptor " + descriptorPath + " does not exists", session.itemExists(descriptorPath));
+ }
+
+}
Propchange: sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Wed May 3 16:33:56 2017
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author
Propchange: sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
------------------------------------------------------------------------------
svn:mime-type = text/plain