public void testDefaultRemoteCacheManagerInjection() { final Properties properties = remoteCacheManager.getProperties(); assertEquals(properties.getProperty(SERVER_LIST_KEY), DEFAULT_SERVER_LIST_VALUE); } }
public void testDefaultRemoteCacheManagerOverride() { final Properties properties = remoteCacheManager.getProperties(); assertEquals(properties.getProperty(SERVER_LIST_KEY), SERVER_LIST_VALUE); }
/** * Test method for * {@link org.infinispan.spring.support.remote.InfinispanRemoteCacheManagerFactoryBean#setServerList(java.util.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.getProperties().get(SERVER_LIST)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.support.remote.InfinispanRemoteCacheManagerFactoryBean#getObject()} * . * * @throws Exception */ @Test public final void shouldProduceARemoteCacheManagerConfiguredUsingDefaultSettingsIfNeitherConfigurationPropertiesNorConfigurationPropertiesFileLocationHasBeenSet() throws Exception { final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); 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().getProperties(), remoteCacheManager.getProperties()); objectUnderTest.destroy(); }
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().getProperties(); } return answer; }
/** * Test method for * {@link org.infinispan.spring.support.remote.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.getProperties().get(TCP_KEEP_ALIVE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.support.remote.InfinispanRemoteCacheManagerFactoryBean#setMarshaller(java.lang.String)} * . * * @throws Exception */ @Test public final void setMarshallerShouldOverrideDefaultMarshaller() throws Exception { final String expectedMarshaller = Marshaller.class.getName(); final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.setMarshaller(expectedMarshaller); objectUnderTest.setStartAutomatically(false); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setMarshaller(" + expectedMarshaller + ") should have overridden property 'marshaller'. However, it didn't.", expectedMarshaller, remoteCacheManager.getProperties().get(MARSHALLER)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.support.remote.InfinispanRemoteCacheManagerFactoryBean#setPingOnStartup(boolean)} * . * * @throws Exception */ @Test public final void setPingOnStartupShouldOverrideDefaultPingOnStartup() throws Exception { final boolean expectedPingOnStartup = true; final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.setPingOnStartup(expectedPingOnStartup); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setPingOnStartup(" + expectedPingOnStartup + ") should have overridden property 'transportFactory'. However, it didn't.", String.valueOf(expectedPingOnStartup), remoteCacheManager.getProperties().get(PING_ON_STARTUP)); 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(); 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().getProperties(), remoteCacheManager.getNativeCacheManager() .getProperties()); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.support.remote.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.getProperties().get(KEY_SIZE_ESTIMATE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.support.remote.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.getProperties().get(TCP_NO_DELAY)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.support.remote.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.getProperties().get(VALUE_SIZE_ESTIMATE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.support.remote.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.getProperties().get(FORCE_RETURN_VALUES)); 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() .getProperties().get(TCP_NO_DELAY)); 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() .getProperties().get(TCP_KEEP_ALIVE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean#setPingOnStartup(boolean)} * . * * @throws Exception */ @Test public final void setPingOnStartupShouldOverrideDefaultPingOnStartup() throws Exception { final boolean expectedPingOnStartup = true; final SpringRemoteCacheManagerFactoryBean objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); objectUnderTest.setPingOnStartup(expectedPingOnStartup); objectUnderTest.afterPropertiesSet(); final SpringRemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertEquals("setPingOnStartup(" + expectedPingOnStartup + ") should have overridden property 'transportFactory'. However, it didn't.", String.valueOf(expectedPingOnStartup), remoteCacheManager.getNativeCacheManager() .getProperties().get(PING_ON_STARTUP)); 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() .getProperties().get(KEY_SIZE_ESTIMATE)); 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().getProperties().get(VALUE_SIZE_ESTIMATE)); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.support.remote.InfinispanRemoteCacheManagerFactoryBean#setConfigurationPropertiesFileLocation(org.springframework.core.io.Resource)} * . */ @Test public final void shouldProduceACacheConfiguredUsingPropertiesLoadedFromALocationDeclaredThroughSetConfigurationPropertiesFileLocation() throws Exception { final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); objectUnderTest.setConfigurationPropertiesFileLocation(HOTROD_CLIENT_PROPERTIES_LOCATION); objectUnderTest.afterPropertiesSet(); final RemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertPropertiesSubset( "The configuration properties used by the RemoteCacheManager returned by getObject() should be equal " + "to those passed into InfinispanRemoteCacheMangerFactoryBean via setConfigurationPropertiesFileLocation(propsFileLocation). " + "However, those two are not equal.", loadConfigurationProperties(HOTROD_CLIENT_PROPERTIES_LOCATION), remoteCacheManager.getProperties()); objectUnderTest.destroy(); }
/** * Test method for * {@link org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean#setConfigurationPropertiesFileLocation(org.springframework.core.io.Resource)} * . */ @Test public final void shouldProduceACacheConfiguredUsingPropertiesLoadedFromALocationDeclaredThroughSetConfigurationPropertiesFileLocation() throws Exception { final SpringRemoteCacheManagerFactoryBean objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); objectUnderTest.setConfigurationPropertiesFileLocation(HOTROD_CLIENT_PROPERTIES_LOCATION); objectUnderTest.afterPropertiesSet(); final SpringRemoteCacheManager remoteCacheManager = objectUnderTest.getObject(); assertPropertiesSubset( "The configuration properties used by the SpringRemoteCacheManager returned von getObject() should be equal " + "to those passed into SpringRemoteCacheManagerFactoryBean via setConfigurationPropertiesFileLocation(propsFileLocation). " + "However, those two are not equal.", loadConfigurationProperties(HOTROD_CLIENT_PROPERTIES_LOCATION), remoteCacheManager .getNativeCacheManager().getProperties()); objectUnderTest.destroy(); }