blob: e0776c5471947badcf51e50ef1656a36cb015656 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jrt;
import static org.junit.Assert.assertTrue;
public class ConnectTest {
@org.junit.Test
public void testConnect() throws ListenFailedException {
Test.Orb server = new Test.Orb(new Transport());
Test.Orb client = new Test.Orb(new Transport());
Acceptor acceptor = server.listen(new Spec(0));
Connection target = (Connection) client.connect(new Spec("localhost", acceptor.port()));
for (int i = 0; i < 100; i++) {
if (target.isConnected()) {
break;
}
try { Thread.sleep(100); } catch (InterruptedException e) {}
}
assertTrue(target.isConnected());
target.close();
for (int i = 0; i < 100; i++) {
if (target.isClosed()) {
break;
}
try { Thread.sleep(100); } catch (InterruptedException e) {}
}
assertTrue(target.isClosed());
acceptor.shutdown().join();
client.transport().shutdown().join();
server.transport().shutdown().join();
}
}
|