http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/ThinClientRegionInterestTestsN.cs
----------------------------------------------------------------------
diff --git a/clicache/integration-test/ThinClientRegionInterestTestsN.cs 
b/clicache/integration-test/ThinClientRegionInterestTestsN.cs
new file mode 100644
index 0000000..9cf64f2
--- /dev/null
+++ b/clicache/integration-test/ThinClientRegionInterestTestsN.cs
@@ -0,0 +1,1216 @@
+/*
+ * 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.Threading;
+
+namespace Apache.Geode.Client.UnitTests
+{
+  using NUnit.Framework;
+  using Apache.Geode.DUnitFramework;
+  using Apache.Geode.Client;
+
+  [TestFixture]
+  [Category("group1")]
+  [Category("unicast_only")]
+  [Category("generics")]
+  public class ThinClientRegionInterestTests : ThinClientRegionSteps
+  {
+    #region Private members and methods
+
+    private UnitProcess m_client1, m_client2, m_client3, m_feeder;
+    private static string[] m_regexes = { "Key-*1", "Key-*2",
+      "Key-*3", "Key-*4" };
+    private const string m_regex23 = "Key-[23]";
+    private const string m_regexWildcard = "Key-.*";
+    private const int m_numUnicodeStrings = 5;
+
+    private static string[] m_keysNonRegex = { "key-1", "key-2", "key-3" };
+    private static string[] m_keysForRegex = {"key-regex-1",
+      "key-regex-2", "key-regex-3" };
+    private static string[] RegionNamesForInterestNotify =
+      { "RegionTrue", "RegionFalse", "RegionOther" };
+
+    string GetUnicodeString(int index)
+    {
+      return new string('\x0905', 40) + index.ToString("D10");
+    }
+
+    #endregion
+
+    protected override ClientBase[] GetClients()
+    {
+      m_client1 = new UnitProcess();
+      m_client2 = new UnitProcess();
+      m_client3 = new UnitProcess();
+      m_feeder  = new UnitProcess();
+      return new ClientBase[] { m_client1, m_client2, m_client3, m_feeder };
+    }
+
+    [TestFixtureTearDown]
+    public override void EndTests()
+    {
+      CacheHelper.StopJavaServers();
+      base.EndTests();
+    }
+
+    [TearDown]
+    public override void EndTest()
+    {
+      try
+      {
+        m_client1.Call(DestroyRegions);
+        m_client2.Call(DestroyRegions);
+        CacheHelper.ClearEndpoints();
+      }
+      finally
+      {
+        CacheHelper.StopJavaServers();
+      }
+      base.EndTest();
+    }
+
+    #region Steps for Thin Client IRegion<object, object> with Interest
+
+    public void StepFourIL()
+    {
+      VerifyCreated(m_regionNames[0], m_keys[0]);
+      VerifyCreated(m_regionNames[1], m_keys[2]);
+      VerifyEntry(m_regionNames[0], m_keys[0], m_vals[0]);
+      VerifyEntry(m_regionNames[1], m_keys[2], m_vals[2]);
+    }
+
+    public void StepFourRegex3()
+    {
+      IRegion<object, object> region0 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+      IRegion<object, object> region1 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[1]);
+      try
+      {
+        Util.Log("Registering empty regular expression.");
+        region0.GetSubscriptionService().RegisterRegex(string.Empty);
+        Assert.Fail("Did not get expected exception!");
+      }
+      catch (Exception ex)
+      {
+        Util.Log("Got expected exception {0}: {1}", ex.GetType(), ex.Message);
+      }
+      try
+      {
+        Util.Log("Registering null regular expression.");
+        region1.GetSubscriptionService().RegisterRegex(null);
+        Assert.Fail("Did not get expected exception!");
+      }
+      catch (Exception ex)
+      {
+        Util.Log("Got expected exception {0}: {1}", ex.GetType(), ex.Message);
+      }
+      try
+      {
+        Util.Log("Registering non-existent regular expression.");
+        
region1.GetSubscriptionService().UnregisterRegex("Non*Existent*Regex*");
+        Assert.Fail("Did not get expected exception!");
+      }
+      catch (Exception ex)
+      {
+        Util.Log("Got expected exception {0}: {1}", ex.GetType(), ex.Message);
+      }
+    }
+
+    public void StepFourFailoverRegex()
+    {
+      VerifyCreated(m_regionNames[0], m_keys[0]);
+      VerifyCreated(m_regionNames[1], m_keys[2]);
+      VerifyEntry(m_regionNames[0], m_keys[0], m_vals[0]);
+      VerifyEntry(m_regionNames[1], m_keys[2], m_vals[2]);
+
+      UpdateEntry(m_regionNames[1], m_keys[1], m_vals[1], true);
+      UnregisterRegexes(null, m_regexes[2]);
+    }
+
+    public void StepFiveIL()
+    {
+      VerifyCreated(m_regionNames[0], m_keys[1]);
+      VerifyCreated(m_regionNames[1], m_keys[3]);
+      VerifyEntry(m_regionNames[0], m_keys[1], m_vals[1]);
+      VerifyEntry(m_regionNames[1], m_keys[3], m_vals[3]);
+
+      UpdateEntry(m_regionNames[0], m_keys[0], m_nvals[0], false);
+      UpdateEntry(m_regionNames[1], m_keys[2], m_nvals[2], false);
+    }
+
+    public void StepFiveRegex()
+    {
+      CreateEntry(m_regionNames[0], m_keys[2], m_vals[2]);
+      CreateEntry(m_regionNames[1], m_keys[3], m_vals[3]);
+    }
+
+    public void CreateAllEntries(string regionName)
+    {
+      CreateEntry(regionName, m_keys[0], m_vals[0]);
+      CreateEntry(regionName, m_keys[1], m_vals[1]);
+      CreateEntry(regionName, m_keys[2], m_vals[2]);
+      CreateEntry(regionName, m_keys[3], m_vals[3]);
+    }
+
+    public void VerifyAllEntries(string regionName, bool newVal, bool checkVal)
+    {
+      string[] vals = newVal ? m_nvals : m_vals;
+      VerifyEntry(regionName, m_keys[0], vals[0], checkVal);
+      VerifyEntry(regionName, m_keys[1], vals[1], checkVal);
+      VerifyEntry(regionName, m_keys[2], vals[2], checkVal);
+      VerifyEntry(regionName, m_keys[3], vals[3], checkVal);
+    }
+
+    public void VerifyInvalidAll(string regionName, params string[] keys)
+    {
+      if (keys != null)
+      {
+        foreach (string key in keys)
+        {
+          VerifyInvalid(regionName, key);
+        }
+      }
+    }
+
+    public void UpdateAllEntries(string regionName, bool checkVal)
+    {
+      UpdateEntry(regionName, m_keys[0], m_nvals[0], checkVal);
+      UpdateEntry(regionName, m_keys[1], m_nvals[1], checkVal);
+      UpdateEntry(regionName, m_keys[2], m_nvals[2], checkVal);
+      UpdateEntry(regionName, m_keys[3], m_nvals[3], checkVal);
+    }
+
+    public void DoNetsearchAllEntries(string regionName, bool newVal,
+      bool checkNoKey)
+    {
+      string[] vals;
+      if (newVal)
+      {
+        vals = m_nvals;
+      }
+      else
+      {
+        vals = m_vals;
+      }
+      DoNetsearch(regionName, m_keys[0], vals[0], checkNoKey);
+      DoNetsearch(regionName, m_keys[1], vals[1], checkNoKey);
+      DoNetsearch(regionName, m_keys[2], vals[2], checkNoKey);
+      DoNetsearch(regionName, m_keys[3], vals[3], checkNoKey);
+    }
+
+    public void StepFiveFailoverRegex()
+    {
+      UpdateEntry(m_regionNames[0], m_keys[0], m_nvals[0], false);
+      UpdateEntry(m_regionNames[1], m_keys[2], m_nvals[2], false);
+      VerifyEntry(m_regionNames[1], m_keys[1], m_vals[1], false);
+    }
+
+    public void StepSixIL()
+    {
+      VerifyEntry(m_regionNames[0], m_keys[0], m_nvals[0]);
+      VerifyEntry(m_regionNames[1], m_keys[2], m_vals[2]);
+      IRegion<object, object> region0 = CacheHelper.GetRegion<object, 
object>(m_regionNames[0]);
+      IRegion<object, object> region1 = CacheHelper.GetRegion<object, 
object>(m_regionNames[1]);
+      region0.Remove(m_keys[1]);
+      region1.Remove(m_keys[3]);
+    }
+
+    public void StepSixRegex()
+    {
+      CreateEntry(m_regionNames[0], m_keys[0], m_vals[0]);
+      CreateEntry(m_regionNames[1], m_keys[1], m_vals[1]);
+      VerifyEntry(m_regionNames[0], m_keys[2], m_vals[2]);
+      VerifyEntry(m_regionNames[1], m_keys[3], m_vals[3]);
+
+      UnregisterRegexes(null, m_regexes[3]);
+    }
+
+    public void StepSixFailoverRegex()
+    {
+      VerifyEntry(m_regionNames[0], m_keys[0], m_nvals[0], false);
+      VerifyEntry(m_regionNames[1], m_keys[2], m_vals[2], false);
+      UpdateEntry(m_regionNames[1], m_keys[1], m_nvals[1], false);
+    }
+
+    public void StepSevenIL()
+    {
+      VerifyDestroyed(m_regionNames[0], m_keys[1]);
+      VerifyEntry(m_regionNames[1], m_keys[3], m_vals[3]);
+    }
+
+    public void StepSevenRegex()
+    {
+      VerifyEntry(m_regionNames[0], m_keys[0], m_vals[0]);
+      VerifyEntry(m_regionNames[1], m_keys[1], m_vals[1]);
+      UpdateEntry(m_regionNames[0], m_keys[2], m_nvals[2], true);
+      UpdateEntry(m_regionNames[1], m_keys[3], m_nvals[3], true);
+
+      UnregisterRegexes(null, m_regexes[1]);
+    }
+
+    public void StepSevenRegex2()
+    {
+      VerifyEntry(m_regionNames[0], m_keys[1], m_vals[1]);
+      VerifyEntry(m_regionNames[0], m_keys[2], m_vals[2]);
+
+      DoNetsearch(m_regionNames[0], m_keys[0], m_vals[0], true);
+      DoNetsearch(m_regionNames[0], m_keys[3], m_vals[3], true);
+
+      UpdateAllEntries(m_regionNames[1], true);
+    }
+
+    public void StepSevenInterestResultPolicyInv()
+    {
+      IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+      region.GetSubscriptionService().RegisterRegex(m_regex23);
+
+      VerifyInvalidAll(m_regionNames[0], m_keys[1], m_keys[2]);
+      VerifyEntry(m_regionNames[0], m_keys[0], m_vals[0], true);
+      VerifyEntry(m_regionNames[0], m_keys[3], m_vals[3], true);
+    }
+
+    public void StepSevenFailoverRegex()
+    {
+      UpdateEntry(m_regionNames[0], m_keys[0], m_vals[0], true);
+      UpdateEntry(m_regionNames[1], m_keys[2], m_vals[2], true);
+      VerifyEntry(m_regionNames[1], m_keys[1], m_nvals[1]);
+    }
+
+    public void StepEightIL()
+    {
+      VerifyEntry(m_regionNames[0], m_keys[0], m_nvals[0]);
+      VerifyEntry(m_regionNames[1], m_keys[2], m_nvals[2]);
+    }
+
+    public void StepEightRegex()
+    {
+      VerifyEntry(m_regionNames[0], m_keys[2], m_nvals[2]);
+      VerifyEntry(m_regionNames[1], m_keys[3], m_vals[3]);
+      UpdateEntry(m_regionNames[0], m_keys[0], m_nvals[0], true);
+      UpdateEntry(m_regionNames[1], m_keys[1], m_nvals[1], true);
+    }
+
+    public void StepEightInterestResultPolicyInv()
+    {
+      IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[1]);
+      region.GetSubscriptionService().RegisterAllKeys();
+
+      VerifyInvalidAll(m_regionNames[1], m_keys[0], m_keys[1],
+      m_keys[2], m_keys[3]);
+      UpdateAllEntries(m_regionNames[0], true);
+    }
+
+    public void StepEightFailoverRegex()
+    {
+      VerifyEntry(m_regionNames[0], m_keys[0], m_vals[0]);
+      VerifyEntry(m_regionNames[1], m_keys[2], m_vals[2]);
+    }
+
+    public void StepNineRegex()
+    {
+      VerifyEntry(m_regionNames[0], m_keys[0], m_nvals[0]);
+      VerifyEntry(m_regionNames[1], m_keys[1], m_vals[1]);
+    }
+
+    public void StepNineRegex2()
+    {
+      VerifyEntry(m_regionNames[0], m_keys[0], m_vals[0]);
+      VerifyEntry(m_regionNames[0], m_keys[1], m_nvals[1]);
+      VerifyEntry(m_regionNames[0], m_keys[2], m_nvals[2]);
+      VerifyEntry(m_regionNames[0], m_keys[3], m_vals[3]);
+    }
+
+    public void StepNineInterestResultPolicyInv()
+    {
+      IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+      region.GetSubscriptionService().UnregisterRegex(m_regex23);
+      List<Object> keys = new List<Object>();
+      keys.Add(m_keys[0]);
+      keys.Add(m_keys[1]);
+      keys.Add(m_keys[2]);  
+      region.GetSubscriptionService().RegisterKeys(keys);
+
+      VerifyInvalidAll(m_regionNames[0], m_keys[0], m_keys[1], m_keys[2]);
+    }
+
+    public void PutUnicodeKeys(string regionName, bool updates)
+    {
+      IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, 
object>(regionName);
+      string key;
+      object val;
+      for (int index = 0; index < m_numUnicodeStrings; ++index)
+      {
+        key = GetUnicodeString(index);
+        if (updates)
+        {
+          val = index + 100;
+        }
+        else
+        {
+          val = (float)index + 20.0F;
+        }
+        region[key] = val;
+      }
+    }
+
+    public void RegisterUnicodeKeys(string regionName)
+    {
+      IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, 
object>(regionName);
+      string[] keys = new string[m_numUnicodeStrings];
+      for (int index = 0; index < m_numUnicodeStrings; ++index)
+      {
+        keys[m_numUnicodeStrings - index - 1] = GetUnicodeString(index);
+      }
+      region.GetSubscriptionService().RegisterKeys(keys);
+    }
+
+    public void VerifyUnicodeKeys(string regionName, bool updates)
+    {
+      IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, 
object>(regionName);
+      string key;
+      object expectedVal;
+      for (int index = 0; index < m_numUnicodeStrings; ++index)
+      {
+        key = GetUnicodeString(index);
+        if (updates)
+        {
+          expectedVal = index + 100;
+          Assert.AreEqual(expectedVal, region.GetEntry(key).Value,
+            "Got unexpected value");
+        }
+        else
+        {
+          expectedVal = (float)index + 20.0F;
+          Assert.AreEqual(expectedVal, region[key],
+            "Got unexpected value");
+        }
+      }
+    }
+
+    public void CreateRegionsInterestNotify_Pool(string[] regionNames,
+      string locators, string poolName, bool notify, string nbs)
+    {
+      Properties<string, string> props = Properties<string, 
string>.Create<string, string>();
+      //props.Insert("notify-by-subscription-override", nbs);
+      CacheHelper.InitConfig(props);
+      CacheHelper.CreateTCRegion_Pool(regionNames[0], true, true,
+        new TallyListener<object, object>(), locators, poolName, notify);
+      CacheHelper.CreateTCRegion_Pool(regionNames[1], true, true,
+        new TallyListener<object, object>(), locators, poolName, notify);
+      CacheHelper.CreateTCRegion_Pool(regionNames[2], true, true,
+        new TallyListener<object, object>(), locators, poolName, notify);
+    }
+
+    /*
+    public void CreateRegionsInterestNotify(string[] regionNames,
+      string endpoints, bool notify, string nbs)
+    {
+      Properties props = Properties.Create();
+      //props.Insert("notify-by-subscription-override", nbs);
+      CacheHelper.InitConfig(props);
+      CacheHelper.CreateTCRegion(regionNames[0], true, false,
+        new TallyListener(), endpoints, notify);
+      CacheHelper.CreateTCRegion(regionNames[1], true, false,
+        new TallyListener(), endpoints, notify);
+      CacheHelper.CreateTCRegion(regionNames[2], true, false,
+        new TallyListener(), endpoints, notify);
+    }
+     * */
+
+    public void DoFeed()
+    {
+      foreach (string regionName in RegionNamesForInterestNotify)
+      {
+        IRegion<object, object> region = CacheHelper.GetRegion<object, 
object>(regionName);
+        foreach (string key in m_keysNonRegex)
+        {
+          region[key] = "00";
+        }
+        foreach (string key in m_keysForRegex)
+        {
+          region[key] = "00";
+        }
+      }
+    }
+
+    public void DoFeederOps()
+    {
+      foreach (string regionName in RegionNamesForInterestNotify)
+      {
+        IRegion<object, object> region = CacheHelper.GetRegion<object, 
object>(regionName);
+        foreach (string key in m_keysNonRegex)
+        {
+          region[key] = "11";
+          region[key] = "22";
+          region[key] = "33";
+          region.GetLocalView().Invalidate(key);
+          region.Remove(key);
+        }
+        foreach (string key in m_keysForRegex)
+        {
+          region[key] = "11";
+          region[key] = "22";
+          region[key] = "33";
+          region.GetLocalView().Invalidate(key);
+          region.Remove(key);
+        }
+      }
+    }
+
+    public void DoRegister()
+    {
+      DoRegisterInterests(RegionNamesForInterestNotify[0], true);
+      DoRegisterInterests(RegionNamesForInterestNotify[1], false);
+      // We intentionally do not register interest in Region3
+      //DoRegisterInterestsBlah(RegionNamesForInterestNotifyBlah[2]);
+    }
+
+    public void DoRegisterInterests(string regionName, bool receiveValues)
+    {
+      IRegion<object, object> region = CacheHelper.GetRegion<object, 
object>(regionName);
+      List<string> keys = new List<string>();
+      foreach (string key in m_keysNonRegex)
+      {
+        keys.Add(key);
+      }
+      region.GetSubscriptionService().RegisterKeys(keys.ToArray(), false, 
false, receiveValues);
+      region.GetSubscriptionService().RegisterRegex("key-regex.*", false, 
null, false, receiveValues);
+    }
+
+    public void DoUnregister()
+    {
+      DoUnregisterInterests(RegionNamesForInterestNotify[0]);
+      DoUnregisterInterests(RegionNamesForInterestNotify[1]);
+    }
+
+    public void DoUnregisterInterests(string regionName)
+    {
+      List<string> keys = new List<string>();
+      foreach (string key in m_keysNonRegex)
+      {
+        keys.Add(key);
+      }
+      IRegion<object, object> region = CacheHelper.GetRegion<object, 
object>(regionName);
+      region.GetSubscriptionService().UnregisterKeys(keys.ToArray());
+      region.GetSubscriptionService().UnregisterRegex("key-regex.*");
+    }
+
+    public void DoValidation(string clientName, string regionName,
+      int creates, int updates, int invalidates, int destroys)
+    {
+      IRegion<object, object> region = CacheHelper.GetRegion<object, 
object>(regionName);
+      TallyListener<object, object> listener = region.Attributes.CacheListener 
as TallyListener<object, object>;
+
+      Util.Log(clientName + ": " + regionName + ": creates expected=" + 
creates +
+        ", actual=" + listener.Creates);
+      Util.Log(clientName + ": " + regionName + ": updates expected=" + 
updates +
+        ", actual=" + listener.Updates);
+      Util.Log(clientName + ": " + regionName + ": invalidates expected=" + 
invalidates +
+        ", actual=" + listener.Invalidates);
+      Util.Log(clientName + ": " + regionName + ": destroys expected=" + 
destroys +
+        ", actual=" + listener.Destroys);
+
+      Assert.AreEqual(creates, listener.Creates, clientName + ": " + 
regionName);
+      Assert.AreEqual(updates, listener.Updates, clientName + ": " + 
regionName);
+      Assert.AreEqual(invalidates, listener.Invalidates, clientName + ": " + 
regionName);
+      Assert.AreEqual(destroys, listener.Destroys, clientName + ": " + 
regionName);
+    }
+
+    #endregion
+
+    void runInterestList()
+    {
+      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.");
+
+      m_client1.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepOne complete.");
+
+      m_client2.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepTwo complete.");
+
+      m_client1.Call(StepThree);
+      m_client1.Call(RegisterKeys, m_keys[1], m_keys[3]);
+      Util.Log("StepThree complete.");
+
+      m_client2.Call(StepFour);
+      m_client2.Call(RegisterKeys, m_keys[0], (string)null);
+      Util.Log("StepFour complete.");
+
+      m_client1.Call(StepFiveIL);
+      m_client1.Call(UnregisterKeys, (string)null, m_keys[3]);
+      Util.Log("StepFive complete.");
+
+      m_client2.Call(StepSixIL);
+      Util.Log("StepSix complete.");
+
+      m_client1.Call(StepSevenIL);
+      Util.Log("StepSeven complete.");
+
+      m_client1.Call(Close);
+      m_client2.Call(Close);
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver 1 stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+    void RegisterKeysPdx()
+    {
+      Serializable.RegisterPdxType(PdxTests.PdxTypes1.CreateDeserializable);
+      Serializable.RegisterPdxType(PdxTests.PdxTypes8.CreateDeserializable);
+      IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+
+      region.GetSubscriptionService().RegisterAllKeys();
+    }
+    void StepThreePdx()
+    {
+      Serializable.RegisterPdxType(PdxTests.PdxTypes1.CreateDeserializable);
+      Serializable.RegisterPdxType(PdxTests.PdxTypes8.CreateDeserializable);
+      IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+
+      region[1] = new PdxTests.PdxTypes8();
+    }
+    void StepFourPdx()
+    {
+      Thread.Sleep(2000);
+      IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+
+      IRegion<object, object> regionLocal = region.GetLocalView();
+      object ret = regionLocal[1];
+
+      Assert.IsNotNull(ret);
+      Assert.IsTrue(ret is IPdxSerializable);
+    }
+    void runInterestListPdx()
+    {
+      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.");
+
+      m_client1.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepOne complete.");
+
+      m_client2.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepTwo complete.");
+
+      m_client2.Call(RegisterKeysPdx);
+
+      m_client1.Call(StepThreePdx);
+      
+      Util.Log("StepThreePdx complete.");
+
+      m_client2.Call(StepFourPdx);
+      Util.Log("StepFourPdx complete.");
+
+      
+      m_client1.Call(Close);
+      m_client2.Call(Close);
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver 1 stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+
+    void runInterestList2()
+    {
+      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.");
+
+      m_client1.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepOne complete.");
+
+      m_client2.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepTwo complete.");
+
+      m_client1.Call(StepThree);
+      m_client1.Call(RegisterAllKeys,
+        new string[] { RegionNames[0], RegionNames[1] });
+      Util.Log("StepThree complete.");
+
+      m_client2.Call(StepFour);
+      m_client2.Call(RegisterAllKeys, new string[] { RegionNames[0] });
+      Util.Log("StepFour complete.");
+
+      m_client1.Call(StepFiveIL);
+      m_client1.Call(UnregisterAllKeys, new string[] { RegionNames[1] });
+      Util.Log("StepFive complete.");
+
+      m_client2.Call(StepSixIL);
+      Util.Log("StepSix complete.");
+
+      m_client1.Call(StepSevenIL);
+      Util.Log("StepSeven complete.");
+
+      m_client1.Call(Close);
+      m_client2.Call(Close);
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver 1 stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+
+    void runRegexInterest()
+    {
+      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.");
+
+      m_client1.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepOne complete.");
+
+      m_client2.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepTwo complete.");
+
+      m_client1.Call(RegisterRegexes, m_regexes[0], m_regexes[1]);
+      Util.Log("StepThree complete.");
+
+      m_client2.Call(RegisterRegexes, m_regexes[2], m_regexes[3]);
+      Util.Log("StepFour complete.");
+
+      m_client1.Call(StepFiveRegex);
+      Util.Log("StepFive complete.");
+
+      m_client2.Call(StepSixRegex);
+      Util.Log("StepSix complete.");
+
+      m_client1.Call(StepSevenRegex);
+      Util.Log("StepSeven complete.");
+
+      m_client2.Call(StepEightRegex);
+      Util.Log("StepEight complete.");
+
+      m_client1.Call(StepNineRegex);
+      Util.Log("StepNine complete.");
+
+      m_client1.Call(Close);
+      m_client2.Call(Close);
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver 1 stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+ 
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+
+    void runRegexInterest2()
+    {
+      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.");
+
+      m_client1.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepOne complete.");
+
+      m_client2.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepTwo complete.");
+
+      m_client1.Call(RegisterRegexes, m_regex23, (string)null);
+      Util.Log("StepThree complete.");
+
+      m_client2.Call(RegisterRegexes, (string)null, m_regexWildcard);
+      Util.Log("StepFour complete.");
+
+      m_client1.Call(CreateAllEntries, RegionNames[1]);
+      Util.Log("StepFive complete.");
+
+      m_client2.Call(CreateAllEntries, RegionNames[0]);
+      m_client2.Call(VerifyAllEntries, RegionNames[1], false, false);
+      Util.Log("StepSix complete.");
+
+      m_client1.Call(StepSevenRegex2);
+      m_client1.Call(UpdateAllEntries, RegionNames[1], true);
+      Util.Log("StepSeven complete.");
+
+      m_client2.Call(VerifyAllEntries, RegionNames[1], true, true);
+      m_client2.Call(UpdateAllEntries, RegionNames[0], true);
+      Util.Log("StepEight complete.");
+
+      m_client1.Call(StepNineRegex2);
+      Util.Log("StepNine complete.");
+
+      m_client1.Call(Close);
+      m_client2.Call(Close);
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver 1 stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+
+    void runRegexInterest3()
+    {
+      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.");
+
+      m_client1.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepOne complete.");
+
+      m_client2.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepTwo complete.");
+
+      try
+      {
+        m_client1.Call(RegisterRegexes, "a*", "*[*2-[");
+        Assert.Fail("Did not get expected exception!");
+      }
+      catch (Exception ex)
+      {
+        Util.Log("Got expected exception {0}: {1}", ex.GetType(), ex.Message);
+      }
+      Util.Log("StepThree complete.");
+
+      m_client2.Call(StepFourRegex3);
+      Util.Log("StepFour complete.");
+
+      m_client1.Call(Close);
+      m_client2.Call(Close);
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver 1 stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+
+    void runInterestResultPolicyInv()
+    {
+      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.");
+
+      m_client1.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepOne complete.");
+
+      m_client2.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepTwo complete.");
+
+      m_client1.Call(CreateAllEntries, RegionNames[1]);
+      Util.Log("StepThree complete.");
+
+      m_client2.Call(CreateAllEntries, RegionNames[0]);
+      Util.Log("StepFour complete.");
+
+      m_client2.Call(DoNetsearchAllEntries, RegionNames[1], false, true);
+      Util.Log("StepFive complete.");
+
+      m_client1.Call(DoNetsearchAllEntries, RegionNames[0], false, true);
+      Util.Log("StepSix complete.");
+
+      m_client1.Call(StepSevenInterestResultPolicyInv);
+      Util.Log("StepSeven complete.");
+
+      m_client2.Call(StepEightInterestResultPolicyInv);
+      Util.Log("StepEight complete.");
+
+      m_client1.Call(StepNineInterestResultPolicyInv);
+      Util.Log("StepNine complete.");
+
+      m_client1.Call(Close);
+      m_client2.Call(Close);
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver 1 stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+
+    void runFailoverInterest()
+    {
+      CacheHelper.SetupJavaServers( true,
+        "cacheserver_notify_subscription.xml",
+        "cacheserver_notify_subscription2.xml");
+      CacheHelper.StartJavaLocator(1, "GFELOC");
+      Util.Log("Locator started");
+      CacheHelper.StartJavaServerWithLocators(1, "GFECS1", 1);
+      Util.Log("Cacheserver 1 started.");
+
+      m_client1.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepOne complete.");
+
+      m_client2.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepTwo complete.");
+
+      m_client2.Call(RegisterKeys, m_keys[0], m_keys[2]);
+      Util.Log("StepTwo complete.");
+
+      m_client1.Call(StepThree);
+      Util.Log("StepThree complete.");
+
+      m_client2.Call(StepFourIL);
+      Util.Log("StepFour complete.");
+
+      CacheHelper.StartJavaServerWithLocators(2, "GFECS2", 1);
+      Util.Log("Cacheserver 2 started.");
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver 1 stopped.");
+
+      m_client1.Call(StepFiveFailover);
+      Util.Log("StepFive complete.");
+
+      m_client2.Call(StepSixFailover);
+      Util.Log("StepSix complete.");
+
+      m_client1.Call(Close);
+      m_client2.Call(Close);
+
+      CacheHelper.StopJavaServer(2);
+      Util.Log("Cacheserver 2 stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+
+    void runFailoverInterest2()
+    {
+      CacheHelper.SetupJavaServers(true,
+        "cacheserver_notify_subscription.xml",
+        "cacheserver_notify_subscription2.xml");
+      CacheHelper.StartJavaLocator(1, "GFELOC");
+      Util.Log("Locator started");
+      CacheHelper.StartJavaServerWithLocators(1, "GFECS1", 1);
+      Util.Log("Cacheserver 1 started.");
+
+      m_client1.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepOne complete.");
+
+      m_client2.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+      Util.Log("StepTwo complete.");
+
+      m_client2.Call(RegisterAllKeys, RegionNames);
+      Util.Log("StepTwo complete.");
+
+      m_client1.Call(StepThree);
+      Util.Log("StepThree complete.");
+
+      m_client2.Call(StepFourIL);
+      Util.Log("StepFour complete.");
+
+      CacheHelper.StartJavaServerWithLocators(2, "GFECS2", 1);
+      Util.Log("Cacheserver 2 started.");
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver 1 stopped.");
+
+      m_client1.Call(StepFiveFailover);
+      Util.Log("StepFive complete.");
+
+      m_client2.Call(StepSixFailover);
+      Util.Log("StepSix complete.");
+
+      // Client2, unregister all keys
+      m_client2.Call(UnregisterAllKeys, RegionNames);
+      Util.Log("UnregisterAllKeys complete.");
+
+      m_client1.Call(StepSevenFailover);
+      Util.Log("StepSeven complete.");
+
+      m_client2.Call(StepEightIL);
+      Util.Log("StepEight complete.");
+
+      m_client1.Call(Close);
+      m_client2.Call(Close);
+
+      CacheHelper.StopJavaServer(2);
+      Util.Log("Cacheserver 2 stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+
+    void runFailoverRegexInterest()
+    {
+      CacheHelper.SetupJavaServers(true,
+        "cacheserver_notify_subscription.xml",
+        "cacheserver_notify_subscription2.xml");
+      CacheHelper.StartJavaLocator(1, "GFELOC");
+      Util.Log("Locator started");
+      CacheHelper.StartJavaServerWithLocators(1, "GFECS1", 1);
+      Util.Log("Cacheserver 1 started.");
+
+      m_client1.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+
+      m_client1.Call(CreateEntry, RegionNames[1], m_keys[1], m_vals[1]);
+      Util.Log("StepOne complete.");
+
+      m_client2.Call(CreateTCRegions_Pool, RegionNames,
+        CacheHelper.Locators, "__TESTPOOL1_", true);
+
+      m_client2.Call(CreateEntry, RegionNames[1], m_keys[1], m_nvals[1]);
+      m_client2.Call(RegisterRegexes, m_regexes[0], m_regexes[2]);
+      Util.Log("StepTwo complete.");
+
+      m_client1.Call(StepThree);
+      m_client1.Call(RegisterRegexes, (string)null, m_regexes[1]);
+      m_client1.Call(DoNetsearch, RegionNames[1],
+        m_keys[1], m_nvals[1], false);
+      Util.Log("StepThree complete.");
+
+      m_client2.Call(StepFourFailoverRegex);
+      Util.Log("StepFour complete.");
+
+      CacheHelper.StartJavaServerWithLocators(2, "GFECS2", 1);
+      Util.Log("Cacheserver 2 started.");
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver 1 stopped.");
+
+      m_client1.Call(StepFiveFailoverRegex);
+      Util.Log("StepFive complete.");
+
+      m_client2.Call(StepSixFailoverRegex);
+      Util.Log("StepSix complete.");
+
+      m_client1.Call(StepSevenFailoverRegex);
+      Util.Log("StepSeven complete.");
+
+      m_client2.Call(StepEightFailoverRegex);
+      Util.Log("StepEight complete.");
+
+      m_client1.Call(Close);
+      m_client2.Call(Close);
+
+      CacheHelper.StopJavaServer(2);
+      Util.Log("Cacheserver 2 stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+
+    void runInterestNotify()
+    {
+      CacheHelper.SetupJavaServers(true,
+        "cacheserver_interest_notify.xml");
+
+      // start locator and server
+
+      CacheHelper.StartJavaLocator(1, "GFELOC");
+      Util.Log("Locator started");
+      CacheHelper.StartJavaServerWithLocators(1, "GFECS1", 1);
+      Util.Log("Cacheserver started.");
+
+      // create feeder and 3 clients each with 3 regions and
+      // populate initial keys
+
+      m_feeder.Call(CreateRegionsInterestNotify_Pool, 
RegionNamesForInterestNotify,
+        CacheHelper.Locators, "__TESTPOOL1_", false, "server" /* nbs */);
+
+      m_feeder.Call(DoFeed);
+
+      m_client1.Call(CreateRegionsInterestNotify_Pool, 
RegionNamesForInterestNotify,
+        CacheHelper.Locators, "__TESTPOOL1_", true, "true" /* nbs */);
+      //m_client2.Call(CreateRegionsInterestNotify_Pool, 
RegionNamesForInterestNotify,
+      //  CacheHelper.Locators, "__TESTPOOL1_", true, "false" /* nbs */);
+      //m_client3.Call(CreateRegionsInterestNotify_Pool, 
RegionNamesForInterestNotify,
+      //  CacheHelper.Locators, "__TESTPOOL1_", true, "server" /* nbs */);
+
+      // Register interests and get initial values
+      m_client1.Call(DoRegister);
+      //m_client2.Call(DoRegister);
+      //m_client3.Call(DoRegister);
+
+      // Do ops while interest is registered
+      m_feeder.Call(DoFeederOps);
+
+      m_client1.Call(DoUnregister);
+      //m_client2.Call(DoUnregister);
+      //m_client3.Call(DoUnregister);
+
+      // Do ops while interest is no longer registered
+      m_feeder.Call(DoFeederOps);
+
+      m_client1.Call(DoRegister);
+      //m_client2.Call(DoRegister);
+      //m_client3.Call(DoRegister);
+
+      // Do ops while interest is re-registered
+      m_feeder.Call(DoFeederOps);
+
+      // Validate clients receive relevant expected event counts:
+
+      m_client1.Call(DoValidation, "Client1", RegionNamesForInterestNotify[0], 
6, 30, 0, 12);
+      m_client1.Call(DoValidation, "Client1", RegionNamesForInterestNotify[1], 
0, 0, 36, 12);
+      m_client1.Call(DoValidation, "Client1", RegionNamesForInterestNotify[2], 
0, 0, 0, 0);
+
+      /*
+      m_client2.Call(DoValidation, "Client2", RegionNamesForInterestNotify[0], 
0, 0, 54, 18);
+      m_client2.Call(DoValidation, "Client2", RegionNamesForInterestNotify[1], 
0, 0, 54, 18);
+      m_client2.Call(DoValidation, "Client2", RegionNamesForInterestNotify[2], 
0, 0, 54, 18);
+
+      m_client3.Call(DoValidation, "Client3", RegionNamesForInterestNotify[0], 
0, 0, 54, 18);
+      m_client3.Call(DoValidation, "Client3", RegionNamesForInterestNotify[1], 
0, 0, 54, 18);
+      m_client3.Call(DoValidation, "Client3", RegionNamesForInterestNotify[2], 
0, 0, 54, 18);
+       * */
+
+      // close down
+
+      m_client1.Call(Close);
+      //m_client2.Call(Close);
+      //m_client3.Call(Close);
+      m_feeder.Call(Close);
+
+      CacheHelper.StopJavaServer(1);
+      Util.Log("Cacheserver stopped.");
+
+      CacheHelper.StopJavaLocator(1);
+      Util.Log("Locator stopped");
+      CacheHelper.ClearEndpoints();
+      CacheHelper.ClearLocators();
+    }
+
+    [Test]
+    public void InterestList()
+    {
+      runInterestList(); 
+    }
+
+    [Test]
+    public void InterestListWithPdx()
+    {
+      runInterestListPdx();
+    }
+
+    [Test]
+    public void InterestList2()
+    {
+      runInterestList2();
+    }
+
+    [Test]
+    public void RegexInterest()
+    {
+      runRegexInterest();
+    }
+
+    [Test]
+    public void RegexInterest2()
+    {
+      runRegexInterest2();
+    }
+
+    [Test]
+    public void RegexInterest3()
+    {
+      runRegexInterest3();
+    }
+
+    [Test]
+    public void InterestResultPolicyInv()
+    {
+      runInterestResultPolicyInv();
+    }
+
+    [Test]
+    public void FailoverInterest()
+    {
+      runFailoverInterest();
+    }
+
+    [Test]
+    public void FailoverInterest2()
+    {
+      runFailoverInterest2();
+    }
+
+    [Test]
+    public void FailoverRegexInterest()
+    {
+      runFailoverRegexInterest();
+    }
+
+    [Test]
+    public void InterestNotify()
+    {
+      runInterestNotify();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/integration-test/ThinClientRegionStepsN.cs
----------------------------------------------------------------------
diff --git a/clicache/integration-test/ThinClientRegionStepsN.cs 
b/clicache/integration-test/ThinClientRegionStepsN.cs
new file mode 100644
index 0000000..dc03f78
--- /dev/null
+++ b/clicache/integration-test/ThinClientRegionStepsN.cs
@@ -0,0 +1,705 @@
+/*
+ * 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.Threading;
+
+namespace Apache.Geode.Client.UnitTests
+{
+  using NUnit.Framework;
+  using Apache.Geode.DUnitFramework;
+  using Apache.Geode.Client;
+  using AssertionException = Apache.Geode.Client.AssertionException;
+
+
+  [TestFixture]
+  [Category("group1")]
+  [Category("unicast_only")]
+  [Category("generics")]
+  public abstract class ThinClientRegionSteps : DistOpsSteps
+  {
+    #region Protected statics/constants and members
+
+    protected const string RegionName = "DistRegionAck";
+    protected static string[] RegionNames = { RegionName, "DistRegionNoAck" };
+    protected static string[] RegionNames2 = { "exampleRegion", RegionName };
+    protected static string[] RegionNames3 = { "testregion", RegionName };
+    protected const string PartitionRegion1 = "R1";
+    protected const string PartitionRegion2 = "R2";
+    protected const string PartitionRegion3 = "R3";
+    protected const string KeyPrefix = "key-";
+    protected const string ValuePrefix = "value-";
+    protected const string NValuePrefix = "nvalue-";
+    protected const string TradeKeyRegion = "TradeKeyRegion";
+
+    #endregion
+
+    protected override string ExtraPropertiesFile
+    {
+      get
+      {
+        return "geode.properties.nativeclient";
+      }
+    }
+
+    #region Steps for Thin Client IRegion<object, object>
+
+    public void CreateNonExistentRegion(string locators)
+    {
+      string regionName = "non-region";
+
+      CacheHelper.CreateTCRegion_Pool<object, object>(regionName, true, true,
+        null, locators, "__TESTPOOL1_", false);
+
+      try
+      {
+        CreateEntry(regionName, m_keys[0], m_vals[0]);
+        Assert.Fail("Expected CacheServerException for operations on a " +
+          "non-existent region [{0}].", regionName);
+      }
+      catch (CacheServerException ex)
+      {
+        Util.Log("Got expected exception in CreateNonExistentRegion: {0}",
+          ex.Message);
+      }
+    }
+
+    public override void DestroyRegions()
+    {
+      if (m_regionNames != null)
+      {
+        CacheHelper.DestroyRegion<object, object>(m_regionNames[0], true, 
false);
+        CacheHelper.DestroyRegion<object, object>(m_regionNames[1], true, 
false);
+      }
+    }
+
+    public void RegisterKeys(string key0, string key1)
+    {
+      IRegion<object, object> region0 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+      IRegion<object, object> region1 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[1]);
+      
+      if (key0 != null)
+      {
+        //region0.RegisterKeys(new CacheableKey[] {new CacheableString(key0) 
});
+        List<Object> keys0 = new List<Object>();
+        keys0.Add(key0);      
+        region0.GetSubscriptionService().RegisterKeys(keys0);
+      }
+      if (key1 != null)
+      {
+        List<Object> keys1 = new List<Object>();
+        keys1.Add(key1);      
+        region1.GetSubscriptionService().RegisterKeys(keys1);
+      }
+    }
+
+    public void UnregisterKeys(string key0, string key1)
+    {
+      IRegion<object, object> region0 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+      IRegion<object, object> region1 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[1]);
+      if (key0 != null)
+      {
+          List<Object> keys0 = new List<Object>();
+          keys0.Add(key0);
+          region0.GetSubscriptionService().UnregisterKeys(keys0);
+      }
+      if (key1 != null)
+      {
+          List<Object> keys1 = new List<Object>();
+          keys1.Add(key1);
+          region1.GetSubscriptionService().UnregisterKeys(keys1);
+      }
+    }
+
+    public void RegisterAllKeys(string[] regionNames)
+    {
+      IRegion<object, object> region;
+      if (regionNames != null)
+      {
+        foreach (string regionName in regionNames)
+        {
+          region = CacheHelper.GetVerifyRegion<object, object>(regionName);
+          region.GetSubscriptionService().RegisterAllKeys();
+        }
+      }
+    }
+
+    public void UnregisterAllKeys(string[] regionNames)
+    {
+      IRegion<object, object> region;
+      if (regionNames != null)
+      {
+        foreach (string regionName in regionNames)
+        {
+          region = CacheHelper.GetVerifyRegion<object, object>(regionName);
+            region.GetSubscriptionService().UnregisterAllKeys();
+        }
+      }
+    }
+
+    public void RegisterRegexes(string regex0, string regex1)
+    {
+      if (regex0 != null)
+      {
+        IRegion<object, object> region0 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+        region0.GetSubscriptionService().RegisterRegex(regex0);
+      }
+      if (regex1 != null)
+      {
+        IRegion<object, object> region1 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[1]);
+        region1.GetSubscriptionService().RegisterRegex(regex1);
+      }
+    }
+
+    public void UnregisterRegexes(string regex0, string regex1)
+    {
+      if (regex0 != null)
+      {
+        IRegion<object, object> region0 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+          region0.GetSubscriptionService().UnregisterRegex(regex0);
+      }
+      if (regex1 != null)
+      {
+        IRegion<object, object> region1 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[1]);
+          region1.GetSubscriptionService().UnregisterRegex(regex1);
+      }
+    }
+
+    public void CheckServerKeys()
+    {
+      IRegion<object, object> region0 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[0]);
+      IRegion<object, object> region1 = CacheHelper.GetVerifyRegion<object, 
object>(m_regionNames[1]);
+
+      //ICacheableKey[] keys0 = region0.GetServerKeys();
+      ICollection<Object> keys0 = region0.Keys;
+      //ICacheableKey[] keys1 = region1.GetServerKeys();
+      ICollection<Object> keys1 = region1.Keys;
+
+      Assert.AreEqual(2, keys0.Count, "Should have 2 keys in region {0}.",
+        m_regionNames[0]);
+      Assert.AreEqual(2, keys1.Count, "Should have 2 keys in region {0}.",
+        m_regionNames[1]);
+
+      string key0, key1;
+
+      IEnumerator<Object> obj = keys0.GetEnumerator();
+      obj.MoveNext();
+      key0 = obj.Current.ToString();
+      //Console.WriteLine("key0 = {0}", key0);
+      obj.MoveNext();
+      key1 = obj.Current.ToString();
+      
+      //key0 = keys0[0].ToString();
+      //key1 = keys0[1].ToString();
+      Assert.AreNotEqual(key0, key1,
+        "The two keys should be different in region {0}.", m_regionNames[0]);
+      Assert.IsTrue(key0 == m_keys[0] || key0 == m_keys[1],
+        "Unexpected key in first region.");
+      Assert.IsTrue(key1 == m_keys[0] || key1 == m_keys[1],
+        "Unexpected key in first region.");
+
+      //key0 = keys1[0].ToString();
+      //key1 = keys1[1].ToString();
+      IEnumerator<Object> obj1 = keys1.GetEnumerator();
+      obj1.MoveNext();
+      key0 = obj1.Current.ToString();
+      //Console.WriteLine("key0 = {0}", key0);
+      obj1.MoveNext();
+      key1 = obj1.Current.ToString();
+
+      Assert.AreNotEqual(key0, key1,
+        "The two keys should be different in region {0}.", m_regionNames[1]);
+      Assert.IsTrue(key0 == m_keys[2] || key0 == m_keys[3],
+        "Unexpected key in first region.");
+      Assert.IsTrue(key1 == m_keys[2] || key1 == m_keys[3],
+        "Unexpected key in first region.");
+    }
+
+    //public void StepFiveNotify()
+    //{
+    //  DoNetsearch(m_regionNames[0], m_keys[1], m_vals[1], true);
+    //  DoNetsearch(m_regionNames[1], m_keys[3], m_vals[3], true);
+    //  UpdateEntry(m_regionNames[0], m_keys[0], m_nvals[0], true);
+    //  UpdateEntry(m_regionNames[1], m_keys[2], m_nvals[2], true);
+    //  VerifyEntry(m_regionNames[0], m_keys[0], m_nvals[0]);
+    //  VerifyEntry(m_regionNames[1], m_keys[2], m_nvals[2]);
+    //}
+
+    public void StepFiveFailover()
+    {
+      UpdateEntry(m_regionNames[0], m_keys[0], m_nvals[0], false);
+      //DestroyEntry(m_regionNames[0], m_keys[0]);
+      UpdateEntry(m_regionNames[1], m_keys[2], m_nvals[2], false);
+    }
+
+    public override void StepSix(bool checkVal)
+    {
+      DoNetsearch(m_regionNames[0], m_keys[0], m_vals[0], false);
+      DoNetsearch(m_regionNames[1], m_keys[2], m_vals[2], false);
+      UpdateEntry(m_regionNames[0], m_keys[1], m_nvals[1], checkVal);
+      UpdateEntry(m_regionNames[1], m_keys[3], m_nvals[3], checkVal);
+    }
+
+    public void StepSixNotify(bool checkVal)
+    {
+      VerifyEntry(m_regionNames[0], m_keys[0], m_nvals[0], checkVal);
+      VerifyEntry(m_regionNames[1], m_keys[2], m_nvals[2], checkVal);
+      UpdateEntry(m_regionNames[0], m_keys[1], m_nvals[1], checkVal);
+      UpdateEntry(m_regionNames[1], m_keys[3], m_nvals[3], checkVal);
+    }
+
+    public void StepSixFailover()
+    {
+      VerifyEntry(m_regionNames[0], m_keys[0], m_nvals[0], false);
+      VerifyEntry(m_regionNames[1], m_keys[2], m_nvals[2], false);
+    }
+
+    public void StepSevenNotify(bool checkVal)
+    {
+      VerifyInvalid(m_regionNames[0], m_keys[1]);
+      VerifyInvalid(m_regionNames[1], m_keys[3]);
+      VerifyEntry(m_regionNames[0], m_keys[1], m_nvals[1], checkVal);
+      VerifyEntry(m_regionNames[1], m_keys[3], m_nvals[3], checkVal);
+      InvalidateEntry(m_regionNames[0], m_keys[0]);
+      InvalidateEntry(m_regionNames[1], m_keys[2]);
+    }
+
+    public void StepSevenFailover()
+    {
+      UpdateEntry(m_regionNames[0], m_keys[0], m_vals[0], false);
+      UpdateEntry(m_regionNames[1], m_keys[2], m_vals[2], false);
+    }
+
+    public void StepEightNotify(bool checkVal)
+    {
+      VerifyEntry(m_regionNames[0], m_keys[0], m_nvals[0], checkVal);
+      VerifyEntry(m_regionNames[1], m_keys[2], m_nvals[2], checkVal);
+      InvalidateEntry(m_regionNames[0], m_keys[1]);
+      InvalidateEntry(m_regionNames[1], m_keys[3]);
+    }
+
+    public void StepNineNotify(bool checkVal)
+    {
+      VerifyEntry(m_regionNames[0], m_keys[1], m_nvals[1], checkVal);
+      VerifyEntry(m_regionNames[1], m_keys[3], m_nvals[3], checkVal);
+      DestroyEntry(m_regionNames[0], m_keys[0]);
+      DestroyEntry(m_regionNames[1], m_keys[2]);
+    }
+
+    #endregion
+
+    #region Functions invoked by the tests
+
+    public void Close()
+    {
+      CacheHelper.Close();
+    }
+
+    public void CloseKeepAlive()
+    {
+      CacheHelper.CloseCacheKeepAlive();
+    }
+
+    public void ReadyForEvents2()
+    {
+      CacheHelper.ReadyForEvents();
+    }
+
+    public void DoPutsMU(int numOps, Client.Properties<string, string> 
credentials, bool multiuserMode, ExpectedResult result)
+    {
+      DoPuts(numOps, false, result, credentials, multiuserMode);
+    }
+
+    public void DoPutsMU(int numOps, Client.Properties<string, string> 
credentials, bool multiuserMode)
+    {
+      DoPuts(numOps, false, ExpectedResult.Success, credentials, 
multiuserMode);
+    }
+
+    public void DoPuts(int numOps)
+    {
+      DoPuts(numOps, false, ExpectedResult.Success, null, false);
+    }
+
+    public void DoPuts(int numOps, bool useNewVal)
+    {
+      DoPuts(numOps, useNewVal, ExpectedResult.Success, null, false);
+    }
+
+    public void DoPuts(int numOps, bool useNewVal, ExpectedResult expect)
+    {
+      DoPuts(numOps, useNewVal, expect, null, false);
+    }
+
+    public void DoPuts(int numOps, bool useNewVal, ExpectedResult expect, 
Client.Properties<string, string> credentials, bool multiuserMode)
+    {
+      string valPrefix = (useNewVal ? NValuePrefix : ValuePrefix);
+      IRegion<object, object> region;
+      if (multiuserMode)
+        region = CacheHelper.GetVerifyRegion<object, object>(RegionName, 
credentials);
+      else
+        region = CacheHelper.GetVerifyRegion<object, object>(RegionName);
+      Serializable.RegisterPdxType(PdxTests.PdxTypes1.CreateDeserializable);
+      Serializable.RegisterPdxType(PdxTests.PdxTypes8.CreateDeserializable);
+      for (int opNum = 1; opNum <= numOps; ++opNum)
+      {
+        try
+        {
+          region[KeyPrefix + opNum] = valPrefix + opNum;
+
+          region.Invalidate(KeyPrefix + opNum);
+
+          region[KeyPrefix + opNum] = valPrefix + opNum;
+
+          Util.Log("Pdx ops starts");
+          region[opNum] = new PdxTests.PdxTypes8();
+          region[opNum + "_pdx1"] = new PdxTests.PdxTypes1();
+          region[opNum + "_pdx_8"] = new PdxTests.PdxTypes8();
+
+          IDictionary<object, object> putall = new Dictionary<object,object>();
+          putall.Add(opNum +"_pdxputall81", new PdxTests.PdxTypes8());
+          putall.Add(opNum + "_pdxputall82", new PdxTests.PdxTypes8());
+          region.PutAll(putall);
+
+        
+          Util.Log("Pdx ops ends");
+
+          if (expect != ExpectedResult.Success)
+          {
+            Assert.Fail("DoPuts: Expected an exception in put");
+          }
+        }
+        catch (AssertionException)
+        {
+          throw;
+        }
+        catch (NotAuthorizedException ex)
+        {
+          if (expect == ExpectedResult.NotAuthorizedException)
+          {
+            Util.Log("DoPuts: got expected unauthorized exception: " +
+              ex.GetType() + "::" + ex.Message);
+          }
+          else
+          {
+            Assert.Fail("DoPuts: unexpected exception caught: " + ex);
+          }
+        }
+        catch (AuthenticationFailedException ex)
+        {
+          if (expect == ExpectedResult.AuthFailedException)
+          {
+            Util.Log("DoPuts: got expected authentication Failed exception: " +
+              ex.GetType() + "::" + ex.Message);
+          }
+          else
+          {
+            Assert.Fail("DoPuts: unexpected exception caught: " + ex);
+          }
+        }
+        catch (Exception ex)
+        {
+          if (expect == ExpectedResult.OtherException)
+          {
+            Util.Log("DoPuts: got expected exception: " +
+              ex.GetType() + "::" + ex.Message);
+          }
+          else
+          {
+            Assert.Fail("DoPuts: unexpected exception caught: " + ex);
+          }
+        }
+      }
+    }
+
+    public void DoPutsTx(int numOps, bool useNewVal, ExpectedResult expect, 
Client.Properties<string, string> credentials, bool multiuserMode)
+    {
+      Util.Log("DoPutsTx starts");
+      CacheHelper.CSTXManager.Begin();
+      string valPrefix = (useNewVal ? NValuePrefix : ValuePrefix);
+      IRegion<object, object> region;
+      if (multiuserMode)
+          region = CacheHelper.GetVerifyRegion<object, object>(RegionName, 
credentials);
+      else
+          region = CacheHelper.GetVerifyRegion<object, object>(RegionName);
+      Serializable.RegisterPdxType(PdxTests.PdxTypes1.CreateDeserializable);
+      Serializable.RegisterPdxType(PdxTests.PdxTypes8.CreateDeserializable);
+      for (int opNum = 1; opNum <= numOps; ++opNum)
+      {
+        try
+        {
+          region[KeyPrefix + opNum] = valPrefix + opNum;
+          region.Invalidate(KeyPrefix + opNum);
+          region[KeyPrefix + opNum] = valPrefix + opNum;
+          Util.Log("Pdx ops starts");
+          region[opNum] = new PdxTests.PdxTypes8();
+          region[opNum + "_pdx1"] = new PdxTests.PdxTypes1();
+          region[opNum + "_pdx_8"] = new PdxTests.PdxTypes8();
+          IDictionary<object, object> putall = new Dictionary<object, 
object>();
+          putall.Add(opNum + "_pdxputall81", new PdxTests.PdxTypes8());
+          putall.Add(opNum + "_pdxputall82", new PdxTests.PdxTypes8());
+          region.PutAll(putall);
+          Util.Log("Pdx ops ends");
+          if (expect != ExpectedResult.Success)
+          {
+            Assert.Fail("DoPuts: Expected an exception in put");
+          }
+        }
+        catch (AssertionException)
+        {
+          throw;
+        }
+        catch (NotAuthorizedException ex)
+        {
+          if (expect == ExpectedResult.NotAuthorizedException)
+          {
+            Util.Log("DoPuts: got expected unauthorized exception: " +
+                ex.GetType() + "::" + ex.Message);
+          }
+          else
+          {
+            Assert.Fail("DoPuts: unexpected exception caught: " + ex);
+          }
+        }
+        catch (AuthenticationFailedException ex)
+        {
+          if (expect == ExpectedResult.AuthFailedException)
+          {
+            Util.Log("DoPuts: got expected authentication Failed exception: " +
+              ex.GetType() + "::" + ex.Message);
+          }
+          else
+          {
+            Assert.Fail("DoPuts: unexpected exception caught: " + ex);
+          }
+        }
+        catch (Exception ex)
+        {
+          if (expect == ExpectedResult.OtherException)
+          {
+            Util.Log("DoPuts: got expected exception: " +
+              ex.GetType() + "::" + ex.Message);
+          }
+          else
+          {
+            Assert.Fail("DoPuts: unexpected exception caught: " + ex);
+          }
+        }
+      }
+      CacheHelper.CSTXManager.Commit();
+      Util.Log("DoPutsTx Done");
+    }
+
+    public void DoGetsMU(int numOps, Client.Properties<string, string> 
credential, bool isMultiuser, ExpectedResult result)
+    {
+      DoGets(numOps, false, result, credential, isMultiuser);
+    }
+
+    public void DoGetsMU(int numOps, Client.Properties<string, string> 
credential, bool isMultiuser)
+    {
+      DoGets(numOps, false, ExpectedResult.Success, credential, isMultiuser);
+    }
+
+    public void DoGets(int numOps)
+    {
+      DoGets(numOps, false, ExpectedResult.Success, null, false);
+    }
+
+    public void DoGets(int numOps, bool useNewVal)
+    {
+      DoGets(numOps, useNewVal, ExpectedResult.Success, null, false);
+    }
+
+    public void DoGets(int numOps, bool useNewVal, ExpectedResult expect)
+    {
+      DoGets(numOps, useNewVal, expect, null, false);
+    }
+    public void DoGets(int numOps, bool useNewVal, ExpectedResult expect, 
Client.Properties<string, string> credential, bool isMultiuser)
+    {
+      string valPrefix = (useNewVal ? NValuePrefix : ValuePrefix);
+      IRegion<object, object> region;
+      Serializable.RegisterPdxType(PdxTests.PdxTypes1.CreateDeserializable);
+      Serializable.RegisterPdxType(PdxTests.PdxTypes8.CreateDeserializable);
+      if (isMultiuser)
+      {
+        region = CacheHelper.GetVerifyRegion<object, object>(RegionName, 
credential);
+      }
+      else
+      {
+        region = CacheHelper.GetVerifyRegion<object, object>(RegionName);
+      }
+
+      for (int index = 1; index <= numOps; ++index)
+      {
+        try
+        {
+          region.GetLocalView().Invalidate(index + "_pdxputall81");
+          region.GetLocalView().Invalidate(index + "_pdxputall82");
+        }
+        catch (Exception )
+        { }
+      }
+      
+      if (expect == ExpectedResult.Success)
+      {
+        for (int index = 1; index <= numOps; ++index)
+        {
+          object ret1 = region[index + "_pdxputall81"];
+          object ret2 = region[index + "_pdxputall82"];
+
+          Assert.IsTrue(ret1 != null && ret1 is PdxTests.PdxTypes8);
+          Assert.IsTrue(ret1 != null && ret2 is PdxTests.PdxTypes8);
+        }
+      }
+
+      for (int index = 1; index <= numOps; ++index)
+      {
+        try
+        {
+          region.GetLocalView().Invalidate(index + "_pdxputall81");
+          region.GetLocalView().Invalidate(index + "_pdxputall82");
+        }
+        catch (Exception )
+        { }
+      }
+
+      if (expect == ExpectedResult.Success)
+      {
+        for (int index = 1; index <= numOps; ++index)
+        {
+          ICollection<object> pdxKeys = new List<object>();
+          pdxKeys.Add(index + "_pdxputall81");
+          pdxKeys.Add(index + "_pdxputall82");
+          IDictionary<object, object> getall = new Dictionary<object, 
object>();
+          region.GetAll(pdxKeys, getall, null);
+
+          Assert.AreEqual(2, getall.Count);
+        }
+      }
+
+      for (int index = 1; index <= numOps; ++index)
+      {
+        string key = KeyPrefix + index;
+        try
+        {
+          region.GetLocalView().Invalidate(key);
+        }
+        catch (Exception)
+        {
+          // ignore exception if key is not found in the region
+        }
+        Object value = null;
+        try
+        {
+          value = region[key];
+          Object retPdx = region[index];
+
+          Assert.IsTrue(retPdx != null && retPdx is PdxTests.PdxTypes8);
+          if (expect != ExpectedResult.Success)
+          {
+            Assert.Fail("DoGets: Expected an exception in get");
+          }
+        }
+        catch (AssertionException)
+        {
+          throw;
+        }
+        catch (NotAuthorizedException ex)
+        {
+          if (expect == ExpectedResult.NotAuthorizedException)
+          {
+            Util.Log("DoGets: got expected unauthorized exception: " +
+              ex.GetType() + "::" + ex.Message);
+            continue;
+          }
+          else
+          {
+            Assert.Fail("DoGets: unexpected unauthorized exception caught: " +
+              ex);
+          }
+        }
+        catch (AuthenticationFailedException ex)
+        {
+          if (expect == ExpectedResult.AuthFailedException)
+          {
+            Util.Log("DoPuts: got expected authentication Failed exception: " +
+              ex.GetType() + "::" + ex.Message);
+          }
+          else
+          {
+            Assert.Fail("DoPuts: unexpected exception caught: " + ex);
+          }
+        }
+        catch (Exception ex)
+        {
+          if (expect == ExpectedResult.OtherException)
+          {
+            Util.Log("DoGets: got expected exception: " +
+              ex.GetType() + "::" + ex.Message);
+            continue;
+          }
+          else
+          {
+            Assert.Fail("DoGets: unexpected exception caught: " + ex);
+          }
+        }
+        Assert.IsNotNull(value);
+        Assert.AreEqual(valPrefix + index, value.ToString());
+      }
+    }
+
+    public void DoLocalGets(int numOps)
+    {
+      DoLocalGets(numOps, false);
+    }
+
+    public void DoLocalGets(int numOps, bool useNewVal)
+    {
+      string valPrefix = (useNewVal ? NValuePrefix : ValuePrefix);
+      IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, 
object>(RegionName);
+      for (int index = 1; index <= numOps; ++index)
+      {
+        int sleepMillis = 100;
+        int numTries = 30;
+        string key = KeyPrefix + index;
+        string value = valPrefix + index;
+        while (numTries-- > 0)
+        {
+          if (region.ContainsValueForKey(key))
+          {
+            string foundValue = region[key].ToString();
+            if (value.Equals(foundValue))
+            {
+              break;
+            }
+          }
+          Thread.Sleep(sleepMillis);
+        }
+      }
+      for (int index = 1; index <= numOps; ++index)
+      {
+        string key = KeyPrefix + index;
+        Assert.IsTrue(region.ContainsValueForKey(key));
+        Object value = region[key];
+        Assert.IsNotNull(value);
+        Assert.AreEqual(valPrefix + index, value.ToString());
+      }
+    }
+
+    #endregion
+  }
+}

Reply via email to