{"action":"created","comment":{"url":"https://api.github.com/repos/manikandan89/livy/pulls/comments/66175332","id":66175332,"diff_hunk":"@@ -0,0 +1,222 @@\n+/*\n+ * Licensed to Cloudera, Inc. under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  Cloudera, Inc. licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package com.cloudera.livy.scalaapi\n+\n+import java.io._\n+import java.net.URI\n+import java.nio.charset.StandardCharsets._\n+import java.util._\n+import java.util.jar.JarOutputStream\n+import java.util.zip.ZipEntry\n+\n+import org.apache.spark.SparkFiles\n+import org.apache.spark.launcher.SparkLauncher\n+import org.scalatest.{BeforeAndAfter, FunSuite}\n+import org.scalatest.concurrent.ScalaFutures\n+import scala.collection.mutable.ArrayBuffer\n+import scala.concurrent.Await\n+import scala.concurrent.ExecutionContext.Implicits.global\n+import scala.concurrent.duration._\n+import scala.language.postfixOps\n+import scala.util.{Failure, Success, Try}\n+\n+import com.cloudera.livy.rsc.RSCConf.Entry._\n+\n+class ScalaClientTest extends FunSuite with ScalaFutures with BeforeAndAfter {\n+\n+  import com.cloudera.livy._\n+\n+  private var client: LivyScalaClient = _\n+\n+  after {\n+    if (client != null) {\n+      client.stop(true)\n+      client = null\n+    }\n+  }\n+\n+  test(\"test Job Submission\") {\n+    configureClient(true)\n+    val jobHandle = client.submit(ScalaClientTest.helloJob)\n+    val result = Await.result(jobHandle, 10 second)\n+    assert(result === \"hello\")\n+  }\n+\n+  test(\"test Simple Spark Job\") {\n+    configureClient(true)\n+    val sFuture = client.submit(ScalaClientTest.simpleSparkJob)\n+    val result = Await.result(sFuture, 10 second)\n+    assert(result === 5)\n+  }\n+\n+  test(\"test Job Failure\") {\n+    configureClient(true)\n+    val sFuture = client.submit(ScalaClientTest.throwExceptionJob)\n+    Thread.sleep(5000)\n+    sFuture onComplete {\n+      case Success(t) => {\n+        fail(\"Should have thrown an exception\")\n+      }\n+      case Failure(e) => {\n+        assert(e.getMessage.contains(\"CustomTestFailureException\"))\n+      }\n+    }\n+  }\n+\n+  test(\"test Sync Rpc\") {\n+    configureClient(true)\n+    val future = client.run(ScalaClientTest.helloJob)\n+    val result = Await.result(future, 10 second)\n+    assert(result === \"hello\")\n+  }\n+\n+  test(\"test Remote client\") {\n+    configureClient(false)\n+    val sFuture = client.submit(ScalaClientTest.simpleSparkJob)\n+    val result = Await.result(sFuture, 10 second)\n+    assert(result === 5)\n+  }\n+\n+  test(\"test add file\") {\n+    configureClient(true)\n+    var file: File = null\n+    file = File.createTempFile(\"test\", \".file\")\n+    val fileStream = new FileOutputStream(file)\n+    fileStream.write(\"test file\".getBytes(\"UTF-8\"))\n+    fileStream.close\n+    client.addFile(new URI(\"file:\" + file.getAbsolutePath()))\n+    Thread.sleep(5000)","path":"scala-api/src/test/scala/com/cloudera/livy/scalaapi/ScalaClientTest.scala","position":null,"original_position":104,"commit_id":"d72da53a9889af95227f0ea02752df68fa42f974","original_commit_id":"450fb6249845c77a06c914ed0ea35a5aa119e55d","user":{"login":"manikandan89","id":8599433,"avatar_url":"https://avatars.githubusercontent.com/u/8599433?v=3","gravatar_id":"","url":"https://api.github.com/users/manikandan89","html_url":"https://github.com/manikandan89","followers_url":"https://api.github.com/users/manikandan89/followers","following_url":"https://api.github.com/users/manikandan89/following{/other_user}","gists_url":"https://api.github.com/users/manikandan89/gists{/gist_id}","starred_url":"https://api.github.com/users/manikandan89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manikandan89/subscriptions","organizations_url":"https://api.github.com/users/manikandan89/orgs","repos_url":"https://api.github.com/users/manikandan89/repos","events_url":"https://api.github.com/users/manikandan89/events{/privacy}","received_events_url":"https://api.github.com/users/manikandan89/received_events","type":"User","site_admin":false},"body":"Fixed","created_at":"2016-06-08T00:19:36Z","updated_at":"2016-06-08T00:19:36Z","html_url":"https://github.com/manikandan89/livy/pull/1#discussion_r66175332","pull_request_url":"https://api.github.com/repos/manikandan89/livy/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/manikandan89/livy/pulls/comments/66175332"},"html":{"href":"https://github.com/manikandan89/livy/pull/1#discussion_r66175332"},"pull_request":{"href":"https://api.github.com/repos/manikandan89/livy/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/manikandan89/livy/pulls/1","id":71625881,"html_url":"https://github.com/manikandan89/livy/pull/1","diff_url":"https://github.com/manikandan89/livy/pull/1.diff","patch_url":"https://github.com/manikandan89/livy/pull/1.patch","issue_url":"https://api.github.com/repos/manikandan89/livy/issues/1","number":1,"state":"open","locked":false,"title":"Fix for some code review feedback","user":{"login":"manikandan89","id":8599433,"avatar_url":"https://avatars.githubusercontent.com/u/8599433?v=3","gravatar_id":"","url":"https://api.github.com/users/manikandan89","html_url":"https://github.com/manikandan89","followers_url":"https://api.github.com/users/manikandan89/followers","following_url":"https://api.github.com/users/manikandan89/following{/other_user}","gists_url":"https://api.github.com/users/manikandan89/gists{/gist_id}","starred_url":"https://api.github.com/users/manikandan89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manikandan89/subscriptions","organizations_url":"https://api.github.com/users/manikandan89/orgs","repos_url":"https://api.github.com/users/manikandan89/repos","events_url":"https://api.github.com/users/manikandan89/events{/privacy}","received_events_url":"https://api.github.com/users/manikandan89/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-26T21:15:50Z","updated_at":"2016-06-08T00:19:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"01805ae29dd6137fa989273a424b252952f64957","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/manikandan89/livy/pulls/1/commits","review_comments_url":"https://api.github.com/repos/manikandan89/livy/pulls/1/comments","review_comment_url":"https://api.github.com/repos/manikandan89/livy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/manikandan89/livy/issues/1/comments","statuses_url":"https://api.github.com/repos/manikandan89/livy/statuses/d72da53a9889af95227f0ea02752df68fa42f974","head":{"label":"manikandan89:scala-api-changes","ref":"scala-api-changes","sha":"d72da53a9889af95227f0ea02752df68fa42f974","user":{"login":"manikandan89","id":8599433,"avatar_url":"https://avatars.githubusercontent.com/u/8599433?v=3","gravatar_id":"","url":"https://api.github.com/users/manikandan89","html_url":"https://github.com/manikandan89","followers_url":"https://api.github.com/users/manikandan89/followers","following_url":"https://api.github.com/users/manikandan89/following{/other_user}","gists_url":"https://api.github.com/users/manikandan89/gists{/gist_id}","starred_url":"https://api.github.com/users/manikandan89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manikandan89/subscriptions","organizations_url":"https://api.github.com/users/manikandan89/orgs","repos_url":"https://api.github.com/users/manikandan89/repos","events_url":"https://api.github.com/users/manikandan89/events{/privacy}","received_events_url":"https://api.github.com/users/manikandan89/received_events","type":"User","site_admin":false},"repo":{"id":59509286,"name":"livy","full_name":"manikandan89/livy","owner":{"login":"manikandan89","id":8599433,"avatar_url":"https://avatars.githubusercontent.com/u/8599433?v=3","gravatar_id":"","url":"https://api.github.com/users/manikandan89","html_url":"https://github.com/manikandan89","followers_url":"https://api.github.com/users/manikandan89/followers","following_url":"https://api.github.com/users/manikandan89/following{/other_user}","gists_url":"https://api.github.com/users/manikandan89/gists{/gist_id}","starred_url":"https://api.github.com/users/manikandan89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manikandan89/subscriptions","organizations_url":"https://api.github.com/users/manikandan89/orgs","repos_url":"https://api.github.com/users/manikandan89/repos","events_url":"https://api.github.com/users/manikandan89/events{/privacy}","received_events_url":"https://api.github.com/users/manikandan89/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/manikandan89/livy","description":"Livy is an open source REST interface for interacting with Apache Spark from anywhere","fork":true,"url":"https://api.github.com/repos/manikandan89/livy","forks_url":"https://api.github.com/repos/manikandan89/livy/forks","keys_url":"https://api.github.com/repos/manikandan89/livy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/manikandan89/livy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/manikandan89/livy/teams","hooks_url":"https://api.github.com/repos/manikandan89/livy/hooks","issue_events_url":"https://api.github.com/repos/manikandan89/livy/issues/events{/number}","events_url":"https://api.github.com/repos/manikandan89/livy/events","assignees_url":"https://api.github.com/repos/manikandan89/livy/assignees{/user}","branches_url":"https://api.github.com/repos/manikandan89/livy/branches{/branch}","tags_url":"https://api.github.com/repos/manikandan89/livy/tags","blobs_url":"https://api.github.com/repos/manikandan89/livy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/manikandan89/livy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/manikandan89/livy/git/refs{/sha}","trees_url":"https://api.github.com/repos/manikandan89/livy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/manikandan89/livy/statuses/{sha}","languages_url":"https://api.github.com/repos/manikandan89/livy/languages","stargazers_url":"https://api.github.com/repos/manikandan89/livy/stargazers","contributors_url":"https://api.github.com/repos/manikandan89/livy/contributors","subscribers_url":"https://api.github.com/repos/manikandan89/livy/subscribers","subscription_url":"https://api.github.com/repos/manikandan89/livy/subscription","commits_url":"https://api.github.com/repos/manikandan89/livy/commits{/sha}","git_commits_url":"https://api.github.com/repos/manikandan89/livy/git/commits{/sha}","comments_url":"https://api.github.com/repos/manikandan89/livy/comments{/number}","issue_comment_url":"https://api.github.com/repos/manikandan89/livy/issues/comments{/number}","contents_url":"https://api.github.com/repos/manikandan89/livy/contents/{+path}","compare_url":"https://api.github.com/repos/manikandan89/livy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/manikandan89/livy/merges","archive_url":"https://api.github.com/repos/manikandan89/livy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/manikandan89/livy/downloads","issues_url":"https://api.github.com/repos/manikandan89/livy/issues{/number}","pulls_url":"https://api.github.com/repos/manikandan89/livy/pulls{/number}","milestones_url":"https://api.github.com/repos/manikandan89/livy/milestones{/number}","notifications_url":"https://api.github.com/repos/manikandan89/livy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/manikandan89/livy/labels{/name}","releases_url":"https://api.github.com/repos/manikandan89/livy/releases{/id}","deployments_url":"https://api.github.com/repos/manikandan89/livy/deployments","created_at":"2016-05-23T18:42:46Z","updated_at":"2016-05-23T18:42:47Z","pushed_at":"2016-06-07T07:51:34Z","git_url":"git://github.com/manikandan89/livy.git","ssh_url":"git@github.com:manikandan89/livy.git","clone_url":"https://github.com/manikandan89/livy.git","svn_url":"https://github.com/manikandan89/livy","homepage":"","size":1082,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"manikandan89:master","ref":"master","sha":"06165cce1ee99504b6ead12daae0cb34b8e3ea32","user":{"login":"manikandan89","id":8599433,"avatar_url":"https://avatars.githubusercontent.com/u/8599433?v=3","gravatar_id":"","url":"https://api.github.com/users/manikandan89","html_url":"https://github.com/manikandan89","followers_url":"https://api.github.com/users/manikandan89/followers","following_url":"https://api.github.com/users/manikandan89/following{/other_user}","gists_url":"https://api.github.com/users/manikandan89/gists{/gist_id}","starred_url":"https://api.github.com/users/manikandan89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manikandan89/subscriptions","organizations_url":"https://api.github.com/users/manikandan89/orgs","repos_url":"https://api.github.com/users/manikandan89/repos","events_url":"https://api.github.com/users/manikandan89/events{/privacy}","received_events_url":"https://api.github.com/users/manikandan89/received_events","type":"User","site_admin":false},"repo":{"id":59509286,"name":"livy","full_name":"manikandan89/livy","owner":{"login":"manikandan89","id":8599433,"avatar_url":"https://avatars.githubusercontent.com/u/8599433?v=3","gravatar_id":"","url":"https://api.github.com/users/manikandan89","html_url":"https://github.com/manikandan89","followers_url":"https://api.github.com/users/manikandan89/followers","following_url":"https://api.github.com/users/manikandan89/following{/other_user}","gists_url":"https://api.github.com/users/manikandan89/gists{/gist_id}","starred_url":"https://api.github.com/users/manikandan89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manikandan89/subscriptions","organizations_url":"https://api.github.com/users/manikandan89/orgs","repos_url":"https://api.github.com/users/manikandan89/repos","events_url":"https://api.github.com/users/manikandan89/events{/privacy}","received_events_url":"https://api.github.com/users/manikandan89/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/manikandan89/livy","description":"Livy is an open source REST interface for interacting with Apache Spark from anywhere","fork":true,"url":"https://api.github.com/repos/manikandan89/livy","forks_url":"https://api.github.com/repos/manikandan89/livy/forks","keys_url":"https://api.github.com/repos/manikandan89/livy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/manikandan89/livy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/manikandan89/livy/teams","hooks_url":"https://api.github.com/repos/manikandan89/livy/hooks","issue_events_url":"https://api.github.com/repos/manikandan89/livy/issues/events{/number}","events_url":"https://api.github.com/repos/manikandan89/livy/events","assignees_url":"https://api.github.com/repos/manikandan89/livy/assignees{/user}","branches_url":"https://api.github.com/repos/manikandan89/livy/branches{/branch}","tags_url":"https://api.github.com/repos/manikandan89/livy/tags","blobs_url":"https://api.github.com/repos/manikandan89/livy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/manikandan89/livy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/manikandan89/livy/git/refs{/sha}","trees_url":"https://api.github.com/repos/manikandan89/livy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/manikandan89/livy/statuses/{sha}","languages_url":"https://api.github.com/repos/manikandan89/livy/languages","stargazers_url":"https://api.github.com/repos/manikandan89/livy/stargazers","contributors_url":"https://api.github.com/repos/manikandan89/livy/contributors","subscribers_url":"https://api.github.com/repos/manikandan89/livy/subscribers","subscription_url":"https://api.github.com/repos/manikandan89/livy/subscription","commits_url":"https://api.github.com/repos/manikandan89/livy/commits{/sha}","git_commits_url":"https://api.github.com/repos/manikandan89/livy/git/commits{/sha}","comments_url":"https://api.github.com/repos/manikandan89/livy/comments{/number}","issue_comment_url":"https://api.github.com/repos/manikandan89/livy/issues/comments{/number}","contents_url":"https://api.github.com/repos/manikandan89/livy/contents/{+path}","compare_url":"https://api.github.com/repos/manikandan89/livy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/manikandan89/livy/merges","archive_url":"https://api.github.com/repos/manikandan89/livy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/manikandan89/livy/downloads","issues_url":"https://api.github.com/repos/manikandan89/livy/issues{/number}","pulls_url":"https://api.github.com/repos/manikandan89/livy/pulls{/number}","milestones_url":"https://api.github.com/repos/manikandan89/livy/milestones{/number}","notifications_url":"https://api.github.com/repos/manikandan89/livy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/manikandan89/livy/labels{/name}","releases_url":"https://api.github.com/repos/manikandan89/livy/releases{/id}","deployments_url":"https://api.github.com/repos/manikandan89/livy/deployments","created_at":"2016-05-23T18:42:46Z","updated_at":"2016-05-23T18:42:47Z","pushed_at":"2016-06-07T07:51:34Z","git_url":"git://github.com/manikandan89/livy.git","ssh_url":"git@github.com:manikandan89/livy.git","clone_url":"https://github.com/manikandan89/livy.git","svn_url":"https://github.com/manikandan89/livy","homepage":"","size":1082,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/manikandan89/livy/pulls/1"},"html":{"href":"https://github.com/manikandan89/livy/pull/1"},"issue":{"href":"https://api.github.com/repos/manikandan89/livy/issues/1"},"comments":{"href":"https://api.github.com/repos/manikandan89/livy/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/manikandan89/livy/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/manikandan89/livy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/manikandan89/livy/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/manikandan89/livy/statuses/d72da53a9889af95227f0ea02752df68fa42f974"}}}}
{"actor":{"display_login":"manikandan89"}}