Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

533: Create explicitly a mock socket #629

Merged
merged 4 commits into from
Mar 2, 2016
Merged

533: Create explicitly a mock socket #629

merged 4 commits into from
Mar 2, 2016

Conversation

essobedo
Copy link
Contributor

Fix for #533:

Followed the principale described here by replacing a mock created with Mockito with an explicit mock Socket called MkSocket.

@davvd
Copy link

davvd commented Feb 29, 2016

@essobedo Thanks, I will find someone to review this PR soon

@davvd
Copy link

davvd commented Feb 29, 2016

@krzyk please review, thanks

final Socket socket = Mockito.mock(Socket.class);
Mockito.when(socket.getInputStream()).thenReturn(
new ByteArrayInputStream(
private static BkBasicTest.MkSocket createMockSocket() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@essobedo maybe it would be better to inline this method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krzyk I'm not sure I understand your remark here. Could please clarify?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@essobedo remove createMockSocket method and use the class directly (using new MkSocket())

@krzyk
Copy link
Contributor

krzyk commented Mar 1, 2016

@essobedo please see my comments

@essobedo
Copy link
Contributor Author

essobedo commented Mar 1, 2016

@krzyk thx for the review and the remarks. Here is a new version of my PR, please note that I finally kept the method createMockSocket because it used in several places in the test class and the input stream of the socket is specific to those tests and as the goal is to make MkSocket reusable, I had to add a new parameter to the constructor to specify the expected input stream.

*/
public MkSocket(final InputStream input) throws IOException {
super();
this.address = InetAddress.getLocalHost();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@essobedo use InetAddress.getLoopbackAddress() and remove throws IOException

@krzyk
Copy link
Contributor

krzyk commented Mar 1, 2016

@essobedo one additional comment

@essobedo
Copy link
Contributor Author

essobedo commented Mar 1, 2016

@krzyk good one, here is the new version of the PR

@krzyk
Copy link
Contributor

krzyk commented Mar 1, 2016

@rultor merge pls

@rultor
Copy link
Collaborator

rultor commented Mar 1, 2016

@rultor merge pls

@krzyk Thanks for your request. @yegor256 Please confirm this.

@yegor256
Copy link
Owner

yegor256 commented Mar 2, 2016

@rultor try to merge

@rultor
Copy link
Collaborator

rultor commented Mar 2, 2016

@rultor try to merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit d890345 into yegor256:master Mar 2, 2016
@rultor
Copy link
Collaborator

rultor commented Mar 2, 2016

@rultor try to merge

@yegor256 Done! FYI, the full log is here (took me 23min)

@essobedo essobedo deleted the 533 branch March 2, 2016 07:47
@exper0
Copy link
Contributor

exper0 commented Mar 2, 2016

@yegor256 so why did you rejected my PR(#539) and accepted this one - here is again fake sockets(not real ones in tests)

@davvd
Copy link

davvd commented Mar 3, 2016

@elenavolokhova please, review this issue for QA compliance, as per par.24

@davvd
Copy link

davvd commented Mar 3, 2016

@rultor please deploy

@rultor
Copy link
Collaborator

rultor commented Mar 3, 2016

@rultor please deploy

@davvd OK, I'll try to deploy now. You can check the progress here

@elenavolokhova
Copy link

@davvd Looks good!

@rultor
Copy link
Collaborator

rultor commented Mar 3, 2016

@rultor please deploy

@davvd Done! FYI, the full log is here (took me 12min)

@davvd
Copy link

davvd commented Mar 3, 2016

@davvd Looks good!

@elenavolokhova thank you :)

@@ -64,8 +62,6 @@
* persistent connections. Would be great to implement
* this feature. BkBasic.accept should handle more
* than one HTTP request in one connection.
* @todo #516:30min It will be nice to refactor tests with Socket usage and
* replace them to real statements. See usage of BkBasicTest.createMockSocket.
* @todo #516:15min Move header names from BkBasic to public constants.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@essobedo you had to use 533 here instead of 516
that's why #533 not closed yet I guess

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@essobedo ignore my comment
my bad you didn't add the puzzle

@davvd
Copy link

davvd commented Mar 4, 2016

@krzyk added 10 mins to @elenavolokhova, for QA review, payment code is 79291627

done, I added 23 mins in payment 79291648, 49 hours and 16 mins spent to complete this

review comments (c=8) added as a bonus

+23 added to your rating, at the moment it is: +5953

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants