Simple Spark Java app with support for Selenium testing. The App serves Chuck Norris jokes in a Web application.
- Java JDK (openjdk-7-jdk recommended)
git clone
this repo../gradlew run
in the repo's base folder.- Check out a random joke on localhost:4567.
- Check out a specific joke (number 5) on localhost:4567/id/5.
To run SparkApp on another port ID, export PORT environmental variable to a valid integer port and it will be used.
export PORT=1337
./gradlew run
./gradlew test
- simple enough.
- For running locally on your MacOS/Linux computer, you'll need to install Firefox 28.0
- Newer versions might work, but 28.0 will work, so ...
- You can grab Firefox 28.0 here.
- Friendly note: Make sure autoupdate is turned off.
- For all systems you must expose Firefox in your path (how to do so depends on what OS you are running, so please Bing for answers).
- For running on Servers (GreenQloud for example) where you do not have a GUI, you'll need to install X Virtual Frame Buffer (xvfb) and additional packages and Firefox 28.0.
sudo apt-get install -y xvfb
sudo apt-get install -y xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
sudo apt-get install -y firefox=28.0+build2-0ubuntu2
- For running on Windows:
- Java JDK 7 in your Path (Example
C:\Program Files\Java\openjdk-7.0.71\bin
) - Firefox 28.0 needs to be accesible from the Command Line
- Change lines in
build.gradle
that run the server in theselenium.doFirst
task to use a valid Windows Path, something likeC:\\path-to-project\\build\\install\\sparkit\\bin\\sparkit.bat
(not tested).
- Java JDK 7 in your Path (Example
Note if installing firefox on the server doesn't work, you can do the following:
sudo apt-get purge firefox
cd /tmp
wget https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/28.0/linux-x86_64/en-US/firefox-28.0.tar.bz2
tar xvjf firefox-28.0.tar.bz2
sudo mv firefox/ /opt/firefox28
sudo ln -s /opt/firefox28/firefox /usr/bin/firefox
- Locally just do
./gradlew selenium
- Headless mode on servers:
export DISPLAY=:99
./gradlew seleniumXvfb
Gradle creates test reports for us. Look at the build/reports
folder for more sweet Gradle juice.