Search in sources :

Example 1 with TwoWayKey2StringMapper

use of org.infinispan.persistence.keymappers.TwoWayKey2StringMapper in project wildfly by wildfly.

the class OrdinalKeyFormatMapperTestCase method testSinglePadding.

@Test
public void testSinglePadding() {
    TwoWayKey2StringMapper mapper = new IndexedKeyFormatMapper(createPersistenceList(16));
    Assert.assertTrue(mapper.isSupportedType(Type.TYPE00.getClass()));
    Assert.assertTrue(mapper.isSupportedType(Type.TYPE15.getClass()));
    Assert.assertFalse(mapper.isSupportedType(Type.TYPE16.getClass()));
    Assert.assertFalse(mapper.isSupportedType(Type.TYPE17.getClass()));
    String result = mapper.getStringMapping(Type.TYPE00);
    Assert.assertSame(Type.TYPE00, mapper.getKeyMapping(result));
    Assert.assertEquals("0TYPE00", result);
    result = mapper.getStringMapping(Type.TYPE15);
    Assert.assertSame(Type.TYPE15, mapper.getKeyMapping(result));
    Assert.assertEquals("FTYPE15", result);
}
Also used : TwoWayKey2StringMapper(org.infinispan.persistence.keymappers.TwoWayKey2StringMapper) Test(org.junit.Test)

Example 2 with TwoWayKey2StringMapper

use of org.infinispan.persistence.keymappers.TwoWayKey2StringMapper in project wildfly by wildfly.

the class OrdinalKeyFormatMapperTestCase method testDoublePadding.

@Test
public void testDoublePadding() {
    TwoWayKey2StringMapper mapper = new IndexedKeyFormatMapper(createPersistenceList(17));
    Assert.assertTrue(mapper.isSupportedType(Type.TYPE00.getClass()));
    Assert.assertTrue(mapper.isSupportedType(Type.TYPE15.getClass()));
    Assert.assertTrue(mapper.isSupportedType(Type.TYPE16.getClass()));
    Assert.assertFalse(mapper.isSupportedType(Type.TYPE17.getClass()));
    String result = mapper.getStringMapping(Type.TYPE00);
    Assert.assertSame(Type.TYPE00, mapper.getKeyMapping(result));
    Assert.assertEquals("00TYPE00", result);
    result = mapper.getStringMapping(Type.TYPE15);
    Assert.assertSame(Type.TYPE15, mapper.getKeyMapping(result));
    Assert.assertEquals("0FTYPE15", result);
    result = mapper.getStringMapping(Type.TYPE16);
    Assert.assertSame(Type.TYPE16, mapper.getKeyMapping(result));
    Assert.assertEquals("10TYPE16", result);
}
Also used : TwoWayKey2StringMapper(org.infinispan.persistence.keymappers.TwoWayKey2StringMapper) Test(org.junit.Test)

Example 3 with TwoWayKey2StringMapper

use of org.infinispan.persistence.keymappers.TwoWayKey2StringMapper in project wildfly by wildfly.

the class SimpleKeyFormatMapperTestCase method test.

@Test
public void test() {
    KeyFormat<Object> keyFormat = mock(KeyFormat.class);
    TwoWayKey2StringMapper mapper = new SimpleKeyFormatMapper(keyFormat);
    Object key = new Object();
    String formatted = "foo";
    when(keyFormat.getTargetClass()).thenReturn(Object.class);
    when(keyFormat.format(key)).thenReturn(formatted);
    when(keyFormat.parse(formatted)).thenReturn(key);
    Assert.assertSame(formatted, mapper.getStringMapping(key));
    Assert.assertSame(key, mapper.getKeyMapping(formatted));
    Assert.assertTrue(mapper.isSupportedType(Object.class));
    Assert.assertFalse(mapper.isSupportedType(Integer.class));
}
Also used : TwoWayKey2StringMapper(org.infinispan.persistence.keymappers.TwoWayKey2StringMapper) Test(org.junit.Test)

Example 4 with TwoWayKey2StringMapper

use of org.infinispan.persistence.keymappers.TwoWayKey2StringMapper in project wildfly by wildfly.

the class KeyMapperTestCase method test.

@Test
public void test() {
    TwoWayKey2StringMapper mapper = new KeyMapper();
    Assert.assertTrue(mapper.isSupportedType(SessionCreationMetaDataKey.class));
    Assert.assertTrue(mapper.isSupportedType(SessionAccessMetaDataKey.class));
    Assert.assertTrue(mapper.isSupportedType(SessionAttributesKey.class));
    Assert.assertTrue(mapper.isSupportedType(SessionAttributeNamesKey.class));
    Assert.assertTrue(mapper.isSupportedType(SessionAttributeKey.class));
    Assert.assertTrue(mapper.isSupportedType(AuthenticationKey.class));
    Assert.assertTrue(mapper.isSupportedType(CoarseSessionsKey.class));
    Set<String> formatted = new HashSet<>();
    String id = "ABC123";
    SessionCreationMetaDataKey creationMetaDataKey = new SessionCreationMetaDataKey(id);
    String formattedCreationMetaDataKey = mapper.getStringMapping(creationMetaDataKey);
    Assert.assertEquals(creationMetaDataKey, mapper.getKeyMapping(formattedCreationMetaDataKey));
    Assert.assertTrue(formatted.add(formattedCreationMetaDataKey));
    SessionAccessMetaDataKey accessMetaDataKey = new SessionAccessMetaDataKey(id);
    String formattedAccessMetaDataKey = mapper.getStringMapping(accessMetaDataKey);
    Assert.assertEquals(accessMetaDataKey, mapper.getKeyMapping(formattedAccessMetaDataKey));
    Assert.assertTrue(formatted.add(formattedAccessMetaDataKey));
    SessionAttributesKey attributesKey = new SessionAttributesKey(id);
    String formattedAttributesKey = mapper.getStringMapping(attributesKey);
    Assert.assertEquals(attributesKey, mapper.getKeyMapping(formattedAttributesKey));
    Assert.assertTrue(formatted.add(formattedAttributesKey));
    SessionAttributeNamesKey attributeNamesKey = new SessionAttributeNamesKey(id);
    String formattedAttributeNamesKey = mapper.getStringMapping(attributeNamesKey);
    Assert.assertEquals(attributeNamesKey, mapper.getKeyMapping(formattedAttributeNamesKey));
    Assert.assertTrue(formatted.add(formattedAttributeNamesKey));
    for (int i = 0; i < 10; ++i) {
        SessionAttributeKey attributeKey = new SessionAttributeKey(id, i);
        String formattedAttributeKey = mapper.getStringMapping(attributeKey);
        Assert.assertEquals(attributeKey, mapper.getKeyMapping(formattedAttributeKey));
        Assert.assertTrue(formatted.add(formattedAttributeKey));
    }
    AuthenticationKey authKey = new AuthenticationKey(id);
    String formattedAuthKey = mapper.getStringMapping(authKey);
    Assert.assertEquals(authKey, mapper.getKeyMapping(formattedAuthKey));
    Assert.assertTrue(formatted.add(formattedAuthKey));
    CoarseSessionsKey sessionsKey = new CoarseSessionsKey(id);
    String formattedSessionsKey = mapper.getStringMapping(sessionsKey);
    Assert.assertEquals(sessionsKey, mapper.getKeyMapping(formattedSessionsKey));
    Assert.assertTrue(formatted.add(formattedSessionsKey));
}
Also used : TwoWayKey2StringMapper(org.infinispan.persistence.keymappers.TwoWayKey2StringMapper) SessionAttributeNamesKey(org.wildfly.clustering.web.infinispan.session.fine.SessionAttributeNamesKey) SessionAttributesKey(org.wildfly.clustering.web.infinispan.session.coarse.SessionAttributesKey) SessionCreationMetaDataKey(org.wildfly.clustering.web.infinispan.session.SessionCreationMetaDataKey) SessionAttributeKey(org.wildfly.clustering.web.infinispan.session.fine.SessionAttributeKey) AuthenticationKey(org.wildfly.clustering.web.infinispan.sso.AuthenticationKey) SessionAccessMetaDataKey(org.wildfly.clustering.web.infinispan.session.SessionAccessMetaDataKey) CoarseSessionsKey(org.wildfly.clustering.web.infinispan.sso.coarse.CoarseSessionsKey) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with TwoWayKey2StringMapper

use of org.infinispan.persistence.keymappers.TwoWayKey2StringMapper in project wildfly by wildfly.

the class KeyMapperTestCase method test.

@Test
public void test() {
    TwoWayKey2StringMapper mapper = new KeyMapper();
    Assert.assertTrue(mapper.isSupportedType(InfinispanBeanKey.class));
    Assert.assertTrue(mapper.isSupportedType(InfinispanBeanGroupKey.class));
    Set<String> formatted = new HashSet<>();
    SessionID id = new UUIDSessionID(UUID.randomUUID());
    BeanKey<SessionID> beanKey = new InfinispanBeanKey<>(id);
    String formattedBeanKey = mapper.getStringMapping(beanKey);
    Assert.assertEquals(beanKey, mapper.getKeyMapping(formattedBeanKey));
    Assert.assertTrue(formatted.add(formattedBeanKey));
    BeanGroupKey<SessionID> beanGroupKey = new InfinispanBeanGroupKey<>(id);
    String formattedBeanGroupKey = mapper.getStringMapping(beanGroupKey);
    Assert.assertEquals(beanGroupKey, mapper.getKeyMapping(formattedBeanGroupKey));
    Assert.assertTrue(formatted.add(formattedBeanGroupKey));
}
Also used : TwoWayKey2StringMapper(org.infinispan.persistence.keymappers.TwoWayKey2StringMapper) UUIDSessionID(org.jboss.ejb.client.UUIDSessionID) InfinispanBeanKey(org.wildfly.clustering.ejb.infinispan.bean.InfinispanBeanKey) InfinispanBeanGroupKey(org.wildfly.clustering.ejb.infinispan.group.InfinispanBeanGroupKey) UUIDSessionID(org.jboss.ejb.client.UUIDSessionID) SessionID(org.jboss.ejb.client.SessionID) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

TwoWayKey2StringMapper (org.infinispan.persistence.keymappers.TwoWayKey2StringMapper)6 Test (org.junit.Test)6 HashSet (java.util.HashSet)3 InetSocketAddress (java.net.InetSocketAddress)1 SessionID (org.jboss.ejb.client.SessionID)1 UUIDSessionID (org.jboss.ejb.client.UUIDSessionID)1 ServiceName (org.jboss.msc.service.ServiceName)1 InfinispanBeanKey (org.wildfly.clustering.ejb.infinispan.bean.InfinispanBeanKey)1 InfinispanBeanGroupKey (org.wildfly.clustering.ejb.infinispan.group.InfinispanBeanGroupKey)1 Node (org.wildfly.clustering.group.Node)1 AddressableNode (org.wildfly.clustering.server.group.AddressableNode)1 LocalNode (org.wildfly.clustering.server.group.LocalNode)1 SessionAccessMetaDataKey (org.wildfly.clustering.web.infinispan.session.SessionAccessMetaDataKey)1 SessionCreationMetaDataKey (org.wildfly.clustering.web.infinispan.session.SessionCreationMetaDataKey)1 SessionAttributesKey (org.wildfly.clustering.web.infinispan.session.coarse.SessionAttributesKey)1 SessionAttributeKey (org.wildfly.clustering.web.infinispan.session.fine.SessionAttributeKey)1 SessionAttributeNamesKey (org.wildfly.clustering.web.infinispan.session.fine.SessionAttributeNamesKey)1 AuthenticationKey (org.wildfly.clustering.web.infinispan.sso.AuthenticationKey)1 CoarseSessionsKey (org.wildfly.clustering.web.infinispan.sso.coarse.CoarseSessionsKey)1