Clean up test integration towards OpenWhisk (#66)

diff --git a/settings.gradle b/settings.gradle
index 6a8804d..660d005 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,12 +1,14 @@
-include 'tests', ':WhiskTest', ':common:scala', ':core:invoker', ':core:controller'
+def owPath = System.getenv("OPENWHISK_HOME") ?: '../open'
+def owDirectory = new File(owPath)
+
+include 'common:scala'; project(':common:scala').projectDir = new File(owDirectory, 'common/scala')
+include 'core:controller'; project(':core:controller').projectDir = new File(owDirectory, 'core/controller')
+include 'core:invoker'; project(':core:invoker').projectDir = new File(owDirectory, 'core/invoker')
+include 'whisktests'; project(':whisktests').projectDir = new File(owDirectory, 'tests')
+
+include 'tests'
 
 rootProject.name = 'openwhisk-package-cloudant'
-def whiskhome = "$System.env.OPENWHISK_HOME"
-
-project(':WhiskTest').projectDir = new File(whiskhome, 'tests')
-project(':common:scala').projectDir = new File(whiskhome + '/common', 'scala')
-project(':core:invoker').projectDir = new File(whiskhome + '/core', 'invoker')
-project(':core:controller').projectDir = new File(whiskhome + '/core', 'controller')
 
 gradle.ext.scala = [
         version: '2.11.8',
diff --git a/tests/build.gradle b/tests/build.gradle
index c564eb4..87d3451 100644
--- a/tests/build.gradle
+++ b/tests/build.gradle
@@ -1,61 +1,24 @@
-def whiskhome = "$System.env.OPENWHISK_HOME"
-
 apply plugin: 'scala'
 apply plugin: 'eclipse'
 compileTestScala.options.encoding = 'UTF-8'
 
+evaluationDependsOn(':whisktests')
+
 repositories {
     mavenCentral()
     maven {
         url 'https://oss.sonatype.org/content/repositories/snapshots/'
     }
+
 }
 
-sourceSets {
-    test {
-        scala {
-            srcDirs = ['src/']
-        }
-    }
-}
-
-test {
-    systemProperty 'testthreads', System.getProperty('testthreads', '1')
+tasks.withType(Test) {
     testLogging {
         events "passed", "skipped", "failed"
         showStandardStreams = true
         exceptionFormat = 'full'
     }
-    outputs.upToDateWhen { false } // force tests to run everytime
-}
-
-dependencies {
-    testCompile "org.scala-lang:scala-library:${gradle.scala.version}"
-    testCompile 'org.apache.commons:commons-exec:1.1'
-    testCompile 'org.apache.commons:commons-lang3:3.3.2'
-    testCompile 'commons-logging:commons-logging:1.1.3'
-    testCompile 'org.codehaus.groovy:groovy:2.4.3'
-    testCompile 'org.codehaus.groovy:groovy-json:2.4.3'
-    testCompile 'org.codehaus.groovy:groovy-xml:2.4.3'
-    testCompile 'com.google.guava:guava:18.0'
-    testCompile 'org.hamcrest:hamcrest-core:1.3'
-    testCompile 'org.apache.httpcomponents:httpmime:4.3.6'
-    testCompile 'junit:junit:4.11'
-    testCompile 'com.jayway.restassured:rest-assured:2.4.1'
-    testCompile 'org.scalatest:scalatest_2.11:3.0.1'
-    testCompile 'org.seleniumhq.selenium:selenium-java:2.45.0'
-    testCompile 'io.spray:spray-testkit_2.11:1.3.3'
-    testCompile 'io.spray:spray-json_2.11:1.3.2'
-    testCompile 'com.google.code.tempus-fugit:tempus-fugit:1.2-SNAPSHOT'
-    testCompile 'com.google.code.gson:gson:2.3.1'
-    testCompile 'com.cloudant:cloudant-client:1.0.1'
-
-    testCompile project(':common:scala')
-    testCompile project(':WhiskTest').sourceSets.test.output
-}
-
-tasks.withType(ScalaCompile) {
-    scalaCompileOptions.additionalParameters = gradle.scala.compileFlags
+    outputs.upToDateWhen { false } // force tests to run every time
 }
 
 task testHealth(type: Test) {
@@ -63,14 +26,13 @@
     include 'system/packages/**'
 }
 
-def keystorePath = new File(buildDir, 'classes/test/keystore')
-task deleteKeystore(type: Delete) {
-    delete keystorePath
+dependencies {
+    compile "org.scala-lang:scala-library:${gradle.scala.version}"
+    compile 'com.cloudant:cloudant-client:1.0.1'
+    compile project(':whisktests')
+    compile project(':whisktests').sourceSets.test.output
 }
-task createKeystore(dependsOn: deleteKeystore) << {
-    Properties props = new Properties()
-    props.load(new FileInputStream(file(whiskhome+'/whisk.properties')))
-    def cmd = ['keytool', '-import', '-alias', 'Whisk', '-noprompt', '-trustcacerts', '-file', file(props['whisk.ssl.cert']), '-keystore', keystorePath, '-storepass', 'openwhisk']
-    cmd.execute().waitForProcessOutput(System.out, System.err)
+
+tasks.withType(ScalaCompile) {
+    scalaCompileOptions.additionalParameters = gradle.scala.compileFlags
 }
-compileTestScala.finalizedBy createKeystore
diff --git a/tests/src/catalog/CloudantUtil.java b/tests/src/test/scala/catalog/CloudantUtil.java
similarity index 100%
rename from tests/src/catalog/CloudantUtil.java
rename to tests/src/test/scala/catalog/CloudantUtil.java
diff --git a/tests/src/catalog/cloudant/CloudantAccountActionsTests.scala b/tests/src/test/scala/catalog/cloudant/CloudantAccountActionsTests.scala
similarity index 100%
rename from tests/src/catalog/cloudant/CloudantAccountActionsTests.scala
rename to tests/src/test/scala/catalog/cloudant/CloudantAccountActionsTests.scala
diff --git a/tests/src/catalog/cloudant/CloudantBindingTests.scala b/tests/src/test/scala/catalog/cloudant/CloudantBindingTests.scala
similarity index 100%
rename from tests/src/catalog/cloudant/CloudantBindingTests.scala
rename to tests/src/test/scala/catalog/cloudant/CloudantBindingTests.scala
diff --git a/tests/src/catalog/cloudant/CloudantDatabaseActionsTests.scala b/tests/src/test/scala/catalog/cloudant/CloudantDatabaseActionsTests.scala
similarity index 100%
rename from tests/src/catalog/cloudant/CloudantDatabaseActionsTests.scala
rename to tests/src/test/scala/catalog/cloudant/CloudantDatabaseActionsTests.scala
diff --git a/tests/src/catalog/cloudant/CloudantFeedTests.scala b/tests/src/test/scala/catalog/cloudant/CloudantFeedTests.scala
similarity index 100%
rename from tests/src/catalog/cloudant/CloudantFeedTests.scala
rename to tests/src/test/scala/catalog/cloudant/CloudantFeedTests.scala
diff --git a/tests/src/catalog/cloudant/CloudantTriggerPersistencyTest.scala b/tests/src/test/scala/catalog/cloudant/CloudantTriggerPersistencyTest.scala
similarity index 100%
rename from tests/src/catalog/cloudant/CloudantTriggerPersistencyTest.scala
rename to tests/src/test/scala/catalog/cloudant/CloudantTriggerPersistencyTest.scala
diff --git a/tests/src/system/packages/CloudantHealthFeedTests.scala b/tests/src/test/scala/system/packages/CloudantHealthFeedTests.scala
similarity index 100%
rename from tests/src/system/packages/CloudantHealthFeedTests.scala
rename to tests/src/test/scala/system/packages/CloudantHealthFeedTests.scala