>From 0e772c84fd7da2476733f3ea517e7e404fe8e1d4 Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Fri, 8 Nov 2013 11:41:42 -0500
Subject: [PATCH] Provide build scripts for the Java test classes.

Added the scripts to compile the java test sources when trying
to build a beaker test rpm. This is required in a CI setup as the
source is freshly checked out and the build is automated.

Tickets 725, 785
---
 README_FOR_TESTS                 | 43 ++++++++++++++++++++++++++++++++++++++++
 scripts/compose_pki_test_package | 26 +++++++++++++++++++++++-
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/README_FOR_TESTS b/README_FOR_TESTS
index f690fcbb4ddc499e032759c3e325d13a39a8bc32..3ca143519f1e03ba4d3d32e10eb6790e074cbc7d 100644
--- a/README_FOR_TESTS
+++ b/README_FOR_TESTS
@@ -178,3 +178,46 @@
 
 **Note- In the case of creating a repository on a remote machine, the remote
         machine must be a known_host to the local machine.
+
+2. Setting up a Jenkins server for continuous integration testing
+
+  -- Install Jenkins. (It is better to configure the Jenkins server to use a
+                       port other than 8080)
+
+  -- Create a New Project - ex: Dogtag-pki
+
+  -- Configuring the project (Click on "Configure" in the left panel):
+
+     * Setting up the workspace:
+
+       i. For continuous integration, the project can be configured to clone
+          the source from the repository (git://git.fedorahosted.org/git/pki.git).
+          To use the Git SCM, install the Jenkins-Git plugin.
+          Goto Jenkins -> Manage Jenkins -> Manage Plugins to find and install
+          the plugin. The Git option can be found in the SCM section.
+
+       ii. For using the working project directory as the source to build the
+           rpms - Select None in the SCM section and set the path to the
+           project root (pki) as custom workspace in the Advanced Project Options section.
+           Click on Advanced -> Select Use custom workspace -> Enter the path.
+
+   -- Building the rpms and running the tests.
+
+      In the "Build" section, select "Add build step" -> "Execute Shell"
+      Paste the following code in the Command text box.
+
+      cd $WORKSPACE/scripts; ./compose_pki_core_packages [--createrepo=<repository_file_absolute_path>] hybrid_rpms
+      echo "Compose the test package and submit the beaker task and job"
+      cd $WORKSPACE/scripts; ./compose_pki_test_package <UserID> <Job_XML_config_file_absolute_path> --runtests
+
+      This will build the rpms, create the repo(if specified), compose
+      the test rpm and submit the tests to the beaker.
+      (The description to the commands used and setting up the beaker-client
+       are specified in the previous sections of this document)
+
+   -- The Build Triggers section provides options for specifying the time at
+      which a new build can be triggered - periodically or on a git commit.
+
+   -- If no Build triggers are configured in the project, the build process can be initiated by clicking on "Build Now" link in the left panel.
+      The console output can be viewed by clicking the "Console Output" link.
+
diff --git a/scripts/compose_pki_test_package b/scripts/compose_pki_test_package
index 075495489b96fda39039313cf3bd5d5e127b23e9..eca169f6b0d1f6568c7357b2ffe9393fe12f6b02 100755
--- a/scripts/compose_pki_test_package
+++ b/scripts/compose_pki_test_package
@@ -61,7 +61,31 @@ cd $BUILD_DIR
 
 cp -r "$PKI_SOURCE_DIR/tests" .
 
-cd tests/dogtag
+### Compile the java test source ###
+
+if [ ! -d "$PKI_SOURCE_DIR/build/classes" ] ; then
+
+   echo "\nThe java tests cannot be compiled since the pki source is not compiled/built.\n"
+   echo "The core sources can be compiled either by eclipse or using the compose scripts.\n"
+   echo "Cannot build the test RPM."
+
+   exit -1
+
+fi
+
+cd tests/dogtag/dev_java_tests
+
+rm -rf bin
+
+mkdir bin
+
+CLASSPATH=$PKI_SOURCE_DIR/build/classes:/usr/share/java/junit4.jar:`pwd`/src:/usr/lib64/jss/jss4.jar:/usr/share/java/httpcomponents/httpclient.jar:/usr/share/java/httpcomponents/httpcore.jar:/usr/share/java/resteasy/jaxrs-api.jar:/usr/share/java/resteasy/resteasy-atom-provider.jar:/usr/share/java/resteasy/resteasy-jaxb-provider.jar:/usr/share/java/resteasy/resteasy-jaxrs.jar:/usr/share/java/resteasy/resteasy-jaxrs-jandex.jar:/usr/share/java/resteasy/resteasy-jettison-provider.jar:/usr/share/java/apache-commons-cli.jar:/usr/share/java/apache-commons-codec.jar:/usr/share/java/apache-commons-logging.jar:/usr/share/java/commons-codec.jar:/usr/share/java/commons-httpclient.jar:/usr/share/java/idm-console-base-1.1.7.jar:/usr/share/java/idm-console-mcc.jar:/usr/share/java/idm-console-nmclf.jar:/usr/share/java/jakarta-commons-httpclient.jar:/usr/share/java/jaxb-api.jar:/usr/share/java/ldapjdk.jar:/usr/share/java/apache-commons-lang.jar:/usr/share/java/istack-commons-runtime.jar:/usr/share/java/scannotation.jar:/usr/share/java/servlet.jar:/usr/share/java/velocity.jar:/usr/share/java/xerces-j2.jar:/usr/share/java/xml-commons-apis.jar:/usr/share/java/tomcat/catalina.jar:/usr/share/java/tomcat/tomcat-util.jar:/usr/share/java/commons-io.jar
+
+javac -classpath $CLASSPATH -d bin src/*java
+
+### Building the test rm
+
+cd ..
 
 ### Passing the keyword for personalizing and an option
 ### to maintain a seperate folder for each beaker job (Optional)
-- 
1.8.3.1

