You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2017/08/11 23:53:02 UTC
[46/52] [partial] geode-native git commit: GEODE-3165: Reogranized
sources relative to the root for better CMake IDE integration.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/CacheServPoolRedun3.xml
----------------------------------------------------------------------
diff --git a/clicache/integration-test/CacheServPoolRedun3.xml b/clicache/integration-test/CacheServPoolRedun3.xml
new file mode 100644
index 0000000..e62a640
--- /dev/null
+++ b/clicache/integration-test/CacheServPoolRedun3.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+
+<cache xmlns="http://geode.apache.org/schema/cache"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
+ version="1.0">
+ <!--cache-server host="cod" port="24682" /-->
+ <cache-server port="HOST_PORT3">
+ <group>ServerGroup1</group>
+ </cache-server>
+ <region name="PoolRegion1">
+ <region-attributes scope="distributed-ack" data-policy="replicate"/>
+ </region>
+ <region name="PoolRegion2">
+ <region-attributes scope="distributed-ack" data-policy="replicate"/>
+ </region>
+ <region name="PoolRegion3">
+ <region-attributes scope="distributed-ack" data-policy="replicate"/>
+ </region>
+</cache>
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/CacheServerMsgs.cs
----------------------------------------------------------------------
diff --git a/clicache/integration-test/CacheServerMsgs.cs b/clicache/integration-test/CacheServerMsgs.cs
new file mode 100644
index 0000000..076e59a
--- /dev/null
+++ b/clicache/integration-test/CacheServerMsgs.cs
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Apache.Geode.Client.UnitTests
+{
+ using NUnit.Framework;
+ using Apache.Geode.DUnitFramework;
+
+ [TestFixture]
+ [Category("unicast_only")]
+ public class CacheServerMsgs : UnitTests
+ {
+ Cache m_cache = null;
+
+ protected override ClientBase[] GetClients()
+ {
+ return null;
+ }
+
+ [TestFixtureSetUp]
+ public override void InitTests()
+ {
+ base.InitTests();
+ CacheHelper.InitConfig("MessagesTest", "theCache", "SERVER", null,
+ null, null);
+ m_cache = CacheHelper.DCache;
+ }
+
+ [TestFixtureTearDown]
+ public override void EndTests()
+ {
+ try
+ {
+ CacheHelper.Close();
+ }
+ finally
+ {
+ base.EndTests();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/CacheableWrapper.cs
----------------------------------------------------------------------
diff --git a/clicache/integration-test/CacheableWrapper.cs b/clicache/integration-test/CacheableWrapper.cs
new file mode 100644
index 0000000..f8acd21
--- /dev/null
+++ b/clicache/integration-test/CacheableWrapper.cs
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Collections;
+using System.Runtime.Serialization;
+
+namespace Apache.Geode.Client.UnitTests
+{
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Interface class for wrappers of geode cacheable types.
+ /// </summary>
+ /// <remarks>
+ /// This interface has various useful functions like setting value randomly,
+ /// and finding checksum.
+ /// </remarks>
+ public abstract class CacheableWrapper
+ {
+ #region Protected members
+
+ protected IGeodeSerializable m_cacheableObject = null;
+ protected uint m_typeId;
+
+ #endregion
+
+ public virtual IGeodeSerializable Cacheable
+ {
+ get
+ {
+ return m_cacheableObject;
+ }
+ }
+
+ public uint TypeId
+ {
+ get
+ {
+ return m_typeId;
+ }
+ set
+ {
+ m_typeId = value;
+ }
+ }
+
+ public abstract void InitRandomValue(int maxSize);
+
+ public abstract uint GetChecksum(IGeodeSerializable cacheableObject);
+
+ public virtual uint GetChecksum()
+ {
+ return GetChecksum(m_cacheableObject);
+ }
+ }
+
+ /// <summary>
+ /// Interface class for wrappers of geode cacheable key types.
+ /// </summary>
+ /// <remarks>
+ /// This interface has various useful functions like setting value randomly,
+ /// and finding checksum, initializing key etc.
+ /// </remarks>
+ public abstract class CacheableKeyWrapper : CacheableWrapper
+ {
+ public override IGeodeSerializable Cacheable
+ {
+ get
+ {
+ return m_cacheableObject;
+ }
+ }
+
+ public virtual ICacheableKey CacheableKey
+ {
+ get
+ {
+ return (ICacheableKey)m_cacheableObject;
+ }
+ }
+
+ public abstract int MaxKeys
+ {
+ get;
+ }
+
+ public abstract void InitKey(int keyIndex, int maxSize);
+ }
+
+ public delegate CacheableWrapper CacheableWrapperDelegate();
+ public delegate CacheableKeyWrapper CacheableKeyWrapperDelegate();
+
+ /// <summary>
+ /// Factory class to create <c>CacheableWrapper</c> objects.
+ /// </summary>
+ public static class CacheableWrapperFactory
+ {
+ #region Private members
+
+ private static Dictionary<UInt32, CacheableKeyWrapperDelegate>
+ m_registeredKeyTypeIdMap =
+ new Dictionary<UInt32, CacheableKeyWrapperDelegate>();
+ private static Dictionary<UInt32, Delegate>
+ m_registeredValueTypeIdMap = new Dictionary<UInt32, Delegate>();
+ private static Dictionary<UInt32, Type>
+ m_typeIdNameMap = new Dictionary<UInt32, Type>();
+
+ #endregion
+
+ #region Public methods
+
+ public static CacheableWrapper CreateInstance(UInt32 typeId)
+ {
+ Delegate wrapperDelegate;
+ lock (((ICollection)m_registeredValueTypeIdMap).SyncRoot)
+ {
+ if (m_registeredValueTypeIdMap.TryGetValue(typeId,
+ out wrapperDelegate))
+ {
+ CacheableWrapper wrapper =
+ (CacheableWrapper)wrapperDelegate.DynamicInvoke(null);
+ wrapper.TypeId = typeId;
+ return wrapper;
+ }
+ }
+ return null;
+ }
+
+ public static CacheableKeyWrapper CreateKeyInstance(UInt32 typeId)
+ {
+ CacheableKeyWrapperDelegate wrapperDelegate;
+ lock (((ICollection)m_registeredKeyTypeIdMap).SyncRoot)
+ {
+ if (m_registeredKeyTypeIdMap.TryGetValue(typeId,
+ out wrapperDelegate))
+ {
+ CacheableKeyWrapper wrapper = wrapperDelegate();
+ wrapper.TypeId = typeId;
+ return wrapper;
+ }
+ }
+ return null;
+ }
+
+ public static void RegisterType(UInt32 typeId,
+ Type type, CacheableWrapperDelegate wrapperDelegate)
+ {
+ m_registeredValueTypeIdMap[typeId] = wrapperDelegate;
+ m_typeIdNameMap[typeId] = type;
+ }
+
+ public static void RegisterKeyType(UInt32 typeId,
+ Type type, CacheableKeyWrapperDelegate wrapperDelegate)
+ {
+ m_registeredKeyTypeIdMap[typeId] = wrapperDelegate;
+ m_registeredValueTypeIdMap[typeId] = wrapperDelegate;
+ m_typeIdNameMap[typeId] = type;
+ }
+
+ public static void ClearStatics()
+ {
+ m_registeredKeyTypeIdMap.Clear();
+ m_registeredValueTypeIdMap.Clear();
+ m_typeIdNameMap.Clear();
+ }
+
+ public static Type GetTypeForId(UInt32 typeId)
+ {
+ Type type;
+ lock (((ICollection)m_typeIdNameMap).SyncRoot)
+ {
+ if (m_typeIdNameMap.TryGetValue(typeId, out type))
+ {
+ return type;
+ }
+ }
+ return null;
+ }
+
+ public static ICollection<UInt32> GetRegisteredKeyTypeIds()
+ {
+ return m_registeredKeyTypeIdMap.Keys;
+ }
+
+ public static ICollection<UInt32> GetRegisteredValueTypeIds()
+ {
+ return m_registeredValueTypeIdMap.Keys;
+ }
+
+ #endregion
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/CacheableWrapperN.cs
----------------------------------------------------------------------
diff --git a/clicache/integration-test/CacheableWrapperN.cs b/clicache/integration-test/CacheableWrapperN.cs
new file mode 100644
index 0000000..6a79f46
--- /dev/null
+++ b/clicache/integration-test/CacheableWrapperN.cs
@@ -0,0 +1,269 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Collections;
+using System.Runtime.Serialization;
+
+namespace Apache.Geode.Client.UnitTests
+{
+
+ using NUnit.Framework;
+ using Apache.Geode.Client;
+ /// <summary>
+ /// Interface class for wrappers of geode cacheable types.
+ /// </summary>
+ /// <remarks>
+ /// This interface has various useful functions like setting value randomly,
+ /// and finding checksum.
+ /// </remarks>
+ public abstract class CacheableWrapper
+ {
+ #region Protected members
+
+ protected object m_cacheableObject = null;
+ protected uint m_typeId;
+
+ #endregion
+
+ public virtual object Cacheable
+ {
+ get
+ {
+ return m_cacheableObject;
+ }
+ }
+
+ public uint TypeId
+ {
+ get
+ {
+ return m_typeId;
+ }
+ set
+ {
+ m_typeId = value;
+ }
+ }
+
+ public abstract void InitRandomValue(int maxSize);
+
+ public abstract uint GetChecksum(object cacheableObject);
+
+ public virtual int GetHashCodeN(object cacheableObject)
+ {
+ return cacheableObject.GetHashCode();
+ }
+
+ public virtual uint GetChecksum()
+ {
+ return GetChecksum(m_cacheableObject);
+ }
+
+ public virtual int GetHashCodeN()
+ {
+ return GetHashCodeN(m_cacheableObject);
+ }
+
+ }
+
+ /// <summary>
+ /// Interface class for wrappers of geode cacheable key types.
+ /// </summary>
+ /// <remarks>
+ /// This interface has various useful functions like setting value randomly,
+ /// and finding checksum, initializing key etc.
+ /// </remarks>
+ public abstract class CacheableKeyWrapper : CacheableWrapper
+ {
+ public override object Cacheable
+ {
+ get
+ {
+ return m_cacheableObject;
+ }
+ }
+
+ public virtual object CacheableKey
+ {
+ get
+ {
+ return (object)m_cacheableObject;
+ }
+ }
+
+ public abstract int MaxKeys
+ {
+ get;
+ }
+
+ public abstract void InitKey(int keyIndex, int maxSize);
+ }
+
+ public delegate CacheableWrapper CacheableWrapperDelegate();
+ public delegate CacheableKeyWrapper CacheableKeyWrapperDelegate();
+
+ /// <summary>
+ /// Factory class to create <c>CacheableWrapper</c> objects.
+ /// </summary>
+ public static class CacheableWrapperFactory
+ {
+ #region Private members
+
+ private static Dictionary<UInt32, CacheableKeyWrapperDelegate>
+ m_registeredKeyTypeIdMap =
+ new Dictionary<UInt32, CacheableKeyWrapperDelegate>();
+ private static Dictionary<UInt32, Delegate>
+ m_registeredValueTypeIdMap = new Dictionary<UInt32, Delegate>();
+ private static Dictionary<UInt32, Type>
+ m_typeIdNameMap = new Dictionary<UInt32, Type>();
+ private static Dictionary<Type, UInt32>
+ m_dotnetTypeVsCKWDelegate =
+ new Dictionary<Type, UInt32>();
+
+ #endregion
+
+ #region Public methods
+
+ public static CacheableWrapper CreateInstance(UInt32 typeId)
+ {
+ Delegate wrapperDelegate;
+ lock (((ICollection)m_registeredValueTypeIdMap).SyncRoot)
+ {
+ if (m_registeredValueTypeIdMap.TryGetValue(typeId,
+ out wrapperDelegate))
+ {
+ CacheableWrapper wrapper =
+ (CacheableWrapper)wrapperDelegate.DynamicInvoke(null);
+ wrapper.TypeId = typeId;
+ return wrapper;
+ }
+ }
+ return null;
+ }
+
+ public static CacheableWrapper CreateInstance(Object obj)
+ {
+ UInt32 typeId;
+ lock (((ICollection)m_registeredValueTypeIdMap).SyncRoot)
+ {
+ if (m_dotnetTypeVsCKWDelegate.TryGetValue(obj.GetType(),
+ out typeId))
+ {
+ return CreateInstance(typeId);
+ }
+ }
+ return null;
+ }
+
+ public static CacheableKeyWrapper CreateKeyInstance(UInt32 typeId)
+ {
+ CacheableKeyWrapperDelegate wrapperDelegate;
+ lock (((ICollection)m_registeredKeyTypeIdMap).SyncRoot)
+ {
+ if (m_registeredKeyTypeIdMap.TryGetValue(typeId,
+ out wrapperDelegate))
+ {
+ CacheableKeyWrapper wrapper = wrapperDelegate();
+ wrapper.TypeId = typeId;
+ return wrapper;
+ }
+ }
+ return null;
+ }
+
+ public static CacheableKeyWrapper CreateKeyInstance(object obj)
+ {
+ uint typeId;
+ lock (((ICollection)m_dotnetTypeVsCKWDelegate).SyncRoot)
+ {
+ if (m_dotnetTypeVsCKWDelegate.TryGetValue(obj.GetType(),
+ out typeId))
+ {
+ return CreateKeyInstance(typeId);
+ }
+ }
+ return null;
+ }
+
+ public static void RegisterType(UInt32 typeId,
+ Type type, CacheableWrapperDelegate wrapperDelegate)
+ {
+ m_registeredValueTypeIdMap[typeId] = wrapperDelegate;
+ m_typeIdNameMap[typeId] = type;
+ }
+
+ public static void RegisterType(UInt32 typeId,
+ Type type, CacheableWrapperDelegate wrapperDelegate, Type dotnetType)
+ {
+ m_registeredValueTypeIdMap[typeId] = wrapperDelegate;
+ m_typeIdNameMap[typeId] = type;
+ m_dotnetTypeVsCKWDelegate[dotnetType] = typeId;
+ }
+
+ public static void RegisterKeyType(UInt32 typeId,
+ Type type, CacheableKeyWrapperDelegate wrapperDelegate)
+ {
+ m_registeredKeyTypeIdMap[typeId] = wrapperDelegate;
+ m_registeredValueTypeIdMap[typeId] = wrapperDelegate;
+ m_typeIdNameMap[typeId] = type;
+ }
+
+ public static void RegisterKeyType(UInt32 typeId,
+ Type type, CacheableKeyWrapperDelegate wrapperDelegate, Type dotnetType)
+ {
+ m_registeredKeyTypeIdMap[typeId] = wrapperDelegate;
+ m_registeredValueTypeIdMap[typeId] = wrapperDelegate;
+ m_typeIdNameMap[typeId] = type;
+ m_dotnetTypeVsCKWDelegate[dotnetType] = typeId;
+ }
+
+ public static void ClearStaticVaraiables()
+ {
+ m_registeredKeyTypeIdMap.Clear();
+ m_registeredValueTypeIdMap.Clear();
+ m_typeIdNameMap.Clear();
+ m_dotnetTypeVsCKWDelegate.Clear();
+
+ }
+ public static Type GetTypeForId(UInt32 typeId)
+ {
+ Type type;
+ lock (((ICollection)m_typeIdNameMap).SyncRoot)
+ {
+ if (m_typeIdNameMap.TryGetValue(typeId, out type))
+ {
+ return type;
+ }
+ }
+ return null;
+ }
+
+ public static ICollection<UInt32> GetRegisteredKeyTypeIds()
+ {
+ return m_registeredKeyTypeIdMap.Keys;
+ }
+
+ public static ICollection<UInt32> GetRegisteredValueTypeIds()
+ {
+ return m_registeredValueTypeIdMap.Keys;
+ }
+
+ #endregion
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/CachelessTestsN.cs
----------------------------------------------------------------------
diff --git a/clicache/integration-test/CachelessTestsN.cs b/clicache/integration-test/CachelessTestsN.cs
new file mode 100644
index 0000000..15abf94
--- /dev/null
+++ b/clicache/integration-test/CachelessTestsN.cs
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading;
+
+namespace Apache.Geode.Client.UnitTests
+{
+ using NUnit.Framework;
+ using Apache.Geode.DUnitFramework;
+ using Apache.Geode.Client;
+
+ [TestFixture]
+ [Category("generics")]
+ public class CachelessTests : UnitTests
+ {
+ private const string RegionName = "DistRegionAck";
+ private RegionWrapper m_regionw;
+ private TallyListener<object, object> m_listener;
+
+ private UnitProcess m_client1, m_client2, m_client3, m_client4;
+
+ protected override ClientBase[] GetClients()
+ {
+ m_client1 = new UnitProcess();
+ m_client2 = new UnitProcess();
+ m_client3 = new UnitProcess();
+ m_client4 = new UnitProcess();
+ return new ClientBase[] { m_client1, m_client2, m_client3, m_client4 };
+ }
+
+ public void CreateRegion(string locators,
+ bool caching, bool listener)
+ {
+ if (listener)
+ {
+ m_listener = new TallyListener<object, object>();
+ }
+ else
+ {
+ m_listener = null;
+ }
+ IRegion<object, object> region = null;
+
+ region = CacheHelper.CreateTCRegion_Pool<object, object>(RegionName, true, caching,
+ m_listener, locators, "__TESTPOOL1_", true);
+ m_regionw = new RegionWrapper(region);
+ }
+
+ public void NoEvents()
+ {
+ Util.Log("Verifying TallyListener has received nothing.");
+ Assert.AreEqual(0, m_listener.Creates, "Should be no creates");
+ Assert.AreEqual(0, m_listener.Updates, "Should be no updates");
+ Assert.IsNull(m_listener.LastKey, "Should be no key");
+ Assert.IsNull(m_listener.LastValue, "Should be no value");
+ }
+
+ public void SendPut(int key, int val)
+ {
+ m_regionw.Put(key, val);
+ }
+
+
+
+ public void CheckEmpty()
+ {
+ Util.Log("check s2p2-subset is still empty.");
+ Thread.Sleep(100); //let it do receiving...
+ m_regionw.Test(1, -1);
+ Assert.AreEqual(0, m_listener.Creates, "Should be no creates");
+ Assert.AreEqual(0, m_listener.Updates, "Should be no updates");
+ m_regionw.Put(2, 1);
+ Assert.AreEqual(1, m_listener.ExpectCreates(1), "Should have been 1 create.");
+ Assert.AreEqual(0, m_listener.ExpectUpdates(0), "Should be no updates");
+ }
+
+ void runCacheless()
+ {
+ CacheHelper.SetupJavaServers(true,
+ "cacheserver_notify_subscription.xml");
+ CacheHelper.StartJavaLocator(1, "GFELOC");
+ Util.Log("Locator started");
+ CacheHelper.StartJavaServerWithLocators(1, "GFECS1", 1);
+ Util.Log("Cacheserver 1 started.");
+ Util.Log("Creating region in s1p1-pusher, no-ack, no-cache, no-listener");
+ m_client1.Call(CreateRegion, CacheHelper.Locators,
+ false, true);
+
+ Util.Log("Creating region in s1p2-listener, no-ack, no-cache, with-listener");
+ m_client2.Call(CreateRegion, CacheHelper.Locators,
+ false, true);
+
+ Util.Log("Creating region in s2p1-storage, no-ack, cache, no-listener");
+ m_client3.Call(CreateRegion, CacheHelper.Locators,
+ true, true);
+
+ Util.Log("Creating region in s2p2-subset, no-ack, cache, no-listener");
+ m_client4.Call(CreateRegion, CacheHelper.Locators,
+ true, true);
+
+ Util.Log("createRegion seems to return before peers have handshaked... waiting a while.");
+ Thread.Sleep(10000);
+ Util.Log("tired of waiting....");
+
+ m_client2.Call(NoEvents);
+
+ Util.Log("put(1,1) from s1p1-pusher");
+ m_client1.Call(SendPut, 1, 1);
+
+ Util.Log("update from s2p1-storage");
+ m_client3.Call(SendPut, 1, 2);
+
+ m_client2.Call(CheckEmpty);
+
+ m_client1.Call(CacheHelper.Close);
+ m_client2.Call(CacheHelper.Close);
+ m_client3.Call(CacheHelper.Close);
+ m_client4.Call(CacheHelper.Close);
+
+ CacheHelper.StopJavaServer(1);
+ Util.Log("Cacheserver 1 stopped.");
+
+ CacheHelper.StopJavaLocator(1);
+ Util.Log("Locator stopped");
+
+ CacheHelper.ClearEndpoints();
+ CacheHelper.ClearLocators();
+ }
+
+ [TearDown]
+ public override void EndTest()
+ {
+ base.EndTest();
+ }
+
+ [Test]
+ public void Cacheless()
+ {
+ runCacheless();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/DataIOTests.cs
----------------------------------------------------------------------
diff --git a/clicache/integration-test/DataIOTests.cs b/clicache/integration-test/DataIOTests.cs
new file mode 100644
index 0000000..d4488e5
--- /dev/null
+++ b/clicache/integration-test/DataIOTests.cs
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+
+namespace Apache.Geode.Client.UnitTests
+{
+ using NUnit.Framework;
+ using Apache.Geode.DUnitFramework;
+
+ [TestFixture]
+ [Category("unicast_only")]
+ public class DataIOTests : UnitTests
+ {
+ XmlNodeReaderWriter settings = Util.DefaultSettings;
+
+ protected override ClientBase[] GetClients()
+ {
+ return null;
+ }
+
+ [Test]
+ public void Byte()
+ {
+ List<Dictionary<string, string>> testbytes = settings.GetValues(MethodBase.GetCurrentMethod(), "byte");
+ if (testbytes != null)
+ {
+ foreach (Dictionary<string, string> dEntry in testbytes)
+ {
+ DataOutput dataOutput = new DataOutput();
+ byte testbyte = Util.String2Byte(dEntry["value"]);
+ dataOutput.WriteByte(testbyte);
+ byte[] buffer = dataOutput.GetBuffer();
+ Assert.AreEqual(testbyte, buffer[0]);
+
+ DataInput dataInput = new DataInput(buffer);
+ byte result = dataInput.ReadByte();
+ Assert.AreEqual(testbyte, result);
+ }
+ }
+ }
+
+ [Test]
+ public void Boolean()
+ {
+ List<Dictionary<string, string>> testbools = settings.GetValues(MethodBase.GetCurrentMethod(), "bool");
+ if (testbools != null)
+ {
+ foreach (Dictionary<string, string> dEntry in testbools)
+ {
+ DataOutput dataOutput = new DataOutput();
+ bool testbool = bool.Parse(dEntry["value"]);
+ dataOutput.WriteBoolean(testbool);
+ byte[] buffer = dataOutput.GetBuffer();
+ byte[] expectedBytes = Util.String2Bytes(dEntry["bytes"]);
+ Util.CompareTestArrays(expectedBytes, buffer);
+
+ DataInput dataInput = new DataInput(buffer);
+ bool result = dataInput.ReadBoolean();
+ Assert.AreEqual(testbool, result);
+ }
+ }
+ }
+
+ [Test]
+ public void Int16()
+ {
+ List<Dictionary<string, string>> testshorts = settings.GetValues(MethodBase.GetCurrentMethod(), "short");
+ if (testshorts != null)
+ {
+ foreach (Dictionary<string, string> dEntry in testshorts)
+ {
+ DataOutput dataOutput = new DataOutput();
+ short testshort = Util.String2Int16(dEntry["value"]);
+ dataOutput.WriteInt16(testshort);
+ byte[] buffer = dataOutput.GetBuffer();
+ byte[] expectedBytes = Util.String2Bytes(dEntry["bytes"]);
+ Util.CompareTestArrays(expectedBytes, buffer);
+
+ DataInput dataInput = new DataInput(buffer);
+ short result = dataInput.ReadInt16();
+ Assert.AreEqual(testshort, result);
+ }
+ }
+ }
+
+ [Test]
+ public void Int32()
+ {
+ List<Dictionary<string, string>> testints = settings.GetValues(MethodBase.GetCurrentMethod(), "int");
+ if (testints != null)
+ {
+ foreach (Dictionary<string, string> dEntry in testints)
+ {
+ DataOutput dataOutput = new DataOutput();
+ int testint = Util.String2Int32(dEntry["value"]);
+ dataOutput.WriteInt32(testint);
+ byte[] buffer = dataOutput.GetBuffer();
+ byte[] expectedBytes = Util.String2Bytes(dEntry["bytes"]);
+ Util.CompareTestArrays(expectedBytes, buffer);
+
+ DataInput dataInput = new DataInput(buffer);
+ int result = dataInput.ReadInt32();
+ Assert.AreEqual(testint, result);
+ }
+ }
+ }
+
+ [Test]
+ public void Int64()
+ {
+ List<Dictionary<string, string>> testints = settings.GetValues(MethodBase.GetCurrentMethod(), "int");
+ if (testints != null)
+ {
+ foreach (Dictionary<string, string> dEntry in testints)
+ {
+ DataOutput dataOutput = new DataOutput();
+ long testlong = Util.String2Int64(dEntry["value"]);
+ dataOutput.WriteInt64(testlong);
+ byte[] buffer = dataOutput.GetBuffer();
+ byte[] expectedBytes = Util.String2Bytes(dEntry["bytes"]);
+ Util.CompareTestArrays(expectedBytes, buffer);
+
+ DataInput dataInput = new DataInput(buffer);
+ long result = dataInput.ReadInt64();
+ Assert.AreEqual(testlong, result);
+ }
+ }
+ }
+
+ [Test]
+ public void Float()
+ {
+ List<Dictionary<string, string>> testfloats = settings.GetValues(MethodBase.GetCurrentMethod(), "float");
+ if (testfloats != null)
+ {
+ foreach (Dictionary<string, string> dEntry in testfloats)
+ {
+ DataOutput dataOutput = new DataOutput();
+ float testfloat = float.Parse(dEntry["value"]);
+ dataOutput.WriteFloat(testfloat);
+ byte[] buffer = dataOutput.GetBuffer();
+ byte[] expectedBytes = Util.String2Bytes(dEntry["bytes"]);
+ Util.CompareTestArrays(expectedBytes, buffer);
+
+ DataInput dataInput = new DataInput(buffer);
+ float result = dataInput.ReadFloat();
+ Assert.AreEqual(testfloat, result);
+ }
+ }
+ }
+
+ [Test]
+ public void Double()
+ {
+ List<Dictionary<string, string>> testdoubles = settings.GetValues(MethodBase.GetCurrentMethod(), "double");
+ if (testdoubles != null)
+ {
+ foreach (Dictionary<string, string> dEntry in testdoubles)
+ {
+ DataOutput dataOutput = new DataOutput();
+ double testdouble = double.Parse(dEntry["value"]);
+ dataOutput.WriteDouble(testdouble);
+ byte[] buffer = dataOutput.GetBuffer();
+ byte[] expectedBytes = Util.String2Bytes(dEntry["bytes"]);
+ Util.CompareTestArrays(expectedBytes, buffer);
+
+ DataInput dataInput = new DataInput(buffer);
+ double result = dataInput.ReadDouble();
+ Assert.AreEqual(testdouble, result);
+ }
+ }
+ }
+
+ [Test]
+ public void ASCIIString()
+ {
+ List<Dictionary<string, string>> testasciis = settings.GetValues(MethodBase.GetCurrentMethod(), "ascii");
+ if (testasciis != null)
+ {
+ foreach (Dictionary<string, string> dEntry in testasciis)
+ {
+ DataOutput dataOutput = new DataOutput();
+ string testascii = dEntry["value"];
+ dataOutput.WriteUTF(testascii);
+ byte[] buffer = dataOutput.GetBuffer();
+ Assert.AreEqual(Util.String2Byte(dEntry["byte0"]), buffer[0]);
+ Assert.AreEqual(Util.String2Byte(dEntry["byte1"]), buffer[1]);
+ for (int i = 0; i < testascii.Length; i++)
+ {
+ Assert.AreEqual(testascii[i], buffer[i + 2]);
+ }
+
+ DataInput dataInput = new DataInput(buffer);
+ string result = dataInput.ReadUTF();
+ Assert.AreEqual(testascii.Length, result.Length);
+ Assert.AreEqual(testascii, result);
+ }
+ }
+ }
+
+ [Test]
+ public void UTFString()
+ {
+ List<Dictionary<string, string>> testutfs = settings.GetValues(MethodBase.GetCurrentMethod(), "utf");
+ if (testutfs != null)
+ {
+ foreach (Dictionary<string, string> dEntry in testutfs)
+ {
+ DataOutput dataOutput = new DataOutput();
+ string testutf = Util.String2String(dEntry["value"]);
+ dataOutput.WriteUTF(testutf);
+ byte[] buffer = dataOutput.GetBuffer();
+ byte[] expectedBytes = Util.String2Bytes(dEntry["bytes"]);
+ Util.CompareTestArrays(expectedBytes, buffer);
+
+ DataInput dataInput = new DataInput(buffer);
+ string result = dataInput.ReadUTF();
+ Assert.AreEqual(testutf.Length, result.Length);
+ Assert.AreEqual(testutf, result);
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/DataOutputTests.cs
----------------------------------------------------------------------
diff --git a/clicache/integration-test/DataOutputTests.cs b/clicache/integration-test/DataOutputTests.cs
new file mode 100755
index 0000000..5c253ee
--- /dev/null
+++ b/clicache/integration-test/DataOutputTests.cs
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+
+namespace Apache.Geode.Client.UnitTests
+{
+ using NUnit.Framework;
+ using Apache.Geode.DUnitFramework;
+ using Apache.Geode.Client;
+
+ [TestFixture]
+ [Category("unicast_only")]
+ public class DataOutputTests : UnitTests
+ {
+ XmlNodeReaderWriter settings = Util.DefaultSettings;
+
+ protected override ClientBase[] GetClients()
+ {
+ return null;
+ }
+
+ [Test]
+ public void StringExcedesBufferCapacity()
+ {
+
+ CacheHelper.InitConfig((String) null);
+
+ DataOutput dataOutput = CacheHelper.DCache.CreateDataOutput();
+
+ // Chcek that native buffer is unused and get initial capacity.
+ Assert.AreEqual(0, dataOutput.BufferLength);
+ int bufferSize = dataOutput.GetRemainingBufferLength();
+
+ // New string equal to buffer capacity.
+ string s = "".PadRight(bufferSize, 'a');
+ dataOutput.WriteUTF(s);
+
+ // Checks native buffer capacity, remaining length should be capacity since wrapper has not flushed to native yet.
+ Assert.GreaterOrEqual(dataOutput.GetRemainingBufferLength(), bufferSize + 2, "Buffer should have been resized to account for string + 2 bytes of length");
+ // Forces native buffer to be updated and gets length of used buffers.
+ Assert.AreEqual(bufferSize + 2, dataOutput.BufferLength, "Buffer length should be string plus 2 bytes for length.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/DefaultCacheableN.cs
----------------------------------------------------------------------
diff --git a/clicache/integration-test/DefaultCacheableN.cs b/clicache/integration-test/DefaultCacheableN.cs
new file mode 100644
index 0000000..c9b8145
--- /dev/null
+++ b/clicache/integration-test/DefaultCacheableN.cs
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Apache.Geode.Client.UnitTests
+{
+ using Apache.Geode.Client;
+
+ [Serializable]
+ class CustomSerializableObject
+ {
+ public String key;
+ public String value;
+
+ public CustomSerializableObject()
+ {
+ key = "key";
+ value = "value";
+ }
+ }
+
+ // VJR: TODO: IGeodeSerializable should be replaced by IPdxSerializable when ready
+ class DefaultType : IGeodeSerializable
+ {
+ bool m_cacheableBoolean;
+ int m_cacheableInt32;
+ int[] m_cacheableInt32Array = null;
+ string m_cacheableFileName = null;
+ string m_CacheableStringASCII = null;
+ string[] m_cacheableStringArray = null;
+ //CacheableHashSet m_cacheableHashSet = null;
+ Dictionary<Object, Object> m_cacheableHashMap;
+ //DateTime m_cacheableDate = null;
+ IList<object> m_cacheableVector = null;
+ object m_cacheableObject = null;
+
+ bool m_initialized = false;
+
+ public DefaultType()
+ {
+
+ }
+
+ public DefaultType(bool initialized)
+ {
+ if (initialized)
+ {
+ Log.Fine("DefaultType in constructor");
+ m_initialized = true;
+
+ m_cacheableBoolean = true;
+
+ m_cacheableInt32 = 1000;
+
+ m_cacheableInt32Array =new int[]{1,2,3};
+
+ m_cacheableFileName = "geode.txt";
+
+ m_CacheableStringASCII = "asciistring";
+
+ m_cacheableStringArray = new string[] { "one", "two" };
+
+ /*
+ m_cacheableHashSet = CacheableHashSet.Create(2);
+ m_cacheableHashSet.Add(CacheableString.Create("first"));
+ m_cacheableHashSet.Add(CacheableString.Create("second"));
+ * */
+
+ m_cacheableHashMap = new Dictionary<Object, Object>();
+ m_cacheableHashMap.Add("key-hm", "value-hm");
+
+ //m_cacheableDate = DateTime.Now;
+
+ m_cacheableVector = new List<object>();
+ m_cacheableVector.Add("one-vec");
+ m_cacheableVector.Add("two-vec");
+
+ //m_cacheableObject = new CustomSerializableObject();
+ }
+ }
+
+ public bool CBool
+ {
+ get { return m_cacheableBoolean; }
+ }
+
+ public int CInt
+ {
+ get { return m_cacheableInt32; }
+ }
+
+ public int[] CIntArray
+ {
+ get { return m_cacheableInt32Array; }
+ }
+
+ public string CFileName
+ {
+ get { return m_cacheableFileName; }
+ }
+
+ public string CString
+ {
+ get { return m_CacheableStringASCII; }
+ }
+
+ public string[] CStringArray
+ {
+ get { return m_cacheableStringArray; }
+ }
+
+ /*
+ public CacheableHashSet CHashSet
+ {
+ get { return m_cacheableHashSet; }
+ }
+ * */
+
+ public IDictionary<object, object> CHashMap
+ {
+ get { return m_cacheableHashMap; }
+ }
+
+ /*
+ public DateTime CDate
+ {
+ get { return m_cacheableDate; }
+ }
+ * */
+
+ public IList<object> CVector
+ {
+ get { return m_cacheableVector; }
+ }
+
+ public object CObject
+ {
+ get { return m_cacheableObject; }
+ }
+
+ #region IGeodeSerializable Members
+
+ public uint ClassId
+ {
+ get { return 0x04; }
+ }
+
+ public IGeodeSerializable FromData(DataInput input)
+ {
+ if (!m_initialized)
+ {
+ /*
+ m_cacheableBoolean = (CacheableBoolean)CacheableBoolean.CreateDeserializable();
+ m_cacheableInt32 = (CacheableInt32)CacheableInt32.CreateDeserializable();
+ m_cacheableInt32Array = (CacheableInt32Array)CacheableInt32Array.CreateDeserializable();
+ // m_cacheableFileName = (CacheableFileName)CacheableFileName.CreateDeserializable();
+ //m_CacheableStringASCII = (CacheableString)CacheableString.CreateDeserializable();
+ m_cacheableStringArray = (CacheableStringArray)CacheableStringArray.CreateDeserializable();
+ m_cacheableHashSet = (CacheableHashSet)CacheableHashSet.CreateDeserializable();
+ m_cacheableHashMap = (CacheableHashMap)CacheableHashMap.CreateDeserializable();
+ m_cacheableDate = (CacheableDate)CacheableDate.CreateDeserializable();
+ m_cacheableVector = (CacheableVector)CacheableVector.CreateDeserializable();
+ m_cacheableObject = (CacheableObject)CacheableObject.CreateDeserializable();
+ * */
+ }
+
+ m_cacheableBoolean = input.ReadBoolean();
+ m_cacheableInt32 = input.ReadInt32();
+ int arraylen = input.ReadArrayLen();
+ m_cacheableInt32Array = new int[arraylen];
+ for (int item = 0; item < arraylen; item++)
+ {
+ m_cacheableInt32Array[item] = input.ReadInt32();
+ }
+ //m_cacheableFileName.FromData(input);
+ //m_CacheableStringASCII.FromData(input);
+ m_cacheableFileName = input.ReadUTF();
+ m_CacheableStringASCII = input.ReadUTF();
+ arraylen = input.ReadArrayLen();
+ m_cacheableStringArray = new string[arraylen];
+ for (int item = 0; item < arraylen; item++)
+ {
+ m_cacheableStringArray[item] = input.ReadUTF();
+ }
+ //m_cacheableHashSet.FromData(input);
+ m_cacheableHashMap = new Dictionary<Object, Object>();
+ input.ReadDictionary((System.Collections.IDictionary)m_cacheableHashMap);
+ //m_cacheableHashMap = input.ReadDictionary();
+ //m_cacheableDate = input.ReadDate();
+ arraylen = input.ReadArrayLen();
+ m_cacheableVector = new object[arraylen];
+ for (int item = 0; item < arraylen; item++)
+ {
+ m_cacheableVector[item] = input.ReadObject();
+ }
+ //m_cacheableObject = input.ReadObject();
+ return this;
+ }
+
+ public uint ObjectSize
+ {
+ get { return 100; }//need to implement
+ }
+
+ public void ToData(DataOutput output)
+ {
+ if (m_initialized)
+ {
+ output.WriteBoolean(m_cacheableBoolean);
+ output.WriteInt32(m_cacheableInt32);
+ output.WriteArrayLen(m_cacheableInt32Array.Length);
+ foreach (int item in m_cacheableInt32Array)
+ {
+ output.WriteInt32(item);
+ }
+ //m_cacheableFileName.ToData(output);
+ //m_CacheableStringASCII.ToData(output);
+ output.WriteUTF(m_cacheableFileName);
+ output.WriteUTF(m_CacheableStringASCII);
+ output.WriteArrayLen(m_cacheableStringArray.Length);
+ foreach (string item in m_cacheableStringArray)
+ {
+ output.WriteUTF(item);
+ }
+ //m_cacheableHashSet.ToData(output);
+ output.WriteDictionary((System.Collections.IDictionary)m_cacheableHashMap);
+ //output.WriteDate(m_cacheableDate);
+ output.WriteArrayLen(m_cacheableVector.Count);
+ foreach (object item in m_cacheableVector)
+ {
+ output.WriteObject(item);
+ }
+ //output.WriteObject(m_cacheableObject);
+ }
+ }
+
+ #endregion
+
+ public static IGeodeSerializable CreateDeserializable()
+ {
+ return new DefaultType();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/DistGetTests.cs
----------------------------------------------------------------------
diff --git a/clicache/integration-test/DistGetTests.cs b/clicache/integration-test/DistGetTests.cs
new file mode 100644
index 0000000..ce680bb
--- /dev/null
+++ b/clicache/integration-test/DistGetTests.cs
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading;
+
+namespace Apache.Geode.Client.UnitTests
+{
+ using NUnit.Framework;
+ using Apache.Geode.DUnitFramework;
+
+ [TestFixture]
+ public class DistGetTests : UnitTests
+ {
+ private const string RootRegion = "DistGet";
+ private const string SomeDistRegion = "SomeDistReg";
+ private const string GetRegion = "GetWithInvalid";
+ private const string GetILRegion = "GetWithInvalid_IL";
+
+ private const int InvBeginKey = 2006;
+ private const int InvEndKey = 2260;
+ private const int Inv2BeginKey = 4006;
+ private const int Inv2EndKey = 4260;
+
+ private Region m_region;
+ private UnitProcess m_dataHolder, m_getter, m_invalidOne, m_invalidTwo;
+
+ protected override ClientBase[] GetClients()
+ {
+ m_dataHolder = new UnitProcess();
+ m_getter = new UnitProcess();
+ m_invalidOne = new UnitProcess();
+ m_invalidTwo = new UnitProcess();
+ return new ClientBase[] { m_dataHolder, m_getter, m_invalidOne, m_invalidTwo };
+ }
+
+ #region Functions used by the tests
+
+ public void Puts()
+ {
+ m_region = CacheHelper.CreateDistRegion(RootRegion,
+ ScopeType.DistributedAck, SomeDistRegion, 10);
+ Util.Log("Beginning puts.");
+ m_region.Put("findme", "hello");
+
+ CacheableString cRes = m_region.Get("findme") as CacheableString;
+ Assert.AreEqual("hello", cRes.Value);
+ }
+
+ public void FindItems()
+ {
+ m_region = CacheHelper.CreateDistRegion(RootRegion,
+ ScopeType.DistributedAck, SomeDistRegion, 10);
+
+ Util.Log("Created second process region.");
+
+ CacheableString cKey = new CacheableString("findme");
+ CacheableString cRes = m_region.Get(cKey) as CacheableString;
+ Assert.AreEqual("hello", cRes.Value);
+ Util.Log("Received value for findme: {0}", cRes.Value);
+
+ m_region.LocalInvalidateRegion();
+ Util.Log("invalidated region");
+ Assert.IsTrue(m_region.ContainsKey(cKey));
+ Assert.IsFalse(m_region.ContainsValueForKey(cKey));
+ Util.Log("passed invalid assertions.");
+
+ cRes = m_region.Get(cKey) as CacheableString;
+ Util.Log("get completed.");
+ Assert.AreEqual("hello", cRes.Value);
+ Util.Log("Received value for findme: {0}", cRes.Value);
+ }
+
+ public void MakeDataTwo(string regionName)
+ {
+ m_region = CacheHelper.CreateILRegion(regionName, true, true, null);
+ CacheableInt32 cKey;
+ for (int i = InvBeginKey; i <= InvEndKey; i++)
+ {
+ cKey = new CacheableInt32(i);
+ m_region.Put(cKey, cKey);
+ }
+ }
+
+ public void Join(string regionName)
+ {
+ m_region = CacheHelper.CreateILRegion(regionName, true, true, null);
+ CacheableInt32 cVal;
+ for (int i = InvBeginKey; i <= InvEndKey; i++)
+ {
+ cVal = m_region.Get(i) as CacheableInt32;
+ Assert.IsNotNull(cVal);
+ Assert.AreEqual(i, cVal.Value);
+ }
+ m_region.LocalInvalidateRegion();
+ }
+
+ public void CheckNotValid(string regionName)
+ {
+ m_region = CacheHelper.CreateILRegion(regionName, true, true, null);
+ CacheableInt32 cVal;
+ for (int i = InvBeginKey; i <= InvEndKey; i++)
+ {
+ cVal = m_region.Get(i) as CacheableInt32;
+ Assert.IsNotNull(cVal);
+ Assert.AreEqual(i, cVal.Value);
+ }
+ for (int i = InvBeginKey; i <= InvEndKey; i++)
+ {
+ m_region.Put(i, -i);
+ }
+ for (int i = InvBeginKey; i <= InvEndKey; i++)
+ {
+ cVal = m_region.Get(i) as CacheableInt32;
+ Assert.IsNotNull(cVal);
+ Assert.AreEqual(-i, cVal.Value);
+ }
+ }
+
+ public void PutKeys(int start, int end, int factor, bool invalidate)
+ {
+ for (int i = start; i <= end; i++)
+ {
+ m_region.Put(i, i * factor);
+ if (invalidate)
+ {
+ m_region.LocalInvalidate(i);
+ }
+ }
+ }
+
+ public void CheckKeys(int start, int end, int factor, bool invalidate, bool netSearch)
+ {
+ CacheableInt32 cKey, cVal;
+ for (int i = start; i <= end; i++)
+ {
+ cKey = new CacheableInt32(i);
+ if (netSearch)
+ {
+ Assert.IsFalse(m_region.ContainsKey(cKey));
+ }
+ else
+ {
+ Assert.IsTrue(m_region.ContainsValueForKey(cKey));
+ }
+ cVal = m_region.Get(cKey) as CacheableInt32;
+ Assert.IsNotNull(cVal);
+ Assert.AreEqual(i * factor, cVal.Value);
+ if (invalidate)
+ {
+ m_region.LocalInvalidate(cKey);
+ }
+ }
+ }
+
+ #endregion
+
+ [Test]
+ public void DistReg()
+ {
+ m_dataHolder.Call(Puts);
+ m_getter.Call(FindItems);
+ }
+
+ [Test]
+ public void GetWithInvalid()
+ {
+ m_dataHolder.Call(MakeDataTwo, GetRegion);
+ m_invalidOne.Call(Join, GetRegion);
+ m_invalidTwo.Call(Join, GetRegion);
+ m_getter.Call(CheckNotValid, GetRegion);
+
+ m_invalidTwo.Call(CheckKeys, InvBeginKey, InvEndKey, -1, false, false);
+ m_invalidOne.Call(CheckKeys, InvBeginKey, InvEndKey, -1, false, false);
+ }
+ }
+}