package org.infinispan.client.hotrod; import java.util.Properties; import org.infinispan.client.hotrod.impl.ConfigurationProperties; import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.server.core.Main; import org.infinispan.server.hotrod.HotRodServer; import org.infinispan.test.SingleCacheManagerTest; import org.infinispan.test.fwk.TestCacheManagerFactory; import org.infinispan.util.logging.Log; import org.infinispan.util.logging.LogFactory; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; /** * @author Adrian Brock * @since 5.0 */ @Test public class SSLTest extends SingleCacheManagerTest { private static final Log log = LogFactory.getLog(SSLTest.class); RemoteCache defaultRemote; private RemoteCacheManager remoteCacheManager; protected HotRodServer hotrodServer; @Override protected EmbeddedCacheManager createCacheManager() throws Exception { cacheManager = TestCacheManagerFactory.createLocalCacheManager(); cacheManager.getCache(); hotrodServer = new HotRodServer(); Properties properties = new Properties(); properties.put(Main.PROP_KEY_USE_SSL(), "true"); properties.put(Main.PROP_KEY_NEED_CLIENT_AUTH(), "true"); properties.put(Main.PROP_KEY_KEY_STORE_FILE_NAME(), "c:\\cygwin\\keystore"); properties.put(Main.PROP_KEY_KEY_STORE_PASSWORD(), "secret"); properties.put(Main.PROP_KEY_TRUST_STORE_FILE_NAME(), "c:\\cygwin\\keystore"); properties.put(Main.PROP_KEY_TRUST_STORE_PASSWORD(), "secret"); hotrodServer.start(properties, cacheManager); log.info("Started server on port: " + hotrodServer.getPort()); Properties config = new Properties(); config.put("infinispan.client.hotrod.server_list", "127.0.0.1:" + hotrodServer.getPort()); config.put(ConfigurationProperties.USE_SSL, "true"); config.put(ConfigurationProperties.KEY_STORE_FILE_NAME, "c:\\cygwin\\keystore"); config.put(ConfigurationProperties.KEY_STORE_PASSWORD, "secret"); config.put(ConfigurationProperties.TRUST_STORE_FILE_NAME, "c:\\cygwin\\keystore"); config.put(ConfigurationProperties.TRUST_STORE_PASSWORD, "secret"); config.put("timeBetweenEvictionRunsMillis", "2000"); remoteCacheManager = new RemoteCacheManager(config); defaultRemote = remoteCacheManager.getCache(); return cacheManager; } @AfterClass public void testDestroyRemoteCacheFactory() { remoteCacheManager.stop(); hotrodServer.stop(); } public void testSSL() throws Exception { defaultRemote.put("k","v"); assert defaultRemote.get("k").equals("v"); } }