@Test
  public void testValueConstraints() throws Exception {
    AttributesFactory factory = new AttributesFactory();
    factory.setValueConstraint(Portfolio.class);
    RegionAttributes regionAttributes = factory.create();
    Region portolioRegion = cache.createRegion("portfolios", regionAttributes);

    portolioRegion.put("key1", new Portfolio(1));
    try {
      portolioRegion.put("key2", new Data());
      fail("Expected ClassCastException after put as valueConstraint is set to Portfolio.class");
    } catch (ClassCastException ignored) {
    }

    Set address1 = new HashSet();
    Set address2 = new HashSet();
    address1.add(new Address("Hp3 9yf", "Apsley"));
    address1.add(new Address("Hp4 9yf", "Apsleyss"));
    address2.add(new Address("Hp3 8DZ", "Hemel"));
    address2.add(new Address("Hp4 8DZ", "Hemel"));

    // Note that Manager extends Employee

    Manager manager = new Manager("aaa", 27, 270, "QA", 1800, address1, 2701);
    Employee employee = new Employee("bbb", 28, 280, "QA", 1900, address2);

    factory.setValueConstraint(Manager.class);
    regionAttributes = factory.create();
    Region managerRegion = cache.createRegion("managers", regionAttributes);

    factory.setValueConstraint(Employee.class);
    regionAttributes = factory.create();
    Region employeeRegion = cache.createRegion("employees", regionAttributes);

    // This is perfectly valid, as Manager is Derived from Employee
    employeeRegion.put("key1", manager);

    try {
      managerRegion.put("key1", employee);
      fail("Expected ClassCastException after put as valueConstraint is set to Manager.class");
    } catch (ClassCastException ignored) {
    }
  }
Verifies that value constraint is used by Region.put

<p>
TRAC #32947: value constraint not enforced on Region.put or Region.create
geode-core/src/integrationTest/java/org/apache/geode/cache/ValueConstraintRegressionTest.java