You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2021/05/28 20:20:28 UTC
[geode-dotnet-core-client] branch develop updated:
SessionStateCache tests pass with latest C bindings changes
This is an automated email from the ASF dual-hosted git repository.
bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-dotnet-core-client.git
The following commit(s) were added to refs/heads/develop by this push:
new 65ab67f SessionStateCache tests pass with latest C bindings changes
65ab67f is described below
commit 65ab67f73b797099f3f4a22cdd7e5b2ea18cbd28
Author: Blake Bender <bb...@vmware.com>
AuthorDate: Fri May 28 12:59:37 2021 -0700
SessionStateCache tests pass with latest C bindings changes
---
NetCore.Session/NetCoreSessionState.cs | 3 +-
NetCore.Test/CacheFactoryUnitTest.cs | 14 +-
NetCore.Test/CacheUnitTest.cs | 14 +-
NetCore.Test/ObjectLeakUnitTest.cs | 2 +-
NetCore.Test/PoolFactoryUnitTest.cs | 6 +-
NetCore.Test/PoolManagerUnitTest.cs | 2 +-
NetCore.Test/RegionFactoryUnitTest.cs | 4 +-
NetCore/CacheFactory.cs | 10 +-
NetCore/Constants.cs | 6 +-
.../SessionStateIntegrationTests.cs | 313 ++++++++++-----------
Session.Tests/SessionStateCacheTests.cs | 16 --
11 files changed, 174 insertions(+), 216 deletions(-)
diff --git a/NetCore.Session/NetCoreSessionState.cs b/NetCore.Session/NetCoreSessionState.cs
index cdd0260..0f39ae0 100644
--- a/NetCore.Session/NetCoreSessionState.cs
+++ b/NetCore.Session/NetCoreSessionState.cs
@@ -321,10 +321,9 @@ namespace Apache.Geode.Session
}
_connectLock.Wait();
- RegionFactory regionFactory = null;
try
{
- regionFactory = _cache.CreateRegionFactory(RegionShortcut.Proxy);
+ using var regionFactory = _cache.CreateRegionFactory(RegionShortcut.Proxy);
try
{
_logger?.LogTrace("Create CacheRegion");
diff --git a/NetCore.Test/CacheFactoryUnitTest.cs b/NetCore.Test/CacheFactoryUnitTest.cs
index 6dee7fe..20b246a 100644
--- a/NetCore.Test/CacheFactoryUnitTest.cs
+++ b/NetCore.Test/CacheFactoryUnitTest.cs
@@ -16,7 +16,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client))
+ using (var cacheFactory = CacheFactory.Create())
{
Assert.IsNotNull(cacheFactory);
}
@@ -28,7 +28,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client))
+ using (var cacheFactory = CacheFactory.Create())
{
var version = cacheFactory.Version;
Assert.AreNotEqual(version, String.Empty);
@@ -43,7 +43,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client))
+ using (var cacheFactory = CacheFactory.Create())
{
var description = cacheFactory.ProductDescription;
Assert.AreNotEqual(description, String.Empty);
@@ -58,7 +58,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client))
+ using (var cacheFactory = CacheFactory.Create())
{
cacheFactory.PdxIgnoreUnreadFields = true;
cacheFactory.PdxIgnoreUnreadFields = false;
@@ -73,7 +73,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client))
+ using (var cacheFactory = CacheFactory.Create())
{
cacheFactory.PdxReadSerialized = true;
cacheFactory.PdxReadSerialized = false;
@@ -88,7 +88,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client))
+ using (var cacheFactory = CacheFactory.Create())
{
using (var cache = cacheFactory.CreateCache())
{
@@ -105,7 +105,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client))
+ using (var cacheFactory = CacheFactory.Create())
{
cacheFactory.SetProperty("log-level", "none")
.SetProperty("log-file", "geode_native.log");
diff --git a/NetCore.Test/CacheUnitTest.cs b/NetCore.Test/CacheUnitTest.cs
index 65de6e0..f13680a 100644
--- a/NetCore.Test/CacheUnitTest.cs
+++ b/NetCore.Test/CacheUnitTest.cs
@@ -17,7 +17,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "debug")
.SetProperty("log-file", "TestClientCacheGetPdxReadSerialized.log"))
{
@@ -51,7 +51,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none")
.SetProperty("log-file", "geode_native.log"))
{
@@ -77,7 +77,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none")
.SetProperty("log-file", "geode_native.log"))
{
@@ -98,7 +98,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none")
.SetProperty("log-file", "geode_native.log"))
{
@@ -121,7 +121,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none"))
{
cacheFactory.PdxIgnoreUnreadFields = true;
@@ -141,7 +141,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none"))
{
cacheFactory.PdxIgnoreUnreadFields = true;
@@ -162,7 +162,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none"))
{
cacheFactory.PdxIgnoreUnreadFields = true;
diff --git a/NetCore.Test/ObjectLeakUnitTest.cs b/NetCore.Test/ObjectLeakUnitTest.cs
index 93c51c2..a266d6e 100644
--- a/NetCore.Test/ObjectLeakUnitTest.cs
+++ b/NetCore.Test/ObjectLeakUnitTest.cs
@@ -16,7 +16,7 @@ namespace GemfireDotNetTest
{
var client = new Client();
- using (var cacheFactory = CacheFactory.Create(client))
+ using (var cacheFactory = CacheFactory.Create())
{
Assert.Throws<InvalidOperationException>(() => client.Dispose());
}
diff --git a/NetCore.Test/PoolFactoryUnitTest.cs b/NetCore.Test/PoolFactoryUnitTest.cs
index 349b48a..1910206 100644
--- a/NetCore.Test/PoolFactoryUnitTest.cs
+++ b/NetCore.Test/PoolFactoryUnitTest.cs
@@ -16,7 +16,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none")
.SetProperty("log-file", "geode_native.log"))
{
@@ -40,7 +40,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none")
.SetProperty("log-file", "geode_native.log"))
{
@@ -68,7 +68,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client))
+ using (var cacheFactory = CacheFactory.Create())
{
using (var cache = cacheFactory.CreateCache())
{
diff --git a/NetCore.Test/PoolManagerUnitTest.cs b/NetCore.Test/PoolManagerUnitTest.cs
index 88fef25..9c1799e 100644
--- a/NetCore.Test/PoolManagerUnitTest.cs
+++ b/NetCore.Test/PoolManagerUnitTest.cs
@@ -16,7 +16,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client))
+ using (var cacheFactory = CacheFactory.Create())
{
using (var cache = cacheFactory.CreateCache())
{
diff --git a/NetCore.Test/RegionFactoryUnitTest.cs b/NetCore.Test/RegionFactoryUnitTest.cs
index f08ee7d..36f4d38 100644
--- a/NetCore.Test/RegionFactoryUnitTest.cs
+++ b/NetCore.Test/RegionFactoryUnitTest.cs
@@ -92,7 +92,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none")
.SetProperty("log-file", "geode_native.log"))
{
@@ -111,7 +111,7 @@ namespace GemfireDotNetTest
{
using (var client = new Client())
{
- using (var cacheFactory = CacheFactory.Create(client)
+ using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "debug")
.SetProperty("log-file", "geode_native_with_auth.log"))
{
diff --git a/NetCore/CacheFactory.cs b/NetCore/CacheFactory.cs
index 1a15d27..4c2fad1 100644
--- a/NetCore/CacheFactory.cs
+++ b/NetCore/CacheFactory.cs
@@ -14,7 +14,7 @@ namespace Apache
private IAuthInitialize _authInitialize;
[DllImport(Constants.libPath, CharSet = CharSet.Auto)]
- private static extern IntPtr apache_geode_CreateCacheFactory(IntPtr client);
+ private static extern IntPtr apache_geode_CreateCacheFactory();
[DllImport(Constants.libPath, CharSet = CharSet.Auto)]
private static extern void apache_geode_DestroyCacheFactory(IntPtr factory);
@@ -35,14 +35,14 @@ namespace Apache
[DllImport(Constants.libPath, CharSet = CharSet.Auto)]
private static extern void apache_geode_CacheFactory_SetProperty(IntPtr factory, IntPtr key, IntPtr value);
- public static ICacheFactory Create(Client client)
+ public static ICacheFactory Create()
{
- return new CacheFactory(client);
+ return new CacheFactory();
}
- public CacheFactory(GeodeNativeObject client)
+ public CacheFactory()
{
- _containedObject = apache_geode_CreateCacheFactory(client.ContainedObject);
+ _containedObject = apache_geode_CreateCacheFactory();
}
public string Version
diff --git a/NetCore/Constants.cs b/NetCore/Constants.cs
index 5781a10..a301b7b 100644
--- a/NetCore/Constants.cs
+++ b/NetCore/Constants.cs
@@ -7,9 +7,9 @@ namespace Apache
public class Constants
{
- public const string libPath =
- //"/Users/matthewreddington/workspace/apache/geode-native/cppcache/shared/libapache-geode.dylib";
- "c:/geode-native-dotnetcore/build/c_bindings/Debug/apache-geode-c.dll";
+ public const string libPath =
+ //"/Users/matthewreddington/workspace/apache/geode-native/cppcache/shared/libapache-geode.dylib";
+ "c:/Users/bblake/src/nc_install/bin/apache-geode-c.dll";
}
}
}
diff --git a/Session.IntegrationTests/SessionStateIntegrationTests.cs b/Session.IntegrationTests/SessionStateIntegrationTests.cs
index 7a533f0..6f8e200 100644
--- a/Session.IntegrationTests/SessionStateIntegrationTests.cs
+++ b/Session.IntegrationTests/SessionStateIntegrationTests.cs
@@ -10,199 +10,174 @@ namespace Apache.Geode.Session.IntegrationTests
{
public class SessionStateIntegrationTests
{
- private static string _regionName = "testRegion";
+ private static string _regionName = "exampleRegion";
[Fact]
public void SetGet()
{
- using (var client = new Client())
- {
- using (var cacheFactory = CacheFactory.Create(client))
- {
- cacheFactory.SetProperty("log-level", "none");
-
- var cache = (Cache)cacheFactory.CreateCache();
- PoolFactory poolFactory = cache.PoolFactory.AddLocator("localhost", 10334);
- var pool = poolFactory.CreatePool("myPool");
-
- var ssCache = new SessionStateCache(cache, _regionName);
-
- var options = new DistributedCacheEntryOptions();
- DateTime localTime = DateTime.Now.AddDays(1);
- DateTimeOffset dateAndOffset = new DateTimeOffset(localTime,
- TimeZoneInfo.Local.GetUtcOffset(localTime));
- options.AbsoluteExpiration = dateAndOffset;
- var testValue = new byte[] { 1, 2, 3, 4, 5 };
- ssCache.Set("testKey", testValue, options);
- byte[] value = ssCache.Get("testKey");
- Assert.True(testValue.SequenceEqual(value));
- pool.Dispose();
- poolFactory.Dispose();
- cache.Dispose();
- cacheFactory.Dispose();
- ssCache.Dispose();
-
- }
-
- }
+ using var client = new Client();
+ using var cacheFactory = CacheFactory.Create()
+ .SetProperty("log-level", "error");
+
+ using var cache = (Cache)cacheFactory.CreateCache();
+
+ using var poolFactory = cache.PoolFactory.AddLocator("localhost", 10334);
+ using var pool = poolFactory.CreatePool("myPool");
+
+ using var ssCache = new SessionStateCache(cache, _regionName);
+
+ var options = new DistributedCacheEntryOptions();
+ DateTime localTime = DateTime.Now.AddDays(1);
+ DateTimeOffset dateAndOffset = new DateTimeOffset(localTime,
+ TimeZoneInfo.Local.GetUtcOffset(localTime));
+ options.AbsoluteExpiration = dateAndOffset;
+ var testValue = new byte[] { 1, 2, 3, 4, 5 };
+ ssCache.Set("testKey", testValue, options);
+ byte[] value = ssCache.Get("testKey");
+ Assert.True(testValue.SequenceEqual(value));
}
[Fact]
public void Refresh()
{
- using (var client = new Client())
- {
- using (var cacheFactory = CacheFactory.Create(client))
- {
- cacheFactory.SetProperty("log-level", "none");
-
- var cache = (Cache)cacheFactory.CreateCache();
- PoolFactory poolFactory = cache.PoolFactory.AddLocator("localhost", 10334);
- var pool = poolFactory.CreatePool("myPool");
-
- var ssCache = new SessionStateCache(cache, _regionName);
-
- var options = new DistributedCacheEntryOptions();
- int numSeconds = 20;
- options.SlidingExpiration = new TimeSpan(0, 0, numSeconds);
- var testValue = new byte[] { 1, 2, 3, 4, 5 };
-
- // Set a value
- ssCache.Set("testKey", testValue, options);
-
- // Wait half a timeout then refresh
- System.Threading.Thread.Sleep(numSeconds / 2 * 1000);
- ssCache.Refresh("testKey");
-
- // Wait beyond the original expiration
- System.Threading.Thread.Sleep(numSeconds / 2 * 1000 + 1);
-
- // Ensure it's not expired
- byte[] value = ssCache.Get("testKey");
- Assert.True(testValue.SequenceEqual(value));
- }
- }
+ using var client = new Client();
+ using var cacheFactory = CacheFactory.Create()
+ .SetProperty("log-level", "none");
+
+ using var cache = (Cache)cacheFactory.CreateCache();
+ using PoolFactory poolFactory = cache.PoolFactory.AddLocator("localhost", 10334);
+ using var pool = poolFactory.CreatePool("myPool");
+
+ using var ssCache = new SessionStateCache(cache, _regionName);
+
+ var options = new DistributedCacheEntryOptions();
+ int numSeconds = 20;
+ options.SlidingExpiration = new TimeSpan(0, 0, numSeconds);
+ var testValue = new byte[] { 1, 2, 3, 4, 5 };
+
+ // Set a value
+ ssCache.Set("testKey", testValue, options);
+
+ // Wait half a timeout then refresh
+ System.Threading.Thread.Sleep(numSeconds / 2 * 1000);
+ ssCache.Refresh("testKey");
+
+ // Wait beyond the original expiration
+ System.Threading.Thread.Sleep(numSeconds / 2 * 1000 + 1);
+
+ // Ensure it's not expired
+ byte[] value = ssCache.Get("testKey");
+ Assert.True(testValue.SequenceEqual(value));
}
[Fact]
public void SetWithAbsoluteExpiration()
{
- using (var client = new Client())
- {
- using (var cacheFactory = CacheFactory.Create(client))
- {
- cacheFactory.SetProperty("log-level", "none");
-
- var cache = (Cache)cacheFactory.CreateCache();
- PoolFactory poolFactory = cache.PoolFactory;
-
- var ssCache = new SessionStateCache(cache, _regionName);
-
- var options = new DistributedCacheEntryOptions();
- options.AbsoluteExpiration = DateTime.Now.AddSeconds(5);
- ssCache.Set("testKey", Encoding.UTF8.GetBytes("testValue"), options);
- System.Threading.Thread.Sleep(6000);
- byte[] value = ssCache.Get("testKey");
- Assert.Null(value);
- }
- }
+ using var client = new Client();
+ using var cacheFactory = CacheFactory.Create();
+
+ cacheFactory.SetProperty("log-level", "none");
+
+ using var cache = (Cache)cacheFactory.CreateCache();
+ PoolFactory poolFactory = cache.PoolFactory;
+
+ using var ssCache = new SessionStateCache(cache, _regionName);
+
+ var options = new DistributedCacheEntryOptions();
+ options.AbsoluteExpiration = DateTime.Now.AddSeconds(5);
+ ssCache.Set("testKey", Encoding.UTF8.GetBytes("testValue"), options);
+ System.Threading.Thread.Sleep(6000);
+ byte[] value = ssCache.Get("testKey");
+ Assert.Null(value);
}
[Fact]
public void Remove()
{
- using (var client = new Client())
- {
- using (var cacheFactory = CacheFactory.Create(client))
- {
- cacheFactory.SetProperty("log-level", "none");
-
- var cache = (Cache)cacheFactory.CreateCache();
- PoolFactory poolFactory = cache.PoolFactory.AddLocator("localhost", 10334);
- var pool = poolFactory.CreatePool("myPool");
-
- var ssCache = new SessionStateCache(cache, _regionName);
-
- var options = new DistributedCacheEntryOptions();
- DateTime localTime = DateTime.Now.AddDays(1);
- DateTimeOffset dateAndOffset = new DateTimeOffset(localTime,
- TimeZoneInfo.Local.GetUtcOffset(localTime));
- options.AbsoluteExpiration = dateAndOffset;
- var testValue = new byte[] { 1, 2, 3, 4, 5 };
- ssCache.Set("testKey", testValue, options);
- byte[] value = ssCache.Get("testKey");
-
- ssCache.Remove("testKey");
- value = ssCache.Get("testKey");
- Assert.Null(value);
- }
- }
+ using var client = new Client();
+ using var cacheFactory = CacheFactory.Create();
+ cacheFactory.SetProperty("log-level", "none");
+
+ using var cache = (Cache)cacheFactory.CreateCache();
+ using var poolFactory = cache.PoolFactory.AddLocator("localhost", 10334);
+ using var pool = poolFactory.CreatePool("myPool");
+
+ using var ssCache = new SessionStateCache(cache, _regionName);
+
+ var options = new DistributedCacheEntryOptions();
+ DateTime localTime = DateTime.Now.AddDays(1);
+ DateTimeOffset dateAndOffset = new DateTimeOffset(localTime,
+ TimeZoneInfo.Local.GetUtcOffset(localTime));
+ options.AbsoluteExpiration = dateAndOffset;
+ var testValue = new byte[] { 1, 2, 3, 4, 5 };
+ ssCache.Set("testKey", testValue, options);
+ byte[] value = ssCache.Get("testKey");
+
+ ssCache.Remove("testKey");
+ value = ssCache.Get("testKey");
+ Assert.Null(value);
}
[Fact]
public void SetGetRemoveAsync()
{
- using (var client = new Client())
- {
- using (var cacheFactory = CacheFactory.Create(client))
- {
- cacheFactory.SetProperty("log-level", "none");
-
- var cache = (Cache)cacheFactory.CreateCache();
- PoolFactory poolFactory = cache.PoolFactory.AddLocator("localhost", 10334);
- var pool = poolFactory.CreatePool("myPool");
-
- var ssCache = new SessionStateCache(cache, _regionName);
-
- var options = new DistributedCacheEntryOptions();
- DateTime localTime = DateTime.Now.AddDays(1);
- DateTimeOffset dateAndOffset = new DateTimeOffset(localTime,
- TimeZoneInfo.Local.GetUtcOffset(localTime));
- options.AbsoluteExpiration = dateAndOffset;
-
- var testValue1 = new byte[] { 1, 2, 3, 4, 5 };
- var testValue2 = new byte[] { 11, 12, 13, 14, 15 };
- var testValue3 = new byte[] { 21, 22, 23, 24, 25 };
- var testValue4 = new byte[] { 31, 32, 33, 34, 35 };
- var testValue5 = new byte[] { 41, 42, 43, 44, 45 };
-
- Task set1 = ssCache.SetAsync("testKey1", testValue1, options);
- Task set2 = ssCache.SetAsync("testKey2", testValue2, options);
- Task set3 = ssCache.SetAsync("testKey3", testValue3, options);
- Task set4 = ssCache.SetAsync("testKey4", testValue4, options);
- Task set5 = ssCache.SetAsync("testKey5", testValue5, options);
-
- Task.WaitAll(set1, set2, set3, set4, set5);
-
- Task<byte[]> value1 = ssCache.GetAsync("testKey1");
- Task<byte[]> value2 = ssCache.GetAsync("testKey2");
- Task<byte[]> value3 = ssCache.GetAsync("testKey3");
- Task<byte[]> value4 = ssCache.GetAsync("testKey4");
- Task<byte[]> value5 = ssCache.GetAsync("testKey5");
-
- Task.WaitAll(value1, value2, value3, value4, value5);
-
- Assert.True(testValue1.SequenceEqual(value1.Result));
- Assert.True(testValue2.SequenceEqual(value2.Result));
- Assert.True(testValue3.SequenceEqual(value3.Result));
- Assert.True(testValue4.SequenceEqual(value4.Result));
- Assert.True(testValue5.SequenceEqual(value5.Result));
-
- Task rm1 = ssCache.RemoveAsync("testKey1");
- Task rm2 = ssCache.RemoveAsync("testKey2");
- Task rm3 = ssCache.RemoveAsync("testKey3");
- Task rm4 = ssCache.RemoveAsync("testKey4");
- Task rm5 = ssCache.RemoveAsync("testKey5");
-
- Task.WaitAll(rm1, rm2, rm3, rm4, rm5);
-
- Assert.Null(ssCache.Get("testKey1"));
- Assert.Null(ssCache.Get("testKey2"));
- Assert.Null(ssCache.Get("testKey3"));
- Assert.Null(ssCache.Get("testKey4"));
- Assert.Null(ssCache.Get("testKey5"));
- }
- }
+ using var client = new Client();
+ using var cacheFactory = CacheFactory.Create()
+ .SetProperty("log-level", "none");
+
+ using var cache = (Cache)cacheFactory.CreateCache();
+ using var poolFactory = cache.PoolFactory.AddLocator("localhost", 10334);
+ using var pool = poolFactory.CreatePool("myPool");
+
+ using var ssCache = new SessionStateCache(cache, _regionName);
+
+ var options = new DistributedCacheEntryOptions();
+ DateTime localTime = DateTime.Now.AddDays(1);
+ DateTimeOffset dateAndOffset = new DateTimeOffset(localTime,
+ TimeZoneInfo.Local.GetUtcOffset(localTime));
+ options.AbsoluteExpiration = dateAndOffset;
+
+ var testValue1 = new byte[] { 1, 2, 3, 4, 5 };
+ var testValue2 = new byte[] { 11, 12, 13, 14, 15 };
+ var testValue3 = new byte[] { 21, 22, 23, 24, 25 };
+ var testValue4 = new byte[] { 31, 32, 33, 34, 35 };
+ var testValue5 = new byte[] { 41, 42, 43, 44, 45 };
+
+ Task set1 = ssCache.SetAsync("testKey1", testValue1, options);
+ Task set2 = ssCache.SetAsync("testKey2", testValue2, options);
+ Task set3 = ssCache.SetAsync("testKey3", testValue3, options);
+ Task set4 = ssCache.SetAsync("testKey4", testValue4, options);
+ Task set5 = ssCache.SetAsync("testKey5", testValue5, options);
+
+ Task.WaitAll(set1, set2, set3, set4, set5);
+
+ Task<byte[]> value1 = ssCache.GetAsync("testKey1");
+ Task<byte[]> value2 = ssCache.GetAsync("testKey2");
+ Task<byte[]> value3 = ssCache.GetAsync("testKey3");
+ Task<byte[]> value4 = ssCache.GetAsync("testKey4");
+ Task<byte[]> value5 = ssCache.GetAsync("testKey5");
+
+ Task.WaitAll(value1, value2, value3, value4, value5);
+
+ Assert.True(testValue1.SequenceEqual(value1.Result));
+ Assert.True(testValue2.SequenceEqual(value2.Result));
+ Assert.True(testValue3.SequenceEqual(value3.Result));
+ Assert.True(testValue4.SequenceEqual(value4.Result));
+ Assert.True(testValue5.SequenceEqual(value5.Result));
+
+ Task rm1 = ssCache.RemoveAsync("testKey1");
+ Task rm2 = ssCache.RemoveAsync("testKey2");
+ Task rm3 = ssCache.RemoveAsync("testKey3");
+ Task rm4 = ssCache.RemoveAsync("testKey4");
+ Task rm5 = ssCache.RemoveAsync("testKey5");
+
+ Task.WaitAll(rm1, rm2, rm3, rm4, rm5);
+
+ Assert.Null(ssCache.Get("testKey1"));
+ Assert.Null(ssCache.Get("testKey2"));
+ Assert.Null(ssCache.Get("testKey3"));
+ Assert.Null(ssCache.Get("testKey4"));
+ Assert.Null(ssCache.Get("testKey5"));
}
}
}
diff --git a/Session.Tests/SessionStateCacheTests.cs b/Session.Tests/SessionStateCacheTests.cs
index ac64254..2ca07a7 100644
--- a/Session.Tests/SessionStateCacheTests.cs
+++ b/Session.Tests/SessionStateCacheTests.cs
@@ -9,7 +9,6 @@ namespace Apache.Geode.Session.Tests
[Trait("Category", "Integration")]
public class SessionStateStoreTests : IDisposable
{
- private static string _regionName = "testRegion";
private Cache Cache { get; set; }
private string CacheXmlFilePath { get; set; }
@@ -31,20 +30,5 @@ namespace Apache.Geode.Session.Tests
{
}
}
-
- [Fact]
- public void NullPoolFactory_Throws()
- {
- using (var client = new Client())
- {
- PoolFactory poolFactory = null;
- var cacheFactory = CacheFactory.Create(client)
- .SetProperty("log-level", "debug")
- .SetProperty("log-file", "SessionStateCacheTests.log");
-
- var cache = (Cache)cacheFactory.CreateCache();
- Assert.Throws<ArgumentNullException>(() => new SessionStateCache(cache, _regionName));
- }
- }
}
}