Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-8077 Split test classes in order to get clean test runs for nati…
…ve clients
- Loading branch information
1 parent
b4b0fea
commit 284e448
Showing
4 changed files
with
144 additions
and
55 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
...trod-client/src/test/java/org/infinispan/client/hotrod/ForceReturnValuesIdentityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...rod-client/src/test/java/org/infinispan/client/hotrod/RemoteCacheManagerExtendedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters