Skip to content

A demo of Asciidoctor running in a Java Servlet and managed by a CDI bean using the Asciidoctor Java integration library

Notifications You must be signed in to change notification settings

mojavelinux/asciidoctor-servlet-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asciidoctor Servlet Demo

This project demonstrates the use of the Asciidoctor Java integration library in a Servlet. The integration is bootstrapped and configured in an application-scoped CDI bean. The Servlet then invokes that bean to render the AsciiDoc source submitted from a web form.

All of the functionality is tested by Arquillian.

Screenshot

Screenshot of the Asciidoctor Servlet demo

Running the application

Java EE 6 server

  1. Import the project into your IDE

  2. Run the project on a Java EE 6 server (e.g., GlassFish 3.1.2)

  3. Visit http://localhost:8080/asciidoctor-servlet/asciidoctor

  4. Submit the form to see the HTML Asciidoctor generates from the AsciiDoc source

Warning
At the moment, the Asciidoctor Java integration does not work in some modular environments, such as Wildfly (i.e., JBoss AS 7). The Asciidoctor team is exploring this issue and will update these instructions once a solution is found.

Tomcat 7

You can also deploy demo to Tomcat 7 server.

  1. Start your Tomcat server

  2. Run mvn clean install tomcat7:deploy -Ptomcat

  3. Visit http://localhost:8080/asciidoctor-servlet/asciidoctor

  4. Submit the form to see the HTML Asciidoctor generates from the AsciiDoc source

Screenshot of the AsciiDoc source rendered as HTML

Running the tests

The tests are configured to run in GlassFish. If there is a GlassFish server already running, Arquillian will use that one. Otherwise, you need to specify the path to your GlassFish installation in [path]'src/main/resources/arquillian.xml'

Tip
If your GlassFish installation is located at [path]'${user.home}/opt/glassfish', no configuration is required.

Once GlassFish is ready to go, simply run the tests using the normal Maven test goal:

$ mvn test

There tests are run:

AsciidoctorProcessorInContainerTest

An in-container Arquillian test that tests the AsciidoctorProcessor CDI bean

AsciidoctorServletDroneTest

A WebDriver test, orchestrated by Arquillian Drone, that tests the web UI using Firefox

AsciidoctorServletWarpTest

An Arquillian Warp test that tests the web UI and Servlet simultaneously

Note

You may notice that the tests run quite slowly. That delay is due to the fact that JRuby has to bootstrap for each new deployment.

You can make JRuby boot quicker by setting the JRUBY_OPTS environment variable, as shown below, in the terminal where you start GlassFish.

$ export JRUBY_OPTS="-client -J-Xverify:none -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1"

About

A demo of Asciidoctor running in a Java Servlet and managed by a CDI bean using the Asciidoctor Java integration library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages