Uploaded image for project: 'JBehave'
  1. JBEHAVE-763

LoadFromRelativeFile break on windows when using maven traversal

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.6.1
    • Fix Version/s: 3.6.3
    • Component/s: Core
    • Labels:
      None
    • Environment:

      Windows Vista

      Description

      When invoking LoadFromRelativeFile and passing in a traversal substitution stories are not found because the substitution is not applied. This is due to the difference in the StoryFilePath which forces path separators to be '/'. When the LoadFromRelativeFile code gets the absolute path of location file separators are converted to '\'. This keeps the locationPath.replace code from working

      Im invoking the code as..

      public Configuration configuration() {
      return new MostUsefulConfiguration() // where to find the stories
      .useStoryLoader(new LoadFromRelativeFile(CodeLocations.codeLocationFromClass(getClass()), LoadFromRelativeFile.mavenModuleTestStoryFilePath("src/test/resources/jbehave/")))
      .useStoryReporterBuilder(
      new StoryReporterBuilder().withDefaultFormats()
      .withFormats(Format.CONSOLE, Format.TXT));

      The code that breaks in LoadFromRelativeFile that break is

      String locationPath = new File(CodeLocations.getPathFromURL(location)).getAbsolutePath();
      for (StoryFilePath traversal : traversals)

      { String filePath = locationPath.replace(traversal.toRemove, traversal.relativePath) + "/" + resourcePath; locationPath would have all '/' converted to '\' by getAbsolutePath on windows machines. Maybe the following line should be inserted after the definition of locationPath locationPath = locationPath.replace("\\","/"); }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ricardolopez Ricardo Lopez
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: