CCM NG: Todays results of the getting Bebop running in CCM NG
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3843 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
c21ab1e5d7
commit
3321f09481
|
|
@ -11,7 +11,9 @@
|
|||
</Root>
|
||||
<Logger name="com.arsdigita.packaging.Config"
|
||||
level="debug">
|
||||
|
||||
</Logger>
|
||||
<Logger name="com.arsdigita.templating.PatternStylesheetResolver"
|
||||
level="debug">
|
||||
</Logger>
|
||||
<Logger name="com.arsdigita.web.CCMDispatcherServlet"
|
||||
level="debug">
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ http://::host::/::webapp::/themes/::themedir::/::theme::/start.xsl
|
|||
|
||||
# Theme with single entry point (e.g Mandalay) unmanaged default
|
||||
#http://::host::/resource/::webapp::/themes/mandalay/start.xsl
|
||||
http://::host::/::webapp::/themes/foundry-base/start.xsl
|
||||
http://::host::/::webapp::/themes/libreccm-default/start.xsl
|
||||
|
||||
|
||||
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
<properties>
|
||||
<!-- Properties for Hibernate -->
|
||||
<property name="hibernate.hbm2ddl.auto" value="verify"/>
|
||||
<property name="hibernate.hbm2ddl.auto" value="validate"/>
|
||||
<property name="hibernate.connection.autocommit" value="false" />
|
||||
<property name="hibernate.id.new_generator_mappings" value="true"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ package com.arsdigita.templating;
|
|||
import com.arsdigita.util.StringUtils;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
|
@ -38,7 +41,7 @@ import java.util.LinkedList;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -158,7 +161,7 @@ public class PatternStylesheetResolver implements StylesheetResolver {
|
|||
* set com.arsdigita.templating.PatternStylesheetResolver=DEBUG by
|
||||
* uncommenting or adding the line.
|
||||
*/
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
private static final Logger s_log = LogManager.getLogger(
|
||||
PatternStylesheetResolver.class);
|
||||
|
||||
/**
|
||||
|
|
@ -288,12 +291,12 @@ public class PatternStylesheetResolver implements StylesheetResolver {
|
|||
// fall through & try next pattern
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException("cannot open stream "
|
||||
+ resource, ex);
|
||||
+ resource, ex);
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("no path to XSL stylesheet found; "
|
||||
+ "try modifying " + m_path);
|
||||
+ "try modifying " + m_path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -353,7 +356,7 @@ public class PatternStylesheetResolver implements StylesheetResolver {
|
|||
if (clean) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Finished expanding placeholders in "
|
||||
+ StringUtils.join(bits, ""));
|
||||
+ StringUtils.join(bits, ""));
|
||||
}
|
||||
paths.add(bits);
|
||||
}
|
||||
|
|
@ -413,13 +416,15 @@ public class PatternStylesheetResolver implements StylesheetResolver {
|
|||
// Ignore blank lines and comments.
|
||||
line = line.trim();
|
||||
s_log.debug("line is " + line);
|
||||
if ("".equals(line) || line.startsWith("#")
|
||||
|| line.startsWith("!") || line.startsWith("//")) {
|
||||
if ("".equals(line)
|
||||
|| line.startsWith("#")
|
||||
|| line.startsWith("!")
|
||||
|| line.startsWith("//")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Split up the line.
|
||||
List list = StringUtils.splitUp(line, "/::\\w+::/");
|
||||
List list = StringUtils.splitUp(line, "::\\w+::");
|
||||
// Save the split line.
|
||||
m_paths.add(list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import java.util.Objects;
|
|||
public final class TemplatingConfig {
|
||||
|
||||
@Setting
|
||||
private String stylesheetPaths = "/WEB-INF/resources/stylesheet-paths.txt";
|
||||
private String stylesheetPaths = "stylesheet-paths.txt";
|
||||
|
||||
@Setting
|
||||
private String stylesheetResolverClass = PatternStylesheetResolver.class
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ public class UserLoginForm extends Form implements LoginConstants,
|
|||
final Iterator<Bean<?>> iterator = beans.iterator();
|
||||
final ConfigurationManager confManager;
|
||||
if (iterator.hasNext()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Bean<ConfigurationManager> bean = (Bean<ConfigurationManager>) iterator.
|
||||
next();
|
||||
final CreationalContext<ConfigurationManager> ctx = beanManager.
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class SystemInformation {
|
|||
* Map containing all informations provided by the
|
||||
* {@code systeminformation.properties} file.
|
||||
*/
|
||||
private final Map<String, String> sysInfo = new HashMap<String, String>();
|
||||
private final Map<String, String> sysInfo = new HashMap<>();
|
||||
/**
|
||||
* The one and only instance of this class
|
||||
*/
|
||||
|
|
@ -74,7 +74,7 @@ public class SystemInformation {
|
|||
final Properties properties = new Properties();
|
||||
try {
|
||||
final InputStream stream = getClass().getResourceAsStream(
|
||||
"WEB-INF/systeminformation.properties");
|
||||
"systeminformation.properties");
|
||||
if (stream == null) {
|
||||
properties.put("version", "");
|
||||
properties.put("appname", "LibreCCM");
|
||||
|
|
|
|||
|
|
@ -56,16 +56,16 @@ public final class WebConfig {
|
|||
private String defaultScheme = "http";
|
||||
|
||||
@Setting
|
||||
private String server;
|
||||
private String server = "localhost:8080";
|
||||
|
||||
@Setting
|
||||
private String secureServer;
|
||||
private String secureServer = "localhost:8443";
|
||||
|
||||
@Setting
|
||||
private String siteName;
|
||||
private String siteName = "LibreCCM";
|
||||
|
||||
@Setting
|
||||
private String host;
|
||||
private String host = "localhost:8080";
|
||||
|
||||
@Setting
|
||||
private Set<String> secureRequiredFor = new HashSet<>();
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public final class XmlConfig {
|
|||
* @return
|
||||
*/
|
||||
String getDefaultXslTransformerFactoryClassname() {
|
||||
return SAXON;
|
||||
return SAXON_HE;
|
||||
}
|
||||
|
||||
public void setXslTransformer(final String xslTransformer) {
|
||||
|
|
|
|||
|
|
@ -63,19 +63,19 @@ public class StringUtilsTest {
|
|||
@Test
|
||||
public void testSmartText2() {
|
||||
String src = "blabla\n"
|
||||
+ "\n"
|
||||
+ "blub";
|
||||
+ "\n"
|
||||
+ "blub";
|
||||
|
||||
String expected = "<div>\n"
|
||||
+ "blabla\n"
|
||||
+ "</div>\n"
|
||||
+ "\n"
|
||||
+ "<div>\n"
|
||||
+ "blub\n"
|
||||
+ "</div>\n";
|
||||
+ "blabla\n"
|
||||
+ "</div>\n"
|
||||
+ "\n"
|
||||
+ "<div>\n"
|
||||
+ "blub\n"
|
||||
+ "</div>\n";
|
||||
String actual = StringUtils.smartTextToHtml(src);
|
||||
String errMsg = "smartTexttoHtml2, expected = " + expected
|
||||
+ " found = " + actual;
|
||||
+ " found = " + actual;
|
||||
assertEquals(errMsg, expected, actual);
|
||||
}
|
||||
|
||||
|
|
@ -86,84 +86,84 @@ public class StringUtilsTest {
|
|||
@Test
|
||||
public void testSmartText() {
|
||||
String src = "foo *bar* wibble /eek/\n"
|
||||
+ "and mailto:dan@berrange.com eek!\n"
|
||||
+ "\n"
|
||||
+ "the second =paragraph= contains\n"
|
||||
+ "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"
|
||||
+ "\n"
|
||||
+ "* a bullet list\n"
|
||||
+ "* more *bullets* in\n"
|
||||
+ " this list element\n"
|
||||
+ "* a final element\n"
|
||||
+ "\n"
|
||||
+ "-------\n"
|
||||
+ "\n"
|
||||
+ "+ now an enumerated list item\n"
|
||||
+ "+ and one /more/\n"
|
||||
+ "+ this one is split over two lines\n"
|
||||
+ "for testing purposes\n"
|
||||
+ "\n"
|
||||
+ "___\n"
|
||||
+ "\n"
|
||||
+ "and now the end is near, lets test\n"
|
||||
+ "@google(http://www.google.com) a few\n"
|
||||
+ "titled links, including a mailto\n"
|
||||
+ "@Dan B(mailto:dan@@berrange.com)";
|
||||
+ "and mailto:dan@berrange.com eek!\n"
|
||||
+ "\n"
|
||||
+ "the second =paragraph= contains\n"
|
||||
+ "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"
|
||||
+ "\n"
|
||||
+ "* a bullet list\n"
|
||||
+ "* more *bullets* in\n"
|
||||
+ " this list element\n"
|
||||
+ "* a final element\n"
|
||||
+ "\n"
|
||||
+ "-------\n"
|
||||
+ "\n"
|
||||
+ "+ now an enumerated list item\n"
|
||||
+ "+ and one /more/\n"
|
||||
+ "+ this one is split over two lines\n"
|
||||
+ "for testing purposes\n"
|
||||
+ "\n"
|
||||
+ "___\n"
|
||||
+ "\n"
|
||||
+ "and now the end is near, lets test\n"
|
||||
+ "@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"
|
||||
+ "\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"
|
||||
+ "\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"
|
||||
+ "\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";
|
||||
+ "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"
|
||||
+ "\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"
|
||||
+ "\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"
|
||||
+ "\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);
|
||||
|
||||
// assertTrue(expected.equals(actual));
|
||||
String errMsg = "smartTexttoHtml, expected = " + expected
|
||||
+ " found = " + actual;
|
||||
+ " found = " + actual;
|
||||
assertEquals(errMsg, expected, actual);
|
||||
|
||||
}
|
||||
|
|
@ -176,62 +176,62 @@ public class StringUtilsTest {
|
|||
|
||||
String actual = StringUtils.smartTextToHtml(src);
|
||||
String errMsg = "smartTexttoHtml, expected = " + expected
|
||||
+ " found = " + actual;
|
||||
+ " found = " + actual;
|
||||
assertEquals(errMsg, expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSmartTextURL() {
|
||||
String src = "foo *bar* wibble /eek/\n"
|
||||
+ "and mailto:dan@berrange.com eek!\n"
|
||||
+ "\n"
|
||||
+ "the second =paragraph= contains\n"
|
||||
+ "a link to http://www.google.com\n"
|
||||
+ "and now the end is near, lets test\n"
|
||||
+ "@google(http://www.google.com) a few\n"
|
||||
+ "titled links, including a mailto\n"
|
||||
+ "@Dan B(mailto:dan@@berrange.com)";
|
||||
+ "and mailto:dan@berrange.com eek!\n"
|
||||
+ "\n"
|
||||
+ "the second =paragraph= contains\n"
|
||||
+ "a link to http://www.google.com\n"
|
||||
+ "and now the end is near, lets test\n"
|
||||
+ "@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"
|
||||
+ "\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 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";
|
||||
+ "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 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);
|
||||
String errMsg = "smartTexttoHtml, expected = " + expected
|
||||
+ " found = " + actual;
|
||||
+ " found = " + actual;
|
||||
assertEquals(errMsg, expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSmartTextLists() {
|
||||
String src = "+ now an enumerated list item\n"
|
||||
+ "+ and one /more/\n"
|
||||
+ "+ this one is split over two lines\n"
|
||||
+ "for testing purposes\n";
|
||||
+ "+ and one /more/\n"
|
||||
+ "+ this one is split over two lines\n"
|
||||
+ "for testing purposes\n";
|
||||
|
||||
String expected = "<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\n"
|
||||
+ "</li>\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\n"
|
||||
+ "</li>\n"
|
||||
+ "</ol>\n";
|
||||
String actual = StringUtils.smartTextToHtml(src);
|
||||
String errMsg = "smartTexttoHtml, expected = " + expected
|
||||
+ " found = " + actual;
|
||||
+ " found = " + actual;
|
||||
assertEquals(errMsg, expected, actual);
|
||||
|
||||
}
|
||||
|
|
@ -239,25 +239,25 @@ public class StringUtilsTest {
|
|||
@Test
|
||||
public void testSmartTextLists2() {
|
||||
String src = "* a bullet list\n"
|
||||
+ "* more *bullets* in\n"
|
||||
+ " this list element\n"
|
||||
+ "* a final element\n";
|
||||
+ "* more *bullets* in\n"
|
||||
+ " this list element\n"
|
||||
+ "* a final element\n";
|
||||
|
||||
String expected = "<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\n"
|
||||
+ "</li>\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\n"
|
||||
+ "</li>\n"
|
||||
+ "</ul>\n";
|
||||
String actual = StringUtils.smartTextToHtml(src);
|
||||
String errMsg = "smartTexttoHtml, expected = " + expected
|
||||
+ " found = " + actual;
|
||||
+ " found = " + actual;
|
||||
assertEquals(errMsg, expected, actual);
|
||||
|
||||
}
|
||||
|
|
@ -285,7 +285,7 @@ public class StringUtilsTest {
|
|||
assertEquals("&foo", StringUtils.quoteHtml("&foo"));
|
||||
assertEquals("&foo&", StringUtils.quoteHtml("&foo&"));
|
||||
assertEquals("&"<>"&",
|
||||
StringUtils.quoteHtml("&\"<>\"&"));
|
||||
StringUtils.quoteHtml("&\"<>\"&"));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -307,8 +307,8 @@ public class StringUtilsTest {
|
|||
private static void verifyGet(String plist, String key, String expected) {
|
||||
String found = StringUtils.getParameter(key, plist, ',');
|
||||
assertEquals("Expected parameter not found, key=" + key
|
||||
+ " expected=" + expected + " found=" + found,
|
||||
expected, found);
|
||||
+ " expected=" + expected + " found=" + found,
|
||||
expected, found);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -322,7 +322,7 @@ public class StringUtilsTest {
|
|||
verifySplit("bat", ar[3]);
|
||||
verifySplit("rat", ar[4]);
|
||||
assertEquals("expected array length 5, found="
|
||||
+ ar.length, ar.length, 5);
|
||||
+ ar.length, ar.length, 5);
|
||||
plist = ",,dog,fish,,,";
|
||||
ar = StringUtils.split(plist, ',');
|
||||
verifySplit("", ar[0]);
|
||||
|
|
@ -333,14 +333,14 @@ public class StringUtilsTest {
|
|||
verifySplit("", ar[5]);
|
||||
verifySplit("", ar[6]);
|
||||
assertEquals("expected array length 7, found="
|
||||
+ ar.length, ar.length, 7);
|
||||
+ ar.length, ar.length, 7);
|
||||
|
||||
}
|
||||
|
||||
// helper method for above test.
|
||||
private void verifySplit(String expected, String found) {
|
||||
String errMsg = "Split, expected = " + expected
|
||||
+ " found = " + found;
|
||||
+ " found = " + found;
|
||||
assertEquals(errMsg, expected, found);
|
||||
}
|
||||
|
||||
|
|
@ -367,8 +367,28 @@ public class StringUtilsTest {
|
|||
verifySplit("::locale::", (String) list.get(3));
|
||||
verifySplit(".xsl", (String) list.get(4));
|
||||
assertEquals("expected array length 5, found="
|
||||
+ list.size(), list.size(), 5);
|
||||
+ list.size(), list.size(), 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitUp2() {
|
||||
final String path
|
||||
= "http://::host::/::webapp::/themes/::themedir::/::theme::/start.xsl";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<String> list = StringUtils.splitUp(path, "::\\w+::");
|
||||
|
||||
assertThat(list.size(), is(9));
|
||||
assertThat(list.get(0), is(equalTo("http://")));
|
||||
assertThat(list.get(1), is(equalTo("::host::")));
|
||||
assertThat(list.get(2), is(equalTo("/")));
|
||||
assertThat(list.get(3), is(equalTo("::webapp::")));
|
||||
assertThat(list.get(4), is(equalTo("/themes/")));
|
||||
assertThat(list.get(5), is(equalTo("::themedir::")));
|
||||
assertThat(list.get(6), is(equalTo("/")));
|
||||
assertThat(list.get(7), is(equalTo("::theme::")));
|
||||
assertThat(list.get(8), is(equalTo("/start.xsl")));
|
||||
//assertThat(list.get(9), is(equalTo("start.xsl")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -392,7 +412,7 @@ public class StringUtilsTest {
|
|||
verifySplit("\n", (String) list.get(1));
|
||||
verifySplit("blub\n", (String) list.get(2));
|
||||
assertEquals("expected array length 3, found="
|
||||
+ list.size(), list.size(), 3);
|
||||
+ list.size(), list.size(), 3);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -403,7 +423,7 @@ public class StringUtilsTest {
|
|||
String expected = "foo,bar,Qux";
|
||||
String found = StringUtils.join(input, ',');
|
||||
String errMsg = "join char, expected = " + expected
|
||||
+ " found = " + found;
|
||||
+ " found = " + found;
|
||||
assertEquals(errMsg, expected, found);
|
||||
|
||||
}
|
||||
|
|
@ -415,7 +435,7 @@ public class StringUtilsTest {
|
|||
String expected = "foo,bar,Qux";
|
||||
String found = StringUtils.join(input, ",");
|
||||
String errMsg = "join string, expected = " + expected
|
||||
+ " found = " + found;
|
||||
+ " found = " + found;
|
||||
assertEquals(errMsg, expected, found);
|
||||
}
|
||||
|
||||
|
|
@ -426,8 +446,8 @@ public class StringUtilsTest {
|
|||
String expected_out = "< H> e ll/> o .";
|
||||
String actual_out = StringUtils.stripWhiteSpace(in);
|
||||
assertEquals("stripWhiteSpace failed. Expected = '"
|
||||
+ expected_out + "', Found = '" + actual_out + "'",
|
||||
expected_out, actual_out);
|
||||
+ expected_out + "', Found = '" + actual_out + "'",
|
||||
expected_out, actual_out);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -464,7 +484,7 @@ public class StringUtilsTest {
|
|||
String actual_out = StringUtils.htmlToText(in);
|
||||
|
||||
String errMsg = "htmlToText, expected = " + expected_out
|
||||
+ " found = " + actual_out;
|
||||
+ " found = " + actual_out;
|
||||
|
||||
assertEquals(errMsg, expected_out, actual_out);
|
||||
|
||||
|
|
@ -473,7 +493,7 @@ public class StringUtilsTest {
|
|||
actual_out = StringUtils.htmlToText(in);
|
||||
|
||||
errMsg = "htmlToText, expected = " + expected_out
|
||||
+ " found = " + actual_out;
|
||||
+ " found = " + actual_out;
|
||||
assertEquals(errMsg, expected_out, actual_out);
|
||||
}
|
||||
|
||||
|
|
@ -514,43 +534,43 @@ public class StringUtilsTest {
|
|||
String expected_out = in;
|
||||
String actual_out = StringUtils.wrap(in);
|
||||
assertEquals("wrap failed identify test",
|
||||
expected_out,
|
||||
actual_out);
|
||||
expected_out,
|
||||
actual_out);
|
||||
|
||||
// Identify test with multiple words
|
||||
in = "a b c d e\n";
|
||||
expected_out = in;
|
||||
actual_out = StringUtils.wrap(in);
|
||||
assertEquals("wrap failed identify test",
|
||||
expected_out,
|
||||
actual_out);
|
||||
expected_out,
|
||||
actual_out);
|
||||
|
||||
// Simple test with short lines
|
||||
in = StringUtils.repeat("1234 ", 5);
|
||||
expected_out = StringUtils.repeat("1234\n", 5);
|
||||
actual_out = StringUtils.wrap(in, 1);
|
||||
assertEquals("wrap invalid",
|
||||
expected_out,
|
||||
actual_out);
|
||||
expected_out,
|
||||
actual_out);
|
||||
|
||||
// Verify preservation of line breaks
|
||||
in = StringUtils.repeat("1234\n", 5);
|
||||
expected_out = in;
|
||||
actual_out = StringUtils.wrap(in, 100);
|
||||
assertEquals("line break preservation failed",
|
||||
expected_out,
|
||||
actual_out);
|
||||
expected_out,
|
||||
actual_out);
|
||||
|
||||
// Verify a "standard" wrapping case
|
||||
in = StringUtils.repeat("1234 ", 10);
|
||||
expected_out
|
||||
= StringUtils.repeat("1234 ", 5).trim() + "\n"
|
||||
+ StringUtils.repeat("1234 ", 5).trim() + "\n";
|
||||
= StringUtils.repeat("1234 ", 5).trim() + "\n"
|
||||
+ StringUtils.repeat("1234 ", 5).trim() + "\n";
|
||||
|
||||
actual_out = StringUtils.wrap(in, 25);
|
||||
assertEquals("line wrapping failed",
|
||||
expected_out,
|
||||
actual_out);
|
||||
expected_out,
|
||||
actual_out);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -560,8 +580,8 @@ public class StringUtilsTest {
|
|||
String actual_out = StringUtils.interpolate(in, "bar", "eek");
|
||||
|
||||
assertEquals("interpolate failed simple placeholder",
|
||||
expected_out,
|
||||
actual_out);
|
||||
expected_out,
|
||||
actual_out);
|
||||
|
||||
HashMap vars = new HashMap();
|
||||
vars.put("bar", "eek");
|
||||
|
|
@ -571,26 +591,26 @@ public class StringUtilsTest {
|
|||
expected_out = "foo eek wizz wibble done";
|
||||
actual_out = StringUtils.interpolate(in, vars);
|
||||
assertEquals("interpolate failed hashmap test",
|
||||
expected_out,
|
||||
actual_out);
|
||||
expected_out,
|
||||
actual_out);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplace() {
|
||||
String[] pairs = {null, null,
|
||||
"foobar", "foobar",
|
||||
";foobar", "\\;foobar",
|
||||
";foo;bar;baz", "\\;foo\\;bar\\;baz",
|
||||
";;foobar", "\\;\\;foobar",
|
||||
"f;o;obar", "f\\;o\\;obar",
|
||||
"f;o;;bar", "f\\;o\\;\\;bar",
|
||||
"foobar;", "foobar\\;",
|
||||
"foobar;;", "foobar\\;\\;"};
|
||||
"foobar", "foobar",
|
||||
";foobar", "\\;foobar",
|
||||
";foo;bar;baz", "\\;foo\\;bar\\;baz",
|
||||
";;foobar", "\\;\\;foobar",
|
||||
"f;o;obar", "f\\;o\\;obar",
|
||||
"f;o;;bar", "f\\;o\\;\\;bar",
|
||||
"foobar;", "foobar\\;",
|
||||
"foobar;;", "foobar\\;\\;"};
|
||||
|
||||
for (int ii = 0, jj = 1; jj < pairs.length; ii += 2, jj += 2) {
|
||||
System.err.println("ii=" + ii + ", pairs[ii]=" + pairs[ii]
|
||||
+ ", jj=" + jj + ", pairs[jj]=" + pairs[jj]);
|
||||
+ ", jj=" + jj + ", pairs[jj]=" + pairs[jj]);
|
||||
String expected = pairs[jj];
|
||||
String actual = StringUtils.replace(pairs[ii], ";", "\\;");
|
||||
assertEquals(expected, actual);
|
||||
|
|
@ -615,7 +635,10 @@ public class StringUtilsTest {
|
|||
assertEquals("----", StringUtils.urlize(" "));
|
||||
assertEquals("abc-def", StringUtils.urlize("ABC DEF"));
|
||||
assertEquals("-abc-def-", StringUtils.urlize(" ABC DEF "));
|
||||
assertEquals("0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz-_---", StringUtils.urlize("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_ &/"));
|
||||
assertEquals(
|
||||
"0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz-_---",
|
||||
StringUtils.urlize(
|
||||
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_ &/"));
|
||||
assertEquals("helpaplawsorg", StringUtils.urlize("help@aplaws.org"));
|
||||
}
|
||||
|
||||
|
|
@ -631,12 +654,18 @@ public class StringUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testTruncateString() {
|
||||
assertThat(StringUtils.truncateString("Lorem ipsum dolor sit amet", 8, true), is("Lorem"));
|
||||
assertThat(StringUtils.truncateString("Lorem ipsum dolor sit amet", 2, true), is("Lo"));
|
||||
assertThat(StringUtils.truncateString("Lorem ipsum dolor sit amet", 8,
|
||||
true), is("Lorem"));
|
||||
assertThat(StringUtils.truncateString("Lorem ipsum dolor sit amet", 2,
|
||||
true), is("Lo"));
|
||||
assertThat(StringUtils.truncateString(null, 2, true), is(""));
|
||||
assertThat(StringUtils.truncateString("Lorem <b> ipsum </b> dolor sit amet", 12, true), is("Lorem"));
|
||||
assertThat(StringUtils.truncateString("Lorem <b> ipsum </b> dolor sit amet", 12, false), is("Lorem <b>"));
|
||||
assertThat(StringUtils.truncateString("Lorem ipsum dolor sit amet", 99, true), is("Lorem ipsum dolor sit amet"));
|
||||
assertThat(StringUtils.truncateString(
|
||||
"Lorem <b> ipsum </b> dolor sit amet", 12, true), is("Lorem"));
|
||||
assertThat(StringUtils.truncateString(
|
||||
"Lorem <b> ipsum </b> dolor sit amet", 12, false), is("Lorem <b>"));
|
||||
assertThat(StringUtils.truncateString("Lorem ipsum dolor sit amet", 99,
|
||||
true), is(
|
||||
"Lorem ipsum dolor sit amet"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -649,7 +678,7 @@ public class StringUtilsTest {
|
|||
String expected = "foo,bar,Qux";
|
||||
String found = StringUtils.join(input, ",");
|
||||
String errMsg = "join Elements, expected = " + expected
|
||||
+ " found = " + found;
|
||||
+ " found = " + found;
|
||||
assertEquals(errMsg, expected, found);
|
||||
}
|
||||
|
||||
|
|
@ -662,7 +691,8 @@ public class StringUtilsTest {
|
|||
public void testStripNewLines() {
|
||||
|
||||
assertEquals(StringUtils.stripNewLines("line1\nline2"), "line1line2");
|
||||
assertEquals(StringUtils.stripNewLines("Lorem ipsum dolor sit amet"), "Lorem ipsum dolor sit amet");
|
||||
assertEquals(StringUtils.stripNewLines("Lorem ipsum dolor sit amet"),
|
||||
"Lorem ipsum dolor sit amet");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue