From 9546f60007c73cbbe6116b9a60aafbe55eaa9d17 Mon Sep 17 00:00:00 2001 From: Mauro Talevi Date: Fri, 22 Jan 2021 20:15:41 +0000 Subject: [PATCH] JBEHAVE-1450 Removed CrossReference. --- .../src/site/content/configuration.html | 4 +- .../src/site/content/cross-reference.html | 155 ---------- .../src/site/content/developing-stories.html | 9 +- .../src/site/content/reporting-stories.html | 4 +- .../src/site/content/running-stories.html | 3 +- distribution/src/site/content/sitemap.xml | 1 - .../jbehave/examples/core/CoreEmbedder.java | 4 +- .../jbehave/examples/core/CoreStories.java | 3 +- .../org/jbehave/examples/core/CoreStory.java | 4 - .../examples/core/JFrameCoreStories.java | 8 +- .../org/jbehave/core/embedder/Embedder.java | 7 - .../org/jbehave/core/junit/JUnitStories.java | 1 - .../org/jbehave/core/junit/JUnitStory.java | 1 - .../core/reporters/CrossReference.java | 276 ------------------ .../core/reporters/StoryReporterBuilder.java | 14 - .../core/embedder/ConcurrencyBehaviour.java | 10 +- .../core/embedder/EmbedderBehaviour.java | 21 -- .../reporters/CrossReferenceBehaviour.java | 73 ----- 18 files changed, 12 insertions(+), 586 deletions(-) delete mode 100755 distribution/src/site/content/cross-reference.html delete mode 100755 jbehave-core/src/main/java/org/jbehave/core/reporters/CrossReference.java delete mode 100755 jbehave-core/src/test/java/org/jbehave/core/reporters/CrossReferenceBehaviour.java diff --git a/distribution/src/site/content/configuration.html b/distribution/src/site/content/configuration.html index 3c8249b4d..e93b4c7da 100755 --- a/distribution/src/site/content/configuration.html +++ b/distribution/src/site/content/configuration.html @@ -190,8 +190,6 @@

Using ConfigurableEmbedder

Using ConfigurableEmbedder .withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)) .withDefaultFormats().withPathResolver(new ResolveToPackagedName()) .withViewResources(viewResources).withFormats(CONSOLE, TXT, HTML, XML) - .withFailureTrace(true).withFailureTraceCompression(true).withCrossReference(xref)) + .withFailureTrace(true).withFailureTraceCompression(true)) .useParameterConverters(parameterConverters) // use '%' instead of '$' to identify parameters .useStepPatternParser(new RegexPrefixCapturingPatternParser("%")) diff --git a/distribution/src/site/content/cross-reference.html b/distribution/src/site/content/cross-reference.html deleted file mode 100755 index 16f1c0298..000000000 --- a/distribution/src/site/content/cross-reference.html +++ /dev/null @@ -1,155 +0,0 @@ - - - -Cross Reference - - -

Cross Reference

- -

The CrossReference -is a special report Format -that build a cross reference of stories being executed during the run. -It provides both JSON and XML representations, detailing both the -stories and scenarios run, as well as the step matches.

- -

These representations can then be used by any app that can -navigate its contents and render it interactively.

- -

A typical xref.json file is:

- -
-{"xref": {
-  "whenMade": 1298245533227,
-  "createdBy": "JBehave",
-  "meta": [
-  ],
-  "stories": [
-    {
-      "description": "",
-      "narrative": "",
-      "name": "unmatched_search_term.story",
-      "path": "org/jbehave/examples/trader/stories/unmatched_search_term.story",
-      "html": "org.jbehave.examples.trader.stories.unmatched_search_term.html",
-      "meta": "",
-      "scenarios": "Scenario:Search term does match examples table header\u000aG
-iven that I am on Google's Homepage\u000aWhen I enter the search term ridiculou
-sSearchTerm and proceed\u000aThen I should see ridiculous things\u000a\u000a\u0
-00aScenario:Search term does not match examples table header and step is marked 
-as pending\u000aGiven that I am on Google's Homepage\u000aWhen I enter the searc
-h term ridiculousSearchTerm and proceed\u000aThen I should see ridiculous thin
-gs\u000a\u000a\u000a",
-      "passed": true,
-      "pending": false
-    }
-  ],
-  "stepMatches": [
-    {
-      "type": "GIVEN",
-      "annotatedPattern": "that I am on Google's Homepage",
-      "resolvedPattern": "that\\s+I\\s+am\\s+on\\s+Google's\\s+Homepage",
-      "usages": [
-        {
-          "story": "org/jbehave/examples/trader/stories/unmatched_search_term.st
-ory",
-          "scenario": "Search term does match examples table header",
-          "step": "Given that I am on Google's Homepage"
-        },
-        {
-          "story": "org/jbehave/examples/trader/stories/unmatched_search_term.st
-ory",
-          "scenario": "Search term does not match examples table header and step
- is marked as pending",
-          "step": "Given that I am on Google's Homepage"
-        }
-      ]
-    },
-    {
-      "type": "WHEN",
-      "annotatedPattern": "I enter the search term ridiculousSearchTerm and pr
-oceed",
-      "resolvedPattern": "I\\s+enter\\s+the\\s+search\\s+term\\s+ridiculousSear
-chTerm\\s+and\\s+proceed",
-      "usages": [
-        {
-          "story": "org/jbehave/examples/trader/stories/unmatched_search_term.st
-ory",
-          "scenario": "Search term does not match examples table header and step
- is marked as pending",
-          "step": "When I enter the search term ridiculousSearchTerm and proce
-ed"
-        },
-        {
-          "story": "org/jbehave/examples/trader/stories/unmatched_search_term.st
-ory",
-          "scenario": "Search term does match examples table header",
-          "step": "When I enter the search term ridiculousSearchTerm and proce
-ed"
-        }
-      ]
-    },
-    {
-      "type": "THEN",
-      "annotatedPattern": "I should see ridiculous things",
-      "resolvedPattern": "I\\s+should\\s+see\\s+ridiculous\\s+things",
-      "usages": [
-        {
-          "story": "org/jbehave/examples/trader/stories/unmatched_search_term.st
-ory",
-          "scenario": "Search term does not match examples table header and step
- is marked as pending",
-          "step": "Then I should see ridiculous things"
-        },
-        {
-          "story": "org/jbehave/examples/trader/stories/unmatched_search_term.st
-ory",
-          "scenario": "Search term does match examples table header",
-          "step": "Then I should see ridiculous things"
-        }
-      ]
-    }
-  ]
-}}
-
- -

Configuration

- -

The CrossReference instance needs to configured in the StoryReporterBuilder:

-
-public class CoreStories extends JUnitStories {
-    
-    @Override
-    public Configuration configuration() {
-        CrossReference xref = new CrossReference();
-        return new MostUsefulConfiguration()
-            .useStoryReporterBuilder(new StoryReporterBuilder()
-                .withCrossReference(xref)) 
-            .useStepMonitor(xref.getStepMonitor());                               
-    }
-}
-
- -

If the CrossReference is configured, the JSON and XML -representations are generated automatically in the JBehave report view -directory (target/jbehave/view by default) by the JUnit-based -ConfigurableEmbedder, i.e. JUnitStory and JUnitStories. In other case, you -may generate them on demand via the Embedder method generateCrossReference().

- -

Optionally, CrossReference can be configured to update file output after each story and to output -to JSON or XML only (instead of both). Moreover, the user can choose to exclude stories when there are no executed scenarios

- -

Note that in the above code fragment we are only focusing on the -configuration of the CrossReference. In particular, you may be chaining -more than one step monitor together in the useStepMonitor(..) line. -Also, there will be typically other methods to implement in JUnitStories -for finding stories and other configuration elements to specify. -

- -

Examples

- -

Examples of configuration of CrossReference can be found in core example.

- - - diff --git a/distribution/src/site/content/developing-stories.html b/distribution/src/site/content/developing-stories.html index fb3ccc92b..87271abbc 100755 --- a/distribution/src/site/content/developing-stories.html +++ b/distribution/src/site/content/developing-stories.html @@ -148,8 +148,6 @@

JUnit-enabled Embeddables

JUnit-enabled Embeddables .withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)) .withDefaultFormats().withPathResolver(new ResolveToPackagedName()) .withViewResources(viewResources).withFormats(CONSOLE, TXT, HTML, XML) - .withFailureTrace(true).withFailureTraceCompression(true).withCrossReference(xref)) + .withFailureTrace(true).withFailureTraceCompression(true)) .useParameterConverters(parameterConverters) // use '%' instead of '$' to identify parameters .useStepPatternParser(new RegexPrefixCapturingPatternParser("%")) @@ -210,8 +208,6 @@

JUnit-enabled Embeddables

JUnit-enabled Embeddables .withViewResources(viewResources) .withFormats(CONSOLE, TXT, HTML_TEMPLATE, XML_TEMPLATE) .withFailureTrace(true) - .withFailureTraceCompression(true) - .withCrossReference(xref)) + .withFailureTraceCompression(true)) .useParameterConverters(parameterConverters) // use '%' instead of '$' to identify parameters .useStepPatternParser(new RegexPrefixCapturingPatternParser( diff --git a/distribution/src/site/content/reporting-stories.html b/distribution/src/site/content/reporting-stories.html index 82f2aba85..90b06d52e 100755 --- a/distribution/src/site/content/reporting-stories.html +++ b/distribution/src/site/content/reporting-stories.html @@ -53,8 +53,6 @@

Story Reporters

Story Reporters .withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)) .withDefaultFormats().withPathResolver(new ResolveToPackagedName()) .withViewResources(viewResources).withFormats(CONSOLE, TXT, HTML, XML) - .withFailureTrace(true).withFailureTraceCompression(true).withCrossReference(xref)) + .withFailureTrace(true).withFailureTraceCompression(true)) .useParameterConverters(parameterConverters) // use '%' instead of '$' to identify parameters .useStepPatternParser(new RegexPrefixCapturingPatternParser("%")) diff --git a/distribution/src/site/content/running-stories.html b/distribution/src/site/content/running-stories.html index 179ac068b..a6559252b 100755 --- a/distribution/src/site/content/running-stories.html +++ b/distribution/src/site/content/running-stories.html @@ -105,8 +105,7 @@

Running Stories in a framework-neutral way

.useStoryReporterBuilder(new StoryReporterBuilder() .withCodeLocation(CodeLocations.codeLocationFromClass(embedderClass)) .withDefaultFormats() - .withFormats(CONSOLE, TXT, HTML, XML) - .withCrossReference(new CrossReference())) + .withFormats(CONSOLE, TXT, HTML, XML)) .useParameterConverters(new ParameterConverters() .addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")))) // use custom date pattern .useStepPatternParser(new RegexPrefixCapturingPatternParser( diff --git a/distribution/src/site/content/sitemap.xml b/distribution/src/site/content/sitemap.xml index 9ce130538..9dae86c6f 100755 --- a/distribution/src/site/content/sitemap.xml +++ b/distribution/src/site/content/sitemap.xml @@ -64,7 +64,6 @@ story-mapping.html story-timeouts.html story-transformers.html - cross-reference.html surefire-reporter.html context-view.html multi-threading.html diff --git a/examples/core/src/main/java/org/jbehave/examples/core/CoreEmbedder.java b/examples/core/src/main/java/org/jbehave/examples/core/CoreEmbedder.java index 01925f8ef..aedbffade 100755 --- a/examples/core/src/main/java/org/jbehave/examples/core/CoreEmbedder.java +++ b/examples/core/src/main/java/org/jbehave/examples/core/CoreEmbedder.java @@ -10,7 +10,6 @@ import org.jbehave.core.io.LoadFromClasspath; import org.jbehave.core.model.TableTransformers; import org.jbehave.core.parsers.RegexPrefixCapturingPatternParser; -import org.jbehave.core.reporters.CrossReference; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; import org.jbehave.core.steps.InstanceStepsFactory; @@ -47,8 +46,7 @@ public Configuration configuration() { .useStoryReporterBuilder(new StoryReporterBuilder() .withCodeLocation(CodeLocations.codeLocationFromClass(embedderClass)) .withDefaultFormats() - .withFormats(CONSOLE, TXT, HTML, XML) - .withCrossReference(new CrossReference())) + .withFormats(CONSOLE, TXT, HTML, XML)) .useTableTransformers(tableTransformers) .useParameterConverters(new ParameterConverters(resourceLoader, tableTransformers) .addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")))) // use custom date pattern diff --git a/examples/core/src/main/java/org/jbehave/examples/core/CoreStories.java b/examples/core/src/main/java/org/jbehave/examples/core/CoreStories.java index 424703dc9..8ea370de2 100755 --- a/examples/core/src/main/java/org/jbehave/examples/core/CoreStories.java +++ b/examples/core/src/main/java/org/jbehave/examples/core/CoreStories.java @@ -42,7 +42,6 @@ */ public class CoreStories extends JUnitStories { - private final CrossReference xref = new CrossReference(); private Context context = new Context(); private Format contextFormat = new ContextOutput(context); @@ -87,7 +86,7 @@ public Configuration configuration() { .withCodeLocation(codeLocationFromClass(embeddableClass)) .withDefaultFormats().withViewResources(viewResources) .withFormats(contextFormat, ANSI_CONSOLE, TXT, HTML_TEMPLATE, XML_TEMPLATE).withFailureTrace(true) - .withFailureTraceCompression(true).withCrossReference(xref) + .withFailureTraceCompression(true) .withSurefireReporter(surefireReporter)) .useParameterConverters(parameterConverters) .useParameterControls(parameterControls) diff --git a/examples/core/src/main/java/org/jbehave/examples/core/CoreStory.java b/examples/core/src/main/java/org/jbehave/examples/core/CoreStory.java index 9757ed727..8dc3f0294 100755 --- a/examples/core/src/main/java/org/jbehave/examples/core/CoreStory.java +++ b/examples/core/src/main/java/org/jbehave/examples/core/CoreStory.java @@ -21,7 +21,6 @@ import org.jbehave.core.model.TableParsers; import org.jbehave.core.model.TableTransformers; import org.jbehave.core.parsers.RegexStoryParser; -import org.jbehave.core.reporters.CrossReference; import org.jbehave.core.reporters.FilePrintStreamFactory.ResolveToPackagedName; import org.jbehave.core.reporters.StoryReporterBuilder; import org.jbehave.core.steps.InjectableStepsFactory; @@ -51,8 +50,6 @@ */ public abstract class CoreStory extends JUnitStory { - private final CrossReference xref = new CrossReference(); - public CoreStory() { configuredEmbedder().embedderControls().doGenerateViewAfterStories(true).doIgnoreFailureInStories(false) .doIgnoreFailureInView(true).useThreads(1).useStoryTimeouts("60"); @@ -88,7 +85,6 @@ public Configuration configuration() { .withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)) .withDefaultFormats().withPathResolver(new ResolveToPackagedName()) .withViewResources(viewResources).withFormats(CONSOLE, TXT, HTML_TEMPLATE, XML) - .withCrossReference(xref) .withFailureTrace(true).withFailureTraceCompression(true)) .useParameterConverters(parameterConverters) .useParameterControls(parameterControls) diff --git a/examples/core/src/main/java/org/jbehave/examples/core/JFrameCoreStories.java b/examples/core/src/main/java/org/jbehave/examples/core/JFrameCoreStories.java index eb2c87f47..6cb39f2b6 100755 --- a/examples/core/src/main/java/org/jbehave/examples/core/JFrameCoreStories.java +++ b/examples/core/src/main/java/org/jbehave/examples/core/JFrameCoreStories.java @@ -4,10 +4,8 @@ import org.jbehave.core.context.Context; import org.jbehave.core.context.ContextView; import org.jbehave.core.context.JFrameContextView; -import org.jbehave.core.reporters.ContextOutput; -import org.jbehave.core.reporters.CrossReference; -import org.jbehave.core.reporters.Format; import org.jbehave.core.steps.ContextStepMonitor; +import org.jbehave.core.steps.NullStepMonitor; /** *

@@ -16,11 +14,9 @@ */ public class JFrameCoreStories extends CoreStories { - private final CrossReference xref = new CrossReference(); private Context context = new Context(); - private Format contextFormat = new ContextOutput(context); private ContextView contextView = new JFrameContextView().sized(640, 120); - private ContextStepMonitor contextStepMonitor = new ContextStepMonitor(context, contextView, xref.getStepMonitor()); + private ContextStepMonitor contextStepMonitor = new ContextStepMonitor(context, contextView, new NullStepMonitor()); @Override public Configuration configuration() { diff --git a/jbehave-core/src/main/java/org/jbehave/core/embedder/Embedder.java b/jbehave-core/src/main/java/org/jbehave/core/embedder/Embedder.java index 4e53a8198..7c2576011 100755 --- a/jbehave-core/src/main/java/org/jbehave/core/embedder/Embedder.java +++ b/jbehave-core/src/main/java/org/jbehave/core/embedder/Embedder.java @@ -283,13 +283,6 @@ private void handleFailures(ReportsCount count) { } } - public void generateCrossReference() { - StoryReporterBuilder builder = configuration().storyReporterBuilder(); - if (builder.hasCrossReference()) { - builder.crossReference().serialise(storyManager().performableRoot(), builder.outputDirectory()); - } - } - public void generateSurefireReport() { StoryReporterBuilder builder = configuration().storyReporterBuilder(); if (builder.hasSurefireReporter()) { diff --git a/jbehave-core/src/main/java/org/jbehave/core/junit/JUnitStories.java b/jbehave-core/src/main/java/org/jbehave/core/junit/JUnitStories.java index ff2e843c2..e4e42ffae 100755 --- a/jbehave-core/src/main/java/org/jbehave/core/junit/JUnitStories.java +++ b/jbehave-core/src/main/java/org/jbehave/core/junit/JUnitStories.java @@ -20,7 +20,6 @@ public void run() { try { embedder.runStoriesAsPaths(storyPaths()); } finally { - embedder.generateCrossReference(); embedder.generateSurefireReport(); } } diff --git a/jbehave-core/src/main/java/org/jbehave/core/junit/JUnitStory.java b/jbehave-core/src/main/java/org/jbehave/core/junit/JUnitStory.java index d4e0cbf4c..4348ac5de 100755 --- a/jbehave-core/src/main/java/org/jbehave/core/junit/JUnitStory.java +++ b/jbehave-core/src/main/java/org/jbehave/core/junit/JUnitStory.java @@ -24,7 +24,6 @@ public void run() { try { embedder.runStoriesAsPaths(asList(storyPath)); } finally { - embedder.generateCrossReference(); embedder.generateSurefireReport(); } } diff --git a/jbehave-core/src/main/java/org/jbehave/core/reporters/CrossReference.java b/jbehave-core/src/main/java/org/jbehave/core/reporters/CrossReference.java deleted file mode 100755 index c05949120..000000000 --- a/jbehave-core/src/main/java/org/jbehave/core/reporters/CrossReference.java +++ /dev/null @@ -1,276 +0,0 @@ -package org.jbehave.core.reporters; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.security.AnyTypePermission; -import org.jbehave.core.embedder.MatchingStepMonitor.StepMatch; -import org.jbehave.core.embedder.PerformableTree.ExamplePerformableScenario; -import org.jbehave.core.embedder.PerformableTree.NormalPerformableScenario; -import org.jbehave.core.embedder.PerformableTree.PerformableRoot; -import org.jbehave.core.embedder.PerformableTree.PerformableScenario; -import org.jbehave.core.embedder.PerformableTree.PerformableSteps; -import org.jbehave.core.embedder.PerformableTree.PerformableStory; -import org.jbehave.core.embedder.PerformableTree.Status; -import org.jbehave.core.failures.PendingStepStrategy; -import org.jbehave.core.model.*; -import org.jbehave.core.model.TableTransformers.Formatting; -import org.jbehave.core.model.TableTransformers.FromLandscape; -import org.jbehave.core.model.TableTransformers.Replacing; -import org.jbehave.core.steps.AbstractStepResult.Comment; -import org.jbehave.core.steps.AbstractStepResult.Failed; -import org.jbehave.core.steps.AbstractStepResult.Ignorable; -import org.jbehave.core.steps.AbstractStepResult.NotPerformed; -import org.jbehave.core.steps.AbstractStepResult.Pending; -import org.jbehave.core.steps.AbstractStepResult.Silent; -import org.jbehave.core.steps.AbstractStepResult.Skipped; -import org.jbehave.core.steps.AbstractStepResult.Successful; -import org.jbehave.core.steps.NullStepMonitor; -import org.jbehave.core.steps.StepMonitor; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver; -import org.jbehave.core.steps.Timing; - -public class CrossReference { - - private boolean doJson = true; - private boolean doXml = true; - private String name; - - public CrossReference() { - this("XREF"); - } - - public CrossReference(String name) { - this.name = name; - } - - public CrossReference withJsonOnly() { - doJson = true; - doXml = false; - return this; - } - - public CrossReference withXmlOnly() { - doJson = false; - doXml = true; - return this; - } - - public synchronized void serialise(PerformableRoot root, - File outputDirectory) { - XRef xref = new XRef(root); - if (doXml) { - serialise(xref, "xml", outputDirectory); - } - if (doJson) { - serialise(xref, "json", outputDirectory); - } - } - - private void serialise(Object object, String format, File outputDirectory) { - try { - serialise(object, xstream(format), writer(format, outputDirectory)); - } catch (IOException e) { - throw new RuntimeException(name, e); - } - } - - private void serialise(Object object, XStream xstream, Writer writer) - throws IOException { - writer.write(xstream.toXML(object)); - writer.flush(); - writer.close(); - } - - private Writer writer(String format, File outputDirectory) - throws IOException { - String name = fileName(format); - File outputDir = new File(outputDirectory, "view"); - outputDir.mkdirs(); - return new FileWriter(new File(outputDir, name)); - } - - private XStream xstream(String format) { - XStream xstream = (format.equals("json") ? new XStream( - new JsonHierarchicalStreamDriver()) : new XStream()); - configure(xstream); - return xstream; - } - - private void configure(XStream xstream) { - XStream.setupDefaultSecurity(xstream); - xstream.addPermission(AnyTypePermission.ANY); - xstream.setMode(XStream.NO_REFERENCES); - xstream.alias("xref", XRef.class); - xstream.alias(name.toLowerCase(), PerformableRoot.class); - xstream.alias("performableStory", PerformableStory.class); - xstream.alias("performableScenario", PerformableScenario.class); - xstream.alias("performableSteps", PerformableSteps.class); - xstream.alias("normalPerformableScenario", NormalPerformableScenario.class); - xstream.alias("examplePerformableScenario", ExamplePerformableScenario.class); - xstream.alias("status", Status.class); - xstream.alias("story", Story.class); - xstream.alias("scenario", Scenario.class); - xstream.alias("lifecycleSteps", Lifecycle.Steps.class); - xstream.alias("givenStory", GivenStory.class); - xstream.alias("comment", Comment.class); - xstream.alias("failed", Failed.class); - xstream.alias("pending", Pending.class); - xstream.alias("notPerformed", NotPerformed.class); - xstream.alias("successful", Successful.class); - xstream.alias("ignorable", Ignorable.class); - xstream.alias("silent", Silent.class); - xstream.alias("skipped", Skipped.class); - xstream.alias("fromLandscape", FromLandscape.class); - xstream.alias("formatting", Formatting.class); - xstream.alias("replacing", Replacing.class); - xstream.alias("stepMatch", StepMatch.class); - xstream.alias("timing", Timing.class); - xstream.omitField(ExamplesTable.class, "parameterConverters"); - xstream.omitField(ExamplesTable.class, "tableTransformers"); - xstream.omitField(ExamplesTable.class, "defaults"); - } - - private String fileName(String extension) { - return name.toLowerCase() + "." + extension; - } - - /** - * @deprecated - */ - @Deprecated - public synchronized void outputToFiles( - StoryReporterBuilder storyReporterBuilder) { - } - - /** - * @deprecated - */ - @Deprecated - public CrossReference withMetaFilter(String metaFilter) { - return this; - } - - /** - * @deprecated - */ - @Deprecated - public CrossReference withPendingStepStrategy( - PendingStepStrategy pendingStepStrategy) { - return this; - } - - /** - * @deprecated - */ - @Deprecated - public CrossReference withOutputAfterEachStory(boolean outputAfterEachStory) { - return this; - } - - /** - * @deprecated - */ - @Deprecated - public CrossReference withThreadSafeDelegateFormat(Format format) { - return this; - } - - /** - * @deprecated - */ - @Deprecated - public CrossReference excludingStoriesWithNoExecutedScenarios( - boolean exclude) { - return this; - } - - /** - * @deprecated - */ - @Deprecated - public String getMetaFilter() { - return ""; - } - - /** - * @deprecated - */ - @Deprecated - public StepMonitor getStepMonitor() { - return new NullStepMonitor(); - } - - /** - * @deprecated - */ - @Deprecated - protected XRefRoot newXRefRoot() { - return new XRefRoot(); - } - - /** - * @deprecated - */ - @Deprecated - protected Writer makeWriter(File file) throws IOException { - return new FileWriter(file); - } - - /** - * @deprecated - */ - @Deprecated - protected void aliasForXRefStory(XStream xstream) { - } - - /** - * @deprecated - */ - @Deprecated - protected void aliasForXRefRoot(XStream xstream) { - } - - /** - * @deprecated - */ - @Deprecated - public StoryReporter createStoryReporter(FilePrintStreamFactory factory, - final StoryReporterBuilder storyReporterBuilder) { - return new NullStoryReporter(); - } - - /** - * @deprecated - */ - @Deprecated - public static class XRefRoot { - } - - /** - * @deprecated - */ - @Deprecated - public static class XRefStory { - } - - public static class XRef { - private List stories; - private List scenarios = new ArrayList<>(); - - public XRef(PerformableRoot root) { - stories = root.getStories(); - for (PerformableStory story : stories) { - scenarios.addAll(story.getScenarios()); - } - } - - } - -} diff --git a/jbehave-core/src/main/java/org/jbehave/core/reporters/StoryReporterBuilder.java b/jbehave-core/src/main/java/org/jbehave/core/reporters/StoryReporterBuilder.java index 9bbd062d4..c4efb382d 100755 --- a/jbehave-core/src/main/java/org/jbehave/core/reporters/StoryReporterBuilder.java +++ b/jbehave-core/src/main/java/org/jbehave/core/reporters/StoryReporterBuilder.java @@ -151,7 +151,6 @@ public enum Format { protected boolean compressFailureTrace = false; protected Keywords keywords; protected SGRCodes codes; - protected CrossReference crossReference; protected SurefireReporter surefireReporter; protected boolean multiThreading; protected Configuration configuration; @@ -266,19 +265,6 @@ public StoryReporterBuilder withCodeLocation(URL codeLocation) { return this; } - public CrossReference crossReference() { - return crossReference; - } - - public boolean hasCrossReference() { - return crossReference != null; - } - - public StoryReporterBuilder withCrossReference(CrossReference crossReference) { - this.crossReference = crossReference; - return this; - } - public SurefireReporter surefireReporter() { return surefireReporter; } diff --git a/jbehave-core/src/test/java/org/jbehave/core/embedder/ConcurrencyBehaviour.java b/jbehave-core/src/test/java/org/jbehave/core/embedder/ConcurrencyBehaviour.java index 5278b956a..b48c2fe9a 100644 --- a/jbehave-core/src/test/java/org/jbehave/core/embedder/ConcurrencyBehaviour.java +++ b/jbehave-core/src/test/java/org/jbehave/core/embedder/ConcurrencyBehaviour.java @@ -77,11 +77,7 @@ public void shouldAllowStoriesToBeCancelledByPaths() { public void shouldAllowStoriesToBeTimed() { Embedder embedder = new Embedder(); embedder.embedderControls().useStoryTimeouts("10").useThreads(2).doVerboseFailures(true); - try { - embedder.runAsEmbeddables(asList(ThreadsStories.class.getName())); - } finally { - embedder.generateCrossReference(); - } + embedder.runAsEmbeddables(asList(ThreadsStories.class.getName())); } @Test @@ -243,8 +239,8 @@ public static class ThreadsStories extends JUnitStories { public Configuration configuration() { return new MostUsefulConfiguration() .useStoryLoader(new LoadFromClasspath(this.getClass())) - .useStoryReporterBuilder(new StoryReporterBuilder().withFormats(CONSOLE, HTML, XML, JSON) - .withCrossReference(new CrossReference())); + .useStoryReporterBuilder(new StoryReporterBuilder() + .withFormats(CONSOLE, HTML, XML, JSON)); } @Override diff --git a/jbehave-core/src/test/java/org/jbehave/core/embedder/EmbedderBehaviour.java b/jbehave-core/src/test/java/org/jbehave/core/embedder/EmbedderBehaviour.java index 7c5ce95d8..477b6f50b 100755 --- a/jbehave-core/src/test/java/org/jbehave/core/embedder/EmbedderBehaviour.java +++ b/jbehave-core/src/test/java/org/jbehave/core/embedder/EmbedderBehaviour.java @@ -59,7 +59,6 @@ import org.jbehave.core.model.Story; import org.jbehave.core.model.StoryMap; import org.jbehave.core.model.StoryMaps; -import org.jbehave.core.reporters.CrossReference; import org.jbehave.core.reporters.PrintStreamStepdocReporter; import org.jbehave.core.reporters.ReportsCount; import org.jbehave.core.reporters.StoryReporter; @@ -1133,26 +1132,6 @@ public void shouldAllowStringRepresentationOfEmbedder() { assertThat(embedderAsString, containsString(PrintStreamEmbedderMonitor.class.getSimpleName())); } - @Test - public void shouldGenerateCrossReferenceWhenAvailable() { - - Embedder embedder = new Embedder(); - embedder.useConfiguration(new MostUsefulConfiguration().useStoryReporterBuilder(new StoryReporterBuilder() - .withCrossReference(new CrossReference()))); - - // When - embedder.generateCrossReference(); - - // Then - assertXrefExists(embedder.configuration().storyReporterBuilder(), "json"); - assertXrefExists(embedder.configuration().storyReporterBuilder(), "xml"); - - } - - private void assertXrefExists(StoryReporterBuilder storyReporterBuilder, String ext) { - assertThat(new File(storyReporterBuilder.outputDirectory(), "view/xref." + ext).exists(), is(true)); - } - private String dos2unix(String string) { return string.replace("\r\n", "\n"); } diff --git a/jbehave-core/src/test/java/org/jbehave/core/reporters/CrossReferenceBehaviour.java b/jbehave-core/src/test/java/org/jbehave/core/reporters/CrossReferenceBehaviour.java deleted file mode 100755 index 49e7693e1..000000000 --- a/jbehave-core/src/test/java/org/jbehave/core/reporters/CrossReferenceBehaviour.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.jbehave.core.reporters; - -import org.apache.commons.io.IOUtils; -import org.jbehave.core.embedder.MatchingStepMonitor.StepMatch; -import org.jbehave.core.embedder.PerformableTree.*; -import org.jbehave.core.i18n.LocalizedKeywords; -import org.jbehave.core.model.*; -import org.jbehave.core.steps.StepType; -import org.junit.Test; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; - - -public class CrossReferenceBehaviour { - - @Test - public void shouldProduceXmlAndJsonOutputsOfStoriesAndSteps() throws Exception { - - // Given - CrossReference crossReference = new CrossReference(); - - // When - PerformableRoot root = performableRoot(); - File outputDirectory = new File("target"); - crossReference.serialise(root, outputDirectory); - - - // Then - String expectedXml = resource("xref.xml"); - String actualXml = output(outputDirectory, "xref.xml"); - - String expectedJson = resource("xref.json"); - String actualJson = output(outputDirectory, "xref.json"); - - assertThat(actualXml, equalTo(expectedXml)); - assertThat(actualJson, equalTo(expectedJson)); - } - - private String resource(String name) throws IOException { - return IOUtils.toString(getClass().getResource(name), StandardCharsets.UTF_8).replaceAll("(?:\\n|\\r)", ""); - } - - private String output(File outputDirectory, String name) throws IOException { - return IOUtils.toString(new FileReader(new File(outputDirectory, "view/"+name))).replaceAll("(?:\\n|\\r)", ""); - } - - private PerformableRoot performableRoot() { - PerformableRoot root = new PerformableRoot(); - Story story = new Story("/path/to/story", new Description("An interesting story"), new Meta(Arrays.asList("+theme testing", "+author Mauro")), new Narrative("renovate my house", "customer", "get a loan"), new ArrayList()); - PerformableStory performableStory = new PerformableStory(story, new LocalizedKeywords(), false); - root.add(performableStory); - Scenario scenario = new Scenario(Arrays.asList("")); - PerformableScenario performableScenario = new PerformableScenario(scenario, story.getPath()); - performableStory.add(performableScenario); - List stepMatches = new ArrayList<>(); - stepMatches.add(new StepMatch(new StepPattern(StepType.GIVEN, "(def)", "[abc]"))); - NormalPerformableScenario normalScenario = new NormalPerformableScenario(story, scenario); - normalScenario.addSteps(new PerformableSteps(null, stepMatches)); - performableScenario.useNormalScenario(normalScenario); - return root; - } - - -}