You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/03/21 22:17:42 UTC
[GitHub] dubee closed pull request #3478: Remove deadcode and clone/own.
dubee closed pull request #3478: Remove deadcode and clone/own.
URL: https://github.com/apache/incubator-openwhisk/pull/3478
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/tests/src/test/scala/common/rest/WskRest.scala b/tests/src/test/scala/common/rest/WskRest.scala
index aaac4ba1b9..fb12172fed 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRest.scala
@@ -28,8 +28,6 @@ import org.scalatest.FlatSpec
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.time.Span.convertDurationToSpan
-import scala.collection.JavaConversions.mapAsJavaMap
-import scala.collection.mutable.Buffer
import scala.collection.immutable.Seq
import scala.concurrent.duration.Duration
import scala.concurrent.duration.DurationInt
@@ -67,7 +65,6 @@ import common.BaseDeleteFromCollection
import common.BaseListOrGetFromCollection
import common.HasActivation
import common.RunWskCmd
-import common.TestUtils
import common.TestUtils.SUCCESS_EXIT
import common.TestUtils.ANY_ERROR_EXIT
import common.TestUtils.DONTCARE_EXIT
@@ -144,11 +141,12 @@ object HttpConnection {
* @return https connection context
*/
def getContext(protocol: String)(implicit system: ActorSystem) = {
- if (protocol == "https")
+ if (protocol == "https") {
SSL.httpsConnectionContext
- else
-// supports http
+ } else {
+ // supports http
Http().defaultClientHttpsContext
+ }
}
}
@@ -1359,22 +1357,10 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
else name
}
- def fullEntityName(name: String)(implicit wp: WskProps) = {
- name.split("/") match {
- // Example: /namespace/package_name/entity_name
- case Array(empty, namespace, packageName, entityName) if empty.isEmpty => s"/$namespace/$packageName/$entityName"
- // Example: /namespace/entity_name
- case Array(empty, namespace, entityName) if empty.isEmpty => s"/$namespace/$entityName"
- // Example: namespace/package_name/entity_name
- case Array(namespace, packageName, entityName) => s"/$namespace/$packageName/$entityName"
- // Example: /namespace
- case Array(empty, namespace) if empty.isEmpty => namespace
- // Example: package_name/entity_name
- case Array(packageName, entityName) if !packageName.isEmpty => s"/${wp.namespace}/$packageName/$entityName"
- // Example: entity_name
- case Array(entityName) => s"/${wp.namespace}/$name"
- case _ => s"/${wp.namespace}/$name"
- }
+ def fullEntityName(name: String)(implicit wp: WskProps): String = {
+ val (ns, rest) = getNamespaceEntityName(name)
+ if (rest.nonEmpty) s"/$ns/$rest"
+ else s"/$ns"
}
def convertIntoComponents(comps: String)(implicit wp: WskProps): Array[JsValue] = {
@@ -1419,7 +1405,7 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
val path =
if (web) Path(s"$basePath/web/$systemNamespace/$actName.http")
else Path(s"$basePath/namespaces/$ns/actions/$actName")
- var paramMap = Map("blocking" -> blocking.toString, "result" -> result.toString)
+ val paramMap = Map("blocking" -> blocking.toString, "result" -> result.toString)
val input = parameterFile map { pf =>
Some(FileUtils.readFileToString(new File(pf), StandardCharsets.UTF_8))
} getOrElse Some(parameters.toJson.toString())
@@ -1438,67 +1424,6 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
}
}
-object WskRestAdmin {
- private val binDir = WhiskProperties.getFileRelativeToWhiskHome("bin")
- private val binaryName = "wskadmin"
-
- def exists = {
- val dir = binDir
- val exec = new File(dir, binaryName)
- assert(dir.exists, s"did not find $dir")
- assert(exec.exists, s"did not find $exec")
- }
-
- def baseCommand = {
- Buffer(WhiskProperties.python, new File(binDir, binaryName).toString)
- }
-
- def listKeys(namespace: String, pick: Integer = 1): List[(String, String)] = {
- val wskadmin = new RunWskRestAdminCmd {}
- wskadmin
- .cli(Seq("user", "list", namespace, "--pick", pick.toString))
- .stdout
- .split("\n")
- .map("""\s+""".r.split(_))
- .map(parts => (parts(0), parts(1)))
- .toList
- }
-
-}
-
-trait RunWskRestAdminCmd extends RunWskCmd {
- override def baseCommand = WskRestAdmin.baseCommand
-
- def adminCommand(params: Seq[String],
- expectedExitCode: Int = SUCCESS_EXIT,
- verbose: Boolean = false,
- env: Map[String, String] = Map("WSK_CONFIG_FILE" -> ""),
- workingDir: File = new File("."),
- stdinFile: Option[File] = None,
- showCmd: Boolean = false): RunResult = {
- val args = baseCommand
- if (verbose) args += "--verbose"
- if (showCmd) println(args.mkString(" ") + " " + params.mkString(" "))
- val rr = TestUtils.runCmd(
- DONTCARE_EXIT,
- workingDir,
- TestUtils.logger,
- sys.env ++ env,
- stdinFile.getOrElse(null),
- args ++ params: _*)
-
- withClue(reportFailure(args ++ params, expectedExitCode, rr)) {
- if (expectedExitCode != TestUtils.DONTCARE_EXIT) {
- val ok = (rr.exitCode == expectedExitCode) || (expectedExitCode == TestUtils.ANY_ERROR_EXIT && rr.exitCode != 0)
- if (!ok) {
- rr.exitCode shouldBe expectedExitCode
- }
- }
- }
- rr
- }
-}
-
object RestResult {
val codeConversion = 256
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services