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