Using REST to access remote resources

REST is a commonly-used protocol to provide access to remote resources.

JBehave supports accessing resources via REST using the jbehave-rest module.

REST is typically used to access wikis. Each REST provider has its own API.

Using provider-specific components

JBehave allows provider-specific implementation of the following interface:

Currently supported as REST providers are Redmine and XWiki. Also supported for resource indexing and loading (but not for uploading) is Confluence.

JBehave allows provider-agnostic components for importing/export from/to providers:

Currently supported are filesystem-based import/export implementations:

Typically, importer/exporter implementations will be injected with provider-specific implementations of resource indexer, loader and uploader.

Using Maven goals

The import/export filesystem functionality is also exposed via Maven goals:

<plugin>
    <groupId>org.jbehave</groupId>
    <artifactId>jbehave-rest</artifactId>
    <version>[version]</version>
    <executions>
        <execution>
            <id>import-to-filesystem</id>
            <phase>process-resources</phase>
            <configuration>
                <restProvider>xwiki</restProvider>
                <restRootURI>http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages</restRootURI>
                <restUsername>[optional]</restUsername>
                <restPassword>[optional]</restPassword>
                <resourcesPath>[optional|src/main/resources/stories]</resourcesPath>
                <resourcesExt>[optional|.story]</resourcesExt>
            </configuration>
            <goals>
                <goal>import-to-filesystem</goal>
            </goals>
        </execution>
        <execution>
            <id>export-from-filesystem</id>
            <phase>process-resources</phase>
            <configuration>
                <restProvider>xwiki</restProvider>
                <restRootURI>http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages</restRootURI>
                <restUsername>[optional]</restUsername>
                <restPassword>[optional]</restPassword>
                <resourcesPath>[optional|src/main/resources/stories]</resourcesPath>
                <resourcesExt>[optional|.story]</resourcesExt>
                <resourcesIncludes>[optional|**]</resourcesIncludes>
            </configuration>
            <goals>
                <goal>export-from-filesystem</goal>
            </goals>
        </execution>
    </executions>
</plugin>

In command-line, without the need to configure the plugin in a pom.xml:

mvn org.jbehave:jbehave-rest:import-to-filesystem   -Djbehave.rest.rootURI=http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages
                                                    -Djbehave.rest.resourcesPath=src/main/resources/stories -Djbehave.rest.resourcesExt=.story
mvn org.jbehave:jbehave-rest:export-from-filesystem -Djbehave.restRootURI=http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages
                                                    -Djbehave.rest.resourcesPath=src/main/resources/stories -Djbehave.rest.resourcesExt=.story
                                                    -Djbehave.rest.resourcesIncludes=**/*.story