Search in sources :

Example 1 with DummyServerStateManager

use of org.infinispan.server.core.DummyServerStateManager in project infinispan by infinispan.

the class AbstractRestResourceTest method createCacheManagers.

@Override
protected void createCacheManagers() throws Exception {
    Security.doAs(ADMIN, () -> {
        for (int i = 0; i < NUM_SERVERS; i++) {
            GlobalConfigurationBuilder configForNode = getGlobalConfigForNode(i);
            addClusterEnabledCacheManager(new GlobalConfigurationBuilder().read(configForNode.build()), getDefaultCacheBuilder(), TransportFlags.minimalXsiteFlags());
        }
        cacheManagers.forEach(this::defineCaches);
        cacheManagers.forEach(cm -> cm.defineConfiguration("invalid", getDefaultCacheBuilder().encoding().mediaType(APPLICATION_OBJECT_TYPE).indexing().enabled(true).addIndexedEntities("invalid").build()));
        serverStateManager = new DummyServerStateManager();
        for (EmbeddedCacheManager cm : cacheManagers) {
            BasicComponentRegistry bcr = SecurityActions.getGlobalComponentRegistry(cm).getComponent(BasicComponentRegistry.class.getName());
            bcr.registerComponent(ServerStateManager.class, serverStateManager, false);
            cm.getClassAllowList().addClasses(TestClass.class);
            waitForClusterToForm(cm.getCacheNames().stream().filter(name -> {
                try {
                    cm.getCache(name);
                    return true;
                } catch (CacheConfigurationException ignored) {
                    return false;
                }
            }).toArray(String[]::new));
            RestServerHelper restServerHelper = new RestServerHelper(cm);
            if (isSecurityEnabled()) {
                BasicAuthenticator basicAuthenticator = new BasicAuthenticator(new SimpleSecurityDomain(ADMIN, USER), REALM);
                restServerHelper.withAuthenticator(basicAuthenticator);
            }
            if (ssl) {
                restServerHelper.withKeyStore(SERVER_KEY_STORE, STORE_PASSWORD, STORE_TYPE).withTrustStore(SERVER_KEY_STORE, STORE_PASSWORD, STORE_TYPE);
            }
            restServerHelper.start(TestResourceTracker.getCurrentTestShortName());
            restServers.add(restServerHelper);
        }
    });
    adminClient = RestClient.forConfiguration(getClientConfig("admin", "admin").build());
    client = RestClient.forConfiguration(getClientConfig("user", "user").build());
}
Also used : PrivateGlobalConfigurationBuilder(org.infinispan.configuration.internal.PrivateGlobalConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DummyServerStateManager(org.infinispan.server.core.DummyServerStateManager) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) BasicAuthenticator(org.infinispan.rest.authentication.impl.BasicAuthenticator) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) SimpleSecurityDomain(org.infinispan.rest.resources.security.SimpleSecurityDomain) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) RestServerHelper(org.infinispan.rest.helper.RestServerHelper)

Example 2 with DummyServerStateManager

use of org.infinispan.server.core.DummyServerStateManager in project infinispan by infinispan.

the class MemcachedSingleNodeTest method createCacheManager.

@Override
protected EmbeddedCacheManager createCacheManager() throws Exception {
    cacheManager = createTestCacheManager();
    cacheManager.getGlobalComponentRegistry().registerComponent(new DummyServerStateManager(), ServerStateManager.class);
    TestingUtil.replaceComponent(cacheManager, TimeService.class, timeService, true);
    server = startMemcachedTextServer(cacheManager);
    client = createMemcachedClient(60000, server.getPort());
    cache = cacheManager.getCache(server.getConfiguration().defaultCacheName());
    return cacheManager;
}
Also used : DummyServerStateManager(org.infinispan.server.core.DummyServerStateManager)

Aggregations

DummyServerStateManager (org.infinispan.server.core.DummyServerStateManager)2 CacheConfigurationException (org.infinispan.commons.CacheConfigurationException)1 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)1 PrivateGlobalConfigurationBuilder (org.infinispan.configuration.internal.PrivateGlobalConfigurationBuilder)1 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 BasicAuthenticator (org.infinispan.rest.authentication.impl.BasicAuthenticator)1 RestServerHelper (org.infinispan.rest.helper.RestServerHelper)1 SimpleSecurityDomain (org.infinispan.rest.resources.security.SimpleSecurityDomain)1