• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

igniterealtime / Smack / #3223

03 Jul 2024 02:47PM UTC coverage: 38.956% (-0.003%) from 38.959%
#3223

push

github

guusdk
[sinttest] XEP-0373 Integration Tests should clean-up

After test execution, the OpenPGP for XMPP integration tests should clean up the data published via PEP. This prevents these tests from interfering with other tests.

0 of 40 new or added lines in 2 files covered. (0.0%)

3 existing lines in 3 files now uncovered.

16979 of 43585 relevant lines covered (38.96%)

0.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.38
/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/util/ResultSyncPoint.java
1
/**
2
 *
3
 * Copyright 2015-2024 Florian Schmaus
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
package org.igniterealtime.smack.inttest.util;
18

19
import java.util.concurrent.TimeoutException;
20

21
import org.jivesoftware.smack.util.Objects;
22

23
public class ResultSyncPoint<R, E extends Exception> {
1✔
24

25
    private R result;
26
    private E exception;
27

28
    public R waitForResult(long timeout) throws E, InterruptedException, TimeoutException {
29
        return waitForResult(timeout, null);
1✔
30
    }
31

32
    public R waitForResult(long timeout, String timeoutMessage) throws E, InterruptedException, TimeoutException {
33
        synchronized (this) {
1✔
34
            if (result != null) {
1✔
35
                return result;
1✔
36
            }
37
            if (exception != null) {
1✔
38
                throw exception;
1✔
39
            }
40
            final long deadline = System.currentTimeMillis() + timeout;
1✔
41
            while (result == null && exception == null) {
1✔
42
                final long now = System.currentTimeMillis();
1✔
43
                if (now >= deadline) break;
1✔
44
                wait(deadline - now);
1✔
45
            }
1✔
46
        }
1✔
47
        if (result != null) {
1✔
UNCOV
48
            return result;
×
49
        }
50
        if (exception != null) {
1✔
51
            throw exception;
1✔
52
        }
53

54
        String message = "Timeout after " + timeout + "ms";
×
55
        if (timeoutMessage != null) {
×
56
            message += ": " + timeoutMessage;
×
57
        }
58
        throw new TimeoutException(message);
×
59
    }
60

61

62
    public void signal(R result) {
63
        synchronized (this) {
1✔
64
            this.result = Objects.requireNonNull(result);
1✔
65
            notifyAll();
1✔
66
        }
1✔
67
    }
1✔
68

69
    public void signal(E exception) {
70
        synchronized (this) {
1✔
71
            this.exception = Objects.requireNonNull(exception);
1✔
72
            notifyAll();
1✔
73
        }
1✔
74
    }
1✔
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc