Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISPN-8077 Split test classes in order to get clean test runs for nati… #5303

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,72 @@
package org.infinispan.client.hotrod;

import org.infinispan.client.hotrod.test.HotRodClientTestingUtil;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.server.hotrod.HotRodServer;
import org.infinispan.test.SingleCacheManagerTest;
import org.infinispan.test.fwk.CleanupAfterMethod;
import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNotSame;
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertSame;

@Test(testName = "client.hotrod.ForceReturnValuesIdentityTest", groups = "functional")
@CleanupAfterMethod
public class ForceReturnValuesIdentityTest extends SingleCacheManagerTest {

private HotRodServer hotRodServer;
private RemoteCacheManager remoteCacheManager;

@Override
protected EmbeddedCacheManager createCacheManager() throws Exception {
cacheManager = TestCacheManagerFactory.createCacheManager(hotRodCacheConfiguration());
cache = cacheManager.getCache();

hotRodServer = HotRodClientTestingUtil.startHotRodServer(cacheManager);

org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder =
new org.infinispan.client.hotrod.configuration.ConfigurationBuilder();
clientBuilder.addServer().host("localhost").port(hotRodServer.getPort());
remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
return cacheManager;
}

@AfterMethod
void shutdown() {
HotRodClientTestingUtil.killRemoteCacheManager(remoteCacheManager);
HotRodClientTestingUtil.killServers(hotRodServer);
}

public void testSameInstanceForSameForceReturnValues() {
RemoteCache<String, String> rcDontForceReturn = remoteCacheManager.getCache(false);
RemoteCache<String, String> rcDontForceReturn2 = remoteCacheManager.getCache(false);
assertSame("RemoteCache instances should be the same", rcDontForceReturn, rcDontForceReturn2);

RemoteCache<String, String> rcForceReturn = remoteCacheManager.getCache(true);
RemoteCache<String, String> rcForceReturn2 = remoteCacheManager.getCache(true);
assertSame("RemoteCache instances should be the same", rcForceReturn, rcForceReturn2);
}

public void testDifferentInstancesForDifferentForceReturnValues() {
RemoteCache<String, String> rcDontForceReturn = remoteCacheManager.getCache(false);
RemoteCache<String, String> rcForceReturn = remoteCacheManager.getCache(true);
assertNotSame("RemoteCache instances should not be the same", rcDontForceReturn, rcForceReturn);

String rv = rcDontForceReturn.put("Key", "Value");
assertNull(rv);
rv = rcDontForceReturn.put("Key", "Value2");
assertNull(rv);

rv = rcForceReturn.put("Key2", "Value");
assertNull(rv);
rv = rcForceReturn.put("Key2", "Value2");
assertNotNull(rv);
assertEquals("Previous value should be 'Value'", "Value", rv);
}
}
@@ -1,12 +1,5 @@
package org.infinispan.client.hotrod;

import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNotSame;
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertSame;

import org.infinispan.client.hotrod.test.HotRodClientTestingUtil;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.server.hotrod.HotRodServer;
Expand All @@ -15,6 +8,7 @@
import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;

@Test(testName = "client.hotrod.ForceReturnValuesTest", groups = "functional")
@CleanupAfterMethod
Expand All @@ -30,7 +24,7 @@ protected EmbeddedCacheManager createCacheManager() throws Exception {
hotRodServer = HotRodClientTestingUtil.startHotRodServer(cacheManager);

org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder =
new org.infinispan.client.hotrod.configuration.ConfigurationBuilder();
new org.infinispan.client.hotrod.configuration.ConfigurationBuilder();
clientBuilder.addServer().host("localhost").port(hotRodServer.getPort());
remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
return cacheManager;
Expand Down Expand Up @@ -58,31 +52,4 @@ public void testForceReturnValues() {
assert rv != null;
assert "Value".equals(rv);
}

public void testSameInstanceForSameForceReturnValues() {
RemoteCache<String, String> rcDontForceReturn = remoteCacheManager.getCache(false);
RemoteCache<String, String> rcDontForceReturn2 = remoteCacheManager.getCache(false);
assertSame("RemoteCache instances should be the same", rcDontForceReturn, rcDontForceReturn2);

RemoteCache<String, String> rcForceReturn = remoteCacheManager.getCache(true);
RemoteCache<String, String> rcForceReturn2 = remoteCacheManager.getCache(true);
assertSame("RemoteCache instances should be the same", rcForceReturn, rcForceReturn2);
}

public void testDifferentInstancesForDifferentForceReturnValues() {
RemoteCache<String, String> rcDontForceReturn = remoteCacheManager.getCache(false);
RemoteCache<String, String> rcForceReturn = remoteCacheManager.getCache(true);
assertNotSame("RemoteCache instances should not be the same", rcDontForceReturn, rcForceReturn);

String rv = rcDontForceReturn.put("Key", "Value");
assertNull(rv);
rv = rcDontForceReturn.put("Key", "Value2");
assertNull(rv);

rv = rcForceReturn.put("Key2", "Value");
assertNull(rv);
rv = rcForceReturn.put("Key2", "Value2");
assertNotNull(rv);
assertEquals("Previous value should be 'Value'", "Value", rv);
}
}
@@ -0,0 +1,70 @@
package org.infinispan.client.hotrod;

import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.test.HotRodClientTestingUtil;
import org.infinispan.commons.marshall.jboss.GenericJBossMarshaller;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.server.hotrod.HotRodServer;
import org.infinispan.test.SingleCacheManagerTest;
import org.infinispan.test.TestingUtil;
import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.testng.annotations.AfterTest;
import org.testng.annotations.Test;

import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertTrue;

/**
* @author Mircea.Markus@jboss.com
* @since 4.1
*
* Adds tests for remote cache mangaer which are not supported
* by native clients (C++ and C#). See HRCPP-189 HRCPP-190.
*/
@Test(testName = "client.hotrod.RemoteCacheManagerExtendedTest", groups = "functional" )
public class RemoteCacheManagerExtendedTest extends SingleCacheManagerTest {

HotRodServer hotrodServer;
int port;
RemoteCacheManager remoteCacheManager;

@Override
protected EmbeddedCacheManager createCacheManager() throws Exception {
return TestCacheManagerFactory.createCacheManager(
hotRodCacheConfiguration());
}

@Override
protected void setup() throws Exception {
super.setup();
hotrodServer = HotRodClientTestingUtil.startHotRodServer(cacheManager);
port = hotrodServer.getPort();
remoteCacheManager = null;
}

@AfterTest
public void release() {
TestingUtil.killCacheManagers(cacheManager);
HotRodClientTestingUtil.killServers(hotrodServer);
HotRodClientTestingUtil.killRemoteCacheManager(remoteCacheManager);
}

public void testGetUndefinedCache() {
ConfigurationBuilder clientBuilder =
new ConfigurationBuilder();
clientBuilder.addServer().host("localhost").port(port);
remoteCacheManager = new RemoteCacheManager(clientBuilder.build(), false);
assert !remoteCacheManager.isStarted();
remoteCacheManager.start();
assert null == remoteCacheManager.getCache("Undefined1234");
}

public void testMarshallerInstance() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer().host("127.0.0.1").port(port);
GenericJBossMarshaller marshaller = new GenericJBossMarshaller();
builder.marshaller(marshaller);
remoteCacheManager = new RemoteCacheManager(builder.build());
assertTrue(marshaller == remoteCacheManager.getMarshaller());
}
}
Expand Up @@ -6,7 +6,6 @@

import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.test.HotRodClientTestingUtil;
import org.infinispan.commons.marshall.jboss.GenericJBossMarshaller;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.server.hotrod.HotRodServer;
import org.infinispan.test.SingleCacheManagerTest;
Expand Down Expand Up @@ -76,23 +75,4 @@ public void testConfigurationConstructor() {
remoteCacheManager = new RemoteCacheManager(builder.build());
assertTrue(remoteCacheManager.isStarted());
}

public void testGetUndefinedCache() {
org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder =
new org.infinispan.client.hotrod.configuration.ConfigurationBuilder();
clientBuilder.addServer().host("localhost").port(port);
remoteCacheManager = new RemoteCacheManager(clientBuilder.build(), false);
assert !remoteCacheManager.isStarted();
remoteCacheManager.start();
assert null == remoteCacheManager.getCache("Undefined1234");
}

public void testMarshallerInstance() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer().host("127.0.0.1").port(port);
GenericJBossMarshaller marshaller = new GenericJBossMarshaller();
builder.marshaller(marshaller);
remoteCacheManager = new RemoteCacheManager(builder.build());
assertTrue(marshaller == remoteCacheManager.getMarshaller());
}
}