@Test public void create() { User bartSimpson = newUser("bartSimpson"); usersTemplate.create(getKey(bartSimpson), bartSimpson); assertThat(users.containsKey(getKey(bartSimpson))).isTrue(); assertThat(users.containsValueForKey(getKey(bartSimpson))).isTrue(); assertThat(users.containsValue(bartSimpson)).isTrue(); assertThat(users.get(getKey(bartSimpson))).isEqualTo(bartSimpson); }
/** * Check that containsValueForKey() called on the tests' region has the expected result. Throw an * error if any problems. * * @param key The key to check. * @param expected The expected result of containsValueForKey * @param logStr Used if throwing an error due to an unexpected value. */ protected void checkContainsValueForKey(Object key, boolean expected, String logStr) { boolean containsValue = aRegion.containsValueForKey(key); if (containsValue != expected) throw new TestException( "Expected containsValueForKey(" + key + ") to be " + expected + ", but it was " + containsValue + ": " + logStr); }
/** Called for debugging */ public void printKeyRange(Region aRegion) { int lower = ((Integer) (lowerKeyRange.get())).intValue(); int upper = ((Integer) (upperKeyRange.get())).intValue(); StringBuffer aStr = new StringBuffer(); for (int i = lower; i <= upper; i++) { Object key = NameFactory.getObjectNameForCounter(i); aStr.append( "key " + key + " containsKey: " + aRegion.containsKey(key) + ", containsValueForKey: " + aRegion.containsValueForKey(key) + ", getValueInVM: " + diskReg.DiskRegUtil.getValueInVM(aRegion, key) + "\n"); } Log.getLogWriter().info(aStr.toString()); }