1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 05:22:06 +01:00
Commit graph

5156 commits

Author SHA1 Message Date
Florian Schmaus
e69e7d2342 [sinttest] Add TestNotPossibleException(Throwable) 2024-05-20 21:59:32 +02:00
Florian Schmaus
eed707f39d [sinttest] Inline createLockedMuc()
This method only had one call site and using such "helper" methods has
the drawback that it is not immediatly obvious what it does when
reading the integration test code. Therefore, we better inline it.
2024-05-20 21:58:16 +02:00
Florian Schmaus
c87bb8aaa4 [sinttest] Ensure that message has body in mucJoinEventOrderingTest()
It is possible that messages do not have a body. Therefore, we need to
ensure that the message has one before we compare the body.
2024-05-20 21:52:01 +02:00
Florian Schmaus
9447030cd4 [muc] Do not invoke userHasLeft() on nickname change
When the incoming unavailable presence is signalling a nickname
change (303), then do not invoke userHasLeft(), because the user
actually does not leave but instead just changes its nickname.

Note that this would also have had fixed SMACK-942, as it would
resolve the deadlock. However, using a dedicated lock for
changeNickname() still seems sensible, and if its just to avoid a bit
of lock contention.

What this also fixes is that a MultiUserChat does no longer invoke its
listener-based callbacks after a nickname change, as previously, after
a nickname change, the userHasLeft() would have been invoked, which
tears down the listeners. This issue was found with
MultiUserChatOccupantIntegrationTest.mucChangeNicknameInformationTest().
2024-05-20 21:45:47 +02:00
Florian Schmaus
c34c9bdb62 [muc] Fix MultiUserChat.changeNickname(Resourcepart)
Using this method used to result in a deadlock, as shown by these two threads

"main" #1 prio=5 os_prio=0 cpu=926.39ms elapsed=21.00s tid=0x00007f463802c800 nid=0x5a691 in Object.wait()  [0x00007f463f323000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(java.base@11.0.23/Native Method)
	- waiting on <0x0000000622e82fd8> (a org.jivesoftware.smack.StanzaCollector)
	at org.jivesoftware.smack.StanzaCollector.nextResult(StanzaCollector.java:206)
	- waiting to re-lock in wait() <0x0000000622e82fd8> (a org.jivesoftware.smack.StanzaCollector)
	at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:270)
	at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:228)
	at org.jivesoftware.smackx.muc.MultiUserChat.changeNickname(MultiUserChat.java:1314)
	- locked <0x0000000622e19700> (a org.jivesoftware.smackx.muc.MultiUserChat)
	at org.jivesoftware.smackx.muc.MultiUserChatOccupantIntegrationTest.mucChangeNicknameInformationTest(MultiUserChatOccupantIntegrationTest.java:981)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@11.0.23/Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@11.0.23/NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@11.0.23/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@11.0.23/Method.java:566)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.lambda$runTests$0(SmackIntegrationTestFramework.java:476)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework$$Lambda$141/0x000000084026e040.execute(Unknown Source)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.runConcreteTest(SmackIntegrationTestFramework.java:551)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework$PreparedTest.run(SmackIntegrationTestFramework.java:759)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.runTests(SmackIntegrationTestFramework.java:539)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.run(SmackIntegrationTestFramework.java:277)
	- locked <0x000000062d191318> (a org.igniterealtime.smack.inttest.SmackIntegrationTestFramework)
	at
	org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.main(SmackIntegrationTestFramework.java:115)

"Smack Cached Executor" #19 daemon prio=5 os_prio=0 cpu=7.85ms elapsed=20.48s tid=0x00007f4638a42800 nid=0x5a6b2 waiting for monitor entry  [0x00007f46023fe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at org.jivesoftware.smackx.muc.MultiUserChat.userHasLeft(MultiUserChat.java:2281)
	- waiting to lock <0x0000000622e19700> (a org.jivesoftware.smackx.muc.MultiUserChat)
	at org.jivesoftware.smackx.muc.MultiUserChat.access$800(MultiUserChat.java:117)
	at org.jivesoftware.smackx.muc.MultiUserChat$3.processStanza(MultiUserChat.java:263)
	at org.jivesoftware.smack.AbstractXMPPConnection.lambda$invokeStanzaCollectorsAndNotifyRecvListeners$8(AbstractXMPPConnection.java:1654)
	at org.jivesoftware.smack.AbstractXMPPConnection$$Lambda$127/0x000000084022f440.run(Unknown Source)
	at org.jivesoftware.smack.AbstractXMPPConnection$10.run(AbstractXMPPConnection.java:2213)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11.0.23/ThreadPoolExecutor.java:1128)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11.0.23/ThreadPoolExecutor.java:628)
	at java.lang.Thread.run(java.base@11.0.23/Thread.java:829)

The changeNickname() method was synchronized and is userHasLeft(),
this caused a deadlock since changeNickname() awaits the presence that
is send as result of the nickname change. But this presence is also
processed in a listener which invokes userHasLeft(). However, this
invocation blocks as userHasLeft() is waiting on the montior currently
hold by the thread invoking changeNickname().

To fix this, we change changeNickname() to not take the MultiUserChat
monitor, but instead use a dedicate lock.

Fixes SMACK-942.
2024-05-20 21:45:34 +02:00
Florian Schmaus
1836537c42 [core] Add unit test for IQ parsing
Motivated by
https://discourse.igniterealtime.org/t/question-about-tigase-server-8-3-1-and-smack-4-4-7/93796/
2024-05-20 15:18:37 +02:00
Florian Schmaus
e70d0cd858 [sinttest] Improve MultiUResultSyncPoint's TimoutException message 2024-05-20 15:11:28 +02:00
Florian Schmaus
c4ce6b4707 [muc] Add support for muc#roomconfig_roomname in MucConfigFormManager 2024-05-20 15:10:56 +02:00
Florian Schmaus
1bf0aed0f5 [build.gradle] Add junit-platform-launcher add testRuntimeOnly
Fixes

   NoSuchMethodError: 'java.util.Set org.junit.platform.engine.TestDescriptor.getAncestors()

when running unit tests in Eclipse.
2024-05-20 15:09:22 +02:00
Guus der Kinderen
121d4ac245 [sinttest] Normalization of SpecificationReference to include dash-seperator
When comparing SINT-configuration to annotations, a bit of normalization occurs, to ensure that common variations in denoting a specification are detected to be equal to each-other.

The dash (`-`) character is commonly used when referencing a specification (eg: `XEP-0001`).

This commit ensures that usage of a dash (`-`) character is included in the normalization process, making `XEP 0001`, `XEP0001` and `XEP-0001` all to be identified as the same reference.
2024-05-10 15:05:50 +02:00
Guus der Kinderen
4cc9a7d7eb [sinttest] Configuration.normalizeSpecification() should be public
It is likely to be desirable to re-use the normalization of specification references, for example in implementations of `TestRunResultProcessor`.
2024-05-10 15:01:44 +02:00
Florian Schmaus
617d1bfff2 [smack-examples] Add XmppConnectionTool 2024-05-08 15:53:00 +02:00
Florian Schmaus
e08c95a0a1 [smack-repl] Fix scala.repl's imports 2024-05-08 14:59:05 +02:00
Florian Schmaus
e0f335be40 [smack-repl] Bump Ammonite to 3.0.0-M1 and Scala to 2.13.13 2024-05-08 14:58:43 +02:00
Florian Schmaus
e79429e052
Merge pull request #591 from guusdk/sint-specref-version
[sinttest] Add optional version to specification reference
2024-05-02 09:50:26 +00:00
Guus der Kinderen
e79934938c [sinttest] Add optional version to specification reference
Some specifications are versioned. XEPs, for example, typically are. It is useful to annotate an implementation with the specific version of the specification that is being tested.
2024-04-30 22:04:20 +02:00
Florian Schmaus
1bba38decd
Merge pull request #519 from guusdk/SINT_roster-presence-based
[sinttest] Add roster tests that are driven by presence stanzas
2024-04-30 15:00:06 +00:00
Florian Schmaus
36d6ff2995
Merge pull request #482 from Fishbowler/xep-0045-coverage-part4
[sinttest] Additional tests covering s7 of XEP-0045
2024-04-30 10:08:39 +02:00
Dan Caseley
855f01e6b2 [sinttest] Additional tests for s7 of XEP-0045 2024-04-30 09:44:58 +02:00
Florian Schmaus
5fcd0b56dd
Merge pull request #590 from guusdk/sint_add-ignite-to-default-scanner
[sinttest] Expand list of default test packages
2024-04-29 17:22:35 +00:00
Guus der Kinderen
8efa4bd732 [sinttest] Expand list of default test packages
The default set of packages that is scanned for integration tests are referencing jivesoftware. This commit adds igniterealtime-oriented package names.
2024-04-26 17:16:03 +02:00
Guus der Kinderen
ad756810c1 SINT: Removing invalid test
The implementation of the test that is being removed depends on a server
characteristic that will cause a loop of presence stanzas (which obviously is
bad). A RFC3921-compliant client can send an 'acknowledgement' after receiving
a presence 'subscribed' stanza, in the form of a presence 'subscribe' stanza.
See section 8.2 of RFC3921.

When a server implementation does not ignore this acknowledgement, the domain
of the recipient MUST (RFC6121 section 3.1.3) respond with a 'subscribed' on
behalf of the recipient (which is what the now removed test was verifying).
This can trigger the RFC3921-compliant sender to again receive 'subscribed',
that it again can acknowledge, which causes a loop.

To test RFC6121, the subscription state of the recipient must somehow be
modified to reflect a different state than that of the initiator. I'm not sure
if that is feasible with the SINT framework.
2024-04-26 10:56:33 +02:00
Guus der Kinderen
26ec0d412d SINT: Add roster tests that are driven by presence stanzas
RFC-6121 defines server-sided behavior of the interaction between presence stanzas and rosters.
This commit adds tests for that behavior.
2024-04-26 10:56:21 +02:00
Florian Schmaus
8a71029fbc
Merge pull request #588 from guusdk/sint_configurable-testresultprocessor
[sinttest] Allow custom processing of test run result
2024-04-17 15:35:50 +00:00
Florian Schmaus
37f4f35675
Merge pull request #589 from guusdk/sint_syncpoint_timeoutmessage
[sinttest] Carry over assertion message when sync point times out
2024-04-17 10:43:35 +00:00
Guus der Kinderen
77dc527a63 [sinttest] Carry over assertion message when sync point times out
`AbstractSmackIntTest#assertResult()` takes an argument that is an assertion message. When the sync point times out, that message should be logged.

The following illustrates the change, as a result of this assertion failing:

```
assertResult(resultSyncPoint, "Expected " + conTwo.getUser() + " to receive message that was sent by " + conOne.getUser() + " in room " + mucAddress + " (but it did not).");
```

Prior to this change, this is logged:

```
SEVERE: MultiUserChatIntegrationTest.mucTest (Normal) failed: java.util.concurrent.TimeoutException: Timeout expired
java.util.concurrent.TimeoutException: Timeout expired
	at org.igniterealtime.smack.inttest.util.ResultSyncPoint.waitForResult(ResultSyncPoint.java:49)
	at org.igniterealtime.smack.inttest.AbstractSmackIntTest.assertResult(AbstractSmackIntTest.java:104)
	at org.igniterealtime.smack.inttest.AbstractSmackIntTest.assertResult(AbstractSmackIntTest.java:99)
	at org.jivesoftware.smackx.muc.MultiUserChatIntegrationTest.mucTest(MultiUserChatIntegrationTest.java:132)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	(snip)
```

With the change in this commit, that becomes:

```
SEVERE: MultiUserChatIntegrationTest.mucTest (Normal) failed: java.util.concurrent.TimeoutException: Expected smack-inttest-two-jskr4@example.org/two-jskr4 to receive message that was sent by smack-inttest-one-jskr4@example.org/one-jskr4 in room smack-inttest-message-jskr4-aud43i@conference.example.org (but it did not).
java.util.concurrent.TimeoutException: Expected smack-inttest-two-jskr4@example.org/two-jskr4 to receive message that was sent by smack-inttest-one-jskr4@example.org/one-jskr4 in room smack-inttest-message-jskr4-aud43i@conference.example.org (but it did not).
	at org.igniterealtime.smack.inttest.util.ResultSyncPoint.waitForResult(ResultSyncPoint.java:53)
	at org.igniterealtime.smack.inttest.AbstractSmackIntTest.assertResult(AbstractSmackIntTest.java:104)
	at org.igniterealtime.smack.inttest.AbstractSmackIntTest.assertResult(AbstractSmackIntTest.java:99)
	at org.jivesoftware.smackx.muc.MultiUserChatIntegrationTest.mucTest(MultiUserChatIntegrationTest.java:132)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	(snip)
```
2024-04-17 10:10:00 +02:00
Guus der Kinderen
5622bb07d1 [sinttest] Allow custom processing of test run result
This adds a new configuration option, `testRunResultProcessors`, that allows a user to customize the way the results of a test run is processed.

By default, the pre-exising printing-to-stderr is used.
2024-04-17 09:40:17 +02:00
Florian Schmaus
2e94599d58
Merge pull request #587 from guusdk/sint_fix-annotation-read
[sinttest] Fix processing of SpecificationReference
2024-04-11 14:07:11 +00:00
Guus der Kinderen
d515a24e1c [sinttest] Fix processing of SpecificationReference
When refactoring the original implementation, this annotation was expected to be present on methods. It later was changed to be a type-based annotation. This particular usage of the annotation was not properly modified to account for that change.
2024-04-11 15:07:10 +02:00
Florian Schmaus
355cc4eb53
Merge pull request #586 from guusdk/sint_muc-defaultaffilition-order
[sinttest] Refactoring XEP-0045 test for default roles
2024-04-10 16:35:29 +00:00
Guus der Kinderen
900b25235c [sinttest] Refactoring XEP-0045 test for default roles
When testing for default role assignment based on affiliation, depending on the 'adminGranted' callback is dangerous, as this callback appears to be only invoked when the affected occupant has already joined the room.

The exact occupant count isn't something that these tests need to assert either.

This commit changes the test implementations to proceed when all expected occupants have been detected by the user performing the change.

These changes combined intend to make the tests more robust, with regards to the order in which several events are fired (which might be unexpeced, given threading implementation in server (clusters) and Smack stanza handling.
2024-04-10 17:29:43 +02:00
Florian Schmaus
6b300ec279
Merge pull request #585 from guusdk/sint_assertequals-argument-order
[sinttest]: Fix order of arguments in assertEquals()
2024-04-10 14:58:34 +00:00
Florian Schmaus
78814d2f86 Smack 4.5.0-alpha4-SNAPSHOT 2024-04-10 13:20:52 +02:00
Florian Schmaus
621dc48865 Smack 4.5.0-alpha3 2024-04-10 12:40:27 +02:00
Guus der Kinderen
c67292ea86 [sinttest]: Fix order of arguments in assertEquals()
When using 'assertEquals', the first argument is to be the _expected_ value, the second the _actual_ value. When this is inverted, the functional test will still succeed, but any generated error message ("Expected X, got Y") will be wrong.

This commit fixes the order of arguments, mostly in the sinttest module.
2024-04-10 11:40:55 +02:00
Florian Schmaus
2cbdfa0153
Merge pull request #584 from guusdk/sint_human-readable-assertion-messages
[sinttest] Assertions to have human readable messages
2024-04-09 15:35:55 +00:00
Guus der Kinderen
2298364384 [sinttest] Assertions to have human readable messages
This adds human-readable text to nearly all assertions in SINT. It is intended that these, together with an XMPP dump of the traffic that was exchanged during the test, allows an observer to have a chance to determine why a particular test failed, without analyzing the test code itself.
2024-04-09 17:25:16 +02:00
Florian Schmaus
211cf342a4
Merge pull request #579 from guusdk/sint_tagging
Sint tagging
2024-04-09 14:17:48 +00:00
Florian Schmaus
d204d24223
Merge pull request #583 from Flowdalic/sinttest-assert-result
[sinttest] Add AbstractSmackIntTest.assertResult()
2024-04-09 14:16:44 +00:00
Guus der Kinderen
8839808746 [sinttest] Retrofit most pre-existing tests to use new tagging
This applies the new features from the previous commit, and applies them to pre-existing tests.
2024-04-09 15:29:15 +02:00
Guus der Kinderen
f76f0791e6 [sinttest] Add tagging of tests with references to (XMPP) specifications
A new annotation is introduced (`SpecificationReference`) that can be used to annotate a SINT test class

The properties are available in the annotation:
- `document`: Identifier for a specification document, such as 'RFC 6120' or 'XEP-0485'

The pre-existing `SmackIntegrationTest` annotation has now received two new properties:
- `section`: Identifier for a section (or paragraph), such as '6.2.1'
- `quote`: A quotation of relevant text from the section
These are expected to be used in context of the `SpecificationReference` annotation.

The SINT execution framework is modified so that two new configuration options are available:
- `enabledSpecifications`
- `disabledSpecifications`

These operate on the value of the `document` property of the annotation. Their usage is comparable
to that of the pre-existing `enabledTests` and `disabledTest` configuration options.

Execution output now includes the document, section and quote that's on the annotated test, when
the test fails. This allows an end-user to easily correspond a test failure with a particular
specification.
2024-04-09 15:25:21 +02:00
Florian Schmaus
dc96484d2b [sinttest] Add AbstractSmackIntTest.assertResult() 2024-04-04 21:04:21 +02:00
Florian Schmaus
7139a43291
Merge pull request #580 from guusdk/debugger-context
Debugger context
2024-04-03 15:10:32 +00:00
Guus der Kinderen
d92fef432e SINT: Expose the test that's being executed 2024-04-03 17:07:20 +02:00
Florian Schmaus
e3d12eed94 Merge remote-tracking branch 'origin/master' 2024-04-02 18:53:34 +02:00
Florian Schmaus
d24767c6a4
Merge pull request #578 from guusdk/typo
SINT: fix typo in output for disabled test
2024-04-02 16:51:59 +00:00
Florian Schmaus
4c60986795 Merge branch '4.4' 2024-04-02 18:48:36 +02:00
Florian Schmaus
951588e4ed Smack 4.4.9-SNAPSHOT 2024-04-02 18:48:17 +02:00
Florian Schmaus
0ca22f22a9 Smack 4.4.8 2024-04-02 18:28:10 +02:00
Florian Schmaus
505e1088b4
Merge pull request #577 from Flowdalic/supress-roster-not-loaded-warning
Supress roster not loaded warning if self-presence
2024-04-02 15:23:35 +02:00