diff --git a/build.gradle b/build.gradle index dafd64ba12..4f989b5330 100644 --- a/build.gradle +++ b/build.gradle @@ -111,7 +111,10 @@ subprojects { exclude '**/*Sample*' minHeapSize = "128m" maxHeapSize = "512m" - jvmArgs '-XX:MaxPermSize=256m' + if (!JavaVersion.current().isJava8Compatible()) { + jvmArgs '-XX:MaxPermSize=256m' + } + maxParallelForks = 2 } task integrationTests(type: Test) { @@ -123,8 +126,11 @@ subprojects { reports.junitXml.destination = "${buildDir}/reports/integration-tests" reports.html.destination = "${buildDir}/reports/integration-tests" minHeapSize = "128m" - maxHeapSize = "2048m" - jvmArgs '-XX:MaxPermSize=256m' + maxHeapSize = "4096m" + if (!JavaVersion.current().isJava8Compatible()) { + jvmArgs '-XX:MaxPermSize=256m' + } + maxParallelForks = 2 } test { diff --git a/core/build.gradle b/core/build.gradle index aa2b5f9bdc..4ca27b6a26 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -17,7 +17,6 @@ dependencies { compile project(':serenity-report-resources') compile 'com.google.code.gson:gson:2.3.1' - compile 'com.fatboyindustrial.gson-javatime-serialisers:gson-javatime-serialisers:1.1.1' compile ("cglib:cglib:2.2.2") { exclude group: 'asm', module: 'asm' @@ -66,7 +65,6 @@ dependencies { compile "com.thoughtworks.xstream:xstream:1.4.1" compile "org.apache.commons:commons-lang3:3.3.2" compile "commons-collections:commons-collections:3.2.1" - compile "net.sf.flexjson:flexjson:2.1" compile "org.freemarker:freemarker:2.3.19" compile ("net.sourceforge.jexcelapi:jxl:2.6.12") { exclude group: 'log4j', module: 'log4j' @@ -77,7 +75,6 @@ dependencies { compile 'org.hamcrest:hamcrest-library:1.3' compile "com.thoughtworks.xstream:xstream:1.4.1" compile "commons-collections:commons-collections:3.2.1" - compile "net.sf.flexjson:flexjson:2.1" compile ("net.sourceforge.htmlunit:htmlunit:2.15") { exclude group: 'org.apache.commons', module: 'commons-lang3' exclude group: 'commons-logging', module: 'commons-logging' diff --git a/core/src/main/java/net/thucydides/core/reports/html/ExampleTable.java b/core/src/main/java/net/thucydides/core/reports/html/ExampleTable.java index cd76062748..427208fa5b 100644 --- a/core/src/main/java/net/thucydides/core/reports/html/ExampleTable.java +++ b/core/src/main/java/net/thucydides/core/reports/html/ExampleTable.java @@ -3,6 +3,7 @@ import com.google.common.base.CharMatcher; import com.google.common.base.Splitter; import com.google.common.collect.Lists; +import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.regex.Pattern; @@ -10,12 +11,22 @@ import static org.apache.commons.collections.IteratorUtils.toList; public class ExampleTable { + + private final static String NEWLINE_CHAR = "\u2424"; + private final static String NEWLINE = "\u0085"; + private final static String LINE_SEPARATOR = "\u2028"; + private final static String PARAGRAPH_SEPARATOR = "\u2089"; + private final static String LEFT_BRACKET = "\u0FF3B"; + private final static String RIGHT_BRACKET = "\u0FF3D"; + List headers; List> rows = Lists.newArrayList(); - final static Pattern NEW_LINE = Pattern.compile("(\\r\\n)|(\\n)|(\\r)|(␤)|(\\r␤)"); - private static final String SQUARE_BRACKETS_OR_WHITE_SPACE = "[][] \t"; + final static Pattern NEW_LINE + = Pattern.compile("(\\r\\n)|(\\n)|(\\r)|(" + NEWLINE_CHAR + ")|(" + LINE_SEPARATOR + ")|(" + PARAGRAPH_SEPARATOR + ")|(\\r" + NEWLINE_CHAR + ")"); + private static final String SQUARE_BRACKETS_OR_WHITE_SPACE = "[]" + LEFT_BRACKET + RIGHT_BRACKET + "\t"; public ExampleTable(String tableContents) { + tableContents = stripBracketsFromOuterPipes(tableContents); List lines = toList(Splitter.on(NEW_LINE) .omitEmptyStrings() .trimResults(CharMatcher.anyOf(SQUARE_BRACKETS_OR_WHITE_SPACE)) @@ -26,6 +37,13 @@ public ExampleTable(String tableContents) { } } + public static String stripBracketsFromOuterPipes(String text) { + text = StringUtils.replace(text, "[|", "|"); + text = StringUtils.replace(text,"|]","|"); + text = StringUtils.replace(text,LEFT_BRACKET + "|","|"); + text = StringUtils.replace(text,"|" + RIGHT_BRACKET,"|"); + return text; + } private void addRowFrom(String row) { rows.add(cellsFrom(row)); } diff --git a/core/src/main/java/net/thucydides/core/reports/html/Formatter.java b/core/src/main/java/net/thucydides/core/reports/html/Formatter.java index c03f9cda0e..a4e4160162 100644 --- a/core/src/main/java/net/thucydides/core/reports/html/Formatter.java +++ b/core/src/main/java/net/thucydides/core/reports/html/Formatter.java @@ -44,6 +44,13 @@ public class Formatter { private static final String ASCIIDOC = "asciidoc"; private static final String NEW_LINE = System.getProperty("line.separator"); + private final static String NEWLINE_CHAR = "\u2424"; + private final static String NEWLINE = "\u0085"; + private final static String LINE_SEPARATOR = "\u2028"; + private final static String PARAGRAPH_SEPARATOR = "\u2089"; + private final static String LEFT_BRACKET = "\u0FF3B"; + private final static String RIGHT_BRACKET = "\u0FF3D"; + private final IssueTracking issueTracking; private final EnvironmentVariables environmentVariables; private final MarkupRenderer asciidocRenderer; @@ -159,8 +166,9 @@ public String addLineBreaks(final String text) { } public String convertAnyTables(String text) { - text = convertNonStandardNLChars(text); if (shouldFormatEmbeddedTables() && containsEmbeddedTable(text)) { + text = convertNonStandardNLChars(text); + text = ExampleTable.stripBracketsFromOuterPipes(text); text = withTablesReplaced(text); } @@ -180,9 +188,11 @@ private String withTablesReplaced(String text) { } private String convertNonStandardNLChars(String text) { - StringUtils.replace(text, "\r␤", NEW_LINE) - .replace("␤", NEW_LINE); - return StringUtils.replace(text, "␤", NEW_LINE); + text = StringUtils.replace(text, NEWLINE_CHAR, NEW_LINE); + text = StringUtils.replace(text, NEWLINE, NEW_LINE); + text = StringUtils.replace(text, LINE_SEPARATOR, NEW_LINE); + text = StringUtils.replace(text, PARAGRAPH_SEPARATOR, NEW_LINE); + return text; } private boolean shouldFormatEmbeddedTables() { @@ -210,7 +220,7 @@ private List getEmbeddedTablesIn(String text) { try { String line; while ((line = reader.readLine()) != null) { - if (!inTable && containsTableStart(line)){ // start of a table + if (!inTable && line.contains("|")){ // start of a table inTable = true; } else if (inTable && !line.contains("|") && !(isBlank(line))){ // end of a table embeddedTables.add(tableText.toString().trim()); diff --git a/core/src/main/java/net/thucydides/core/reports/json/gson/GsonJSONConverter.java b/core/src/main/java/net/thucydides/core/reports/json/gson/GsonJSONConverter.java index b7272be5ba..9cfae87fb7 100644 --- a/core/src/main/java/net/thucydides/core/reports/json/gson/GsonJSONConverter.java +++ b/core/src/main/java/net/thucydides/core/reports/json/gson/GsonJSONConverter.java @@ -1,6 +1,5 @@ package net.thucydides.core.reports.json.gson; -import com.fatboyindustrial.gsonjavatime.Converters; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.inject.Inject; @@ -27,7 +26,7 @@ protected Gson getGson() { @Inject public GsonJSONConverter(EnvironmentVariables environmentVariables) { this.environmentVariables = environmentVariables; - GsonBuilder gsonBuilder = Converters.registerAll(new GsonBuilder()) + GsonBuilder gsonBuilder = new GsonBuilder() .registerTypeAdapterFactory(OptionalTypeAdapter.FACTORY) .registerTypeHierarchyAdapter(Collection.class, new CollectionAdapter()) .registerTypeAdapter(File.class, new FileSerializer()) diff --git a/core/src/main/java/net/thucydides/core/requirements/RequirementPersister.java b/core/src/main/java/net/thucydides/core/requirements/RequirementPersister.java index 7fa2126d2e..c6c03806dc 100644 --- a/core/src/main/java/net/thucydides/core/requirements/RequirementPersister.java +++ b/core/src/main/java/net/thucydides/core/requirements/RequirementPersister.java @@ -1,14 +1,11 @@ package net.thucydides.core.requirements; -import com.fatboyindustrial.gsonjavatime.Converters; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; -import net.thucydides.core.reports.json.gson.ClassTypeAdapter; import net.thucydides.core.reports.json.gson.CollectionAdapter; import net.thucydides.core.reports.json.gson.OptionalTypeAdapter; import net.thucydides.core.requirements.model.Requirement; -import org.apache.commons.lang3.reflect.TypeUtils; import java.io.*; import java.lang.reflect.Type; @@ -24,7 +21,7 @@ public class RequirementPersister { public RequirementPersister(File outputDirectory, String rootDirectory) { this.outputDirectory = outputDirectory; this.rootDirectory = rootDirectory; - this.gson = Converters.registerAll(new GsonBuilder()) + this.gson = new GsonBuilder() .registerTypeAdapterFactory(OptionalTypeAdapter.FACTORY) .registerTypeHierarchyAdapter(Collection.class, new CollectionAdapter()).create(); diff --git a/core/src/test/groovy/net/thucydides/core/reports/html/WhenFormattingDataForTheHTMLReports.groovy b/core/src/test/groovy/net/thucydides/core/reports/html/WhenFormattingDataForTheHTMLReports.groovy index a0ff3761fd..2633963047 100644 --- a/core/src/test/groovy/net/thucydides/core/reports/html/WhenFormattingDataForTheHTMLReports.groovy +++ b/core/src/test/groovy/net/thucydides/core/reports/html/WhenFormattingDataForTheHTMLReports.groovy @@ -193,9 +193,11 @@ class WhenFormattingDataForTheHTMLReports extends Specification { embeddedTable == "A table like this:
ownerpoints
Jane80000
Joe50000
" } + def UNICODE_NL = "\u2424" + def "should identify a table within a step using NL new lines"() { given: - def singleCellTable = "A table like this:␤[| owner | points |␤| Jane | 80000 |␤| Joe | 50000 |]" + def singleCellTable = "A table like this:${UNICODE_NL}[| owner | points |${UNICODE_NL}| Jane | 80000 |${UNICODE_NL}| Joe | 50000 |]" def formatter = new Formatter(issueTracking); when: @@ -249,10 +251,13 @@ class WhenFormattingDataForTheHTMLReports extends Specification { embeddedTable == "A table like this:
ownerpoints
Jane80000
Joe50000
" } + def LEFT_BRACKET = '\u0FF3B' + def RIGHT_BRACKET = '\u0FF3D' + def "should identify a table within a step using Windows bracket chars"() { given: - def singleCellTable = "A table like this:\r\n[| owner | points |\r\n| Jane | 80000 |\r\n| Joe | 50000 |]" + def singleCellTable = "A table like this:\r\n${LEFT_BRACKET}| owner | points |\r\n| Jane | 80000 |\r\n| Joe | 50000 |${RIGHT_BRACKET}" def formatter = new Formatter(issueTracking); when: