-
Notifications
You must be signed in to change notification settings - Fork 882
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
[sinttest] Additional tests covering s7 of XEP-0045 #482
[sinttest] Additional tests covering s7 of XEP-0045 #482
Conversation
731bb66
to
36afd84
Compare
65dee17
to
ddf60f1
Compare
This morning I rebased this branch to Fishbowler:xep-0045-coverage-part3 |
@Flowdalic My rebase may have cleared out your earlier comments, which is unfortunate. I remember one about using enums, probably for error types. Do you remember the other one? |
The are still at the commit where I made them (which was "dropped" by you force pushing): 65dee17 |
e8ac665
to
02b88f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related to this PR, but the following pattern repeats over and over in the MUC integration tests
EntityBareJid mucAddress = getRandomRoom("smack-inttest-discoinfo");
MultiUserChat mucAsSeenByOne = mucManagerOne.getMultiUserChat(mucAddress);
createMuc(mucAsSeenByOne, Resourcepart.from("one-" + randomString));
which suggests that we can add a convenience method to reduce the boilerplate code. I thnk of
public MultiUserChat createMuc(MultiUserChatManager manager, String roomnameComponent) {
…
}
which, for example, determines the nickname prefix (one-
, two-
) by the provided manager.
Note that I was not able to review the complete PR yet. But I'd like to provide my feedback early, even if it is incomplete.
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MucConfigFormManager.java
Outdated
Show resolved
Hide resolved
...tegration-test/src/main/java/org/igniterealtime/smack/inttest/util/MultiResultSyncPoint.java
Outdated
Show resolved
Hide resolved
...ion-test/src/main/java/org/jivesoftware/smackx/muc/AbstractMultiUserChatIntegrationTest.java
Outdated
Show resolved
Hide resolved
...ion-test/src/main/java/org/jivesoftware/smackx/muc/AbstractMultiUserChatIntegrationTest.java
Show resolved
Hide resolved
...ion-test/src/main/java/org/jivesoftware/smackx/muc/AbstractMultiUserChatIntegrationTest.java
Show resolved
Hide resolved
...ation-test/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatEntityIntegrationTest.java
Outdated
Show resolved
Hide resolved
...ation-test/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatEntityIntegrationTest.java
Outdated
Show resolved
Hide resolved
...ation-test/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatEntityIntegrationTest.java
Outdated
Show resolved
Hide resolved
messageReflectionSyncPoint.waitForResult(timeout); | ||
|
||
final ResultSyncPoint<String, Exception> subjectResultSyncPoint = new ResultSyncPoint<>(); | ||
List<Object> results = new ArrayList<Object>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check that no concurrent access to this data structure happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the ArrayList?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
...tegration-test/src/main/java/org/igniterealtime/smack/inttest/util/MultiResultSyncPoint.java
Show resolved
Hide resolved
d4141f0
to
112004d
Compare
I've had a play with this, but we regularly need |
...tegration-test/src/main/java/org/igniterealtime/smack/inttest/util/MultiResultSyncPoint.java
Show resolved
Hide resolved
wait(deadline - now); | ||
} | ||
} | ||
if (expectedResultCount <= results.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This duplicated code can be removed by slightly changing the logic of this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What duplication are you referring to here? I don't see how we can reduce the check if the expected count matches the result count, as that needs to happen both before and after waiting. (This mimics what's implemented in ResultSyncPoint
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, I just noticed that this method directly returns results. I am not sure if this is sensible, given that results could potentially concurrently be modified after it was returned. Therefore I would suggest returning a copy, where the copy is made while the monitor lock is held.
I suggest the following, IMHO more idiomatic, implementation for the method. Also note that it follows a more defensive approach, where the exception is thrown, even if all results are there. If there is a compelling reason to swap this, then I could consider that. (It would also be made configurable)
public synchronized List<R> waitForResults(long timeout) throws E, InterruptedException, TimeoutException {
long now = System.currentTimeMillis();
final long deadline = now + timeout;
while (results.size <= expectedResultSize && !exception && now < deadline) {
wait(deadline - now);
now = System.currentTimeMillis();
}
if (now >= deadline) throw new TimeoutException("Timeout waiting " + timeout + " millis");
if (exception != null) throw exception;
return results; // TODO: Copy results
}
How about?
|
c770194
to
7f0daf5
Compare
7f0daf5
to
5f18332
Compare
017ad08
to
a7efe1e
Compare
I've tried doing this, but it doesn't really work out most of the time. Many of the instance references that are removed by such a method are needed elsewhere in the unit test implementation (for example in the assertions) making the replacement effort rather moot. |
776b15b
to
2bef731
Compare
@Flowdalic - is there anything to be done to 'fix' the coveralls check (that's now reporting failure)? |
I've now added a new unit test for the |
32776d3
to
7196c8b
Compare
wait(deadline - now); | ||
} | ||
} | ||
if (expectedResultCount <= results.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, I just noticed that this method directly returns results. I am not sure if this is sensible, given that results could potentially concurrently be modified after it was returned. Therefore I would suggest returning a copy, where the copy is made while the monitor lock is held.
I suggest the following, IMHO more idiomatic, implementation for the method. Also note that it follows a more defensive approach, where the exception is thrown, even if all results are there. If there is a compelling reason to swap this, then I could consider that. (It would also be made configurable)
public synchronized List<R> waitForResults(long timeout) throws E, InterruptedException, TimeoutException {
long now = System.currentTimeMillis();
final long deadline = now + timeout;
while (results.size <= expectedResultSize && !exception && now < deadline) {
wait(deadline - now);
now = System.currentTimeMillis();
}
if (now >= deadline) throw new TimeoutException("Timeout waiting " + timeout + " millis");
if (exception != null) throw exception;
return results; // TODO: Copy results
}
56f566e
to
3978050
Compare
Applied review feedback, and squashed ~3 years of commits into one. |
3978050
to
212dd41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor thing, not sure why did only noticed it yet.
...tegration-test/src/main/java/org/igniterealtime/smack/inttest/util/MultiResultSyncPoint.java
Outdated
Show resolved
Hide resolved
...tegration-test/src/main/java/org/igniterealtime/smack/inttest/util/MultiResultSyncPoint.java
Outdated
Show resolved
Hide resolved
212dd41
to
855f01e
Compare
Follows #475, #477 and #478. Draft until they're merged.