use of io.seata.discovery.registry.RegistryService in project seata by seata.
the class CustomRegistryTest method testCustomRegistryLoad.
@Test
public void testCustomRegistryLoad() {
RegistryService registryService = RegistryFactory.getInstance();
Assertions.assertTrue(registryService instanceof CustomRegistryServiceForTest);
}
use of io.seata.discovery.registry.RegistryService in project seata by seata.
the class EtcdRegistryServiceImplTest method testRegister.
@Test
public void testRegister() throws Exception {
RegistryService registryService = new EtcdRegistryProvider().provide();
InetSocketAddress inetSocketAddress = new InetSocketAddress(HOST, PORT);
// 1.register
registryService.register(inetSocketAddress);
// 2.get instance information
GetOption getOption = GetOption.newBuilder().withPrefix(buildRegistryKeyPrefix()).build();
long count = client.getKVClient().get(buildRegistryKeyPrefix(), getOption).get().getKvs().stream().filter(keyValue -> {
String[] instanceInfo = keyValue.getValue().toString(UTF_8).split(":");
return HOST.equals(instanceInfo[0]) && PORT == Integer.parseInt(instanceInfo[1]);
}).count();
assertThat(count).isEqualTo(1);
}
use of io.seata.discovery.registry.RegistryService in project seata by seata.
the class EtcdRegistryServiceImplTest method testLookup.
@Test
public void testLookup() throws Exception {
RegistryService registryService = new EtcdRegistryProvider().provide();
InetSocketAddress inetSocketAddress = new InetSocketAddress(HOST, PORT);
// 1.register
registryService.register(inetSocketAddress);
// 2.lookup
List<InetSocketAddress> inetSocketAddresses = registryService.lookup(DEFAULT_TX_GROUP);
assertThat(inetSocketAddresses).size().isEqualTo(1);
}
use of io.seata.discovery.registry.RegistryService in project seata by seata.
the class ConsulRegistryServiceImplTest method testRegister.
@Test
public void testRegister() throws Exception {
RegistryService registryService = mock(ConsulRegistryServiceImpl.class);
InetSocketAddress inetSocketAddress = new InetSocketAddress("127.0.0.1", 8091);
registryService.register(inetSocketAddress);
verify(registryService).register(inetSocketAddress);
}
use of io.seata.discovery.registry.RegistryService in project seata by seata.
the class ConsulRegistryServiceImplTest method testLookup.
@Test
public void testLookup() throws Exception {
RegistryService registryService = mock(ConsulRegistryServiceImpl.class);
registryService.lookup("test-key");
verify(registryService).lookup("test-key");
}
Aggregations