Search in sources :

Example 1 with NameserverClient

use of org.rx.net.nameserver.NameserverClient in project rxlib by RockyLOMO.

the class SocksTester method multiNode2.

@Test
public void multiNode2() {
    NameserverClient c1 = new NameserverClient(appUsercenter);
    NameserverClient c2 = new NameserverClient(appOrder);
    c1.registerAsync(node1).join();
    c2.registerAsync(node2).join();
    assert !c1.registerEndpoints().containsAll(c2.registerEndpoints());
    ns2.syncRegister(c1.registerEndpoints());
    sleep4Sync();
    System.out.println(toJsonString(c1.registerEndpoints()));
    assert c1.registerEndpoints().containsAll(c2.registerEndpoints());
}
Also used : NameserverClient(org.rx.net.nameserver.NameserverClient) Test(org.junit.jupiter.api.Test)

Example 2 with NameserverClient

use of org.rx.net.nameserver.NameserverClient in project rxlib by RockyLOMO.

the class SocksTester method multiNode1.

@Test
public void multiNode1() {
    NameserverClient c1 = new NameserverClient(appUsercenter);
    NameserverClient c2 = new NameserverClient(appOrder);
    c1.registerAsync(node1).join();
    c2.registerAsync(node2, node1).join();
    sleep4Sync();
    System.out.println("c1: " + toJsonString(c1.registerEndpoints()));
    assert c1.registerEndpoints().containsAll(c2.registerEndpoints());
    c2.deregisterAsync().join();
    sleep4Sync();
    List<InetAddress> discover = c1.discover(appOrder);
    assert CollectionUtils.isEmpty(discover);
}
Also used : NameserverClient(org.rx.net.nameserver.NameserverClient) InetAddress(java.net.InetAddress) Test(org.junit.jupiter.api.Test)

Example 3 with NameserverClient

use of org.rx.net.nameserver.NameserverClient in project rxlib by RockyLOMO.

the class SocksTester method singleClient.

@SneakyThrows
@Test
public void singleClient() {
    NameserverClient c1 = new NameserverClient(appUsercenter);
    c1.registerAsync(node1, node2);
    c1.wait4Inject();
    sleep4Sync();
    System.out.println("x:" + ns1.getDnsServer().getHosts());
    System.out.println("x2:" + ns2.getDnsServer().getHosts());
}
Also used : NameserverClient(org.rx.net.nameserver.NameserverClient) Test(org.junit.jupiter.api.Test) SneakyThrows(lombok.SneakyThrows)

Example 4 with NameserverClient

use of org.rx.net.nameserver.NameserverClient in project rxlib by RockyLOMO.

the class SocksTester method singleNode.

@Test
public void singleNode() {
    NameserverClient c1 = new NameserverClient(appUsercenter);
    NameserverClient c2 = new NameserverClient(appOrder);
    c1.registerAsync(node1).join();
    List<InetAddress> discover = c1.discover(appUsercenter);
    System.out.println(toJsonString(discover));
    assert discover.contains(Sockets.loopbackAddress());
    discover = c1.discover(appOrder);
    assert CollectionUtils.isEmpty(discover);
    c2.registerAsync(node1).join();
    discover = c1.discover(appOrder);
    assert discover.contains(Sockets.loopbackAddress());
    c2.deregisterAsync().join();
    discover = c1.discover(appOrder);
    assert CollectionUtils.isEmpty(discover);
}
Also used : NameserverClient(org.rx.net.nameserver.NameserverClient) InetAddress(java.net.InetAddress) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 NameserverClient (org.rx.net.nameserver.NameserverClient)4 InetAddress (java.net.InetAddress)2 SneakyThrows (lombok.SneakyThrows)1