Search in sources :

Example 1 with LocalNode

use of org.wildfly.clustering.server.group.LocalNode in project wildfly by wildfly.

the class KeyMapperTestCase method test.

@Test
public void test() throws UnknownHostException {
    TwoWayKey2StringMapper mapper = new KeyMapper();
    Assert.assertTrue(mapper.isSupportedType(LocalNode.class));
    Assert.assertTrue(mapper.isSupportedType(AddressableNode.class));
    Assert.assertTrue(mapper.isSupportedType(ServiceName.class));
    Set<String> formatted = new HashSet<>();
    Node localNode = new LocalNode("cluster", "node");
    String mappedLocalNode = mapper.getStringMapping(localNode);
    Assert.assertEquals(localNode, mapper.getKeyMapping(mappedLocalNode));
    Assert.assertTrue(formatted.add(mappedLocalNode));
    Node addressableNode = new AddressableNode(UUID.randomUUID(), "node", new InetSocketAddress(InetAddress.getLocalHost(), 0));
    String mappedAddressableNode = mapper.getStringMapping(addressableNode);
    Assert.assertEquals(addressableNode, mapper.getKeyMapping(mappedAddressableNode));
    Assert.assertTrue(formatted.add(mappedAddressableNode));
    ServiceName serviceName = ServiceName.of("node");
    String mappedServiceName = mapper.getStringMapping(serviceName);
    Assert.assertEquals(serviceName, mapper.getKeyMapping(mappedServiceName));
    Assert.assertTrue(formatted.add(mappedServiceName));
}
Also used : TwoWayKey2StringMapper(org.infinispan.persistence.keymappers.TwoWayKey2StringMapper) LocalNode(org.wildfly.clustering.server.group.LocalNode) ServiceName(org.jboss.msc.service.ServiceName) InetSocketAddress(java.net.InetSocketAddress) AddressableNode(org.wildfly.clustering.server.group.AddressableNode) LocalNode(org.wildfly.clustering.server.group.LocalNode) Node(org.wildfly.clustering.group.Node) AddressableNode(org.wildfly.clustering.server.group.AddressableNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 HashSet (java.util.HashSet)1 TwoWayKey2StringMapper (org.infinispan.persistence.keymappers.TwoWayKey2StringMapper)1 ServiceName (org.jboss.msc.service.ServiceName)1 Test (org.junit.Test)1 Node (org.wildfly.clustering.group.Node)1 AddressableNode (org.wildfly.clustering.server.group.AddressableNode)1 LocalNode (org.wildfly.clustering.server.group.LocalNode)1