From 3521640c08155a1d6785d7c8d630b531b1c7434f Mon Sep 17 00:00:00 2001
From: pb
+ * FooTestImpl.java - The TestCase based class. Was FooTest in prior example FooTest.java - The TestSetup derived class, which is created wrapping
+ * FooTestImpl.java. Was FooSetup in above example tags (PackageTestSuite.java).
r1723: NodeGenerator now has more context (parent object and property parameters)
(SimpleDomainObjectXMLFormatter.java , NodeGenerator.java )
r1740: Validates a value is a valid HTML hex code for a colour.
git-svn-id: https://svn.libreccm.org/ccm/trunk@60 8810af33-2d31-482b-a856-94f89814c4df
---
.../SimpleDomainObjectXMLFormatter.java | 2 +-
.../PermissionsResources_de.properties | 10 +-
.../src/com/arsdigita/util/StringUtils.java | 35 ++++++-
.../src/com/arsdigita/xml/NodeGenerator.java | 5 +-
.../arsdigita/search/lucene/LuceneTest.java | 2 +-
.../arsdigita/search/lucene/SearchTest.java | 2 +-
.../junit/framework/PackageTestSuite.java | 41 +++++---
.../com/arsdigita/util/StringUtilsTest.java | 98 +++++++++++--------
8 files changed, 125 insertions(+), 70 deletions(-)
diff --git a/ccm-core/src/com/arsdigita/domain/SimpleDomainObjectXMLFormatter.java b/ccm-core/src/com/arsdigita/domain/SimpleDomainObjectXMLFormatter.java
index d83b11b58..553fd9bc0 100755
--- a/ccm-core/src/com/arsdigita/domain/SimpleDomainObjectXMLFormatter.java
+++ b/ccm-core/src/com/arsdigita/domain/SimpleDomainObjectXMLFormatter.java
@@ -85,7 +85,7 @@ public class SimpleDomainObjectXMLFormatter
Object formatted = null;
if (formatter == null) {
- formatted = generator.format(value);
+ formatted = generator.format(obj, prop, value);
} else {
formatted = formatter.format(value);
}
diff --git a/ccm-core/src/com/arsdigita/ui/permissions/PermissionsResources_de.properties b/ccm-core/src/com/arsdigita/ui/permissions/PermissionsResources_de.properties
index 603659950..875c34927 100755
--- a/ccm-core/src/com/arsdigita/ui/permissions/PermissionsResources_de.properties
+++ b/ccm-core/src/com/arsdigita/ui/permissions/PermissionsResources_de.properties
@@ -4,7 +4,7 @@ permissions.button.search=Los!
permissions.denied.title=Keine Zugriffsberechtigung
permissions.directPermissions.explanation=Diesem Objekt hat folgende direkte Zugriffsberechtigungen
permissions.directPermissions.heading=Zugriffsberechtigungen die Sie veraendern koennen
-permissions.index.adminObjects=Sie haben Administrator Berechtigung fuer folgende Objekte
+permissions.index.adminObjects=Sie haben Administrator Berechtigung f\u00FCr folgende Objekte
permissions.index.noAdminObjects=keine
permissions.index.title=Zugriffsberechtigungen
permissions.index.panelTitle=Zugriffsberechtigungen Administration
@@ -13,17 +13,17 @@ permissions.indirectPermissions.explanation=Diese Zugriffsberechtigungen sind ge
permissions.indirectPermissions.context=Das vererbende Objekt ist
permissions.indirectPermissions.heading=Zugriffsberechtigungen die nicht geaendert werden koennen
permissions.main.site=Haupt Seite
-permissions.one.grant.explanation.left=Waehlen Sie die Benutzer/Gruppen
-permissions.one.grant.explanation.right=Waehlen Sie die Zugriffsberechtigungen
+permissions.one.grant.explanation.left=W\u00E4hlen Sie die Benutzer/Gruppen
+permissions.one.grant.explanation.right=W\u00E4hlen Sie die Zugriffsberechtigungen
permissions.one.grant.title=Zuweisung von Zugriffsberechtigungen
permissions.one.title=Zugriffsberechtigungen zu
permissions.personal.site=Meine Seite
permissions.searchForm.label=Eingabe der Objekt ID
permissions.table.grantee=Wer
-permissions.table.actions=Action
+permissions.table.actions=Aktion
permissions.table.actions.removeAll=Wollen Sie wirklich alle Zugriffsberechtigungen fuer diesen User/Gruppe loeschen?
permissions.table.inherited=Geerbt von
-permissions.table.parent.context.null=Diese Objekt hat keinen Kontext.
+permissions.table.parent.context.null=Dieses Objekt hat keinen Kontext.
permissions.userSearchForm.label=Suche Personen oder Gruppen fuer Zuweisung direkter Berechtigungen.
permissions.userSearchForm.noResults=Keine Zielgruppe gefunden.
diff --git a/ccm-core/src/com/arsdigita/util/StringUtils.java b/ccm-core/src/com/arsdigita/util/StringUtils.java
index 47aed7985..852e71d0a 100755
--- a/ccm-core/src/com/arsdigita/util/StringUtils.java
+++ b/ccm-core/src/com/arsdigita/util/StringUtils.java
@@ -3,12 +3,12 @@
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -1300,6 +1300,37 @@ public class StringUtils {
return list;
}
+
+ /**
+ * Convert a name into a URL form, the java equivalent of "
*
* This factory method can then return the TestCase wrapped in some TestDecorator
* that performs initialization.
*
* An example would be:
- * manipulate-input.js"
+ *
+ * For example, "Business promotions!" will be converted to "business-promotions".
+ *
+ * @param name
+ * the to be converted into a URL.
+ * @return the converted name, possibly unchanged and null if the input is null.
+ */
+ public static String urlize(String name) {
+ if (name == null) {
+ return null;
+ }
+ StringBuffer urlizedName = new StringBuffer(name.length());
+
+ for (int i = 0; i < name.length(); i++) {
+ char ch = name.charAt(i);
+
+ if (Character.isLetter(ch)) {
+ urlizedName.append(Character.toLowerCase(ch));
+ }
+ else if (Character.isDigit(ch) || ch == '_' || ch == '-') {
+ urlizedName.append(ch);
+ }
+ else if (ch == ' ' || ch == '&' || ch == '/') {
+ urlizedName.append('-');
+ }
+ }
+ return urlizedName.toString();
+ }
}
diff --git a/ccm-core/src/com/arsdigita/xml/NodeGenerator.java b/ccm-core/src/com/arsdigita/xml/NodeGenerator.java
index 208aadb33..850631134 100755
--- a/ccm-core/src/com/arsdigita/xml/NodeGenerator.java
+++ b/ccm-core/src/com/arsdigita/xml/NodeGenerator.java
@@ -18,6 +18,9 @@
*/
package com.arsdigita.xml;
+import com.arsdigita.domain.DomainObject;
+import com.arsdigita.persistence.metadata.Property;
+
/**
* An interface providing an API for converting an object
* to a new Element. This is useful when rendering objects where
@@ -28,5 +31,5 @@ package com.arsdigita.xml;
*
*/
public interface NodeGenerator {
- Element format(Object value);
+ Element format(DomainObject parent, Property property, Object value);
}
diff --git a/ccm-core/test/src/com/arsdigita/search/lucene/LuceneTest.java b/ccm-core/test/src/com/arsdigita/search/lucene/LuceneTest.java
index dfcada748..48fad4e2f 100755
--- a/ccm-core/test/src/com/arsdigita/search/lucene/LuceneTest.java
+++ b/ccm-core/test/src/com/arsdigita/search/lucene/LuceneTest.java
@@ -77,7 +77,7 @@ public class LuceneTest extends LuceneTestCase {
note.save();
Indexer idx = new Indexer(Index.getLocation());
- idx.sync();
+ idx.run();
// This is kindof a hack since it's possible there are other things in
// the index that will contain the same search term since the search
diff --git a/ccm-core/test/src/com/arsdigita/search/lucene/SearchTest.java b/ccm-core/test/src/com/arsdigita/search/lucene/SearchTest.java
index 8ed69cbc0..def2508bb 100755
--- a/ccm-core/test/src/com/arsdigita/search/lucene/SearchTest.java
+++ b/ccm-core/test/src/com/arsdigita/search/lucene/SearchTest.java
@@ -149,7 +149,7 @@ public class SearchTest extends LuceneTestCase {
private void sync() throws Exception {
Indexer idx = new Indexer(Index.getLocation());
- idx.sync();
+ idx.run();
}
private void cleanIndex() throws Exception {
diff --git a/ccm-core/test/src/com/arsdigita/tools/junit/framework/PackageTestSuite.java b/ccm-core/test/src/com/arsdigita/tools/junit/framework/PackageTestSuite.java
index ddceab4d6..50176fd24 100755
--- a/ccm-core/test/src/com/arsdigita/tools/junit/framework/PackageTestSuite.java
+++ b/ccm-core/test/src/com/arsdigita/tools/junit/framework/PackageTestSuite.java
@@ -32,19 +32,19 @@ import junit.framework.TestSuite;
* This class is the foundation for the test suite methodology. At each package level,
* an PackageTestSuite derived class is defined. For Ant to handle TestSuites, the class
* must define:
- *
- * public static Test suite();
- *
+ *
+ * public static Test suite();
*
* In the PackageTestSuite framework, this method works as in the following example:
*
+ *
* public static Test suite()
* {
* PersistenceSuite suite = new PersistenceSuite();
* populateSuite(suite);
* return suite;
- * }
- *
+ * }
+ *
* The PackageTestSuite.populateSuite method adds all the valid test cases in the same
* package as the derived Suite class. Optionally, if the property test.testpath is defined,
* the framework will look here. test.testpath must be the fully qualified path name.
@@ -75,20 +75,23 @@ public class PackageTestSuite extends TestSuite {
* If the test class has a field named FAILS, the test will not be added to the suite.
* FAILS can be any public static type, such as:
*
- * public static final boolean FAILS = true;
+ *
+ * public static final boolean FAILS = true;
+ *
*
* If the TestCase requires initialization of some external resources, the
* class should implement the following method:
*
- *
+ *
+ *
* public static Test suite()
- *
+ *
+ *
+ *
*
* There is an alternative methodology, which may be cleaner. Since this whole system,
* like the original Ant test setup, relies on class names, there may be a
* better way. If the test for some class Foo requires a TestSetup wrapper,
* the classes could be named as follows:
*
- * FooTestImpl.java - The TestCase based class. Was FooTest in prior example
- * FooTest.java - The TestSetup derived class, which is created wrapping
- * FooTestImpl.java. Was FooSetup in above example
- *
+ *
* public FooTest extends TestCase {
* public static Test suite() {
* TestSuite suite = new TestSuite(FooTest.class);
@@ -110,19 +113,24 @@ public class PackageTestSuite extends TestSuite {
* SQLLoader.clearDatabase();
* }
* }
- *
+ *
+ *
+ *
+ *
* public class FooTest extends TestSetup {
* public FooTest(Test test)
* {
@@ -132,7 +140,8 @@ public class PackageTestSuite extends TestSuite {
* return new FooTest(new TestSuite(FooTestImpl.class));
* }
* }
- *
+ *
+ *
* @param testClass The test class to add to the suite.
*/
public void addTestSuite(final Class testClass) {
diff --git a/ccm-core/test/src/com/arsdigita/util/StringUtilsTest.java b/ccm-core/test/src/com/arsdigita/util/StringUtilsTest.java
index ecaa6c20b..33eed0268 100755
--- a/ccm-core/test/src/com/arsdigita/util/StringUtilsTest.java
+++ b/ccm-core/test/src/com/arsdigita/util/StringUtilsTest.java
@@ -38,7 +38,7 @@ public class StringUtilsTest extends TestCase {
"a link to http://www.google.com\n" +
"and the fractions 1/2 3/4 1/4 and\n" +
"the symbols for copyright (C),\n" +
- "trademark (TM) and rights (R)\n" +
+ "trademark (TM) and rights (R)\n" +
"\n" +
"* a bullet list\n" +
"* more *bullets* in\n" +
@@ -58,59 +58,59 @@ public class StringUtilsTest extends TestCase {
"@google(http://www.google.com) a few\n" +
"titled links, including a mailto\n" +
"@Dan B(mailto:dan@@berrange.com)";
- String expected = "paragraph contains\n" +
- "a link to http://www.google.com\n" +
- "and the fractions ½ ¾ ¼ and\n" +
- "the symbols for copyright ©,\n" +
- "trademark TM and rights ®\n" +
- "paragraph contains\n" +
+ "a link to http://www.google.com\n" +
+ "and the fractions ½ ¾ ¼ and\n" +
+ "the symbols for copyright ©,\n" +
+ "trademark TM and rights ®\n" +
+ "