Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit 43db3a6

Browse files
falkzollmhenke1
authored andcommitted
Update to gradlew 5.6.2, fix for removed getVCAPcredentials. (#96)
* Update to gradlew 5.6.2 to support java 11. * Fix for the removed getVCAPcredentials helper.
1 parent 99ef153 commit 43db3a6

File tree

5 files changed

+50
-21
lines changed

5 files changed

+50
-21
lines changed

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip

tests/src/test/scala/integration/CredentialsIBMPythonCOSTests.scala

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.junit.runner.RunWith
2121
import org.scalatest.junit.JUnitRunner
2222
import java.io.File
2323
import spray.json._
24+
import scala.io.Source
2425
import org.scalatest.BeforeAndAfterAll
2526

2627
@RunWith(classOf[JUnitRunner])
@@ -33,13 +34,20 @@ class CredentialsIBMPythonCOSTests extends TestHelpers with WskTestHelpers with
3334
val datdir = "tests/dat/cos"
3435
val actionName = "testCOSService"
3536
val actionFileName = "testCOSService.py"
36-
val creds = TestUtils.getCredentials("cloud-object-storage")
37-
val apikey = creds.get("apikey").getAsString()
38-
var resource_instance_id = creds.get("resource_instance_id").getAsString()
37+
38+
// read credentials from from vcap_services.json
39+
val vcapFile = WhiskProperties.getProperty("vcap.services.file")
40+
val vcapString = Source.fromFile(vcapFile).getLines.mkString
41+
val vcapInfo =
42+
JsonParser(ParserInput(vcapString)).asJsObject.fields("cloud-object-storage").asInstanceOf[JsArray].elements(0)
43+
val creds = vcapInfo.asJsObject.fields("credentials").asJsObject
44+
45+
val apikey = creds.fields("apikey").asInstanceOf[JsString]
46+
47+
var resource_instance_id = creds.fields("resource_instance_id").asInstanceOf[JsString]
48+
3949
val __bx_creds = JsObject(
40-
"cloud-object-storage" -> JsObject(
41-
"apikey" -> JsString(apikey),
42-
"resource_instance_id" -> JsString(resource_instance_id)))
50+
"cloud-object-storage" -> JsObject("apikey" -> apikey, "resource_instance_id" -> resource_instance_id))
4351

4452
it should "Test connection to Cloud Object Storage COS on IBM Cloud" in withAssetCleaner(wskprops) {
4553
(wp, assetHelper) =>

tests/src/test/scala/integration/CredentialsIBMPythonCloudantTests.scala

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
*/
1616
package integration
1717

18-
import common.{TestHelpers, TestUtils, WskActorSystem, WskProps, WskTestHelpers}
18+
import common.{TestHelpers, WhiskProperties, WskActorSystem, WskProps, WskTestHelpers}
1919
import common.rest.WskRestOperations
2020
import org.junit.runner.RunWith
2121
import org.scalatest.junit.JUnitRunner
2222
import java.io.File
23+
import scala.io.Source
2324
import spray.json._
2425

2526
@RunWith(classOf[JUnitRunner])
@@ -30,7 +31,17 @@ class CredentialsIBMPythonCloudantTests extends TestHelpers with WskTestHelpers
3031
implicit val wskprops: WskProps = WskProps()
3132
val wsk = new WskRestOperations
3233
val datdir = "tests/dat/cloudant/"
33-
var creds = TestUtils.getVCAPcredentials("cloudantNoSQLDB")
34+
35+
// read credentials from from vcap_services.json
36+
val vcapFile = WhiskProperties.getProperty("vcap.services.file")
37+
val vcapString = Source.fromFile(vcapFile).getLines.mkString
38+
val vcapInfo =
39+
JsonParser(ParserInput(vcapString)).asJsObject.fields("cloudantNoSQLDB").asInstanceOf[JsArray].elements(0)
40+
val creds = vcapInfo.asJsObject.fields("credentials").asJsObject
41+
val username = creds.fields("username").asInstanceOf[JsString]
42+
val password = creds.fields("password").asInstanceOf[JsString]
43+
val host = creds.fields("host").asInstanceOf[JsString]
44+
3445
val actionName = "testCloudantService"
3546
val actionFileName = "testCloudantService.py"
3647

@@ -44,10 +55,7 @@ class CredentialsIBMPythonCloudantTests extends TestHelpers with WskTestHelpers
4455
file,
4556
main = Some("main"),
4657
kind = defaultKind,
47-
parameters = Map(
48-
"username" -> JsString(creds.get("username")),
49-
"password" -> JsString(creds.get("password")),
50-
"host" -> JsString(creds.get("host"))))
58+
parameters = Map("username" -> username, "password" -> password, "host" -> host))
5159
}
5260

5361
withActivation(wsk.activation, wsk.action.invoke(actionName)) { activation =>

tests/src/test/scala/integration/CredentialsIBMPythonDb2CloudTests.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.junit.runner.RunWith
2121
import org.scalatest.junit.JUnitRunner
2222
import java.io.File
2323
import spray.json._
24+
import scala.io.Source
2425

2526
@RunWith(classOf[JUnitRunner])
2627
class CredentialsIBMPythonDb2CloudTests extends TestHelpers with WskTestHelpers with WskActorSystem {
@@ -33,9 +34,15 @@ class CredentialsIBMPythonDb2CloudTests extends TestHelpers with WskTestHelpers
3334
val actionName = "testDB2Service"
3435
val actionFileName = "testDB2Service.py"
3536

36-
val creds = TestUtils.getVCAPcredentials("dashDB")
37-
val ssldsn = creds.get("ssldsn")
38-
val __bx_creds = JsObject("dashDB" -> JsObject("ssldsn" -> JsString(ssldsn)))
37+
// read credentials from from vcap_services.json
38+
val vcapFile = WhiskProperties.getProperty("vcap.services.file")
39+
val vcapString = Source.fromFile(vcapFile).getLines.mkString
40+
val vcapInfo =
41+
JsonParser(ParserInput(vcapString)).asJsObject.fields("dashDB").asInstanceOf[JsArray].elements(0)
42+
val creds = vcapInfo.asJsObject.fields("credentials").asJsObject
43+
44+
val ssldsn = creds.fields("ssldsn")
45+
val __bx_creds = JsObject("dashDB" -> JsObject("ssldsn" -> ssldsn))
3946

4047
it should "Test connection to DB2 on IBM Cloud" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
4148
val file = Some(new File(datdir, actionFileName).toString())

tests/src/test/scala/integration/CredentialsIBMPythonWatsonTests.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import common.rest.WskRestOperations
2020
import org.junit.runner.RunWith
2121
import org.scalatest.junit.JUnitRunner
2222
import java.io.File
23+
import scala.io.Source
2324
import spray.json._
2425

2526
@RunWith(classOf[JUnitRunner])
@@ -33,7 +34,15 @@ class CredentialsIBMPythonWatsonTests extends TestHelpers with WskTestHelpers wi
3334
val actionName = "testWatsonService"
3435
val actionFileName = "testWatsonService.py"
3536

36-
var creds = TestUtils.getVCAPcredentials("language_translator")
37+
// read credentials from from vcap_services.json
38+
val vcapFile = WhiskProperties.getProperty("vcap.services.file")
39+
val vcapString = Source.fromFile(vcapFile).getLines.mkString
40+
val vcapInfo =
41+
JsonParser(ParserInput(vcapString)).asJsObject.fields("language_translator").asInstanceOf[JsArray].elements(0)
42+
val creds = vcapInfo.asJsObject.fields("credentials").asJsObject
43+
val url = creds.fields("url").asInstanceOf[JsString]
44+
val username = creds.fields("username").asInstanceOf[JsString]
45+
val password = creds.fields("password").asInstanceOf[JsString]
3746

3847
/*
3948
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
4655
file,
4756
main = Some("main"),
4857
kind = defaultKind,
49-
parameters = Map(
50-
"url" -> JsString(creds.get("url")),
51-
"username" -> JsString(creds.get("username")),
52-
"password" -> JsString(creds.get("password"))))
58+
parameters = Map("url" -> url, "username" -> username, "password" -> password))
5359
}
5460

5561
withActivation(wsk.activation, wsk.action.invoke(actionName)) { activation =>

0 commit comments

Comments
 (0)