{"action":"created","comment":{"url":"https://api.github.com/repos/xjdr/xio/pulls/comments/177180328","pull_request_review_id":107009302,"id":177180328,"diff_hunk":"@@ -0,0 +1,112 @@\n+package com.xjeffrose.xio.http;\n+\n+import static io.netty.handler.codec.http.HttpMethod.GET;\n+import static org.mockito.Mockito.times;\n+import static org.powermock.api.mockito.PowerMockito.when;\n+\n+import com.typesafe.config.ConfigFactory;\n+import com.xjeffrose.xio.bootstrap.ChannelConfiguration;\n+import com.xjeffrose.xio.client.ClientConfig;\n+import com.xjeffrose.xio.tracing.HttpClientTracingHandler;\n+import com.xjeffrose.xio.tracing.XioTracing;\n+import io.netty.buffer.Unpooled;\n+import io.netty.channel.*;\n+import lombok.val;\n+import org.junit.After;\n+import org.junit.Assert;\n+import org.junit.Before;\n+import org.junit.Test;\n+import org.mockito.*;\n+\n+public class ClientTest extends Assert {\n+\n+  private Client subject;\n+  @Mock private XioTracing tracing;\n+  @Mock private HttpClientTracingHandler tracingHandler;\n+\n+  ChannelHandler appHandler =\n+      new ChannelHandler() {\n+        @Override\n+        public void handlerAdded(ChannelHandlerContext channelHandlerContext) throws Exception {}\n+\n+        @Override\n+        public void handlerRemoved(ChannelHandlerContext channelHandlerContext) throws Exception {}\n+\n+        @Override\n+        public void exceptionCaught(\n+            ChannelHandlerContext channelHandlerContext, Throwable throwable) throws Exception {}\n+      };\n+\n+  @Before\n+  public void setUp() {\n+    MockitoAnnotations.initMocks(this);\n+  }\n+\n+  @After\n+  public void tearDown() {\n+    Mockito.reset(tracing);\n+    Mockito.reset(tracingHandler);\n+  }\n+\n+  @Test\n+  public void testDisabledTracing() {\n+    val channelConfig = ChannelConfiguration.clientConfig(1, \"worker\");\n+    val clientConfig =\n+        new ClientConfig(ConfigFactory.load().getConfig(\"xio.invalidZipkinParameters\"));\n+    val clientState = new ClientState(channelConfig, clientConfig);\n+\n+    subject =\n+        new Client(\n+            clientState,\n+            () -> {\n+              return appHandler;\n+            },\n+            null);\n+\n+    Request request =\n+        DefaultFullRequest.builder()\n+            .body(Unpooled.EMPTY_BUFFER)\n+            .headers(new DefaultHeaders())\n+            .method(GET)\n+            .path(\"/\")\n+            .build();\n+    val writeFuture = subject.write(request);\n+\n+    // Assert that we did not call handlerAdded when the tracing/traceHandler is null\n+    // This would crash if we tried adding a null handler, thus no explicit assertion\n+  }\n+\n+  @Test\n+  public void testEnabledTracing() {\n+    val channelConfig = ChannelConfiguration.clientConfig(1, \"worker\");\n+    val clientConfig =\n+        new ClientConfig(ConfigFactory.load().getConfig(\"xio.validZipkinParameters\"));\n+    val clientState = new ClientState(channelConfig, clientConfig);\n+    when(tracing.newClientHandler(clientConfig.getTls().isUseSsl())).thenReturn(tracingHandler);\n+\n+    subject =\n+        new Client(\n+            clientState,\n+            () -> {\n+              return appHandler;\n+            },\n+            tracing);\n+    Request request =\n+        DefaultFullRequest.builder()\n+            .body(Unpooled.EMPTY_BUFFER)\n+            .headers(new DefaultHeaders())\n+            .method(GET)\n+            .path(\"/\")\n+            .build();\n+    val writeFuture = subject.write(request);\n+\n+    // Assert that we did DO call handlerAdded when the tracing/traceHandler is non-null\n+    try {\n+      ArgumentCaptor<ChannelHandlerContext> captor =\n+          ArgumentCaptor.forClass(ChannelHandlerContext.class);\n+      Mockito.verify(tracingHandler, times(1)).handlerAdded(captor.capture());","path":"xio-core/src/test/java/com/xjeffrose/xio/http/ClientTest.java","position":107,"original_position":107,"commit_id":"e12019d56225c93237546674a05e9539c82779e9","original_commit_id":"e12019d56225c93237546674a05e9539c82779e9","user":{"login":"manimaul","id":229469,"avatar_url":"https://avatars0.githubusercontent.com/u/229469?v=4","gravatar_id":"","url":"https://api.github.com/users/manimaul","html_url":"https://github.com/manimaul","followers_url":"https://api.github.com/users/manimaul/followers","following_url":"https://api.github.com/users/manimaul/following{/other_user}","gists_url":"https://api.github.com/users/manimaul/gists{/gist_id}","starred_url":"https://api.github.com/users/manimaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manimaul/subscriptions","organizations_url":"https://api.github.com/users/manimaul/orgs","repos_url":"https://api.github.com/users/manimaul/repos","events_url":"https://api.github.com/users/manimaul/events{/privacy}","received_events_url":"https://api.github.com/users/manimaul/received_events","type":"User","site_admin":false},"body":"it doesn't look like you're using the captor - maybe `any(ChannelHandlerContext.class)` would be better","created_at":"2018-03-26T17:55:29Z","updated_at":"2018-03-26T17:55:30Z","html_url":"https://github.com/xjdr/xio/pull/186#discussion_r177180328","pull_request_url":"https://api.github.com/repos/xjdr/xio/pulls/186","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/xjdr/xio/pulls/comments/177180328"},"html":{"href":"https://github.com/xjdr/xio/pull/186#discussion_r177180328"},"pull_request":{"href":"https://api.github.com/repos/xjdr/xio/pulls/186"}}},"pull_request":{"url":"https://api.github.com/repos/xjdr/xio/pulls/186","id":177510279,"html_url":"https://github.com/xjdr/xio/pull/186","diff_url":"https://github.com/xjdr/xio/pull/186.diff","patch_url":"https://github.com/xjdr/xio/pull/186.patch","issue_url":"https://api.github.com/repos/xjdr/xio/issues/186","number":186,"state":"open","locked":false,"title":"wk/TACO-11 adding zipkin tracing to Client and refactoring call sites…","user":{"login":"khappucino","id":1757615,"avatar_url":"https://avatars3.githubusercontent.com/u/1757615?v=4","gravatar_id":"","url":"https://api.github.com/users/khappucino","html_url":"https://github.com/khappucino","followers_url":"https://api.github.com/users/khappucino/followers","following_url":"https://api.github.com/users/khappucino/following{/other_user}","gists_url":"https://api.github.com/users/khappucino/gists{/gist_id}","starred_url":"https://api.github.com/users/khappucino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khappucino/subscriptions","organizations_url":"https://api.github.com/users/khappucino/orgs","repos_url":"https://api.github.com/users/khappucino/repos","events_url":"https://api.github.com/users/khappucino/events{/privacy}","received_events_url":"https://api.github.com/users/khappucino/received_events","type":"User","site_admin":false},"body":"wk/TACO-11 adding zipkin tracing to Client and refactoring call sites and adding backfilling some tests.\r\nNow the Client takes an xioTracing as a direct constructor dependency and the ApplicationConfig creates the xioTracing dependency","created_at":"2018-03-26T17:08:57Z","updated_at":"2018-03-26T17:55:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c8c57038f76dd1888028b3ae48152b76dcbfa24e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/xjdr/xio/pulls/186/commits","review_comments_url":"https://api.github.com/repos/xjdr/xio/pulls/186/comments","review_comment_url":"https://api.github.com/repos/xjdr/xio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xjdr/xio/issues/186/comments","statuses_url":"https://api.github.com/repos/xjdr/xio/statuses/e12019d56225c93237546674a05e9539c82779e9","head":{"label":"khappucino:wk/TACO-11-Supreme","ref":"wk/TACO-11-Supreme","sha":"e12019d56225c93237546674a05e9539c82779e9","user":{"login":"khappucino","id":1757615,"avatar_url":"https://avatars3.githubusercontent.com/u/1757615?v=4","gravatar_id":"","url":"https://api.github.com/users/khappucino","html_url":"https://github.com/khappucino","followers_url":"https://api.github.com/users/khappucino/followers","following_url":"https://api.github.com/users/khappucino/following{/other_user}","gists_url":"https://api.github.com/users/khappucino/gists{/gist_id}","starred_url":"https://api.github.com/users/khappucino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khappucino/subscriptions","organizations_url":"https://api.github.com/users/khappucino/orgs","repos_url":"https://api.github.com/users/khappucino/repos","events_url":"https://api.github.com/users/khappucino/events{/privacy}","received_events_url":"https://api.github.com/users/khappucino/received_events","type":"User","site_admin":false},"repo":{"id":125466978,"name":"xio","full_name":"khappucino/xio","owner":{"login":"khappucino","id":1757615,"avatar_url":"https://avatars3.githubusercontent.com/u/1757615?v=4","gravatar_id":"","url":"https://api.github.com/users/khappucino","html_url":"https://github.com/khappucino","followers_url":"https://api.github.com/users/khappucino/followers","following_url":"https://api.github.com/users/khappucino/following{/other_user}","gists_url":"https://api.github.com/users/khappucino/gists{/gist_id}","starred_url":"https://api.github.com/users/khappucino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khappucino/subscriptions","organizations_url":"https://api.github.com/users/khappucino/orgs","repos_url":"https://api.github.com/users/khappucino/repos","events_url":"https://api.github.com/users/khappucino/events{/privacy}","received_events_url":"https://api.github.com/users/khappucino/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/khappucino/xio","description":"High performance Multithreaded Async I/O for Java 8","fork":true,"url":"https://api.github.com/repos/khappucino/xio","forks_url":"https://api.github.com/repos/khappucino/xio/forks","keys_url":"https://api.github.com/repos/khappucino/xio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/khappucino/xio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/khappucino/xio/teams","hooks_url":"https://api.github.com/repos/khappucino/xio/hooks","issue_events_url":"https://api.github.com/repos/khappucino/xio/issues/events{/number}","events_url":"https://api.github.com/repos/khappucino/xio/events","assignees_url":"https://api.github.com/repos/khappucino/xio/assignees{/user}","branches_url":"https://api.github.com/repos/khappucino/xio/branches{/branch}","tags_url":"https://api.github.com/repos/khappucino/xio/tags","blobs_url":"https://api.github.com/repos/khappucino/xio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/khappucino/xio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/khappucino/xio/git/refs{/sha}","trees_url":"https://api.github.com/repos/khappucino/xio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/khappucino/xio/statuses/{sha}","languages_url":"https://api.github.com/repos/khappucino/xio/languages","stargazers_url":"https://api.github.com/repos/khappucino/xio/stargazers","contributors_url":"https://api.github.com/repos/khappucino/xio/contributors","subscribers_url":"https://api.github.com/repos/khappucino/xio/subscribers","subscription_url":"https://api.github.com/repos/khappucino/xio/subscription","commits_url":"https://api.github.com/repos/khappucino/xio/commits{/sha}","git_commits_url":"https://api.github.com/repos/khappucino/xio/git/commits{/sha}","comments_url":"https://api.github.com/repos/khappucino/xio/comments{/number}","issue_comment_url":"https://api.github.com/repos/khappucino/xio/issues/comments{/number}","contents_url":"https://api.github.com/repos/khappucino/xio/contents/{+path}","compare_url":"https://api.github.com/repos/khappucino/xio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/khappucino/xio/merges","archive_url":"https://api.github.com/repos/khappucino/xio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/khappucino/xio/downloads","issues_url":"https://api.github.com/repos/khappucino/xio/issues{/number}","pulls_url":"https://api.github.com/repos/khappucino/xio/pulls{/number}","milestones_url":"https://api.github.com/repos/khappucino/xio/milestones{/number}","notifications_url":"https://api.github.com/repos/khappucino/xio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/khappucino/xio/labels{/name}","releases_url":"https://api.github.com/repos/khappucino/xio/releases{/id}","deployments_url":"https://api.github.com/repos/khappucino/xio/deployments","created_at":"2018-03-16T05:16:08Z","updated_at":"2018-03-22T23:07:11Z","pushed_at":"2018-03-26T07:44:20Z","git_url":"git://github.com/khappucino/xio.git","ssh_url":"git@github.com:khappucino/xio.git","clone_url":"https://github.com/khappucino/xio.git","svn_url":"https://github.com/khappucino/xio","homepage":null,"size":28597,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xjdr:master","ref":"master","sha":"721d3e2335b5fa2f94c1764145ca5a3fc7a3a2d8","user":{"login":"xjdr","id":2508631,"avatar_url":"https://avatars3.githubusercontent.com/u/2508631?v=4","gravatar_id":"","url":"https://api.github.com/users/xjdr","html_url":"https://github.com/xjdr","followers_url":"https://api.github.com/users/xjdr/followers","following_url":"https://api.github.com/users/xjdr/following{/other_user}","gists_url":"https://api.github.com/users/xjdr/gists{/gist_id}","starred_url":"https://api.github.com/users/xjdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xjdr/subscriptions","organizations_url":"https://api.github.com/users/xjdr/orgs","repos_url":"https://api.github.com/users/xjdr/repos","events_url":"https://api.github.com/users/xjdr/events{/privacy}","received_events_url":"https://api.github.com/users/xjdr/received_events","type":"User","site_admin":false},"repo":{"id":27653357,"name":"xio","full_name":"xjdr/xio","owner":{"login":"xjdr","id":2508631,"avatar_url":"https://avatars3.githubusercontent.com/u/2508631?v=4","gravatar_id":"","url":"https://api.github.com/users/xjdr","html_url":"https://github.com/xjdr","followers_url":"https://api.github.com/users/xjdr/followers","following_url":"https://api.github.com/users/xjdr/following{/other_user}","gists_url":"https://api.github.com/users/xjdr/gists{/gist_id}","starred_url":"https://api.github.com/users/xjdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xjdr/subscriptions","organizations_url":"https://api.github.com/users/xjdr/orgs","repos_url":"https://api.github.com/users/xjdr/repos","events_url":"https://api.github.com/users/xjdr/events{/privacy}","received_events_url":"https://api.github.com/users/xjdr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xjdr/xio","description":"High performance Multithreaded Async I/O for Java 8","fork":false,"url":"https://api.github.com/repos/xjdr/xio","forks_url":"https://api.github.com/repos/xjdr/xio/forks","keys_url":"https://api.github.com/repos/xjdr/xio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xjdr/xio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xjdr/xio/teams","hooks_url":"https://api.github.com/repos/xjdr/xio/hooks","issue_events_url":"https://api.github.com/repos/xjdr/xio/issues/events{/number}","events_url":"https://api.github.com/repos/xjdr/xio/events","assignees_url":"https://api.github.com/repos/xjdr/xio/assignees{/user}","branches_url":"https://api.github.com/repos/xjdr/xio/branches{/branch}","tags_url":"https://api.github.com/repos/xjdr/xio/tags","blobs_url":"https://api.github.com/repos/xjdr/xio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xjdr/xio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xjdr/xio/git/refs{/sha}","trees_url":"https://api.github.com/repos/xjdr/xio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xjdr/xio/statuses/{sha}","languages_url":"https://api.github.com/repos/xjdr/xio/languages","stargazers_url":"https://api.github.com/repos/xjdr/xio/stargazers","contributors_url":"https://api.github.com/repos/xjdr/xio/contributors","subscribers_url":"https://api.github.com/repos/xjdr/xio/subscribers","subscription_url":"https://api.github.com/repos/xjdr/xio/subscription","commits_url":"https://api.github.com/repos/xjdr/xio/commits{/sha}","git_commits_url":"https://api.github.com/repos/xjdr/xio/git/commits{/sha}","comments_url":"https://api.github.com/repos/xjdr/xio/comments{/number}","issue_comment_url":"https://api.github.com/repos/xjdr/xio/issues/comments{/number}","contents_url":"https://api.github.com/repos/xjdr/xio/contents/{+path}","compare_url":"https://api.github.com/repos/xjdr/xio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xjdr/xio/merges","archive_url":"https://api.github.com/repos/xjdr/xio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xjdr/xio/downloads","issues_url":"https://api.github.com/repos/xjdr/xio/issues{/number}","pulls_url":"https://api.github.com/repos/xjdr/xio/pulls{/number}","milestones_url":"https://api.github.com/repos/xjdr/xio/milestones{/number}","notifications_url":"https://api.github.com/repos/xjdr/xio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xjdr/xio/labels{/name}","releases_url":"https://api.github.com/repos/xjdr/xio/releases{/id}","deployments_url":"https://api.github.com/repos/xjdr/xio/deployments","created_at":"2014-12-06T23:51:21Z","updated_at":"2018-03-22T16:52:20Z","pushed_at":"2018-03-26T17:08:58Z","git_url":"git://github.com/xjdr/xio.git","ssh_url":"git@github.com:xjdr/xio.git","clone_url":"https://github.com/xjdr/xio.git","svn_url":"https://github.com/xjdr/xio","homepage":null,"size":28635,"stargazers_count":26,"watchers_count":26,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":19,"open_issues":9,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xjdr/xio/pulls/186"},"html":{"href":"https://github.com/xjdr/xio/pull/186"},"issue":{"href":"https://api.github.com/repos/xjdr/xio/issues/186"},"comments":{"href":"https://api.github.com/repos/xjdr/xio/issues/186/comments"},"review_comments":{"href":"https://api.github.com/repos/xjdr/xio/pulls/186/comments"},"review_comment":{"href":"https://api.github.com/repos/xjdr/xio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xjdr/xio/pulls/186/commits"},"statuses":{"href":"https://api.github.com/repos/xjdr/xio/statuses/e12019d56225c93237546674a05e9539c82779e9"}},"author_association":"NONE"}}
{"actor":{"display_login":"manimaul"}}