-
+
diff --git a/ccm-core/src/main/java/com/arsdigita/templating/PatternStylesheetResolver.java b/ccm-core/src/main/java/com/arsdigita/templating/PatternStylesheetResolver.java
index 3f1cd2def..1dd0ad694 100755
--- a/ccm-core/src/main/java/com/arsdigita/templating/PatternStylesheetResolver.java
+++ b/ccm-core/src/main/java/com/arsdigita/templating/PatternStylesheetResolver.java
@@ -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;
+
/**
*
@@ -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);
}
diff --git a/ccm-core/src/main/java/com/arsdigita/templating/TemplatingConfig.java b/ccm-core/src/main/java/com/arsdigita/templating/TemplatingConfig.java
index df07074d5..5fd8daeb3 100755
--- a/ccm-core/src/main/java/com/arsdigita/templating/TemplatingConfig.java
+++ b/ccm-core/src/main/java/com/arsdigita/templating/TemplatingConfig.java
@@ -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
diff --git a/ccm-core/src/main/java/com/arsdigita/ui/login/UserLoginForm.java b/ccm-core/src/main/java/com/arsdigita/ui/login/UserLoginForm.java
index 2bb6f48b1..dd5076505 100644
--- a/ccm-core/src/main/java/com/arsdigita/ui/login/UserLoginForm.java
+++ b/ccm-core/src/main/java/com/arsdigita/ui/login/UserLoginForm.java
@@ -144,6 +144,7 @@ public class UserLoginForm extends Form implements LoginConstants,
final Iterator> iterator = beans.iterator();
final ConfigurationManager confManager;
if (iterator.hasNext()) {
+ @SuppressWarnings("unchecked")
final Bean bean = (Bean) iterator.
next();
final CreationalContext ctx = beanManager.
diff --git a/ccm-core/src/main/java/com/arsdigita/util/SystemInformation.java b/ccm-core/src/main/java/com/arsdigita/util/SystemInformation.java
index 58e3cba18..1327976a2 100644
--- a/ccm-core/src/main/java/com/arsdigita/util/SystemInformation.java
+++ b/ccm-core/src/main/java/com/arsdigita/util/SystemInformation.java
@@ -59,7 +59,7 @@ public class SystemInformation {
* Map containing all informations provided by the
* {@code systeminformation.properties} file.
*/
- private final Map sysInfo = new HashMap();
+ private final Map 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");
diff --git a/ccm-core/src/main/java/com/arsdigita/web/WebConfig.java b/ccm-core/src/main/java/com/arsdigita/web/WebConfig.java
index 854fdc781..03781ef07 100644
--- a/ccm-core/src/main/java/com/arsdigita/web/WebConfig.java
+++ b/ccm-core/src/main/java/com/arsdigita/web/WebConfig.java
@@ -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 secureRequiredFor = new HashSet<>();
diff --git a/ccm-core/src/main/java/com/arsdigita/xml/XmlConfig.java b/ccm-core/src/main/java/com/arsdigita/xml/XmlConfig.java
index 9ed205736..631ee3532 100644
--- a/ccm-core/src/main/java/com/arsdigita/xml/XmlConfig.java
+++ b/ccm-core/src/main/java/com/arsdigita/xml/XmlConfig.java
@@ -106,7 +106,7 @@ public final class XmlConfig {
* @return
*/
String getDefaultXslTransformerFactoryClassname() {
- return SAXON;
+ return SAXON_HE;
}
public void setXslTransformer(final String xslTransformer) {
diff --git a/ccm-core/src/test/java/com/arsdigita/util/StringUtilsTest.java b/ccm-core/src/test/java/com/arsdigita/util/StringUtilsTest.java
index c1f0c753c..3cedd67cd 100644
--- a/ccm-core/src/test/java/com/arsdigita/util/StringUtilsTest.java
+++ b/ccm-core/src/test/java/com/arsdigita/util/StringUtilsTest.java
@@ -63,19 +63,19 @@ public class StringUtilsTest {
@Test
public void testSmartText2() {
String src = "blabla\n"
- + "\n"
- + "blub";
+ + "\n"
+ + "blub";
String expected = "\n"
- + "blabla\n"
- + "
\n"
- + "\n"
- + "\n"
- + "blub\n"
- + "
\n";
+ + "blabla\n"
+ + "\n"
+ + "\n"
+ + "\n"
+ + "blub\n"
+ + "
\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 = "\n"
- + "\n"
- + "\n"
- + "the second
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"
- + "
\n"
- + "\n"
- + "\n"
- + "- \n"
- + "a bullet list\n"
- + "
\n"
- + "- \n"
- + "more bullets in\n"
- + " this list element\n"
- + "
\n"
- + "- \n"
- + "a final element
\n"
- + "
\n"
- + "\n"
- + "
\n"
- + "\n"
- + "\n"
- + "- \n"
- + "now an enumerated list item\n"
- + "
\n"
- + "- \n"
- + "and one more\n"
- + "
\n"
- + "- \n"
- + "this one is split over two lines\n"
- + "for testing purposes
\n"
- + "
\n"
- + "\n"
- + "
\n"
- + "\n"
- + "\n"
- + "and now the end is near, lets test\n"
- + "
google a few\n"
- + "titled links, including a mailto\n"
- + "
Dan B\n"
- + "
\n";
+ + "foo bar wibble eek\n"
+ + "and mailto:dan@berrange.com eek!\n"
+ + "\n"
+ + "\n"
+ + "\n"
+ + "the second
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"
+ + "
\n"
+ + "\n"
+ + "\n"
+ + "- \n"
+ + "a bullet list\n"
+ + "
\n"
+ + "- \n"
+ + "more bullets in\n"
+ + " this list element\n"
+ + "
\n"
+ + "- \n"
+ + "a final element
\n"
+ + "
\n"
+ + "\n"
+ + "
\n"
+ + "\n"
+ + "\n"
+ + "- \n"
+ + "now an enumerated list item\n"
+ + "
\n"
+ + "- \n"
+ + "and one more\n"
+ + "
\n"
+ + "- \n"
+ + "this one is split over two lines\n"
+ + "for testing purposes
\n"
+ + "
\n"
+ + "\n"
+ + "
\n"
+ + "\n"
+ + "\n"
+ + "and now the end is near, lets test\n"
+ + "
google a few\n"
+ + "titled links, including a mailto\n"
+ + "
Dan B\n"
+ + "
\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 = "\n"
- + "\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 a few\n"
- + "titled links, including a mailto\n"
- + "
Dan B\n"
- + "
\n";
+ + "foo bar wibble eek\n"
+ + "and mailto:dan@berrange.com eek!\n"
+ + "\n"
+ + "\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 a few\n"
+ + "titled links, including a mailto\n"
+ + "
Dan B\n"
+ + "
\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 = "\n"
- + "- \n"
- + "now an enumerated list item\n"
- + "
\n"
- + "- \n"
- + "and one more\n"
- + "
\n"
- + "- \n"
- + "this one is split over two lines\n"
- + "for testing purposes\n"
- + "
\n"
- + "
\n";
+ + "\n"
+ + "now an enumerated list item\n"
+ + "\n"
+ + "\n"
+ + "and one more\n"
+ + "\n"
+ + "\n"
+ + "this one is split over two lines\n"
+ + "for testing purposes\n"
+ + "\n"
+ + "\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 = "\n"
- + "- \n"
- + "a bullet list\n"
- + "
\n"
- + "- \n"
- + "more bullets in\n"
- + " this list element\n"
- + "
\n"
- + "- \n"
- + "a final element\n"
- + "
\n"
- + "
\n";
+ + "\n"
+ + "a bullet list\n"
+ + "\n"
+ + "\n"
+ + "more bullets in\n"
+ + " this list element\n"
+ + "\n"
+ + "\n"
+ + "a final element\n"
+ + "\n"
+ + "\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 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 ipsum dolor sit amet", 12, true), is("Lorem"));
- assertThat(StringUtils.truncateString("Lorem ipsum dolor sit amet", 12, false), is("Lorem "));
- assertThat(StringUtils.truncateString("Lorem ipsum dolor sit amet", 99, true), is("Lorem ipsum dolor sit amet"));
+ assertThat(StringUtils.truncateString(
+ "Lorem ipsum dolor sit amet", 12, true), is("Lorem"));
+ assertThat(StringUtils.truncateString(
+ "Lorem ipsum dolor sit amet", 12, false), is("Lorem "));
+ 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