Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

How to run the Test Suite against the latest release

Micah Silverman edited this page Jan 11, 2016 · 2 revisions

The script pasted below will run all the unit and integration tests against the latest Java SDK version released on Maven Central. It does this by:

  1. Grabbing the latest version identifier from Maven Central
  2. Cloning the Java SDK repository
  3. Checking out the tag identified by the latest version
  4. Running all the tests.

This is useful if you want to run all the tests against the latest release without having to alter your working directory of the Java SDK project.

Note: You'll need to have two Stormpath Tenants setup. The first should have the application limit raised to about 100. The second one should have the default application limit.

Execute the shell script below like so:

STORMPATH_BASE_URL=<base url. usually: https://api.stormpath.com/v1> \
STORMPATH_TEST_APPLICATION_HREF=<href to "My Application" in the first tenant> \
STORMPATH_API_KEY_ID=<api key id from first tenant> \
STORMPATH_API_KEY_SECRET=<api key secret from first tenant> \
STORMPATH_API_KEY_ID_TWO_APP=<api key id from second tenant> \
STORMPATH_API_KEY_SECRET_TWO_APP=<api key secret from second tenant> \
./jsdk_test_latest_version.sh

Here's the jsdk_test_latest_version.sh script:

#! /bin/bash

## Internal Stormpath: Refer to https://stormpath.atlassian.net/wiki/display/SDKS/Testing+Environments
## for the environment variable settings below

[ -z "$STORMPATH_BASE_URL" ] && echo "Need to set STORMPATH_BASE_URL" && exit 1
[ -z "$STORMPATH_TEST_APPLICATION_HREF" ] && echo "Need to set STORMPATH_TEST_APPLICATION_HREF" && exit 1
[ -z "$STORMPATH_API_KEY_ID" ] && echo "Need to set STORMPATH_API_KEY_ID" && exit 1
[ -z "$STORMPATH_API_KEY_SECRET" ] && echo "Need to set STORMPATH_API_KEY_SECRET" && exit 1
[ -z "$STORMPATH_API_KEY_ID_TWO_APP" ] && echo "Need to set STORMPATH_API_KEY_ID_TWO_APP" && exit 1
[ -z "$STORMPATH_API_KEY_SECRET_TWO_APP" ] && echo "Need to set STORMPATH_API_KEY_SECRET_TWO_APP" && exit 1

REPO_DIR="stormpath-sdk-java"
[ -d $REPO_DIR ] && echo "Repo directory: $REPO_DIR already exists. Rename or remove it and rerun the script." && exit 1

# query maven central. return json. 
MAVEN_VERSION_INFO=`curl -s "https://search.maven.org/solrsearch/select?q=stormpath-sdk-root&wt=json"`
REGEX='"latestVersion":"(.*)","repositoryId"'

# extract the latest JSDK version from the json response
if [[ $MAVEN_VERSION_INFO =~ $REGEX ]]; then
  SDK_VERSION=${BASH_REMATCH[1]}
else
  echo "Something's gone horribly wrong! Couldn't get the latest SDK version."
  exit 1;
fi

git clone https://github.com/stormpath/stormpath-sdk-java.git
if [ $? -ne 0 ]; then 
  echo "git clone failed. Bailing."
  exit 1
fi

cd stormpath-sdk-java 

git checkout stormpath-sdk-root-$SDK_VERSION
if [ $? -ne 0 ]; then 
  echo "checkout tag: stormpath-sdk-root-$SDK_VERSION failed. Bailing."
  exit 1
fi

mvn --fail-never -DskipITs=false clean verify && echo "All tests passed. Hooray!" || echo "Some tests failed. Boo."