You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2008/05/05 14:35:29 UTC
svn commit: r653455 - in /incubator/sling/trunk/sling/servlets-post: ./
src/main/java/org/apache/sling/servlets/post/impl/ src/test/ src/test/java/
src/test/java/org/ src/test/java/org/apache/
src/test/java/org/apache/sling/ src/test/java/org/apache/sl...
Author: bdelacretaz
Date: Mon May 5 05:35:28 2008
New Revision: 653455
URL: http://svn.apache.org/viewvc?rev=653455&view=rev
Log:
SLING-420 - Autogenerated node names should not start with a number
Added:
incubator/sling/trunk/sling/servlets-post/src/test/
incubator/sling/trunk/sling/servlets-post/src/test/java/
incubator/sling/trunk/sling/servlets-post/src/test/java/org/
incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/
incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/
incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/servlets/
incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/servlets/post/
incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/servlets/post/impl/
incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/servlets/post/impl/NodeNameFilterTest.java (with props)
Modified:
incubator/sling/trunk/sling/servlets-post/pom.xml
incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/NodeNameFilter.java
Modified: incubator/sling/trunk/sling/servlets-post/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-post/pom.xml?rev=653455&r1=653454&r2=653455&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-post/pom.xml (original)
+++ incubator/sling/trunk/sling/servlets-post/pom.xml Mon May 5 05:35:28 2008
@@ -109,6 +109,12 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
Modified: incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/NodeNameFilter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/NodeNameFilter.java?rev=653455&r1=653454&r2=653455&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/NodeNameFilter.java (original)
+++ incubator/sling/trunk/sling/servlets-post/src/main/java/org/apache/sling/servlets/post/impl/NodeNameFilter.java Mon May 5 05:35:28 2008
@@ -40,12 +40,15 @@
continue;
}
toAdd = REPLACEMENT_CHAR;
+
+ } else if(i == 0 && Character.isDigit(c)) {
+ sb.append(REPLACEMENT_CHAR);
}
-
+
sb.append(toAdd);
lastAdded = toAdd;
}
-
+
if (sb.length()==0) {
sb.append(REPLACEMENT_CHAR);
}
Added: incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/servlets/post/impl/NodeNameFilterTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/servlets/post/impl/NodeNameFilterTest.java?rev=653455&view=auto
==============================================================================
--- incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/servlets/post/impl/NodeNameFilterTest.java (added)
+++ incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/servlets/post/impl/NodeNameFilterTest.java Mon May 5 05:35:28 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.servlets.post.impl;
+
+import junit.framework.TestCase;
+
+public class NodeNameFilterTest extends TestCase {
+ private final NodeNameFilter filter = new NodeNameFilter();
+
+ protected void runTest(String [] data) {
+ for(int i=0; i < data.length; i++) {
+ final String input = data[i];
+ i++;
+ final String expected = data[i];
+ final String actual = filter.filter(input);
+ assertEquals(expected, actual);
+ }
+ }
+
+ public void testBasicFiltering() {
+ final String [] data = {
+ "test", "test",
+ "t?st", "t_st",
+ "t??st", "t_st"
+ };
+
+ runTest(data);
+ }
+
+ public void testNoInitialNumber() {
+ final String [] data = {
+ "1234", "_1234",
+ "1", "_1"
+ };
+
+ runTest(data);
+ }
+}
\ No newline at end of file
Propchange: incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/servlets/post/impl/NodeNameFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/trunk/sling/servlets-post/src/test/java/org/apache/sling/servlets/post/impl/NodeNameFilterTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL