The spring-security example uses the pseudo URL of
"classpath:..." for the stories and then loads them using the
spring classes.
This is sort of dumb at this point of JBehave but hopefully that
shows the difference between its name/URL and how its loaded.

I think the google docs example as well should show some of
this...

Brian

----- Original message -----
From: "Cristiano Gavião" <[1][email protected]>
To: [2][email protected]
Date: Thu, 08 Mar 2012 16:54:07 -0300
Subject: Re: [jbehave-user] Finding stories with absolute paths
Graham,
Just to complement my last email, anothers examples that shows
more combination of StoryLoader + StoryFinder:
To run JBehave inside an OSGi application, I can't use the normal
StoryFinder (due to classloading issues), so I had to create a
specific one to get stories from the osgi classpath, see:

  @RunWith(AnnotatedEmbedderRunner.class)
  @Configure(using = MyOsgiConfiguration.class,
  stepPatternParser = MyRegexPrefixCapturingPatternParser.class,
  storyControls = MyStoryControls.class, storyLoader =
  MyStoryLoader.class, storyReporterBuilder =
  MyReportBuilder.class, parameterConverters = {
  MyDateConverter.class })
  @UsingEmbedder(embedder = MyEmbedder.class,
  generateViewAfterStories = true, ignoreFailureInStories =
  false, ignoreFailureInView = false, verboseFailures = true,
  storyTimeoutInSecs = 100, threads = 1, metaFilters = "-skip")
  @UsingSteps(instances = { MyLifeCycleSteps.class,
          MyInjectedAuthenticationSteps.class,
  MyScreenshotOnFailureSteps.class })
  public class TaskManagerApplicationAnnotatedEmbedder extends
  InjectableEmbedder {
      @Test
      public void run() {
          List<String> storyPaths = new
  OsgiStoryFinder().findPaths(
                  "/stories/application", "*.story", "");
          injectedEmbedder().runStoriesAsPaths(storyPaths);
      }

  public static class MyStoryLoader extends LoadFromClasspath {
          public MyStoryLoader() {
              super();
          }
      }

And another example is in the jbehave-trader-urls-example, where
we get stories from a URL ( That could be a remote REST server, a
local one or we can create another combination to get stories
from any place)

  public class URLTraderStories extends TraderStories {
      public URLTraderStories() {
      }
      @Override
      public Configuration configuration() {
          Configuration configuration =
  super.configuration();
          StoryReporterBuilder builder =
  configuration.storyReporterBuilder();
          builder.withPathResolver(new ResolveToSimpleName());
          return configuration.useStoryLoader(new
  LoadFromURL());
      }
      @Override
      protected List<String> storyPaths() {
          // Specify story paths as URLs
          String codeLocation =
  codeLocationFromPath("../trader/src/main/java").getFile();
          return new StoryFinder().findPaths(codeLocation,
  asList("**/trader_is_alerted_of_status.story",
                  "**/traders_can_be_subset.story"), asList(""),
  "file:" + codeLocation);
      }

regards,
Cristiano
On 08/03/12 15:30, Graham Abell wrote:

  Hi Christiano,



Thanks for the input. Can I ask what's in your MyStoryLoader
class?



This is the part that I don't understand. Why do we need to
specify a storyLoader when we're providing the stories
explicitly?



thanks!

graham
On 8 March 2012 18:19, Cristiano Gavião <[3][email protected]>
wrote:

Graham, for me, using Embedder is the best for such needs...  the
example that was given for Zoltan is a little bit confuse,
actually...
Look at the example below. I'm specifying the Step classes that I
want and the local where the stories should be searched (in my
case its using the classpath).
Note that the Embedder always needs ONE Configuration object
wherever it comes from. If none is informed it will use a default
one:

  @RunWith(AnnotatedEmbedderRunner.class)
  @Configure(using = MyConfiguration.class, stepPatternParser =
  MyRegexPrefixCapturingPatternParser.class, storyControls =
  MyStoryControls.class, storyLoader = MyStoryLoader.class,
  storyReporterBuilder = MyReportBuilder.class,
  parameterConverters = { MyDateConverter.class })
  @UsingEmbedder(systemProperties =
  "JBEHAVE_WEBDRIVER_FIREFOX_PROFILE=jbehave", embedder =
  MyEmbedder.class, generateViewAfterStories = true,
  ignoreFailureInStories = false, ignoreFailureInView = false,
  verboseFailures = true, storyTimeoutInSecs = 100, threads = 1,
  metaFilters = "-skip")
  @UsingSteps(instances = { MyLifeCycleSteps.class,
          MyInjectedAuthenticationSteps.class })
  public class TaskManagerApplicationAnnotatedEmbedder extends
  InjectableEmbedder {
      private static final WebDriverProvider
  staticDriverProvider = new FirefoxWebDriverProvider();
      private static WebDriverSteps lifecycleSteps = new
  PerStoriesWebDriverSteps(
              staticDriverProvider);
      private static final TaskWebPageFactory pages = new
  TaskWebPageFactory(
              staticDriverProvider);
      private static SeleniumContext context = new
  SeleniumContext();
      private static ContextView contextView = new
  LocalFrameContextView().sized(
              500, 100);
      @Test
      public void run() {
          List<String> storyPaths = new StoryFinder().findPaths(

  codeLocationFromClass(this.getClass()).getFile(),
                  asList("**/*.story"), null);
          injectedEmbedder().runStoriesAsPaths(storyPaths);
      }
      public static class MyConfiguration extends
  SeleniumConfiguration {
          public MyConfiguration() {
              useFailureStrategy(new RethrowingFailure());
              usePendingStepStrategy(new
  FailingUponPendingStep());
              useSeleniumContext(context);
              useWebDriverProvider(staticDriverProvider);
              useStepMonitor(new
  SeleniumStepMonitor(contextView, context,
                      new SilentStepMonitor()));
          }
      }

On 08/03/12 14:24, Graham Abell wrote:

  Hi Mauro,



in the example Zoltan gave, what's the point of providing the
story paths to the embedder if you then have to specify a
location in the config? Is there a way around that or which one
takes precedence?



cheers,

graham

On 8 March 2012 16:55, Mauro Talevi
<[4][email protected]> wrote:

  Hi,
  you can use the StoryFinder with the
  CodeLocations.codeLocationFromPath("/your/absolute/path") as
  your searchIn URL.
  Cheers

On 08/03/2012 17:20, Penzeli, Zoltan wrote:

  Hi All,
  We are in the middle of creating our BDD framework, and
  haven't yet
  decided where our .story files will be - but most likely they
  will be in
  a directory well separated from our Java project.
  We tried the following code:
  ****************************
  public Configuration configuration() {
          URL url = null;
          try {
              url = new URL("file://" +
  System.getProperty("user.dir") +
  "/JBehave/src");
          } catch (MalformedURLException e) {
              return null;
          }
          Class<?>  embedderClass = this.getClass();
          URL codeLocation =
  CodeLocations.codeLocationFromClass(embedderClass);
          Configuration configuration = new
  MostUsefulConfiguration()
                  .useStoryLoader(new LoadFromRelativeFile(url))
                  .useStoryReporterBuilder(new
  StoryReporterBuilder()
                          .withCodeLocation(codeLocation)
                          .withDefaultFormats());
          return configuration;
      }
  ****************************
  public void SmoketestSteps() {
          Embedder embedder = new StackEmbedder();
          StoryFinder finder = new StoryFinder();
          String storyLocation = System.getProperty("user.dir")
  +
  "/JBehave/src/";
          List<String>  storyPaths =
  finder.findPaths(storyLocation,
                  Arrays.asList("**/*.story"),
                  Arrays.asList("**/*smoke*"),
                  "");
          embedder.runStoriesAsPaths(storyPaths);
    }
  (Actually it did us a bit of a time to realise what kind of
  StoryLoader
  we should use...)
  It seems to be running but nothing is actually executed.
  Moreover, we
  couldn't really understand what's the function of the
  constructor of
  LoadFromRelativeFile() AND the first parameter of
  finder.findPaths().
  The latter doesn't seem to have any effect on the execution.
  We couldn't find any concrete example how Stories could be
  found and run
  from _absolute_ paths - if this is possible at all with the
  current
  code.
  It would nice if someone could provide one...
  Best Regards,
  Zoltan
  ______________________________________________________________
  __________
  Privileged, confidential and/or copyright information may be
  contained in this communication. This e-mail and any files
  transmitted with it are confidential and intended solely for
  the use of the individual or entity to whom they are
  addressed. If you are not the intended addressee, you may not
  copy, forward, disclose or otherwise use this e-mail or any
  part of it in any way whatsoever. To do so is prohibited and
  may be unlawful. If you have received this email in error
  please notify the sender immediately.
  Paddy Power PLC may monitor the content of e-mail sent and
  received for the purpose of ensuring compliance with its
  policies and procedures.
  Paddy Power plc, Power Tower, Blocks 1-3 Belfield Office Park,
  Beech Hill Road, Clonskeagh, Dublin 4.  Registered in Ireland:
  16956
  ______________________________________________________________
  __________
  --------------------------------------------------------------
  -------
  To unsubscribe from this list, please visit:
      [5]http://xircles.codehaus.org/manage_email


-----------------------------------------------------------------
----
To unsubscribe from this list, please visit:
  [6]http://xircles.codehaus.org/manage_email

References

1. mailto:[email protected]
2. mailto:[email protected]
3. mailto:[email protected]
4. mailto:[email protected]
5. http://xircles.codehaus.org/manage_email
6. http://xircles.codehaus.org/manage_email

Reply via email to