[jboss-svn-commits] JBL Code SVN: r25587 - in labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src: test/java/org/jboss/labs/clearspace/plugin/hfurl and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Mar 11 06:59:07 EDT 2009


Author: lkrzyzanek
Date: 2009-03-11 06:59:07 -0400 (Wed, 11 Mar 2009)
New Revision: 25587

Modified:
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java
Log:
Changed construction of URL. This rules are applied:
1. Remove all spaces
2. Only ASCII letters. Other letters are transformed to ASCII or to be removed.

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java	2009-03-11 09:00:16 UTC (rev 25586)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java	2009-03-11 10:59:07 UTC (rev 25587)
@@ -49,9 +49,7 @@
 
   public String createHFURLTitle(String documentTitle) {
     // remove white spaces
-    String hfURLTitle = documentTitle.replaceAll("[\\s]+", "-");
-    // to lower case
-    hfURLTitle = hfURLTitle.toLowerCase();
+    String hfURLTitle = documentTitle.replaceAll("[\\s]+", "");
 
     // Remove accents
     // Java 6
@@ -65,9 +63,6 @@
     // remove special characters
     hfURLTitle = hfURLTitle.replaceAll("[^a-zA-Z-]+", "");
 
-    // remove more hyphen with one hyphen
-    hfURLTitle = hfURLTitle.replaceAll("[-]+", "-");
-
     // URL Encode - not needed because all special characters are removed
     // hfURLTitle = URLEncoder.encode(hfURLTitle, "UTF-8");
 

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java	2009-03-11 09:00:16 UTC (rev 25586)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java	2009-03-11 10:59:07 UTC (rev 25587)
@@ -52,8 +52,8 @@
     
     hfURLCache = new HashMap<String, String>();
     
-    hfURLCache.put("DOC-1234", "document-with-friendly-url");
-    hfURLCache.put("DOC-2345", "document-with-friendly-url-2");
+    hfURLCache.put("DOC-1234", "documentwithfriendlyurl");
+    hfURLCache.put("DOC-2345", "documentwithfriendlyurl2");
     
     hfURLManager.setHfURLCache(hfURLCache);
     hfURLManager.setHfURLDAO(new HFURLDAO() {
@@ -68,13 +68,13 @@
    */
   @Test
   public void testCreateHFURLTitle() {
-    assertEquals("document-with-friendly-url", hfURLManager.createHFURLTitle("document with friendly url"));
-    assertEquals("more-than-one-space", hfURLManager.createHFURLTitle("more    than   one  space"));
-    assertEquals("upper-case-document-title", hfURLManager.createHFURLTitle("UPPER CASE DOCUMENT TITLE"));
+    assertEquals("documentwithfriendlyurl", hfURLManager.createHFURLTitle("document with friendly url"));
+    assertEquals("morethanonespace", hfURLManager.createHFURLTitle("more    than   one  space"));
+    assertEquals("UPPERCASEDOCUMENTTITLE", hfURLManager.createHFURLTitle("UPPER CASE DOCUMENT TITLE"));
     
-    assertEquals("special-characters-", hfURLManager.createHFURLTitle("special characters :!@#$%^&*()\"\"\u00a7()[]?><~\u00b1_+`"));
-    assertEquals("title-with-hyphen", hfURLManager.createHFURLTitle("title with - hyphen"));
-    assertEquals("national-characters-escrzyaiedtnescrzyaiedtn", hfURLManager.createHFURLTitle("National characters: \u011b\u0161\u010d\u0159\u017e\u00fd\u00e1\u00ed\u00e9\u010f\u0165\u0148\u011a\u0160\u010c\u0158\u017d\u00dd\u00c1\u00cd\u00c9\u010e\u0164\u0147"));
+    assertEquals("specialcharacters", hfURLManager.createHFURLTitle("special characters :!@#$%^&*()\"\"\u00a7()[]?><~\u00b1_+`"));
+    assertEquals("titlewith-hyphen", hfURLManager.createHFURLTitle("title with - hyphen"));
+    assertEquals("NationalcharactersescrzyaiedtnESCRZYAIEDTN", hfURLManager.createHFURLTitle("National characters: \u011b\u0161\u010d\u0159\u017e\u00fd\u00e1\u00ed\u00e9\u010f\u0165\u0148\u011a\u0160\u010c\u0158\u017d\u00dd\u00c1\u00cd\u00c9\u010e\u0164\u0147"));
   }
 
   /**
@@ -82,8 +82,8 @@
    */
   @Test
   public void testGetDocumentID() {
-    assertEquals("DOC-1234", hfURLManager.getDocumentID("document-with-friendly-url"));
-    assertEquals("DOC-2345", hfURLManager.getDocumentID("document-with-friendly-url-2"));
+    assertEquals("DOC-1234", hfURLManager.getDocumentID("documentwithfriendlyurl"));
+    assertEquals("DOC-2345", hfURLManager.getDocumentID("documentwithfriendlyurl2"));
 
     assertEquals(null, hfURLManager.getDocumentID("not-existing"));
   }




More information about the jboss-svn-commits mailing list