JBehave
  1. JBehave
  2. JBEHAVE-533

Bad encoding in JBehave Raports with default configuration from jbehave archetype in Windows

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows
    • Number of attachments :
      2

      Description

      I have created project from archetype with command:
      mvn archetype:generate -DarchetypeGroupId=org.jbehave -DarchetypeArtifactId=jbehave-spring-archetype
      and edited my.story file (added some international chars)

      After this
      There is:
      ??A scenario with some pending steps łóśťłśóaĹ›Δ™Ĺ‚??
      Should be:
      Scenario: A scenario with some pending steps łσśżłśσaśęł <- here is proper encoded letters

      I have edited pom.xml and added:
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> in properties section.

      The HTML and XML raport should be properly encoded after this. I think option -Dfile.encoding=UTF-8 should be not required for this. Maven project should have identical results on all platforms if properly configured.

        Activity

        Hide
        Mariusz Smykula added a comment - - edited

        Log from jbehave:

        ...

        [INFO] Using 'UTF-8' encoding to copy filtered resources.
        ...

        (BeforeStories)

        [INFO] Using 1 threads
        [INFO] Running story com/sample/spring/stories/my.story
        (com/sample/spring/stories/my.story)

        Scenario: A scenario with some pending steps łóśťłśóaĹ›Δ™Ĺ‚

        ...

        [INFO] Generating reports view to 'e:\Jenkins\jobs\sprint-jbehave-test\workspace\target\jbehave' using formats '[stats, console, txt, html, xml]' and view properties '

        Unknown macro: {defaultFormats=stats, decorateNonHtml=true, viewDirectory=view, decorated=ftl/jbehave-report-decorated.ftl, reports=ftl/jbehave-reports-with-totals.ftl, maps=ftl/jbehave-maps.ftl, navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl}

        '
        [testwar] DEBUG Could not find template in cache, creating new one; id=[ftl/jbehave-report-decorated.ftl[pl_PL,Cp1250,parsed] ]
        [testwar] DEBUG Compiling FreeMarker template ftl/jbehave-report-decorated.ftl[pl_PL,Cp1250,parsed] from jar:file:/C:/.m2/repository/org/jbehave/jbehave-core/3.4.2/jbehave-core-3.4.2.jar!/ftl/jbehave-report-decorated.ftl
        [testwar] DEBUG Could not find template in cache, creating new one; id=[ftl/sh.ftl[pl_PL,Cp1250,parsed] ]
        [testwar] DEBUG Compiling FreeMarker template ftl/sh.ftl[pl_PL,Cp1250,parsed] from jar:file:/C:/.m2/repository/org/jbehave/jbehave-core/3.4.2/jbehave-core-3.4.2.jar!/ftl/sh.ftl
        [testwar] DEBUG ftl/jbehave-report-decorated.ftl[pl_PL,Cp1250,parsed] cached copy not yet stale; using cached.
        [testwar] DEBUG ftl/sh.ftl[pl_PL,Cp1250,parsed] cached copy not yet stale; using cached.
        ....
        [testwar] DEBUG Could not find template in cache, creating new one; id=[ftl/jbehave-reports-with-totals.ftl[pl_PL,Cp1250,parsed] ]
        [testwar] DEBUG Compiling FreeMarker template ftl/jbehave-reports-with-totals.ftl[pl_PL,Cp1250,parsed] from jar:file:/C:/.m2/repository/org/jbehave/jbehave-core/3.4.2/jbehave-core-3.4.2.jar!/ftl/jbehave-reports-with-totals.ftl
        [testwar] DEBUG Could not find template in cache, creating new one; id=[ftl/jbehave-views.ftl[pl_PL,Cp1250,parsed] ]
        [testwar] DEBUG Compiling FreeMarker template ftl/jbehave-views.ftl[pl_PL,Cp1250,parsed] from jar:file:/C:/.m2/repository/org/jbehave/jbehave-core/3.4.2/jbehave-core-3.4.2.jar!/ftl/jbehave-views.ftl
        [INFO] Reports view generated with 3 stories (of which 1 pending) containing 1 scenarios (of which 0 failed and 1 pending)

        There is Cp1250, windows default encoding used.

        Show
        Mariusz Smykula added a comment - - edited Log from jbehave: ... [INFO] Using 'UTF-8' encoding to copy filtered resources. ... (BeforeStories) [INFO] Using 1 threads [INFO] Running story com/sample/spring/stories/my.story (com/sample/spring/stories/my.story) Scenario: A scenario with some pending steps łóśťłśóaĹ›Δ™Ĺ‚ ... [INFO] Generating reports view to 'e:\Jenkins\jobs\sprint-jbehave-test\workspace\target\jbehave' using formats ' [stats, console, txt, html, xml] ' and view properties ' Unknown macro: {defaultFormats=stats, decorateNonHtml=true, viewDirectory=view, decorated=ftl/jbehave-report-decorated.ftl, reports=ftl/jbehave-reports-with-totals.ftl, maps=ftl/jbehave-maps.ftl, navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl} ' [testwar] DEBUG Could not find template in cache, creating new one; id=[ftl/jbehave-report-decorated.ftl [pl_PL,Cp1250,parsed] ] [testwar] DEBUG Compiling FreeMarker template ftl/jbehave-report-decorated.ftl [pl_PL,Cp1250,parsed] from jar: file:/C:/.m2/repository/org/jbehave/jbehave-core/3.4.2/jbehave-core-3.4.2.jar!/ftl/jbehave-report-decorated.ftl [testwar] DEBUG Could not find template in cache, creating new one; id=[ftl/sh.ftl [pl_PL,Cp1250,parsed] ] [testwar] DEBUG Compiling FreeMarker template ftl/sh.ftl [pl_PL,Cp1250,parsed] from jar: file:/C:/.m2/repository/org/jbehave/jbehave-core/3.4.2/jbehave-core-3.4.2.jar!/ftl/sh.ftl [testwar] DEBUG ftl/jbehave-report-decorated.ftl [pl_PL,Cp1250,parsed] cached copy not yet stale; using cached. [testwar] DEBUG ftl/sh.ftl [pl_PL,Cp1250,parsed] cached copy not yet stale; using cached. .... [testwar] DEBUG Could not find template in cache, creating new one; id=[ftl/jbehave-reports-with-totals.ftl [pl_PL,Cp1250,parsed] ] [testwar] DEBUG Compiling FreeMarker template ftl/jbehave-reports-with-totals.ftl [pl_PL,Cp1250,parsed] from jar: file:/C:/.m2/repository/org/jbehave/jbehave-core/3.4.2/jbehave-core-3.4.2.jar!/ftl/jbehave-reports-with-totals.ftl [testwar] DEBUG Could not find template in cache, creating new one; id=[ftl/jbehave-views.ftl [pl_PL,Cp1250,parsed] ] [testwar] DEBUG Compiling FreeMarker template ftl/jbehave-views.ftl [pl_PL,Cp1250,parsed] from jar: file:/C:/.m2/repository/org/jbehave/jbehave-core/3.4.2/jbehave-core-3.4.2.jar!/ftl/jbehave-views.ftl [INFO] Reports view generated with 3 stories (of which 1 pending) containing 1 scenarios (of which 0 failed and 1 pending) There is Cp1250, windows default encoding used.
        Hide
        Mariusz Smykula added a comment -

        I have used jbehave-spring-archetype 3.5-SNAPSHOT, jbehave core is 3.4.2.

        Show
        Mariusz Smykula added a comment - I have used jbehave-spring-archetype 3.5-SNAPSHOT, jbehave core is 3.4.2.
        Hide
        Cristiano Gaviγo added a comment -

        If you set up Jbehave to work with UTF-8, You should ensure that your story file was properly created using UTF-8 too. It is?

        Show
        Cristiano Gaviγo added a comment - If you set up Jbehave to work with UTF-8, You should ensure that your story file was properly created using UTF-8 too. It is?
        Hide
        Mariusz Smykula added a comment -

        Yes, it is. All is fine if I run maven build with -Dfile.encoding=UTF-8, but this should be not needed.

        Show
        Mariusz Smykula added a comment - Yes, it is. All is fine if I run maven build with -Dfile.encoding=UTF-8, but this should be not needed.
        Hide
        Mariusz Smykula added a comment - - edited

        Sample project (other as described) with invalid encoding on Windows even with option -Dfile.encoding=UTF-8

        Sample log from this project:

        (BeforeStories)

        Using 2 threads
        Running story stories/sample.story

        (stories/sample.story)
        Scenario: Przykładowy scenariusz numer 1 śťół
        Given Given cośtamźłóś (PENDING)
        When Byłóśťźń�?ĹšΔ„ (PENDING)
        Then Byłóśťźń�?ĹšΔ„ (PENDING)
        @Given("Given co\u0139\u203Atam\u0139\u015F\u0139\u201A\u0102\u0142\u0139\u203A")

        Show
        Mariusz Smykula added a comment - - edited Sample project (other as described) with invalid encoding on Windows even with option -Dfile.encoding=UTF-8 Sample log from this project: (BeforeStories) Using 2 threads Running story stories/sample.story (stories/sample.story) Scenario: Przykładowy scenariusz numer 1 śťół Given Given cośtamźłóś (PENDING) When Byłóśťźń�?ĹšΔ„ (PENDING) Then Byłóśťźń�?ĹšΔ„ (PENDING) @Given("Given co\u0139\u203Atam\u0139\u015F\u0139\u201A\u0102\u0142\u0139\u203A")
        Mariusz Smykula made changes -
        Field Original Value New Value
        Attachment sample-wrong-encoding-prj.tar.gz [ 55513 ]
        Mariusz Smykula made changes -
        Attachment sample-wrong-encoding-prj.tar.gz [ 55513 ]
        Hide
        Mariusz Smykula added a comment - - edited

        Attached project is wrong always on Windows, with proper file.encoding too

        With -Dfile.encoding=UTF-8 log:

        (stories/sample.story)
        Scenario: Przykładowy scenariusz numer 1 śżσł
        Given Given cośtamźłσś (PENDING)
        When ByłσśżźńŚĄ (PENDING)
        Then Gżegżσłką (PENDING)
        @Given("Given co\u0139\u203Atam\u0139\u015F\u0139\u201A\u0102\u0142\u0139\u203A")
        ...
        Generating reports view to 'e:\Jenkins\jobs\jbehave-encoding-test\workspace\target\jbehave' using formats '[console, txt, html, stats]' and view properties '

        Unknown macro: {defaultFormats=stats, decorateNonHtml=true, viewDirectory=view, decorated=ftl/jbehave-report-decorated.ftl, reports=ftl/jbehave-reports-with-totals.ftl, maps=ftl/jbehave-maps.ftl, navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl}

        '
        [encoding-test] DEBUG Could not find template in cache, creating new one; id=[ftl/jbehave-report-decorated.ftl[pl_PL,Cp1250,parsed] ]
        [encoding-test] DEBUG Compiling FreeMarker template ftl/jbehave-report-decorated.ftl[pl_PL,Cp1250,parsed] from jar:file:/C:/.m2/repository/org/jbehave/jbehave-core/3.4.4/jbehave-core-3.4.4.jar!/ftl/jbehave-report-decorated.ftl
        [encoding-test] DEBUG Could not find template in cache, creating new one; id=[ftl/sh.ftl[pl_PL,Cp1250,parsed] ]
        [

        Show
        Mariusz Smykula added a comment - - edited Attached project is wrong always on Windows, with proper file.encoding too With -Dfile.encoding=UTF-8 log: (stories/sample.story) Scenario: Przykładowy scenariusz numer 1 śżσł Given Given cośtamźłσś (PENDING) When ByłσśżźńŚĄ (PENDING) Then Gżegżσłką (PENDING) @Given("Given co\u0139\u203Atam\u0139\u015F\u0139\u201A\u0102\u0142\u0139\u203A") ... Generating reports view to 'e:\Jenkins\jobs\jbehave-encoding-test\workspace\target\jbehave' using formats ' [console, txt, html, stats] ' and view properties ' Unknown macro: {defaultFormats=stats, decorateNonHtml=true, viewDirectory=view, decorated=ftl/jbehave-report-decorated.ftl, reports=ftl/jbehave-reports-with-totals.ftl, maps=ftl/jbehave-maps.ftl, navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl} ' [encoding-test] DEBUG Could not find template in cache, creating new one; id=[ftl/jbehave-report-decorated.ftl [pl_PL,Cp1250,parsed] ] [encoding-test] DEBUG Compiling FreeMarker template ftl/jbehave-report-decorated.ftl [pl_PL,Cp1250,parsed] from jar: file:/C:/.m2/repository/org/jbehave/jbehave-core/3.4.4/jbehave-core-3.4.4.jar!/ftl/jbehave-report-decorated.ftl [encoding-test] DEBUG Could not find template in cache, creating new one; id=[ftl/sh.ftl [pl_PL,Cp1250,parsed] ] [
        Mariusz Smykula made changes -
        Attachment wrong-encoding-sample-prj.tar.gz [ 55514 ]
        Mariusz Smykula made changes -
        Attachment wrong-encoding-sample-prj.zip [ 55515 ]
        Hide
        Mauro Talevi added a comment -

        Hi, so you seem to be using PL chars in the textual story but not in the Java steps class.

        Can you try running the trader-i18n example stories and see if they work for you?

        Show
        Mauro Talevi added a comment - Hi, so you seem to be using PL chars in the textual story but not in the Java steps class. Can you try running the trader-i18n example stories and see if they work for you?
        Hide
        Brian Repko added a comment -

        Was also wondering what the file.encoding setting is when the mvn archetype:generate was done. Is it possible that the archetype files are UTF-8 but then explode into the character encoding given at the time the project is created? Then we run them as if they are UTF-8 and they aren't. The trader-i18n will probably pull down as UTF-8 based on your git client.

        Show
        Brian Repko added a comment - Was also wondering what the file.encoding setting is when the mvn archetype:generate was done. Is it possible that the archetype files are UTF-8 but then explode into the character encoding given at the time the project is created? Then we run them as if they are UTF-8 and they aren't. The trader-i18n will probably pull down as UTF-8 based on your git client.
        Hide
        Mariusz Smykula added a comment -

        @Mauro Talevi

        Yes, in java steps there are only ASCII chars. Im not sure if @Given("Given co\u0139\u203Atam\u0139\u015F\u0139\u201A\u0102\u0142\u0139\u203A")
        should be escaped. Utf8 charset are legal in source code.

        Admin, please change topic of this bug and remove "from jbehave archetype", I have attached good example and this is not related to archetype. If not, I can fill another bug for this.

        Show
        Mariusz Smykula added a comment - @Mauro Talevi Yes, in java steps there are only ASCII chars. Im not sure if @Given("Given co\u0139\u203Atam\u0139\u015F\u0139\u201A\u0102\u0142\u0139\u203A") should be escaped. Utf8 charset are legal in source code. Admin, please change topic of this bug and remove "from jbehave archetype", I have attached good example and this is not related to archetype. If not, I can fill another bug for this.
        Hide
        Mariusz Smykula added a comment -

        I think this bug is related to Freemaker engine, which is ignoring -Dfile.encoding=utf8 flag and still using cp1250 on Windows.

        Show
        Mariusz Smykula added a comment - I think this bug is related to Freemaker engine, which is ignoring -Dfile.encoding=utf8 flag and still using cp1250 on Windows.
        Mariusz Smykula made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Duplicate [ 3 ]
        Hide
        Mariusz Smykula added a comment -

        Bugs moved to http://jira.codehaus.org/browse/JBEHAVE-538 - better description.

        Show
        Mariusz Smykula added a comment - Bugs moved to http://jira.codehaus.org/browse/JBEHAVE-538 - better description.

          People

          • Assignee:
            Unassigned
            Reporter:
            Mariusz Smykula
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: