// id
final String ids[] = new String[]{"1-2", "watch", "aBcde"};
for (String id : ids) {
//WatchDataSource wds = new WatchDataSourceImpl(
// id, null, EmptyConfiguration.INSTANCE).export();
WatchDataSource wds = new WatchDataSourceImpl();
wds.setConfiguration(EmptyConfiguration.INSTANCE);
wds.initialize();
//wds.setID(id);
//wds.initialize();
Watch watch = construct4(wds, id);
Assert.assertEquals(id, watch.getId());
testInstance(watch);
Utils.close(watch.getWatchDataSource());
}
// Illegal id
try {
String id = null;
WatchDataSourceImpl wdsi = new WatchDataSourceImpl();
wdsi.setID("");
wdsi.setConfiguration(EmptyConfiguration.INSTANCE);
WatchDataSource wds = wdsi.export();
construct4(wds, id);
Assert.fail("IllegalArgumentException expected but not thrown");
} catch (IllegalArgumentException e) {
}
try {
String id = "";
construct1(id);
Assert.fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
}
// watchDataSource
final int collectionSizes[] = new int[]{1, 1000, 5000};
for (int collectionSize : collectionSizes) {
DynamicConfiguration config = new DynamicConfiguration();
config.setEntry("org.rioproject.watch", "collectionSize",
collectionSize);
//WatchDataSource wds = new WatchDataSourceImpl("", null,
// config).export();
WatchDataSource wds = new WatchDataSourceImpl();
wds.setConfiguration(config);
Watch watch = construct4(wds, "watch");
Assert.assertSame(wds, watch.getWatchDataSource());
checkInstance(watch, collectionSize, false);
Utils.close(watch.getWatchDataSource());