{"action":"created","comment":{"url":"https://api.github.com/repos/hierynomus/smbj/pulls/comments/78730561","id":78730561,"diff_hunk":"@@ -0,0 +1,228 @@\n+/*\n+ * Copyright (C)2016 - SMBJ Contributors\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * 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+package com.hierynomus.smbj.share\n+\n+import spock.lang.Specification\n+\n+\n+public class RingBufferTest extends Specification {\n+\n+  private RingBuffer cBuf;\n+\n+  protected void setup() {\n+    cBuf = new RingBuffer(10);\n+  }\n+\n+  def \"should be able to append all bytes to buffer\"() {\n+    given:\n+    def actual = [4, 5, 6, 7, 1] as byte[]\n+    def byteArray = [0, 0, 0, 0, 0] as byte[]\n+\n+\n+    when:\n+    cBuf.write(actual, 0, 5);\n+\n+    then:\n+    cBuf.getUsedSize() == 5\n+    cBuf.read(byteArray)\n+    byteArray == actual\n+  }\n+\n+  def \"should be able to append only selected bytes to buffer\"() {\n+    given:\n+    def actual = [4, 5, 6, 7, 1] as byte[];\n+    def byteArray = [0, 0, 0] as byte[]\n+\n+    when:\n+    cBuf.write(actual, 2, 3);\n+\n+    then:\n+    cBuf.getUsedSize() == 3\n+    cBuf.read(byteArray);\n+    byteArray == [6, 7, 1] as byte[]\n+  }\n+\n+  def \"should throw exception if bytes to write do not exist\"() {\n+    given:\n+    def actual = [4, 5, 6, 7, 1] as byte[];\n+\n+    when:\n+    cBuf.write(actual, 2, 4);\n+\n+    then:\n+    thrown IllegalArgumentException\n+  }\n+\n+  def \"should be able to append single byte to buffer\"() {\n+    given:\n+    def actual = [4, 5, 6, 7, 1] as byte[];\n+    def byteArray = [0, 0, 0, 0] as byte[]\n+\n+    when:\n+    cBuf.write(actual, 2, 3);\n+    cBuf.write(2);\n+\n+    then:\n+    cBuf.getUsedSize() == 4\n+    cBuf.read(byteArray);\n+    byteArray == [6, 7, 1, 2] as byte[]\n+  }\n+\n+  def \"should be able to append more bytes to existing buffer\"() {\n+    given:\n+    def b1 = [4, 5, 6] as byte[]\n+    def b2 = [12, 13] as byte[]\n+    def byteArray = [0, 0, 0, 0, 0] as byte[]\n+\n+    when:\n+    cBuf.write(b1, 0, 3);\n+    cBuf.write(b2, 0, 2);\n+\n+    then:\n+    cBuf.getUsedSize() == 5\n+    cBuf.read(byteArray);\n+    byteArray == [4, 5, 6, 12, 13] as byte[]\n+  }\n+\n+  def \"should throw exception if buffer is full\"() {\n+    given:\n+    def b = [4, 5, 6, 1, 2, 3, 4] as byte[];\n+\n+    when:\n+    cBuf.write(b, 0, 6);\n+    cBuf.write(b, 0, 6);\n+\n+    then:\n+    thrown IndexOutOfBoundsException\n+  }\n+\n+  def \"should read all available bytes from buffer\"() {","path":"src/test/groovy/com/hierynomus/smbj/share/RingBufferTest.groovy","position":112,"original_position":112,"commit_id":"b2119a5251ac060289d11660f83167f866eac28f","original_commit_id":"b2119a5251ac060289d11660f83167f866eac28f","user":{"login":"hierynomus","id":117667,"avatar_url":"https://avatars.githubusercontent.com/u/117667?v=3","gravatar_id":"","url":"https://api.github.com/users/hierynomus","html_url":"https://github.com/hierynomus","followers_url":"https://api.github.com/users/hierynomus/followers","following_url":"https://api.github.com/users/hierynomus/following{/other_user}","gists_url":"https://api.github.com/users/hierynomus/gists{/gist_id}","starred_url":"https://api.github.com/users/hierynomus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hierynomus/subscriptions","organizations_url":"https://api.github.com/users/hierynomus/orgs","repos_url":"https://api.github.com/users/hierynomus/repos","events_url":"https://api.github.com/users/hierynomus/events{/privacy}","received_events_url":"https://api.github.com/users/hierynomus/received_events","type":"User","site_admin":false},"body":"How is this test diferent from the first one?","created_at":"2016-09-14T11:27:31Z","updated_at":"2016-09-14T11:27:31Z","html_url":"https://github.com/hierynomus/smbj/pull/23#discussion_r78730561","pull_request_url":"https://api.github.com/repos/hierynomus/smbj/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/hierynomus/smbj/pulls/comments/78730561"},"html":{"href":"https://github.com/hierynomus/smbj/pull/23#discussion_r78730561"},"pull_request":{"href":"https://api.github.com/repos/hierynomus/smbj/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/hierynomus/smbj/pulls/23","id":85166404,"html_url":"https://github.com/hierynomus/smbj/pull/23","diff_url":"https://github.com/hierynomus/smbj/pull/23.diff","patch_url":"https://github.com/hierynomus/smbj/pull/23.patch","issue_url":"https://api.github.com/repos/hierynomus/smbj/issues/23","number":23,"state":"open","locked":false,"title":"ring byte buffer for FileOutputStream in smbj","user":{"login":"himanshutaneja","id":8086726,"avatar_url":"https://avatars.githubusercontent.com/u/8086726?v=3","gravatar_id":"","url":"https://api.github.com/users/himanshutaneja","html_url":"https://github.com/himanshutaneja","followers_url":"https://api.github.com/users/himanshutaneja/followers","following_url":"https://api.github.com/users/himanshutaneja/following{/other_user}","gists_url":"https://api.github.com/users/himanshutaneja/gists{/gist_id}","starred_url":"https://api.github.com/users/himanshutaneja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himanshutaneja/subscriptions","organizations_url":"https://api.github.com/users/himanshutaneja/orgs","repos_url":"https://api.github.com/users/himanshutaneja/repos","events_url":"https://api.github.com/users/himanshutaneja/events{/privacy}","received_events_url":"https://api.github.com/users/himanshutaneja/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-14T04:47:47Z","updated_at":"2016-09-14T11:27:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hierynomus/smbj/pulls/23/commits","review_comments_url":"https://api.github.com/repos/hierynomus/smbj/pulls/23/comments","review_comment_url":"https://api.github.com/repos/hierynomus/smbj/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hierynomus/smbj/issues/23/comments","statuses_url":"https://api.github.com/repos/hierynomus/smbj/statuses/b2119a5251ac060289d11660f83167f866eac28f","head":{"label":"adityakalia:master","ref":"master","sha":"b2119a5251ac060289d11660f83167f866eac28f","user":{"login":"adityakalia","id":422076,"avatar_url":"https://avatars.githubusercontent.com/u/422076?v=3","gravatar_id":"","url":"https://api.github.com/users/adityakalia","html_url":"https://github.com/adityakalia","followers_url":"https://api.github.com/users/adityakalia/followers","following_url":"https://api.github.com/users/adityakalia/following{/other_user}","gists_url":"https://api.github.com/users/adityakalia/gists{/gist_id}","starred_url":"https://api.github.com/users/adityakalia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adityakalia/subscriptions","organizations_url":"https://api.github.com/users/adityakalia/orgs","repos_url":"https://api.github.com/users/adityakalia/repos","events_url":"https://api.github.com/users/adityakalia/events{/privacy}","received_events_url":"https://api.github.com/users/adityakalia/received_events","type":"User","site_admin":false},"repo":{"id":65119301,"name":"smbj","full_name":"adityakalia/smbj","owner":{"login":"adityakalia","id":422076,"avatar_url":"https://avatars.githubusercontent.com/u/422076?v=3","gravatar_id":"","url":"https://api.github.com/users/adityakalia","html_url":"https://github.com/adityakalia","followers_url":"https://api.github.com/users/adityakalia/followers","following_url":"https://api.github.com/users/adityakalia/following{/other_user}","gists_url":"https://api.github.com/users/adityakalia/gists{/gist_id}","starred_url":"https://api.github.com/users/adityakalia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adityakalia/subscriptions","organizations_url":"https://api.github.com/users/adityakalia/orgs","repos_url":"https://api.github.com/users/adityakalia/repos","events_url":"https://api.github.com/users/adityakalia/events{/privacy}","received_events_url":"https://api.github.com/users/adityakalia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adityakalia/smbj","description":"Server Message Block (SMB2, SMB3) implementation in Java","fork":true,"url":"https://api.github.com/repos/adityakalia/smbj","forks_url":"https://api.github.com/repos/adityakalia/smbj/forks","keys_url":"https://api.github.com/repos/adityakalia/smbj/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adityakalia/smbj/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adityakalia/smbj/teams","hooks_url":"https://api.github.com/repos/adityakalia/smbj/hooks","issue_events_url":"https://api.github.com/repos/adityakalia/smbj/issues/events{/number}","events_url":"https://api.github.com/repos/adityakalia/smbj/events","assignees_url":"https://api.github.com/repos/adityakalia/smbj/assignees{/user}","branches_url":"https://api.github.com/repos/adityakalia/smbj/branches{/branch}","tags_url":"https://api.github.com/repos/adityakalia/smbj/tags","blobs_url":"https://api.github.com/repos/adityakalia/smbj/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adityakalia/smbj/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adityakalia/smbj/git/refs{/sha}","trees_url":"https://api.github.com/repos/adityakalia/smbj/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adityakalia/smbj/statuses/{sha}","languages_url":"https://api.github.com/repos/adityakalia/smbj/languages","stargazers_url":"https://api.github.com/repos/adityakalia/smbj/stargazers","contributors_url":"https://api.github.com/repos/adityakalia/smbj/contributors","subscribers_url":"https://api.github.com/repos/adityakalia/smbj/subscribers","subscription_url":"https://api.github.com/repos/adityakalia/smbj/subscription","commits_url":"https://api.github.com/repos/adityakalia/smbj/commits{/sha}","git_commits_url":"https://api.github.com/repos/adityakalia/smbj/git/commits{/sha}","comments_url":"https://api.github.com/repos/adityakalia/smbj/comments{/number}","issue_comment_url":"https://api.github.com/repos/adityakalia/smbj/issues/comments{/number}","contents_url":"https://api.github.com/repos/adityakalia/smbj/contents/{+path}","compare_url":"https://api.github.com/repos/adityakalia/smbj/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adityakalia/smbj/merges","archive_url":"https://api.github.com/repos/adityakalia/smbj/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adityakalia/smbj/downloads","issues_url":"https://api.github.com/repos/adityakalia/smbj/issues{/number}","pulls_url":"https://api.github.com/repos/adityakalia/smbj/pulls{/number}","milestones_url":"https://api.github.com/repos/adityakalia/smbj/milestones{/number}","notifications_url":"https://api.github.com/repos/adityakalia/smbj/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adityakalia/smbj/labels{/name}","releases_url":"https://api.github.com/repos/adityakalia/smbj/releases{/id}","deployments_url":"https://api.github.com/repos/adityakalia/smbj/deployments","created_at":"2016-08-07T06:29:03Z","updated_at":"2016-08-07T06:29:05Z","pushed_at":"2016-09-14T11:15:02Z","git_url":"git://github.com/adityakalia/smbj.git","ssh_url":"git@github.com:adityakalia/smbj.git","clone_url":"https://github.com/adityakalia/smbj.git","svn_url":"https://github.com/adityakalia/smbj","homepage":null,"size":8326,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hierynomus:master","ref":"master","sha":"1a2a8970e4e76e0593f859a8b5163d01440be426","user":{"login":"hierynomus","id":117667,"avatar_url":"https://avatars.githubusercontent.com/u/117667?v=3","gravatar_id":"","url":"https://api.github.com/users/hierynomus","html_url":"https://github.com/hierynomus","followers_url":"https://api.github.com/users/hierynomus/followers","following_url":"https://api.github.com/users/hierynomus/following{/other_user}","gists_url":"https://api.github.com/users/hierynomus/gists{/gist_id}","starred_url":"https://api.github.com/users/hierynomus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hierynomus/subscriptions","organizations_url":"https://api.github.com/users/hierynomus/orgs","repos_url":"https://api.github.com/users/hierynomus/repos","events_url":"https://api.github.com/users/hierynomus/events{/privacy}","received_events_url":"https://api.github.com/users/hierynomus/received_events","type":"User","site_admin":false},"repo":{"id":50351931,"name":"smbj","full_name":"hierynomus/smbj","owner":{"login":"hierynomus","id":117667,"avatar_url":"https://avatars.githubusercontent.com/u/117667?v=3","gravatar_id":"","url":"https://api.github.com/users/hierynomus","html_url":"https://github.com/hierynomus","followers_url":"https://api.github.com/users/hierynomus/followers","following_url":"https://api.github.com/users/hierynomus/following{/other_user}","gists_url":"https://api.github.com/users/hierynomus/gists{/gist_id}","starred_url":"https://api.github.com/users/hierynomus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hierynomus/subscriptions","organizations_url":"https://api.github.com/users/hierynomus/orgs","repos_url":"https://api.github.com/users/hierynomus/repos","events_url":"https://api.github.com/users/hierynomus/events{/privacy}","received_events_url":"https://api.github.com/users/hierynomus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hierynomus/smbj","description":"Server Message Block (SMB2, SMB3) implementation in Java","fork":false,"url":"https://api.github.com/repos/hierynomus/smbj","forks_url":"https://api.github.com/repos/hierynomus/smbj/forks","keys_url":"https://api.github.com/repos/hierynomus/smbj/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hierynomus/smbj/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hierynomus/smbj/teams","hooks_url":"https://api.github.com/repos/hierynomus/smbj/hooks","issue_events_url":"https://api.github.com/repos/hierynomus/smbj/issues/events{/number}","events_url":"https://api.github.com/repos/hierynomus/smbj/events","assignees_url":"https://api.github.com/repos/hierynomus/smbj/assignees{/user}","branches_url":"https://api.github.com/repos/hierynomus/smbj/branches{/branch}","tags_url":"https://api.github.com/repos/hierynomus/smbj/tags","blobs_url":"https://api.github.com/repos/hierynomus/smbj/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hierynomus/smbj/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hierynomus/smbj/git/refs{/sha}","trees_url":"https://api.github.com/repos/hierynomus/smbj/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hierynomus/smbj/statuses/{sha}","languages_url":"https://api.github.com/repos/hierynomus/smbj/languages","stargazers_url":"https://api.github.com/repos/hierynomus/smbj/stargazers","contributors_url":"https://api.github.com/repos/hierynomus/smbj/contributors","subscribers_url":"https://api.github.com/repos/hierynomus/smbj/subscribers","subscription_url":"https://api.github.com/repos/hierynomus/smbj/subscription","commits_url":"https://api.github.com/repos/hierynomus/smbj/commits{/sha}","git_commits_url":"https://api.github.com/repos/hierynomus/smbj/git/commits{/sha}","comments_url":"https://api.github.com/repos/hierynomus/smbj/comments{/number}","issue_comment_url":"https://api.github.com/repos/hierynomus/smbj/issues/comments{/number}","contents_url":"https://api.github.com/repos/hierynomus/smbj/contents/{+path}","compare_url":"https://api.github.com/repos/hierynomus/smbj/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hierynomus/smbj/merges","archive_url":"https://api.github.com/repos/hierynomus/smbj/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hierynomus/smbj/downloads","issues_url":"https://api.github.com/repos/hierynomus/smbj/issues{/number}","pulls_url":"https://api.github.com/repos/hierynomus/smbj/pulls{/number}","milestones_url":"https://api.github.com/repos/hierynomus/smbj/milestones{/number}","notifications_url":"https://api.github.com/repos/hierynomus/smbj/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hierynomus/smbj/labels{/name}","releases_url":"https://api.github.com/repos/hierynomus/smbj/releases{/id}","deployments_url":"https://api.github.com/repos/hierynomus/smbj/deployments","created_at":"2016-01-25T13:23:01Z","updated_at":"2016-09-07T10:16:49Z","pushed_at":"2016-09-14T11:15:04Z","git_url":"git://github.com/hierynomus/smbj.git","ssh_url":"git@github.com:hierynomus/smbj.git","clone_url":"https://github.com/hierynomus/smbj.git","svn_url":"https://github.com/hierynomus/smbj","homepage":null,"size":8340,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":7,"forks":4,"open_issues":7,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hierynomus/smbj/pulls/23"},"html":{"href":"https://github.com/hierynomus/smbj/pull/23"},"issue":{"href":"https://api.github.com/repos/hierynomus/smbj/issues/23"},"comments":{"href":"https://api.github.com/repos/hierynomus/smbj/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/hierynomus/smbj/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/hierynomus/smbj/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hierynomus/smbj/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/hierynomus/smbj/statuses/b2119a5251ac060289d11660f83167f866eac28f"}}}}
{"actor":{"display_login":"hierynomus"}}