private void assertEqualConfiguration(Configuration config, RemoteCache rc) throws Exception { assertEquals(config.balancingStrategyFactory().get().getClass().getName(), getRequestBalancingStrategyProperty(rc)); for (ServerConfiguration scfg : config.servers()) { boolean found = false; String host; assertEquals(config.forceReturnValues(), Boolean.parseBoolean(getForceReturnValueProperty(rc))); assertEquals(config.tcpNoDelay(), Boolean.parseBoolean(getTcpNoDelayProperty(rc))); assertEquals(config.tcpKeepAlive(), Boolean.parseBoolean(getTcpKeepAliveProperty(rc))); assertEquals(config.maxRetries(), Integer.parseInt(getMaxRetries(rc))); assertEquals(config.asyncExecutorFactory().factoryClass().getName(), rc.getRemoteCacheManager().getConfiguration().asyncExecutorFactory().factoryClass().getName()); if (config.marshaller() != null) { assertEquals(config.marshaller().getClass().getName(), getMarshallerProperty(rc)); } else { assertEquals(config.marshallerClass().getName(), getMarshallerProperty(rc)); assertEquals(config.consistentHashImpl(3).getName(), getHashFunctionImplProperty(rc)); assertEquals(config.keySizeEstimate(), getKeySizeEstimateProperty(rc)); assertEquals(config.valueSizeEstimate(), getValueSizeEstimateProperty(rc));
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanRemoteCacheManagerFactoryBean#setServerList(Collection)} * . * * @throws Exception */ @Test public final void setServerListShouldOverrideDefaultServerList() throws Exception { final Collection<InetSocketAddress> expectedServerList = new ArrayList<InetSocketAddress>(1); expectedServerList.add(new InetSocketAddress("testhost", 4632)); final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); final String expectedServerListString = "testhost:4632"; objectUnderTest.setServerList(expectedServerList); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setServerList(" + expectedServerList + ") should have overridden property 'serverList'. However, it didn't.", expectedServerListString, remoteCacheManager.getConfiguration().properties().get(SERVER_LIST)); objectUnderTest.destroy(); }
@Override public ClassLoader getClassLoader() { return cm.getConfiguration().classLoader(); }
@Override public byte[] getEventData() { RemoteCache cache = remoteCacheManager.getCache(); int keySizeEstimate = cache.getRemoteCacheManager().getConfiguration().keySizeEstimate(); int valueSizeEstimate = cache.getRemoteCacheManager().getConfiguration().valueSizeEstimate(); byte[] key = cache.getDataFormat().keyToBytes(sessionId, keySizeEstimate, valueSizeEstimate); int capacity = UnsignedNumeric.sizeUnsignedInt(key.length) + key.length; byte[] out = new byte[capacity]; int offset = UnsignedNumeric.writeUnsignedInt(out, 0, key.length); System.arraycopy(key, 0, out, offset, key.length); return out; }
.read(origConfig); String securedHotRodEndpoint = origConfig.servers().stream() .map(serverConfiguration -> serverConfiguration.host() + ":" + serverConfiguration.port()) .collect(Collectors.joining(";"));
protected Properties configurationProperties() throws IOException { final Properties answer; if (this.configurationProperties != null) { answer = this.configurationPropertiesOverrides.override(this.configurationProperties); this.logger.debug("Using user-defined properties [" + this.configurationProperties + "] for configuring RemoteCacheManager"); } else if (this.configurationPropertiesFileLocation != null) { answer = loadPropertiesFromFile(this.configurationPropertiesFileLocation); this.logger.debug("Loading properties from file [" + this.configurationProperties + "] for configuring RemoteCacheManager"); } else if (!this.configurationPropertiesOverrides.isEmpty()) { answer = this.configurationPropertiesOverrides.override(new Properties()); this.logger.debug("Using explicitly set configuration settings [" + answer + "] for configuring RemoteCacheManager"); } else { this.logger .debug("No configuration properties. RemoteCacheManager will use default configuration."); answer = new RemoteCacheManager().getConfiguration().properties(); } return answer; }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean#setServerList(Collection)} * . * * @throws Exception */ @Test public final void setServerListShouldOverrideDefaultServerList() throws Exception { final Collection<InetSocketAddress> expectedServerList = new ArrayList<InetSocketAddress>(1); expectedServerList.add(new InetSocketAddress("testhost", 4632)); final SpringRemoteCacheManagerFactoryBean objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); final String expectedServerListString = "testhost:4632"; objectUnderTest.setServerList(expectedServerList); objectUnderTest.afterPropertiesSet(); final SpringRemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setServerList(" + expectedServerList + ") should have overridden property 'serverList'. However, it didn't.", expectedServerListString, remoteCacheManager.getNativeCacheManager().getConfiguration().properties() .get(SERVER_LIST)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanRemoteCacheManagerFactoryBean#setTcpNoDelay(boolean)} * . * * @throws Exception */ @Test public final void setTcpNoDelayShouldOverrideDefaultTcpNoDelay() throws Exception { final boolean expectedTcpNoDelay = true; final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.setTcpNoDelay(expectedTcpNoDelay); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setTcpNoDelay(" + expectedTcpNoDelay + ") should have overridden property 'tcpNoDelay'. However, it didn't.", String.valueOf(expectedTcpNoDelay), remoteCacheManager.getConfiguration().properties().get(TCP_NO_DELAY)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanRemoteCacheManagerFactoryBean#getObject()} * . * * @throws Exception */ @Test public final void shouldProduceARemoteCacheManagerConfiguredUsingDefaultSettingsIfNeitherConfigurationPropertiesNorConfigurationPropertiesFileLocationHasBeenSet() throws Exception { final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); AssertionUtils.assertPropertiesSubset( "The configuration properties used by the RemoteCacheManager returned by getObject() should be equal " + "to RemoteCacheManager's default settings since neither property 'configurationProperties' " + "nor property 'configurationPropertiesFileLocation' has been set. However, those two are not equal.", new RemoteCacheManager().getConfiguration().properties(), remoteCacheManager.getConfiguration().properties()); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanRemoteCacheManagerFactoryBean#setKeySizeEstimate(int)} * . * * @throws Exception */ @Test public final void setKeySizeEstimateShouldOverrideDefaultKeySizeEstimate() throws Exception { final int expectedKeySizeEstimate = -123456; final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.setKeySizeEstimate(expectedKeySizeEstimate); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setKeySizeEstimate(" + expectedKeySizeEstimate + ") should have overridden property 'keySizeEstimate'. However, it didn't.", String.valueOf(expectedKeySizeEstimate), remoteCacheManager.getConfiguration().properties().get(KEY_SIZE_ESTIMATE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanRemoteCacheManagerFactoryBean#setValueSizeEstimate(int)} * . * * @throws Exception */ @Test public final void setValueSizeEstimateShouldOverrideDefaultValueSizeEstimate() throws Exception { final int expectedValueSizeEstimate = -3456789; final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.setValueSizeEstimate(expectedValueSizeEstimate); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setValueSizeEstimate(" + expectedValueSizeEstimate + ") should have overridden property 'valueSizeEstimate'. However, it didn't.", String.valueOf(expectedValueSizeEstimate), remoteCacheManager.getConfiguration().properties().get(VALUE_SIZE_ESTIMATE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanRemoteCacheManagerFactoryBean#setForceReturnValues(boolean)} * . * * @throws Exception */ @Test public final void setForceReturnValuesShouldOverrideDefaultForceReturnValues() throws Exception { final boolean expectedForceReturnValues = true; final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.setForceReturnValues(expectedForceReturnValues); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setForceReturnValue(" + expectedForceReturnValues + ") should have overridden property 'forceReturnValue'. However, it didn't.", String.valueOf(expectedForceReturnValues), remoteCacheManager.getConfiguration().properties().get(FORCE_RETURN_VALUES)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean#setKeySizeEstimate(int)} * . * * @throws Exception */ @Test public final void setKeySizeEstimateShouldOverrideDefaultKeySizeEstimate() throws Exception { final int expectedKeySizeEstimate = -123456; final SpringRemoteCacheManagerFactoryBean objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); objectUnderTest.setKeySizeEstimate(expectedKeySizeEstimate); objectUnderTest.afterPropertiesSet(); final SpringRemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setKeySizeEstimate(" + expectedKeySizeEstimate + ") should have overridden property 'keySizeEstimate'. However, it didn't.", String.valueOf(expectedKeySizeEstimate), remoteCacheManager.getNativeCacheManager() .getConfiguration().properties().get(KEY_SIZE_ESTIMATE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanRemoteCacheManagerFactoryBean#setTcpKeepAlive(boolean)}. * * @throws Exception */ @Test public final void setTcpKeepAliveShouldOverrideDefaultTcpKeepAlive() throws Exception { final boolean expectedTcpKeepAlive = false; final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.setTcpNoDelay(expectedTcpKeepAlive); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setTcpKeepAlive(" + expectedTcpKeepAlive + ") should have overridden property 'tcpNoDelay'. However, it didn't.", String.valueOf(expectedTcpKeepAlive), remoteCacheManager.getConfiguration().properties().get(TCP_KEEP_ALIVE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean#setForceReturnValues(boolean)} * . * * @throws Exception */ @Test public final void setForceReturnValuesShouldOverrideDefaultForceReturnValues() throws Exception { final boolean expectedForceReturnValues = true; final SpringRemoteCacheManagerFactoryBean objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); objectUnderTest.setForceReturnValues(expectedForceReturnValues); objectUnderTest.afterPropertiesSet(); final SpringRemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setForceReturnValue(" + expectedForceReturnValues + ") should have overridden property 'forceReturnValue'. However, it didn't.", String.valueOf(expectedForceReturnValues), remoteCacheManager .getNativeCacheManager().getConfiguration().properties().get(FORCE_RETURN_VALUES)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean#setTcpNoDelay(boolean)} * . * * @throws Exception */ @Test public final void setTcpKeepAliveOverrideDefaultTcpKeepAlive() throws Exception { final boolean expectedTcpKeepAlive = false; final SpringRemoteCacheManagerFactoryBean objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); objectUnderTest.setTcpKeepAlive(expectedTcpKeepAlive); objectUnderTest.afterPropertiesSet(); final SpringRemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setTcpKeepAlive(" + expectedTcpKeepAlive + ") should have overridden property 'tcpKeepAlive'. However, it didn't.", String.valueOf(expectedTcpKeepAlive), remoteCacheManager.getNativeCacheManager() .getConfiguration().properties().get(TCP_KEEP_ALIVE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.remote.support.InfinispanRemoteCacheManagerFactoryBean#setAsyncExecutorFactory(String)} * . * * @throws Exception */ @Test public final void setAsyncExecutorFactoryShouldOverrideDefaultAsyncExecutorFactory() throws Exception { final String expectedAsyncExecutorFactory = ExecutorFactory.class.getName(); final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.setAsyncExecutorFactory(expectedAsyncExecutorFactory); objectUnderTest.setStartAutomatically(false); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setAsyncExecutorFactory(" + expectedAsyncExecutorFactory + ") should have overridden property 'asyncExecutorFactory'. However, it didn't.", expectedAsyncExecutorFactory, remoteCacheManager.getConfiguration().properties().get(ASYNC_EXECUTOR_FACTORY)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean#setValueSizeEstimate(int)} * . * * @throws Exception */ @Test public final void setValueSizeEstimateShouldOverrideDefaultValueSizeEstimate() throws Exception { final int expectedValueSizeEstimate = -3456789; final SpringRemoteCacheManagerFactoryBean objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); objectUnderTest.setValueSizeEstimate(expectedValueSizeEstimate); objectUnderTest.afterPropertiesSet(); final SpringRemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setValueSizeEstimate(" + expectedValueSizeEstimate + ") should have overridden property 'valueSizeEstimate'. However, it didn't.", String.valueOf(expectedValueSizeEstimate), remoteCacheManager .getNativeCacheManager().getConfiguration().properties().get(VALUE_SIZE_ESTIMATE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean#getObject()}. * * @throws Exception */ @Test public final void shouldProduceARemoteCacheManagerConfiguredUsingDefaultSettingsIfNeitherConfigurationPropertiesNorConfigurationPropertiesFileLocationHasBeenSet() throws Exception { final SpringRemoteCacheManagerFactoryBean objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); objectUnderTest.afterPropertiesSet(); final SpringRemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); AssertionUtils.assertPropertiesSubset( "The configuration properties used by the SpringRemoteCacheManager returned von getObject() should be equal " + "to SpringRemoteCacheManager's default settings since neither property 'configurationProperties' " + "nor property 'configurationPropertiesFileLocation' has been set. However, those two are not equal.", new RemoteCacheManager().getConfiguration().properties(), remoteCacheManager.getNativeCacheManager() .getConfiguration().properties()); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean#setTcpNoDelay(boolean)} * . * * @throws Exception */ @Test public final void setTcpNoDelayShouldOverrideDefaultTcpNoDelay() throws Exception { final boolean expectedTcpNoDelay = true; final SpringRemoteCacheManagerFactoryBean objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); objectUnderTest.setTcpNoDelay(expectedTcpNoDelay); objectUnderTest.afterPropertiesSet(); final SpringRemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setTcpNoDelay(" + expectedTcpNoDelay + ") should have overridden property 'tcpNoDelay'. However, it didn't.", String.valueOf(expectedTcpNoDelay), remoteCacheManager.getNativeCacheManager() .getConfiguration().properties().get(TCP_NO_DELAY)); objectUnderTest.destroy(); }