Details
-
Type: Bug
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: 3.9.5
-
Fix Version/s: 3.10
-
Component/s: Core
-
Labels:None
-
Environment:Windows 7 x64
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
-
Number of attachments :
Description
Current implementation of 'org.jbehave.core.reporters.FilePrintStreamFactory.ResolveToPackagedName' is the following:
public static class ResolveToPackagedName extends AbstractPathResolver { public String resolveName(StoryLocation storyLocation , String extension) { String name = storyLocation .getPath().replace('/', '.'); if (name .startsWith(".")) { name = name.substring(1); } return StringUtils.substringBeforeLast( name, ".") + "." + extension ; } }
In the case StoryLocation is represented by URL:
StoryLocation[codeLocation=file:/C:/Users/dpelevin/git/test/build/classes/test/,storyPath=file:/C:/Users/dpelevin/git/test/build/resources/test/stories/test.story,storyPathIsURL=true]
we will get name with unescaped ':' characters:
C:\Users\dpelevin\git\test\build\classes\jbehave\file:.C:.Users.dpelevin.git.test.build.resources.test.stories.test.stats
Such names are not valid on Windows and JBehave fail with:
java.io.FileNotFoundException: C:\Users\dpelevin\git\test\build\classes\jbehave\file:.C:.Users.dpelevin.git.test.build.resources.test.stories.test.stats (Syntax error in the file name, directory name, or volume label) java.io.FileOutputStream.open(Native Method) java.io.FileOutputStream.<init>(FileOutputStream.java:221) org.jbehave.core.reporters.FilePrintStreamFactory$FilePrintStream.<init>(FilePrintStreamFactory.java:138) org.jbehave.core.reporters.FilePrintStreamFactory.createPrintStream(FilePrintStreamFactory.java:38) org.jbehave.core.reporters.Format$9.createStoryReporter(Format.java:108) org.jbehave.core.reporters.StoryReporterBuilder.reporterFor(StoryReporterBuilder.java:316) org.jbehave.core.reporters.StoryReporterBuilder.build(StoryReporterBuilder.java:292) org.jbehave.core.configuration.Configuration.storyReporter(Configuration.java:208) org.jbehave.core.embedder.StoryRunner.reporterFor(StoryRunner.java:358), org.jbehave.core.embedder.StoryRunner.runCancellable(StoryRunner.java:235) org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:219), org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:180) org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:229) org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:201) java.util.concurrent.FutureTask.run(FutureTask.java:262) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) java.lang.Thread.run(Thread.java:745)
WORKAROUND:
Use 'org.jbehave.core.reporters.FilePrintStreamFactory.ResolveToSimpleName' instead of 'ResolveToPackagedName'.
POSSIBLE SOLUTION:
Use only substring that start from next character after last ':'. In this case we will cut off protocol and disk name, preserving only full path from the disk root.
Invalid of invalid name:
C:\Users\dpelevin\git\test\build\classes\jbehave\file:.C:.Users.dpelevin.git.test.build.resources.test.stories.test.stats
we will get valid one:
C:\Users\dpelevin\git\test\build\classes\jbehave\.Users.dpelevin.git.test.build.resources.test.stories.test.stats
Activity
Mauro Talevi
made changes -
Field | Original Value | New Value |
---|---|---|
Affects Version/s | 3.x [ 16979 ] | |
Affects Version/s | 3.9.5 [ 20598 ] | |
Fix Version/s | 3.9.6 [ 20672 ] |
Could you please provide an example project reproducing this behaviour, in particular the configuration you use.