Runtime rt = Runtime.getRuntime();
rt.gc();
long memAvailable = rt.maxMemory() - (rt.totalMemory() - rt.freeMemory());
FileSizeLimitInfo limit = new FileSizeLimitInfo();
// With these limits, the largest possible feed will be about 7/12 of
// available memory - there should not be room for a second one.
limit.setMaxDocumentSize(memAvailable/4);
limit.setMaxFeedSize(memAvailable/3);
DocPusher dpusher =
new DocPusher(feedConnection, dataSource, limit, dfc);
Map<String, Object> config = getTestDocumentConfig();
config.put(SpiConstants.PROPNAME_CONTENT,
new HugeInputStream(limit.maxDocumentSize() - 10));
Document bigDocument = ConnectorTestUtils.createSimpleDocument(config);
assertEquals(PusherStatus.LOW_MEMORY, dpusher.take(bigDocument, null));
dpusher.flush();
assertFalse(feedConnection.isBacklogged());
}