public virtual void RegionNullKeyOperations()

in clicache/integration-test/DistOpsStepsN.cs [1231:1356]


    public virtual void RegionNullKeyOperations(IRegion<object, object> region, bool isRemoteInstance)
    {
      // chk for IllegalArgumentException.
      object value = 0;
      object NullKey = null;
      try
      {
        region.TryGetValue(NullKey, out value); //null
        Assert.Fail("Should have got IllegalArgumentException for null key arguement.");
      }
      catch (IllegalArgumentException ex)
      {
        Util.Log("Got expected IllegalArgumentException for null key arguement. {0} ", ex);
      }
      Util.Log("RegionNullKeyOperations TryGetValue Step complete.");

      // Try adding using Add, an entry in region with key as null, should get IllegalArgumentException.
      try
      {
        region.Add(NullKey, value); // null
        Assert.Fail("Should have got IllegalArgumentException.");
      }
      catch (IllegalArgumentException ex)
      {
        Util.Log("Got expected IllegalArgumentException {0}", ex);
      }

      try
      {
        region.Add(new KeyValuePair<object, object>(NullKey, value));//null
        Assert.Fail("Should have got IllegalArgumentException.");
      }
      catch (IllegalArgumentException ex)
      {
        Util.Log("Got expected IllegalArgumentException {0}", ex);
      }
      Util.Log("RegionNullKeyOperations Add Step complete.");

      // Try putting using Item_Set, an entry in region with key as null, should get IllegalArgumentException.
      try
      {
        region[NullKey] = value; //null key
        Assert.Fail("Should have got IllegalArgumentException");
      }
      catch (IllegalArgumentException)
      {
        Util.Log("Got expected IllegalArgumentException ");
      }
      Util.Log("RegionNullKeyOperations Item_Set Step complete.");

      // Try putting using Item_Set, an entry in region with key as null, should get IllegalArgumentException.
      try
      {
        Object val = region[NullKey];//null
        Assert.Fail("Should have got IllegalArgumentException");
      }
      catch (IllegalArgumentException)
      {
        Util.Log("Got expected IllegalArgumentException ");
      }
      Util.Log("RegionNullKeyOperations Item_Get Step complete.");

      // Try contains with null key, i should throw exception.
      try
      {
        region.Contains(new KeyValuePair<object, object>(NullKey, value));//null key
        Assert.Fail("Should have got IllegalArgumentException");

      }
      catch (IllegalArgumentException ex)
      {
        Util.Log("Got expected IllegalArgumentException {0} ", ex);
      }
      Util.Log("RegionNullKeyOperations Contains Step complete.");
      // Try removing entry with null key, should throw IllegalArgumentException.
      try
      {
        region.Remove(NullKey);//null
        Assert.Fail("Should have got IllegalArgumentException.");
      }
      catch (IllegalArgumentException ex)
      {
        Util.Log("Got expected IllegalArgumentException {0} ", ex);
      }

      Util.Log("RegionNullKeyOperations Remove Step complete.");

      try
      {
        Object val = region[1];
        Assert.Fail("Should have got KeyNotFoundException");
      }
      catch (Apache.Geode.Client.KeyNotFoundException ex)
      {
        Util.Log("Got expected KeyNotFoundException {0} ", ex);
      }
      region[1] = 1;

      //Invalidate an entry and then do a get on to it, should throw EntryNotFoundException.
      region.Invalidate(1);
      try
      {
        Object val = region[1];
        if (!isRemoteInstance)
        {
          Assert.Fail("Should have got KeyNotFoundException");
        }
      }
      catch (Apache.Geode.Client.KeyNotFoundException ex)
      {
        Util.Log("Got expected KeyNotFoundException {0} ", ex);
      }
      region.Remove(1);

      //Remove an entry and then do a get on to it, should throw KeyNotFoundException.
      try
      {
        Object val = region[1];
        Assert.Fail("Should have got KeyNotFoundException");
      }
      catch (Apache.Geode.Client.KeyNotFoundException ex)
      {
        Util.Log("Got expected KeyNotFoundException {0} ", ex);
      }

    }