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/03/06 21:48:45 UTC

svn commit: r1785772 [2/2] - in /sling/branches/fsresource-1.1.x: ./ src/main/java/org/apache/sling/fsprovider/internal/ src/main/java/org/apache/sling/fsprovider/internal/mapper/ src/main/java/org/apache/sling/fsprovider/internal/mapper/jcr/ src/main/...

Propchange: sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/FileVaultFileMonitorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/FileVaultFileMonitorTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Mar  6 21:48:44 2017
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/FileVaultFileMonitorTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/InitialContentImportOptionsTest.java
URL: http://svn.apache.org/viewvc/sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/InitialContentImportOptionsTest.java?rev=1785772&view=auto
==============================================================================
--- sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/InitialContentImportOptionsTest.java (added)
+++ sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/InitialContentImportOptionsTest.java Mon Mar  6 21:48:44 2017
@@ -0,0 +1,59 @@
+/*
+ * 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.fsprovider.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+public class InitialContentImportOptionsTest {
+
+    @Test
+    public void testNull() {
+        InitialContentImportOptions underTest = new InitialContentImportOptions(null);
+        assertFalse(underTest.isOverwrite());
+        assertTrue(underTest.getIgnoreImportProviders().isEmpty());
+    }
+
+    @Test
+    public void testBlank() {
+        InitialContentImportOptions underTest = new InitialContentImportOptions(" ");
+        assertFalse(underTest.isOverwrite());
+        assertTrue(underTest.getIgnoreImportProviders().isEmpty());
+    }
+
+    @Test
+    public void testOptions1() {
+        InitialContentImportOptions underTest = new InitialContentImportOptions("overwrite:=true;ignoreImportProviders:=xml,json");
+        assertTrue(underTest.isOverwrite());
+        assertEquals(ImmutableSet.of("xml,json"), underTest.getIgnoreImportProviders());
+    }
+
+    @Test
+    public void testOptions2() {
+        InitialContentImportOptions underTest = new InitialContentImportOptions(" overwrite := false ; ignoreImportProviders := xml ");
+        assertFalse(underTest.isOverwrite());
+        assertEquals(ImmutableSet.of("xml"), underTest.getIgnoreImportProviders());
+    }
+
+}

Propchange: sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/InitialContentImportOptionsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/InitialContentImportOptionsTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Mar  6 21:48:44 2017
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/InitialContentImportOptionsTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java
URL: http://svn.apache.org/viewvc/sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java?rev=1785772&r1=1785771&r2=1785772&view=diff
==============================================================================
--- sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java (original)
+++ sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java Mon Mar  6 21:48:44 2017
@@ -57,7 +57,10 @@ public class JcrXmlContentTest {
 
     @Rule
     public SlingContext context = new SlingContextBuilder(ResourceResolverType.JCR_MOCK)
-        .plugin(new RegisterFsResourcePlugin("provider.jcrxml.content", true))
+            .plugin(new RegisterFsResourcePlugin(
+                    "provider.fs.mode", FsMode.INITIAL_CONTENT.name(),
+                    "provider.initial.content.import.options", "overwrite:=true;ignoreImportProviders:=json"
+                    ))
         .build();
 
     @Before

Modified: sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java
URL: http://svn.apache.org/viewvc/sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java?rev=1785772&r1=1785771&r2=1785772&view=diff
==============================================================================
--- sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java (original)
+++ sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java Mon Mar  6 21:48:44 2017
@@ -58,7 +58,7 @@ import com.google.common.collect.Immutab
 import com.google.common.collect.ImmutableSet;
 
 /**
- * Test access to files and folders from filesystem.
+ * Test access to files and folders and JSON content from filesystem.
  */
 public class JsonContentTest {
 
@@ -67,7 +67,10 @@ public class JsonContentTest {
 
     @Rule
     public SlingContext context = new SlingContextBuilder(ResourceResolverType.JCR_MOCK)
-        .plugin(new RegisterFsResourcePlugin("provider.json.content", true))
+        .plugin(new RegisterFsResourcePlugin(
+                "provider.fs.mode", FsMode.INITIAL_CONTENT.name(),
+                "provider.initial.content.import.options", "overwrite:=true;ignoreImportProviders:=jcr.xml"
+                ))
         .build();
 
     @Before

Modified: sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java
URL: http://svn.apache.org/viewvc/sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java?rev=1785772&r1=1785771&r2=1785772&view=diff
==============================================================================
--- sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java (original)
+++ sling/branches/fsresource-1.1.x/src/test/java/org/apache/sling/fsprovider/internal/TestUtils.java Mon Mar  6 21:48:44 2017
@@ -28,17 +28,23 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.CharEncoding;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.fsprovider.internal.FileMonitor.ResourceChange;
 import org.apache.sling.hamcrest.ResourceMatchers;
 import org.apache.sling.testing.mock.osgi.MapUtil;
 import org.apache.sling.testing.mock.osgi.context.AbstractContextPlugin;
 import org.apache.sling.testing.mock.sling.context.SlingContextImpl;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventHandler;
 
 class TestUtils {
 
@@ -53,6 +59,7 @@ class TestUtils {
             config.put("provider.file", "src/test/resources/fs-test");
             config.put("provider.roots", "/fs-test");
             config.put("provider.checkinterval", 0);
+            config.put("provider.fs.mode", FsMode.INITIAL_CONTENT_FILES_FOLDERS.name());
             config.putAll(props);
             context.registerInjectActivateService(new FsResourceProvider(), config);
         }
@@ -94,4 +101,30 @@ class TestUtils {
         }
     }    
 
+    public static void assertChange(List<ResourceChange> changes, String path, String topic) {
+        boolean found = false;
+        for (ResourceChange change : changes) {
+            if (StringUtils.equals(change.path, path) && StringUtils.equals(change.topic,  topic)) {
+                found = true;
+                break;
+            }
+        }
+        assertTrue("Change with path=" + path + ", topic=" + topic + " expected", found);
+    }
+    
+    public static class ResourceListener implements EventHandler {
+        private final List<ResourceChange> allChanges = new ArrayList<>();
+        public List<ResourceChange> getChanges() {
+            return allChanges;
+        }
+        @Override
+        public void handleEvent(Event event) {
+            ResourceChange change = new ResourceChange();
+            change.path = (String)event.getProperty(SlingConstants.PROPERTY_PATH);
+            change.resourceType = (String)event.getProperty(SlingConstants.PROPERTY_RESOURCE_TYPE);
+            change.topic = event.getTopic();
+            allChanges.add(change);
+        }
+    }
+
 }

Modified: sling/branches/fsresource-1.1.x/src/test/resources/vaultfs-test/META-INF/vault/filter.xml
URL: http://svn.apache.org/viewvc/sling/branches/fsresource-1.1.x/src/test/resources/vaultfs-test/META-INF/vault/filter.xml?rev=1785772&r1=1785771&r2=1785772&view=diff
==============================================================================
--- sling/branches/fsresource-1.1.x/src/test/resources/vaultfs-test/META-INF/vault/filter.xml (original)
+++ sling/branches/fsresource-1.1.x/src/test/resources/vaultfs-test/META-INF/vault/filter.xml Mon Mar  6 21:48:44 2017
@@ -19,5 +19,7 @@
 -->
 <workspaceFilter version="1.0">
     <filter root="/content/dam/talk.png" />
-    <filter root="/content/samples" />
+    <filter root="/content/samples">
+        <exclude pattern="/content/samples/en/conference(/.*)?"/>
+    </filter>
 </workspaceFilter>

Modified: sling/branches/fsresource-1.1.x/src/test/resources/vaultfs-test/jcr_root/content/dam/talk.png/.content.xml
URL: http://svn.apache.org/viewvc/sling/branches/fsresource-1.1.x/src/test/resources/vaultfs-test/jcr_root/content/dam/talk.png/.content.xml?rev=1785772&r1=1785771&r2=1785772&view=diff
==============================================================================
--- sling/branches/fsresource-1.1.x/src/test/resources/vaultfs-test/jcr_root/content/dam/talk.png/.content.xml (original)
+++ sling/branches/fsresource-1.1.x/src/test/resources/vaultfs-test/jcr_root/content/dam/talk.png/.content.xml Mon Mar  6 21:48:44 2017
@@ -39,8 +39,6 @@
         dc:format="image/png"
         dc:modified="{Date}2014-09-19T21:20:26.812+02:00"
         jcr:primaryType="nt:unstructured"
-        tiff:ImageLength="{Long}270"
-        tiff:ImageWidth="{Long}480"
         writebackEnable="{Boolean}true" />
   </jcr:content>
 </jcr:root>