Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have had some success subclassing the org.jbehave.core.io.LoadFromClasspath class, which I use in my configuration as the story loader, i.e.</p> <pre><code>MostUsefulConfiguration().useStoryLoader(new LoadFromClasspathUtf8()); </code></pre> <p>here's my subclass with the proper method override:</p> <pre><code>import java.io.IOException; import java.io.InputStream; import org.apache.commons.io.IOUtils; import org.jbehave.core.io.InvalidStoryResource; import org.jbehave.core.io.LoadFromClasspath; public class LoadFromClasspathUtf8 extends LoadFromClasspath { public LoadFromClasspathUtf8(Class&lt;?&gt; loadFromClass) { super(loadFromClass); } public LoadFromClasspathUtf8(ClassLoader classLoader) { super(classLoader); } @Override public String loadResourceAsText(String resourcePath) { InputStream stream = resourceAsStream(resourcePath); try { return IOUtils.toString(stream, "UTF-8"); } catch (IOException e) { throw new InvalidStoryResource(resourcePath, stream, e); } } } </code></pre> <p>I say "I had some success" because when I look at the logs of my jbehave execution, accented french characters like è,à,é etc. are replaced by ?, but then, jbehave still matches this correctly to the steps using the regular RegexStoryParser. I didn't take time to investigate why this is, but I'm satisfied that my stories work correctly now.</p> <p>I also added the file.encoding system property to my plugin configuration to make it clear that I intend to use UTF-8 encoding.</p>
 

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