incorporate several APLAWS patches for ccm-core:
r1708: Changed sync() to run() so unit tests now compile (LuceneTest.java, SearchTest.java). r1709: Created java equivalent of manipulate-input.js to convert titles to url form. r1720: Converted formatting of code examples to <pre> 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-94f89814c4dfmaster
parent
6754f1cf85
commit
3521640c08
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 "<code>manipulate-input.js</code>"
|
||||
*
|
||||
* For example, "<code>Business promotions!</code>" will be converted to "<code>business-promotions</code>".
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
* <code>
|
||||
* public static Test suite();
|
||||
* </code>
|
||||
* <pre>
|
||||
* public static Test suite();</pre>
|
||||
*
|
||||
* In the PackageTestSuite framework, this method works as in the following example:
|
||||
*
|
||||
* <pre>
|
||||
* public static Test suite()
|
||||
* {
|
||||
* PersistenceSuite suite = new PersistenceSuite();
|
||||
* populateSuite(suite);
|
||||
* return suite;
|
||||
* }
|
||||
*
|
||||
* }</pre>
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* <code> public static final boolean FAILS = true; </code>
|
||||
* <pre>
|
||||
* public static final boolean FAILS = true;
|
||||
* </pre>
|
||||
*
|
||||
* If the TestCase requires initialization of some external resources, the
|
||||
* class should implement the following method:
|
||||
*
|
||||
* <code>
|
||||
* <pre>
|
||||
* public static Test suite()
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* This factory method can then return the TestCase wrapped in some TestDecorator
|
||||
* that performs initialization.
|
||||
*
|
||||
* An example would be:
|
||||
* <code>
|
||||
*
|
||||
* <pre>
|
||||
* 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();
|
||||
* }
|
||||
* }
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li><p>FooTestImpl.java - The TestCase based class. Was FooTest in prior example</p></li>
|
||||
* <li><p>FooTest.java - The TestSetup derived class, which is created wrapping
|
||||
* FooTestImpl.java. Was FooSetup in above example</p></li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
* An example would be:
|
||||
* <code>
|
||||
*
|
||||
* <pre>
|
||||
* 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));
|
||||
* }
|
||||
* }
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @param testClass The test class to add to the suite.
|
||||
*/
|
||||
public void addTestSuite(final Class testClass) {
|
||||
|
|
|
|||
|
|
@ -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 = "<div>\n" +
|
||||
"foo <strong>bar</strong> wibble <em>eek</em>\n" +
|
||||
"and <a href=\"mailto:dan@berrange.com\">mailto:dan@berrange.com</a> eek!\n" +
|
||||
"</div>\n" +
|
||||
String expected = "<div>\n" +
|
||||
"foo <strong>bar</strong> wibble <em>eek</em>\n" +
|
||||
"and <a href=\"mailto:dan@berrange.com\">mailto:dan@berrange.com</a> eek!\n" +
|
||||
"</div>\n" +
|
||||
"\n" +
|
||||
"<div>\n" +
|
||||
"the second <code>paragraph</code> contains\n" +
|
||||
"a link to <a href=\"http://www.google.com\">http://www.google.com</a>\n" +
|
||||
"and the fractions ½ ¾ ¼ and\n" +
|
||||
"the symbols for copyright ©,\n" +
|
||||
"trademark <sup>TM</sup> and rights ®\n" +
|
||||
"</div>\n" +
|
||||
"<div>\n" +
|
||||
"the second <code>paragraph</code> contains\n" +
|
||||
"a link to <a href=\"http://www.google.com\">http://www.google.com</a>\n" +
|
||||
"and the fractions ½ ¾ ¼ and\n" +
|
||||
"the symbols for copyright ©,\n" +
|
||||
"trademark <sup>TM</sup> and rights ®\n" +
|
||||
"</div>\n" +
|
||||
"\n" +
|
||||
"<ul>\n" +
|
||||
"<li>\n" +
|
||||
"a bullet list\n" +
|
||||
"</li>\n" +
|
||||
"<li>\n" +
|
||||
"more <strong>bullets</strong> in\n" +
|
||||
" this list element\n" +
|
||||
"</li>\n" +
|
||||
"<li>\n" +
|
||||
"a final element</li>\n" +
|
||||
"</ul>\n" +
|
||||
"<ul>\n" +
|
||||
"<li>\n" +
|
||||
"a bullet list\n" +
|
||||
"</li>\n" +
|
||||
"<li>\n" +
|
||||
"more <strong>bullets</strong> in\n" +
|
||||
" this list element\n" +
|
||||
"</li>\n" +
|
||||
"<li>\n" +
|
||||
"a final element</li>\n" +
|
||||
"</ul>\n" +
|
||||
"\n" +
|
||||
"<hr/>\n" +
|
||||
"<hr/>\n" +
|
||||
"\n" +
|
||||
"<ol>\n" +
|
||||
"<li>\n" +
|
||||
"now an enumerated list item\n" +
|
||||
"</li>\n" +
|
||||
"<li>\n" +
|
||||
"and one <em>more</em>\n" +
|
||||
"</li>\n" +
|
||||
"<li>\n" +
|
||||
"this one is split over two lines\n" +
|
||||
"for testing purposes</li>\n" +
|
||||
"</ol>\n" +
|
||||
"<ol>\n" +
|
||||
"<li>\n" +
|
||||
"now an enumerated list item\n" +
|
||||
"</li>\n" +
|
||||
"<li>\n" +
|
||||
"and one <em>more</em>\n" +
|
||||
"</li>\n" +
|
||||
"<li>\n" +
|
||||
"this one is split over two lines\n" +
|
||||
"for testing purposes</li>\n" +
|
||||
"</ol>\n" +
|
||||
"\n" +
|
||||
"<hr/>\n" +
|
||||
"<hr/>\n" +
|
||||
"\n" +
|
||||
"<div>\n" +
|
||||
"and now the end is near, lets test\n" +
|
||||
"<a href=\"http://www.google.com\">google</a> a few\n" +
|
||||
"titled links, including a mailto\n" +
|
||||
"<a href=\"mailto:dan@berrange.com\">Dan B</a>\n" +
|
||||
"<div>\n" +
|
||||
"and now the end is near, lets test\n" +
|
||||
"<a href=\"http://www.google.com\">google</a> a few\n" +
|
||||
"titled links, including a mailto\n" +
|
||||
"<a href=\"mailto:dan@berrange.com\">Dan B</a>\n" +
|
||||
"</div>\n";
|
||||
String actual = StringUtils.smartTextToHtml(src);
|
||||
|
||||
|
||||
s_log.debug("Input: {" + src + "}\n");
|
||||
s_log.debug("Expected: {" + expected + "}\n");
|
||||
s_log.debug("Actual: {" + actual + "}\n");
|
||||
|
||||
|
||||
assertTrue(expected.equals(actual));
|
||||
}
|
||||
|
||||
|
|
@ -359,4 +359,16 @@ public class StringUtilsTest extends TestCase {
|
|||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testUrlize() {
|
||||
assertEquals(null, StringUtils.urlize(null));
|
||||
assertEquals("", StringUtils.urlize(""));
|
||||
assertEquals("-", StringUtils.urlize(" "));
|
||||
assertEquals("----", StringUtils.urlize(" "));
|
||||
assertEquals("abc-def", StringUtils.urlize("ABC DEF"));
|
||||
assertEquals("-abc-def-", StringUtils.urlize(" ABC DEF "));
|
||||
assertEquals("0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz-_---", StringUtils.urlize("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_ &/"));
|
||||
assertEquals("helpaplawsorg", StringUtils.urlize("help@aplaws.org"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue