incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r889608 - in /sling/trunk/installer/jcr/jcrinstall/src: main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java test/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilterTest.java
Date Fri, 11 Dec 2009 13:19:20 GMT
Author: bdelacretaz
Date: Fri Dec 11 13:19:20 2009
New Revision: 889608

URL: http://svn.apache.org/viewvc?rev=889608&view=rev
Log:
SLING-1234 - jcrinstall ignored install folders with paths that contain dots

Modified:
    sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java
    sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilterTest.java

Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java?rev=889608&r1=889607&r2=889608&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java
(original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java
Fri Dec 11 13:19:20 2009
@@ -99,14 +99,19 @@
     int getPriority(final String path) {
     	int result = 0;
     	
-        // If path contains dots, remove suffixes starting with
-        // dots until path matches regexp, and accept if all suffixes
+        // If path contains dots after the last /, remove suffixes 
+    	// starting with dots until path matches regexp, and accept 
+    	// if all suffixes
         // are included in our list of runmodes
         final char DOT = '.';
         
-        if(path.indexOf(DOT) > 0) {
+        String prefix = path;
+        final int lastSlash = prefix.lastIndexOf('/');
+        if(lastSlash > 0) {
+        	prefix = prefix.substring(lastSlash);
+        }
+        if(prefix.indexOf(DOT) > 0) {
             int pos = 0;
-            String prefix = path;
             final List<String> modes = new LinkedList<String>();
             while( (pos = prefix.lastIndexOf(DOT)) >= 0) {
                 modes.add(prefix.substring(pos + 1));

Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilterTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilterTest.java?rev=889608&r1=889607&r2=889608&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilterTest.java
(original)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilterTest.java
Fri Dec 11 13:19:20 2009
@@ -63,6 +63,7 @@
         assertFalse("Test 2", f.getPriority("/libs/install.bar") > 0);
     }
     
+    @Test
     public void testSingleMode() {
         final String [] m = { "dev" };
         final FolderNameFilter f = new FolderNameFilter(ROOTS, DEFAULT_REGEXP, new MockRunMode(m));
@@ -75,6 +76,7 @@
         assertFalse("Test 7", f.getPriority("/libs/install.bar.dev") > 0);
     }
     
+    @Test
     public void testThreeModes() {
         final String [] m = { "dev", "web", "staging" };
         final FolderNameFilter f = new FolderNameFilter(ROOTS, DEFAULT_REGEXP, new MockRunMode(m));
@@ -93,6 +95,7 @@
         assertFalse("Test 13",f.getPriority("/libs/install.bar.dev") > 0);
     }
     
+    @Test
     public void testRootPriorities() {
         final String [] m = { "dev" };
         final FolderNameFilter f = new FolderNameFilter(ROOTS, DEFAULT_REGEXP, new MockRunMode(m));
@@ -100,6 +103,7 @@
     	assertEquals("/apps root", new Integer(200), f.getPriority("/apps/install"));
     }
     
+    @Test
     public void testRunModePriorities() {
         final String [] m = { "dev", "prod", "staging" };
         final FolderNameFilter f = new FolderNameFilter(ROOTS, DEFAULT_REGEXP, new MockRunMode(m));
@@ -110,4 +114,16 @@
     	assertEquals("Matches three runmodes (B)", new Integer(203), f.getPriority("/apps/install.dev.prod.staging"));
     	assertEquals("Matches three runmodes (C)", new Integer(103), f.getPriority("/libs/install.dev.prod.staging"));
     }
+    
+    @Test
+    public void testDotsInPath() {
+        final String [] m = { "dev", "prod", "staging" };
+        final FolderNameFilter f = new FolderNameFilter(ROOTS, DEFAULT_REGEXP, new MockRunMode(m));
+    	assertEquals("Matches no runmode", new Integer(100), f.getPriority("/libs/foo.bar/install"));
+    	assertEquals("Matches dev runmode", new Integer(201), f.getPriority("/apps/foo.bar/install.dev"));
+    	assertEquals("Matches staging runmode", new Integer(201), f.getPriority("/apps/foo.bar/install.staging"));
+    	assertEquals("Matches three runmodes (A)", new Integer(203), f.getPriority("/apps/foo.bar/install.dev.staging.prod"));
+    	assertEquals("Matches three runmodes (B)", new Integer(203), f.getPriority("/apps/foo.bar/install.dev.prod.staging"));
+    	assertEquals("Matches three runmodes (C)", new Integer(103), f.getPriority("/libs/foo.bar/install.dev.prod.staging"));
+    }
 }



Mime
View raw message