@Test public void bindByPool() throws EntitlementRefusedException { String poolid = "pool10"; Pool pool = mock(Pool.class); Entitlement ent = mock(Entitlement.class); List<Entitlement> eList = new ArrayList<Entitlement>(); eList.add(ent); when(pm.find(eq(poolid))).thenReturn(pool); Map<String, Integer> pQs = new HashMap<String, Integer>(); pQs.put(poolid, 1); when(pm.entitleByPools(eq(consumer), eq(pQs))).thenReturn(eList); List<Entitlement> ents = entitler.bindByPoolQuantity(consumer, poolid, 1); assertNotNull(ents); assertEquals(ent, ents.get(0)); }
public static void acquireConnectionsAndDestroyEntriesK1andK2() { try { Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME); assertNotNull(r1); String poolName = r1.getAttributes().getPoolName(); assertNotNull(poolName); PoolImpl pool = (PoolImpl) PoolManager.find(poolName); assertNotNull(pool); Connection conn = pool.acquireConnection(); final Connection conn1; if (conn.getServer().getPort() != PORT2) { conn1 = pool.acquireConnection(); // Ensure we have a server with the proper port } else { conn1 = conn; } assertNotNull(conn1); assertEquals(PORT2, conn1.getServer().getPort()); ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool); srp.destroyOnForTestsOnly( conn1, "key1", null, Operation.DESTROY, new EntryEventImpl(new EventID(new byte[] {1}, 100000, 1)), null); srp.destroyOnForTestsOnly( conn1, "key2", null, Operation.DESTROY, new EntryEventImpl(new EventID(new byte[] {1}, 100000, 2)), null); } catch (Exception ex) { throw new TestException("Failed while setting acquireConnectionsAndDestroyEntry ", ex); } }