Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had exactly the same problem. By default, JBehave doesn't honor platform encoding. In order to fix this, you can use this custom StoryLoader which honors file.encoding system property:</p> <pre><code>import java.io.IOException; import java.io.InputStream; import java.nio.charset.Charset; import org.apache.commons.io.IOUtils; import org.jbehave.core.io.InvalidStoryResource; import org.jbehave.core.io.LoadFromClasspath; /** * @author cedric.vidal * */ public class FixedStoryLoader extends LoadFromClasspath { public String loadResourceAsText(String resourcePath) { InputStream stream = resourceAsStream(resourcePath); try { return IOUtils.toString(stream, platformCharset().name()); } catch (IOException e) { throw new InvalidStoryResource(resourcePath, stream, e); } } public static Charset platformCharset() { String csn = System.getProperty("file.encoding"); Charset cs = Charset.forName(csn); if (cs == null) { cs = Charset.forName("UTF-8"); } return cs; } } </code></pre> <p>Register it in JBehave configuration with:</p> <pre><code>new MostUsefulConfiguration().useStoryLoader(new FixedStoryLoader()); </code></pre> <p>Configure your POM to use UTF-8 in all respectfull plugins (will be used by m2eclipse too):</p> <pre><code>&lt;properties&gt; &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt; &lt;/properties&gt; </code></pre> <p>And tell the JBehave Maven Plugin to use it also (look for the systemProperties block):</p> <pre><code> &lt;plugin&gt; &lt;groupId&gt;org.jbehave&lt;/groupId&gt; &lt;artifactId&gt;jbehave-maven-plugin&lt;/artifactId&gt; &lt;version&gt;${jbehave.core.version}&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;unpack-view-resources&lt;/id&gt; &lt;phase&gt;process-resources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;unpack-view-resources&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;embeddable-stories&lt;/id&gt; &lt;phase&gt;integration-test&lt;/phase&gt; &lt;configuration&gt; &lt;includes&gt; &lt;include&gt;${embeddables}&lt;/include&gt; &lt;/includes&gt; &lt;excludes/&gt; &lt;systemProperties&gt; &lt;property&gt; &lt;name&gt;file.encoding&lt;/name&gt; &lt;value&gt;${project.build.sourceEncoding}&lt;/value&gt; &lt;/property&gt; &lt;/systemProperties&gt; &lt;ignoreFailureInStories&gt;true&lt;/ignoreFailureInStories&gt; &lt;ignoreFailureInView&gt;false&lt;/ignoreFailureInView&gt; &lt;threads&gt;1&lt;/threads&gt; &lt;metaFilters&gt; &lt;metaFilter/&gt; &lt;/metaFilters&gt; &lt;/configuration&gt; &lt;goals&gt; &lt;goal&gt;run-stories-as-embeddables&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload