Repository: incubator-freemarker Updated Branches: refs/heads/3 cfd379605 -> ebb39b845
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/ResourcesExtractor.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/ResourcesExtractor.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/ResourcesExtractor.java index 4e05cdc..a0b4045 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/ResourcesExtractor.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/ResourcesExtractor.java @@ -32,7 +32,7 @@ import java.util.zip.ZipEntry; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -142,8 +142,8 @@ public final class ResourcesExtractor { int arrowIdx = contLine.indexOf(ARROW); if (arrowIdx != -1) { if (!contLine.startsWith("/")) { - throw new IOException("In " + _StringUtil.jQuote(contResource) + ", this line must start with " - + "\"/\" as it uses the " + _StringUtil.jQuote(ARROW) + " operator : " + throw new IOException("In " + _StringUtils.jQuote(contResource) + ", this line must start with " + + "\"/\" as it uses the " + _StringUtils.jQuote(ARROW) + " operator : " + contLine); } contSrcPath = contLine.substring(0, arrowIdx).trim(); @@ -151,7 +151,7 @@ public final class ResourcesExtractor { contSrcPathRelative = false; } else { if (contLine.startsWith("/")) { - throw new IOException("In " + _StringUtil.jQuote(contResource) + throw new IOException("In " + _StringUtils.jQuote(contResource) + ", this line can't start with \"/\": " + contLine); } contSrcPathRelative = true; @@ -172,7 +172,7 @@ public final class ResourcesExtractor { try { if (dstFile.exists()) { throw new IOException( - "Destination already exists; check if " + _StringUtil.jQuote(contDstPath) + "Destination already exists; check if " + _StringUtils.jQuote(contDstPath) + " occurs for multiple times in \"" + CONTENTS_TXT + "\"."); } FileUtils.copyInputStreamToFile(entryIn, dstFile); @@ -180,8 +180,8 @@ public final class ResourcesExtractor { File parent = dstFile; while ((parent = dstFile.getParentFile()) != null) { if (parent.isFile()) { - throw new IOException("An ancestor directory of " + _StringUtil.jQuote(dstFile) + ", " - + _StringUtil.jQuote(parent) + " already exists, but as a file, not as a directory. " + throw new IOException("An ancestor directory of " + _StringUtils.jQuote(dstFile) + ", " + + _StringUtils.jQuote(parent) + " already exists, but as a file, not as a directory. " + "Check if you have accidentally added the directory itself to \"" + CONTENTS_TXT + "\". Only files should be listed there."); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTest.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTest.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTest.java index 9e588d4..dce3719 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTest.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTest.java @@ -41,7 +41,7 @@ import org.apache.freemarker.core.templateresolver.TemplateLoader; import org.apache.freemarker.core.templateresolver.impl.ByteArrayTemplateLoader; import org.apache.freemarker.core.templateresolver.impl.MultiTemplateLoader; import org.apache.freemarker.core.util._NullArgumentException; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; import org.junit.Ignore; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -106,7 +106,7 @@ public abstract class TemplateTest { throw new IOException("Reference output resource not found: " + getClass() + ", " + resName); } try { - expectedOut = TestUtil.removeTxtCopyrightComment(IOUtils.toString(in, StandardCharsets.UTF_8.name())); + expectedOut = TestUtils.removeTxtCopyrightComment(IOUtils.toString(in, StandardCharsets.UTF_8.name())); } finally { in.close(); } @@ -300,16 +300,16 @@ public abstract class TemplateTest { if (needle.startsWith("\\!")) { String netNeedle = needle.substring(2); if (msg.contains(netNeedle)) { - fail("The message shouldn't contain substring " + _StringUtil.jQuote(netNeedle) + ":\n" + msg); + fail("The message shouldn't contain substring " + _StringUtils.jQuote(netNeedle) + ":\n" + msg); } } else if (!msg.contains(needle)) { - fail("The message didn't contain substring " + _StringUtil.jQuote(needle) + ":\n" + msg); + fail("The message didn't contain substring " + _StringUtils.jQuote(needle) + ":\n" + msg); } } } private String normalizeNewLines(String s) { - return _StringUtil.replace(s, "\r\n", "\n").replace('\r', '\n'); + return _StringUtils.replace(s, "\r\n", "\n").replace('\r', '\n'); } public static class TestBean { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTestCase.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTestCase.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTestCase.java index 9c6db39..5774b33 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTestCase.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTestCase.java @@ -35,7 +35,7 @@ import org.apache.freemarker.core.Version; import org.apache.freemarker.core.templateresolver.impl.ClassTemplateLoader; import org.apache.freemarker.core.util._NullArgumentException; import org.apache.freemarker.core.util._NullWriter; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; import org.apache.freemarker.test.templateutil.AssertDirective; import org.apache.freemarker.test.templateutil.AssertEqualsDirective; import org.apache.freemarker.test.templateutil.AssertFailsDirective; @@ -115,8 +115,8 @@ class TemplateTestCase extends FileTestCase { } catch (ConfigurationException e) { throw new RuntimeException( "Failed to set setting " + - _StringUtil.jQuote(param) + " to " + - _StringUtil.jQuote(value) + "; see cause exception.", + _StringUtils.jQuote(param) + " to " + + _StringUtils.jQuote(value) + "; see cause exception.", e); } } @@ -153,7 +153,7 @@ class TemplateTestCase extends FileTestCase { template = confB.build().getTemplate(templateName); } catch (IOException e) { throw new AssertionFailedError( - "Could not load template " + _StringUtil.jQuote(templateName) + ":\n" + getStackTrace(e)); + "Could not load template " + _StringUtils.jQuote(templateName) + ":\n" + getStackTrace(e)); } testSuite.validateTemplate(template); @@ -162,7 +162,7 @@ class TemplateTestCase extends FileTestCase { try { template.process(dataModel, out != null ? out : _NullWriter.INSTANCE); } catch (TemplateException e) { - throw new AssertionFailedError("Template " + _StringUtil.jQuote(templateName) + " has stopped with error:\n" + throw new AssertionFailedError("Template " + _StringUtils.jQuote(templateName) + " has stopped with error:\n" + getStackTrace(e)); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTestSuite.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTestSuite.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTestSuite.java index 932c4ae..93ab0e8 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTestSuite.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTestSuite.java @@ -35,7 +35,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.apache.freemarker.core.Configuration; import org.apache.freemarker.core.Template; import org.apache.freemarker.core.Version; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; import org.junit.runner.RunWith; import org.junit.runners.AllTests; import org.w3c.dom.Attr; @@ -111,7 +111,7 @@ public abstract class TemplateTestSuite extends TestSuite { testCaseNameFilter = filterStr != null ? Pattern.compile(filterStr) : null; if (testCaseNameFilter != null) { System.out.println( - "Note: " + TEST_FILTER_PROPERTY_NAME + " is " + _StringUtil.jQuote(testCaseNameFilter)); + "Note: " + TEST_FILTER_PROPERTY_NAME + " is " + _StringUtils.jQuote(testCaseNameFilter)); } testSuiteIcis = new ArrayList<>(); @@ -197,7 +197,7 @@ public abstract class TemplateTestSuite extends TestSuite { */ private List<TemplateTestCase> createTestCasesFromElement(Element testCaseElem) throws Exception { - final String caseName = _StringUtil.emptyToNull(testCaseElem.getAttribute("name")); + final String caseName = _StringUtils.emptyToNull(testCaseElem.getAttribute("name")); if (caseName == null) throw new Exception("Invalid XML: the \"name\" attribute is mandatory."); if (testCaseNameFilter != null @@ -218,20 +218,20 @@ public abstract class TemplateTestSuite extends TestSuite { } { - String s = _StringUtil.emptyToNull(testCaseElem.getAttribute(ATTR_TEMPLATE)); + String s = _StringUtils.emptyToNull(testCaseElem.getAttribute(ATTR_TEMPLATE)); templateName = s != null ? s : beforeEndTN + ".ftl"; } { - String s = _StringUtil.emptyToNull(testCaseElem.getAttribute(ATTR_EXPECTED)); + String s = _StringUtils.emptyToNull(testCaseElem.getAttribute(ATTR_EXPECTED)); expectedFileName = s != null ? s : beforeEndTN + afterEndTN + ".txt"; } } final boolean noOutput; { - String s = _StringUtil.emptyToNull(testCaseElem.getAttribute(ATTR_NO_OUTPUT)); - noOutput = s != null && _StringUtil.getYesNo(s); + String s = _StringUtils.emptyToNull(testCaseElem.getAttribute(ATTR_NO_OUTPUT)); + noOutput = s != null && _StringUtils.getYesNo(s); } final Map<String, String> testCaseSettings = getCaseFMSettings(testCaseElem); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestUtil.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestUtil.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestUtil.java deleted file mode 100644 index 13b03ec..0000000 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestUtil.java +++ /dev/null @@ -1,244 +0,0 @@ -package org.apache.freemarker.test; - -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.apache.freemarker.core.Configuration; -import org.apache.freemarker.core.Version; - -public final class TestUtil { - - private TestUtil() { - // Not meant to be instantiated - } - - /** - * Returns the closes FreeMarker version number that doesn't exit yet (so it's illegal). - */ - public static Version getClosestFutureVersion() { - Version v = Configuration.getVersion(); - return new Version(v.getMajor(), v.getMinor(), v.getMicro() + 1); - } - - public static String arrayToString(double[] xs) { - StringBuilder sb = new StringBuilder(); - - sb.append('['); - for (double x : xs) { - if (sb.length() != 1) sb.append(", "); - sb.append(x); - } - sb.append(']'); - - return sb.toString(); - } - - public static String arrayToString(Object[] array) { - if (array == null) return "null"; - - StringBuilder sb = new StringBuilder(); - sb.append('['); - for (int i = 0; i < array.length; i++) { - if (i != 0) { - sb.append(", "); - } - sb.append(array[i]); - } - sb.append(']'); - return sb.toString(); - } - - public static String arrayToString(Object[][] arrayArray) { - if (arrayArray == null) return "null"; - - StringBuilder sb = new StringBuilder(); - sb.append('['); - boolean first = true; - for (Object[] array : arrayArray) { - if (!first) { - sb.append(", "); - } else { - first = false; - } - sb.append(arrayToString(array)); - } - sb.append(']'); - return sb.toString(); - } - - public static String arrayToString(int[] array) { - if (array == null) return "null"; - - StringBuilder sb = new StringBuilder(); - sb.append('['); - for (int i = 0; i < array.length; i++) { - if (i != 0) { - sb.append(", "); - } - sb.append(array[i]); - } - sb.append(']'); - return sb.toString(); - } - - public static String arrayToString(int[][] xss) { - if (xss == null) return "null"; - - StringBuilder sb = new StringBuilder(); - sb.append('['); - for (int i = 0; i < xss.length; i++) { - if (i != 0) { - sb.append(", "); - } - sb.append(arrayToString(xss[i])); - } - sb.append(']'); - return sb.toString(); - } - - public static String arrayToString(char[] array) { - if (array == null) return "null"; - - StringBuilder sb = new StringBuilder(); - sb.append('['); - for (int i = 0; i < array.length; i++) { - if (i != 0) { - sb.append(", "); - } - sb.append(array[i]); - } - sb.append(']'); - return sb.toString(); - } - - public static String arrayToString(boolean[] array) { - if (array == null) return "null"; - - StringBuilder sb = new StringBuilder(); - sb.append('['); - for (int i = 0; i < array.length; i++) { - if (i != 0) { - sb.append(", "); - } - sb.append(array[i]); - } - sb.append(']'); - return sb.toString(); - } - - public static String listToString(List<?> list) { - return collectionToString("", list); - } - - public static String setToString(Set<?> list) { - return collectionToString("Set", list); - } - - private static String collectionToString(String prefix, Collection<?> list) { - if (list == null) return "null"; - - StringBuilder sb = new StringBuilder(); - sb.append(prefix); - sb.append('['); - boolean first = true; - for (Object item : list) { - if (!first) { - sb.append(", "); - } else { - first = false; - } - sb.append(item instanceof Object[] ? arrayToString((Object[]) item) : item); - } - sb.append(']'); - return sb.toString(); - } - - public static String removeTxtCopyrightComment(String s) { - if (!s.startsWith("/*")) { - return s; - } - - int commentEnd = s.indexOf("*/"); - if (commentEnd == -1) { - return s; - } - commentEnd += 2; - if (commentEnd < s.length()) { - char c = s.charAt(commentEnd); - if (c == '\n' || c == '\r') { - commentEnd++; - if (c == '\r' && commentEnd < s.length()) { - if (s.charAt(commentEnd) == '\n') { - commentEnd++; - } - } - } - } - - String comment = s.substring(0, commentEnd); - int copyrightIdx = comment.indexOf("copyright"); - if (copyrightIdx == -1) { - copyrightIdx = comment.indexOf("Copyright"); - } - if (copyrightIdx == -1) { - return s; - } - - return s.substring(commentEnd); - } - - public static String removeFTLCopyrightComment(String ftl) { - if (ftl.contains("<#ftl nsPrefixes = {\"D\" : \"http://example.com/eBook\"}>")) { - System.out.println(); - } - - int copyrightIdx = ftl.indexOf("copyright"); - if (copyrightIdx == -1) { - copyrightIdx = ftl.indexOf("Copyright"); - } - if (copyrightIdx == -1) { - return ftl; - } - - final int commentFirstIdx; - final boolean squareBracketTagSyntax; - { - String ftlBeforeCopyright = ftl.substring(0, copyrightIdx); - int abCommentStart = ftlBeforeCopyright.lastIndexOf("<#--"); - int sbCommentStart = ftlBeforeCopyright.lastIndexOf("[#--"); - squareBracketTagSyntax = sbCommentStart > abCommentStart; - commentFirstIdx = squareBracketTagSyntax ? sbCommentStart : abCommentStart; - if (commentFirstIdx == -1) { - throw new AssertionError("Can't find copyright comment start"); - } - } - - final int commentLastIdx; - { - int commentEndStart = ftl.indexOf(squareBracketTagSyntax ? "--]" : "-->", copyrightIdx); - if (commentEndStart == -1) { - throw new AssertionError("Can't find copyright comment end"); - } - commentLastIdx = commentEndStart + 2; - } - - final int afterCommentNLChars; - if (commentLastIdx + 1 < ftl.length()) { - char afterCommentChar = ftl.charAt(commentLastIdx + 1); - if (afterCommentChar == '\n' || afterCommentChar == '\r') { - if (afterCommentChar == '\r' && commentLastIdx + 2 < ftl.length() && ftl.charAt(commentLastIdx + 2) == '\n') { - afterCommentNLChars = 2; - } else { - afterCommentNLChars = 1; - } - } else { - afterCommentNLChars = 0; - } - } else { - afterCommentNLChars = 0; - } - - return ftl.substring(0, commentFirstIdx) + ftl.substring(commentLastIdx + afterCommentNLChars + 1); - } -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestUtils.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestUtils.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestUtils.java new file mode 100644 index 0000000..f338b27 --- /dev/null +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TestUtils.java @@ -0,0 +1,244 @@ +package org.apache.freemarker.test; + +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import org.apache.freemarker.core.Configuration; +import org.apache.freemarker.core.Version; + +public final class TestUtils { + + private TestUtils() { + // Not meant to be instantiated + } + + /** + * Returns the closes FreeMarker version number that doesn't exit yet (so it's illegal). + */ + public static Version getClosestFutureVersion() { + Version v = Configuration.getVersion(); + return new Version(v.getMajor(), v.getMinor(), v.getMicro() + 1); + } + + public static String arrayToString(double[] xs) { + StringBuilder sb = new StringBuilder(); + + sb.append('['); + for (double x : xs) { + if (sb.length() != 1) sb.append(", "); + sb.append(x); + } + sb.append(']'); + + return sb.toString(); + } + + public static String arrayToString(Object[] array) { + if (array == null) return "null"; + + StringBuilder sb = new StringBuilder(); + sb.append('['); + for (int i = 0; i < array.length; i++) { + if (i != 0) { + sb.append(", "); + } + sb.append(array[i]); + } + sb.append(']'); + return sb.toString(); + } + + public static String arrayToString(Object[][] arrayArray) { + if (arrayArray == null) return "null"; + + StringBuilder sb = new StringBuilder(); + sb.append('['); + boolean first = true; + for (Object[] array : arrayArray) { + if (!first) { + sb.append(", "); + } else { + first = false; + } + sb.append(arrayToString(array)); + } + sb.append(']'); + return sb.toString(); + } + + public static String arrayToString(int[] array) { + if (array == null) return "null"; + + StringBuilder sb = new StringBuilder(); + sb.append('['); + for (int i = 0; i < array.length; i++) { + if (i != 0) { + sb.append(", "); + } + sb.append(array[i]); + } + sb.append(']'); + return sb.toString(); + } + + public static String arrayToString(int[][] xss) { + if (xss == null) return "null"; + + StringBuilder sb = new StringBuilder(); + sb.append('['); + for (int i = 0; i < xss.length; i++) { + if (i != 0) { + sb.append(", "); + } + sb.append(arrayToString(xss[i])); + } + sb.append(']'); + return sb.toString(); + } + + public static String arrayToString(char[] array) { + if (array == null) return "null"; + + StringBuilder sb = new StringBuilder(); + sb.append('['); + for (int i = 0; i < array.length; i++) { + if (i != 0) { + sb.append(", "); + } + sb.append(array[i]); + } + sb.append(']'); + return sb.toString(); + } + + public static String arrayToString(boolean[] array) { + if (array == null) return "null"; + + StringBuilder sb = new StringBuilder(); + sb.append('['); + for (int i = 0; i < array.length; i++) { + if (i != 0) { + sb.append(", "); + } + sb.append(array[i]); + } + sb.append(']'); + return sb.toString(); + } + + public static String listToString(List<?> list) { + return collectionToString("", list); + } + + public static String setToString(Set<?> list) { + return collectionToString("Set", list); + } + + private static String collectionToString(String prefix, Collection<?> list) { + if (list == null) return "null"; + + StringBuilder sb = new StringBuilder(); + sb.append(prefix); + sb.append('['); + boolean first = true; + for (Object item : list) { + if (!first) { + sb.append(", "); + } else { + first = false; + } + sb.append(item instanceof Object[] ? arrayToString((Object[]) item) : item); + } + sb.append(']'); + return sb.toString(); + } + + public static String removeTxtCopyrightComment(String s) { + if (!s.startsWith("/*")) { + return s; + } + + int commentEnd = s.indexOf("*/"); + if (commentEnd == -1) { + return s; + } + commentEnd += 2; + if (commentEnd < s.length()) { + char c = s.charAt(commentEnd); + if (c == '\n' || c == '\r') { + commentEnd++; + if (c == '\r' && commentEnd < s.length()) { + if (s.charAt(commentEnd) == '\n') { + commentEnd++; + } + } + } + } + + String comment = s.substring(0, commentEnd); + int copyrightIdx = comment.indexOf("copyright"); + if (copyrightIdx == -1) { + copyrightIdx = comment.indexOf("Copyright"); + } + if (copyrightIdx == -1) { + return s; + } + + return s.substring(commentEnd); + } + + public static String removeFTLCopyrightComment(String ftl) { + if (ftl.contains("<#ftl nsPrefixes = {\"D\" : \"http://example.com/eBook\"}>")) { + System.out.println(); + } + + int copyrightIdx = ftl.indexOf("copyright"); + if (copyrightIdx == -1) { + copyrightIdx = ftl.indexOf("Copyright"); + } + if (copyrightIdx == -1) { + return ftl; + } + + final int commentFirstIdx; + final boolean squareBracketTagSyntax; + { + String ftlBeforeCopyright = ftl.substring(0, copyrightIdx); + int abCommentStart = ftlBeforeCopyright.lastIndexOf("<#--"); + int sbCommentStart = ftlBeforeCopyright.lastIndexOf("[#--"); + squareBracketTagSyntax = sbCommentStart > abCommentStart; + commentFirstIdx = squareBracketTagSyntax ? sbCommentStart : abCommentStart; + if (commentFirstIdx == -1) { + throw new AssertionError("Can't find copyright comment start"); + } + } + + final int commentLastIdx; + { + int commentEndStart = ftl.indexOf(squareBracketTagSyntax ? "--]" : "-->", copyrightIdx); + if (commentEndStart == -1) { + throw new AssertionError("Can't find copyright comment end"); + } + commentLastIdx = commentEndStart + 2; + } + + final int afterCommentNLChars; + if (commentLastIdx + 1 < ftl.length()) { + char afterCommentChar = ftl.charAt(commentLastIdx + 1); + if (afterCommentChar == '\n' || afterCommentChar == '\r') { + if (afterCommentChar == '\r' && commentLastIdx + 2 < ftl.length() && ftl.charAt(commentLastIdx + 2) == '\n') { + afterCommentNLChars = 2; + } else { + afterCommentNLChars = 1; + } + } else { + afterCommentNLChars = 0; + } + } else { + afterCommentNLChars = 0; + } + + return ftl.substring(0, commentFirstIdx) + ftl.substring(commentLastIdx + afterCommentNLChars + 1); + } +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java index 51baeb4..b5f62e7 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertEqualsDirective.java @@ -34,7 +34,7 @@ import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateNumberModel; import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.util.StringToIndexMap; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; public class AssertEqualsDirective implements TemplateDirectiveModel { @@ -92,7 +92,7 @@ public class AssertEqualsDirective implements TemplateDirectiveModel { // This is the same order as comparison goes: else if (value instanceof TemplateNumberModel) return ((TemplateNumberModel) value).getAsNumber().toString(); else if (value instanceof TemplateDateModel) return ((TemplateDateModel) value).getAsDate().toString(); - else if (value instanceof TemplateScalarModel) return _StringUtil.jQuote(((TemplateScalarModel) value).getAsString()); + else if (value instanceof TemplateScalarModel) return _StringUtils.jQuote(((TemplateScalarModel) value).getAsString()); else if (value instanceof TemplateBooleanModel) return String.valueOf(((TemplateBooleanModel) value).getAsBoolean()); // This shouldn't be reached, as the comparison should have failed earlier: else return value.toString(); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertFailsDirective.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertFailsDirective.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertFailsDirective.java index 6fe1505..05a5cb0 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertFailsDirective.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/AssertFailsDirective.java @@ -34,7 +34,7 @@ import org.apache.freemarker.core.model.TemplateNumberModel; import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.util.StringToIndexMap; import org.apache.freemarker.core.util._NullWriter; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; public class AssertFailsDirective implements TemplateDirectiveModel { @@ -93,7 +93,7 @@ public class AssertFailsDirective implements TemplateDirectiveModel { if (e.getMessage() == null) { throw new AssertationFailedInTemplateException( "Failure is not like expected. The exception message was null, " - + "and thus it doesn't contain:\n" + _StringUtil.jQuote(message) + ".", + + "and thus it doesn't contain:\n" + _StringUtils.jQuote(message) + ".", env); } if (message != null) { @@ -101,18 +101,18 @@ public class AssertFailsDirective implements TemplateDirectiveModel { ? ((TemplateException) e).getMessageWithoutStackTop() : e.getMessage(); if (!actualMessage.toLowerCase().contains(message.toLowerCase())) { throw new AssertationFailedInTemplateException( - "Failure is not like expected. The exception message:\n" + _StringUtil + "Failure is not like expected. The exception message:\n" + _StringUtils .jQuote(actualMessage) - + "\ndoesn't contain:\n" + _StringUtil.jQuote(message) + ".", + + "\ndoesn't contain:\n" + _StringUtils.jQuote(message) + ".", env); } } if (messageRegexp != null) { if (!messageRegexp.matcher(e.getMessage()).find()) { throw new AssertationFailedInTemplateException( - "Failure is not like expected. The exception message:\n" + _StringUtil + "Failure is not like expected. The exception message:\n" + _StringUtils .jQuote(e.getMessage()) - + "\ndoesn't match this regexp:\n" + _StringUtil + + "\ndoesn't match this regexp:\n" + _StringUtils .jQuote(messageRegexp.toString()) + ".", env); @@ -121,9 +121,9 @@ public class AssertFailsDirective implements TemplateDirectiveModel { } if (exception != null && !e.getClass().getName().contains(exception)) { throw new AssertationFailedInTemplateException( - "Failure is not like expected. The exception class name " + _StringUtil + "Failure is not like expected. The exception class name " + _StringUtils .jQuote(e.getClass().getName()) - + " doesn't contain " + _StringUtil.jQuote(message) + ".", + + " doesn't contain " + _StringUtils.jQuote(message) + ".", env); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/BadParameterTypeException.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/BadParameterTypeException.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/BadParameterTypeException.java index 0a3a350..34b7ec5 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/BadParameterTypeException.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/BadParameterTypeException.java @@ -21,7 +21,7 @@ package org.apache.freemarker.test.templateutil; import org.apache.freemarker.core.Environment; import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * Indicates that a named directive/function parameter is not of the expected type. @@ -46,9 +46,9 @@ public class BadParameterTypeException extends ParameterException { public BadParameterTypeException( String parameterName, String expectedType, TemplateModel value, String description, Exception cause, Environment env) { super(parameterName, - "The type of the parameter " + _StringUtil.jQuote(parameterName) + " should be " + expectedType + "The type of the parameter " + _StringUtils.jQuote(parameterName) + " should be " + expectedType + ", but the actual value was " + getTypeDescription(value) + "." - + (description != null ? " " + _StringUtil.jQuote(description) : ""), + + (description != null ? " " + _StringUtils.jQuote(description) : ""), cause, env); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/MissingRequiredParameterException.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/MissingRequiredParameterException.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/MissingRequiredParameterException.java index b222cfd..19b2927 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/MissingRequiredParameterException.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/MissingRequiredParameterException.java @@ -20,7 +20,7 @@ package org.apache.freemarker.test.templateutil; import org.apache.freemarker.core.Environment; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * Indicates that a named directive/function parameter is missing. @@ -42,9 +42,9 @@ class MissingRequiredParameterException extends ParameterException { public MissingRequiredParameterException(String parameterName, String description, Exception cause, Environment env) { super(parameterName, - "Required parameter " + _StringUtil.jQuote(parameterName) + " is missing, " + "Required parameter " + _StringUtils.jQuote(parameterName) + " is missing, " + "or the parameter value was null." - + (description != null ? " " + _StringUtil.jQuote(description) : ""), + + (description != null ? " " + _StringUtils.jQuote(description) : ""), cause, env); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ebb39b84/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/UnsupportedParameterException.java ---------------------------------------------------------------------- diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/UnsupportedParameterException.java b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/UnsupportedParameterException.java index f8278f8..4b0e274 100644 --- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/UnsupportedParameterException.java +++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/templateutil/UnsupportedParameterException.java @@ -20,7 +20,7 @@ package org.apache.freemarker.test.templateutil; import org.apache.freemarker.core.Environment; -import org.apache.freemarker.core.util._StringUtil; +import org.apache.freemarker.core.util._StringUtils; /** * Indicates that a named directive/function parameter is unsupported (like a typo). @@ -42,8 +42,8 @@ class UnsupportedParameterException extends ParameterException { public UnsupportedParameterException(String parameterName, String description, Exception cause, Environment env) { super(parameterName, - "Unsuppored parameter: " + _StringUtil.jQuote(parameterName) - + (description == null ? "." : ". " + _StringUtil.jQuote(description)), + "Unsuppored parameter: " + _StringUtils.jQuote(parameterName) + + (description == null ? "." : ". " + _StringUtils.jQuote(description)), cause, env); }
