From a53e68cd63048a55335f8a09e6404cf74e5bda9c Mon Sep 17 00:00:00 2001 From: Falk Zoll Date: Thu, 10 Oct 2019 08:55:00 +0200 Subject: [PATCH 1/2] Update to gradlew 5.6.2 to support java 11. --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f16d266..b41dbe8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip From e694ad48c663cddb0b5bed0e2bc8ab4a71dbe8a6 Mon Sep 17 00:00:00 2001 From: Falk Zoll Date: Thu, 10 Oct 2019 09:52:19 +0200 Subject: [PATCH 2/2] Fix for the removed getVCAPcredentials helper. --- .../CredentialsIBMPythonCOSTests.scala | 20 +++++++++++++------ .../CredentialsIBMPythonCloudantTests.scala | 20 +++++++++++++------ .../CredentialsIBMPythonDb2CloudTests.scala | 13 +++++++++--- .../CredentialsIBMPythonWatsonTests.scala | 16 ++++++++++----- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/tests/src/test/scala/integration/CredentialsIBMPythonCOSTests.scala b/tests/src/test/scala/integration/CredentialsIBMPythonCOSTests.scala index 704cdd3..c050349 100644 --- a/tests/src/test/scala/integration/CredentialsIBMPythonCOSTests.scala +++ b/tests/src/test/scala/integration/CredentialsIBMPythonCOSTests.scala @@ -21,6 +21,7 @@ import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner import java.io.File import spray.json._ +import scala.io.Source import org.scalatest.BeforeAndAfterAll @RunWith(classOf[JUnitRunner]) @@ -33,13 +34,20 @@ class CredentialsIBMPythonCOSTests extends TestHelpers with WskTestHelpers with val datdir = "tests/dat/cos" val actionName = "testCOSService" val actionFileName = "testCOSService.py" - val creds = TestUtils.getCredentials("cloud-object-storage") - val apikey = creds.get("apikey").getAsString() - var resource_instance_id = creds.get("resource_instance_id").getAsString() + + // read credentials from from vcap_services.json + val vcapFile = WhiskProperties.getProperty("vcap.services.file") + val vcapString = Source.fromFile(vcapFile).getLines.mkString + val vcapInfo = + JsonParser(ParserInput(vcapString)).asJsObject.fields("cloud-object-storage").asInstanceOf[JsArray].elements(0) + val creds = vcapInfo.asJsObject.fields("credentials").asJsObject + + val apikey = creds.fields("apikey").asInstanceOf[JsString] + + var resource_instance_id = creds.fields("resource_instance_id").asInstanceOf[JsString] + val __bx_creds = JsObject( - "cloud-object-storage" -> JsObject( - "apikey" -> JsString(apikey), - "resource_instance_id" -> JsString(resource_instance_id))) + "cloud-object-storage" -> JsObject("apikey" -> apikey, "resource_instance_id" -> resource_instance_id)) it should "Test connection to Cloud Object Storage COS on IBM Cloud" in withAssetCleaner(wskprops) { (wp, assetHelper) => diff --git a/tests/src/test/scala/integration/CredentialsIBMPythonCloudantTests.scala b/tests/src/test/scala/integration/CredentialsIBMPythonCloudantTests.scala index 5f117a1..5d622d6 100644 --- a/tests/src/test/scala/integration/CredentialsIBMPythonCloudantTests.scala +++ b/tests/src/test/scala/integration/CredentialsIBMPythonCloudantTests.scala @@ -15,11 +15,12 @@ */ package integration -import common.{TestHelpers, TestUtils, WskActorSystem, WskProps, WskTestHelpers} +import common.{TestHelpers, WhiskProperties, WskActorSystem, WskProps, WskTestHelpers} import common.rest.WskRestOperations import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner import java.io.File +import scala.io.Source import spray.json._ @RunWith(classOf[JUnitRunner]) @@ -30,7 +31,17 @@ class CredentialsIBMPythonCloudantTests extends TestHelpers with WskTestHelpers implicit val wskprops: WskProps = WskProps() val wsk = new WskRestOperations val datdir = "tests/dat/cloudant/" - var creds = TestUtils.getVCAPcredentials("cloudantNoSQLDB") + + // read credentials from from vcap_services.json + val vcapFile = WhiskProperties.getProperty("vcap.services.file") + val vcapString = Source.fromFile(vcapFile).getLines.mkString + val vcapInfo = + JsonParser(ParserInput(vcapString)).asJsObject.fields("cloudantNoSQLDB").asInstanceOf[JsArray].elements(0) + val creds = vcapInfo.asJsObject.fields("credentials").asJsObject + val username = creds.fields("username").asInstanceOf[JsString] + val password = creds.fields("password").asInstanceOf[JsString] + val host = creds.fields("host").asInstanceOf[JsString] + val actionName = "testCloudantService" val actionFileName = "testCloudantService.py" @@ -44,10 +55,7 @@ class CredentialsIBMPythonCloudantTests extends TestHelpers with WskTestHelpers file, main = Some("main"), kind = defaultKind, - parameters = Map( - "username" -> JsString(creds.get("username")), - "password" -> JsString(creds.get("password")), - "host" -> JsString(creds.get("host")))) + parameters = Map("username" -> username, "password" -> password, "host" -> host)) } withActivation(wsk.activation, wsk.action.invoke(actionName)) { activation => diff --git a/tests/src/test/scala/integration/CredentialsIBMPythonDb2CloudTests.scala b/tests/src/test/scala/integration/CredentialsIBMPythonDb2CloudTests.scala index 33f984d..df6d65a 100644 --- a/tests/src/test/scala/integration/CredentialsIBMPythonDb2CloudTests.scala +++ b/tests/src/test/scala/integration/CredentialsIBMPythonDb2CloudTests.scala @@ -21,6 +21,7 @@ import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner import java.io.File import spray.json._ +import scala.io.Source @RunWith(classOf[JUnitRunner]) class CredentialsIBMPythonDb2CloudTests extends TestHelpers with WskTestHelpers with WskActorSystem { @@ -33,9 +34,15 @@ class CredentialsIBMPythonDb2CloudTests extends TestHelpers with WskTestHelpers val actionName = "testDB2Service" val actionFileName = "testDB2Service.py" - val creds = TestUtils.getVCAPcredentials("dashDB") - val ssldsn = creds.get("ssldsn") - val __bx_creds = JsObject("dashDB" -> JsObject("ssldsn" -> JsString(ssldsn))) + // read credentials from from vcap_services.json + val vcapFile = WhiskProperties.getProperty("vcap.services.file") + val vcapString = Source.fromFile(vcapFile).getLines.mkString + val vcapInfo = + JsonParser(ParserInput(vcapString)).asJsObject.fields("dashDB").asInstanceOf[JsArray].elements(0) + val creds = vcapInfo.asJsObject.fields("credentials").asJsObject + + val ssldsn = creds.fields("ssldsn") + val __bx_creds = JsObject("dashDB" -> JsObject("ssldsn" -> ssldsn)) it should "Test connection to DB2 on IBM Cloud" in withAssetCleaner(wskprops) { (wp, assetHelper) => val file = Some(new File(datdir, actionFileName).toString()) diff --git a/tests/src/test/scala/integration/CredentialsIBMPythonWatsonTests.scala b/tests/src/test/scala/integration/CredentialsIBMPythonWatsonTests.scala index c07f86b..98237fd 100644 --- a/tests/src/test/scala/integration/CredentialsIBMPythonWatsonTests.scala +++ b/tests/src/test/scala/integration/CredentialsIBMPythonWatsonTests.scala @@ -20,6 +20,7 @@ import common.rest.WskRestOperations import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner import java.io.File +import scala.io.Source import spray.json._ @RunWith(classOf[JUnitRunner]) @@ -33,7 +34,15 @@ class CredentialsIBMPythonWatsonTests extends TestHelpers with WskTestHelpers wi val actionName = "testWatsonService" val actionFileName = "testWatsonService.py" - var creds = TestUtils.getVCAPcredentials("language_translator") + // read credentials from from vcap_services.json + val vcapFile = WhiskProperties.getProperty("vcap.services.file") + val vcapString = Source.fromFile(vcapFile).getLines.mkString + val vcapInfo = + JsonParser(ParserInput(vcapString)).asJsObject.fields("language_translator").asInstanceOf[JsArray].elements(0) + val creds = vcapInfo.asJsObject.fields("credentials").asJsObject + val url = creds.fields("url").asInstanceOf[JsString] + val username = creds.fields("username").asInstanceOf[JsString] + val password = creds.fields("password").asInstanceOf[JsString] /* Uses Watson Translation Service to translate the word "Hello" in English, to "Hola" in Spanish. @@ -46,10 +55,7 @@ class CredentialsIBMPythonWatsonTests extends TestHelpers with WskTestHelpers wi file, main = Some("main"), kind = defaultKind, - parameters = Map( - "url" -> JsString(creds.get("url")), - "username" -> JsString(creds.get("username")), - "password" -> JsString(creds.get("password")))) + parameters = Map("url" -> url, "username" -> username, "password" -> password)) } withActivation(wsk.activation, wsk.action.invoke(actionName)) { activation =>