JBehave
  1. JBehave
  2. JBEHAVE-729

Current path is converted to file:/home/.../ when accessing codeLocationFromClass from inside a jar

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.4
    • Fix Version/s: 3.6
    • Component/s: Core
    • Labels:
      None
    • Environment:
      linux, windows
    • Number of attachments :
      1

      Description

      I have tried to build a complete jbehave test into a jar file by maven assembly and then to run the test on another machine that doesn't have the dev system installed.

      e.g. java -cp "lib*" org.junit.runner.JUnitCore de.vodafone.jbehave.rrd.runner.Runner

      the reporter tries to create the files in a path that contains $PWD/file:/$PWD/lib/jbehave/view, so I assume the path is converted from the jar location to an url which then is used as a regular path, this doesn't work on Windows or creates a directory file: in linux.

      (In Linux it is possible to work around this by creating a symlink from / to file:)

      I'll try to attach an example project if I can narrow this down

        Activity

        Hide
        Mauro Talevi added a comment -

        Hi Alex, not at all clear what you mean by "running unit tests from inside a jar" nor what you're trying to do.

        Best to discuss on the user list.

        Show
        Mauro Talevi added a comment - Hi Alex, not at all clear what you mean by "running unit tests from inside a jar" nor what you're trying to do. Best to discuss on the user list.
        Hide
        Alexander Lehmann added a comment - - edited

        I have found the cause of the problem already, I just didn't get around to writing a test and fix yet.

        Essentially CodeLocations.codeLocationFromClass doesn't work correctly if the class is stored inside a jar

        (I'll write a more elaborate explanation tonight hopefully including a fix)

        Show
        Alexander Lehmann added a comment - - edited I have found the cause of the problem already, I just didn't get around to writing a test and fix yet. Essentially CodeLocations.codeLocationFromClass doesn't work correctly if the class is stored inside a jar (I'll write a more elaborate explanation tonight hopefully including a fix)
        Hide
        Alexander Lehmann added a comment -

        example project to display the behaviour

        Show
        Alexander Lehmann added a comment - example project to display the behaviour
        Alexander Lehmann made changes -
        Field Original Value New Value
        Attachment jbehave-file-bug.zip [ 59055 ]
        Hide
        Alexander Lehmann added a comment - - edited

        to reproduce the problem, run the project with mvn install package,
        the resulting file jbehave_file_bug-0.0.1-SNAPSHOT-bin.zip is a stand-alone java application that can run without any development environment installed (no maven or javac)

        when unpacking the zip to a new directory and running it as junit test, the wrong pathname shows up

        java -cp "lib/*" org.junit.runner.JUnitCore cx.lehmann.jbehave.file_bug.Runner

        Show
        Alexander Lehmann added a comment - - edited to reproduce the problem, run the project with mvn install package, the resulting file jbehave_file_bug-0.0.1-SNAPSHOT-bin.zip is a stand-alone java application that can run without any development environment installed (no maven or javac) when unpacking the zip to a new directory and running it as junit test, the wrong pathname shows up java -cp "lib/*" org.junit.runner.JUnitCore cx.lehmann.jbehave.file_bug.Runner
        Show
        Alexander Lehmann added a comment - https://github.com/alexlehm/jbehave-core/commit/31ef505512d17f54f9ae5d47a14c722ddd166992 handle jar paths correctly
        Mauro Talevi made changes -
        Affects Version/s 3.6 [ 17721 ]
        Fix Version/s 3.6 [ 17721 ]
        Affects Version/s 3.5.4 [ 18081 ]
        Hide
        Mauro Talevi added a comment -

        Pulled and applied patch with thanks!

        Show
        Mauro Talevi added a comment - Pulled and applied patch with thanks!
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Alexander Lehmann added a comment -

        Actually, the title could be changed to "When running codeLocationFromClass inside a jar, the current path is converted to file:/home/.../file:/home/..."

        Show
        Alexander Lehmann added a comment - Actually, the title could be changed to "When running codeLocationFromClass inside a jar, the current path is converted to file:/home/.../file:/home/ ..."
        Mauro Talevi made changes -
        Summary When running jbehave unit tests from inside a jar, the current path is converted to file:/home/.../  When acccessing codeLocationFromClass from inside a jar, the current path is converted to file:/home/.../
        Mauro Talevi made changes -
        Summary  When acccessing codeLocationFromClass from inside a jar, the current path is converted to file:/home/.../ When acccessing codeLocationFromClass from inside a jar, the current path is converted to file:/home/.../
        Mauro Talevi made changes -
        Summary When acccessing codeLocationFromClass from inside a jar, the current path is converted to file:/home/.../ Current path is converted to file:/home/.../ when accessing codeLocationFromClass from inside a jar

          People

          • Assignee:
            Unassigned
            Reporter:
            Alexander Lehmann
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: