use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.
the class ClientServerMiscDUnitTest method verifyInvalidatesOnBothRegions.
public static void verifyInvalidatesOnBothRegions() {
try {
Cache cache = new ClientServerMiscDUnitTest().getCache();
final Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
final Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r1);
assertNotNull(r2);
WaitCriterion wc = new WaitCriterion() {
String excuse;
public boolean done() {
Object val = r1.getEntry(k1).getValue();
return val == null;
}
public String description() {
return excuse;
}
};
Wait.waitForCriterion(wc, 90 * 1000, 1000, true);
// assertNull(r1.getEntry(k1).getValue());
wc = new WaitCriterion() {
String excuse;
public boolean done() {
Object val = r1.getEntry(k1).getValue();
return val == null;
}
public String description() {
return excuse;
}
};
Wait.waitForCriterion(wc, 90 * 1000, 1000, true);
// assertNull(r1.getEntry(k2).getValue());
wc = new WaitCriterion() {
String excuse;
public boolean done() {
Object val = r1.getEntry(k2).getValue();
return val == null;
}
public String description() {
return excuse;
}
};
Wait.waitForCriterion(wc, 90 * 1000, 1000, true);
// assertNull(r2.getEntry(k1).getValue());
wc = new WaitCriterion() {
String excuse;
public boolean done() {
Object val = r2.getEntry(k1).getValue();
return val == null;
}
public String description() {
return excuse;
}
};
Wait.waitForCriterion(wc, 90 * 1000, 1000, true);
// assertNull(r2.getEntry(k2).getValue());
wc = new WaitCriterion() {
String excuse;
public boolean done() {
Object val = r2.getEntry(k2).getValue();
return val == null;
}
public String description() {
return excuse;
}
};
Wait.waitForCriterion(wc, 90 * 1000, 1000, true);
} catch (Exception ex) {
Assert.fail("failed while verifyInvalidatesOnBothRegions()", ex);
}
}
use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.
the class ClientServerMiscDUnitTest method _createClientCache.
public static Pool _createClientCache(String h, boolean empty, int... ports) throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
Cache cache = new ClientServerMiscDUnitTest().createCacheV(props);
ClientServerMiscDUnitTest.static_cache = cache;
PoolFactory poolFactory = PoolManager.createFactory();
PoolImpl p = (PoolImpl) addServers(poolFactory, h, ports).setSubscriptionEnabled(true).setThreadLocalConnections(true).setReadTimeout(1000).setSocketBufferSize(32768).setMinConnections(3).setSubscriptionRedundancy(-1).setPingInterval(2000).create("ClientServerMiscDUnitTestPool");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
if (empty) {
factory.setDataPolicy(DataPolicy.EMPTY);
}
factory.setPoolName(p.getName());
attrs = factory.create();
Region region1 = cache.createRegion(REGION_NAME1, attrs);
Region region2 = cache.createRegion(REGION_NAME2, attrs);
Region prRegion = cache.createRegion(PR_REGION_NAME, attrs);
assertNotNull(region1);
assertNotNull(region2);
assertNotNull(prRegion);
pool = p;
// conn = pool.acquireConnection();
// assertNotNull(conn);
// TODO does this WaitCriterion actually help?
WaitCriterion wc = new WaitCriterion() {
String excuse;
public boolean done() {
try {
conn = pool.acquireConnection();
if (conn == null) {
excuse = "acquireConnection returned null?";
return false;
}
return true;
} catch (NoAvailableServersException e) {
excuse = "Cannot find a server: " + e;
return false;
}
}
public String description() {
return excuse;
}
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
return p;
}
use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.
the class ConflationDUnitTest method assertCounterSizes.
/**
* assert the counters size are as expected (2)
*
*/
public static void assertCounterSizes() {
WaitCriterion ev = new WaitCriterion() {
public boolean done() {
// TODO is this necessary?
Thread.yield();
return counterCreate == 2;
}
public String description() {
return null;
}
};
Wait.waitForCriterion(ev, 60 * 1000, 200, true);
ev = new WaitCriterion() {
public boolean done() {
// TODO is this necessary?
Thread.yield();
return counterUpdate == 2;
}
public String description() {
return null;
}
};
Wait.waitForCriterion(ev, 60 * 1000, 200, true);
ev = new WaitCriterion() {
public boolean done() {
// TODO is this necessary?
Thread.yield();
return counterDestroy == 2;
}
public String description() {
return null;
}
};
Wait.waitForCriterion(ev, 60 * 1000, 200, true);
}
use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.
the class ConnectionProxyJUnitTest method verifyAckSend.
private void verifyAckSend(long timeToWait, final boolean expectedAckSend) {
WaitCriterion wc = new WaitCriterion() {
public boolean done() {
return expectedAckSend == seo.getAckSend();
}
public String description() {
return "ack flag never became " + expectedAckSend;
}
};
Wait.waitForCriterion(wc, timeToWait, 1000, true);
}
use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.
the class ConnectionProxyJUnitTest method verifyExpiry.
private void verifyExpiry(long timeToWait) {
WaitCriterion wc = new WaitCriterion() {
public boolean done() {
return 0 == proxy.getThreadIdToSequenceIdMap().size();
}
public String description() {
return "Entry never expired";
}
};
Wait.waitForCriterion(wc, timeToWait * 2, 200, true);
}
Aggregations