/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 6907760 6929532
* @summary Tests WatchService behavior when lots of events are pending
* @library ..
*/
public class LotsOfEvents {
try {
} finally {
}
}
/**
* Tests that OVERFLOW events are not retreived with other events.
*/
throws IOException, InterruptedException
{
// create a lot of files
int n = 1024;
for (int i=0; i<n; i++) {
}
// give time for events to accumulate (improve chance of overflow)
// check that we see the create events (or overflow)
// delete the files
for (int i=0; i<n; i++) {
}
// give time for events to accumulate (improve chance of overflow)
// check that we see the delete events (or overflow)
}
}
int count)
throws IOException, InterruptedException
{
// wait for key to be signalled - the timeout is long to allow for
// polling implementations
throw new RuntimeException("Key was signalled (unexpected)");
throw new RuntimeException("Key not signalled (unexpected)");
int nread = 0;
boolean gotOverflow = false;
if (kind == expectedKind) {
// expected event kind
throw new RuntimeException("More events than expected!!");
// overflow event should not be retrieved with other events
throw new RuntimeException("Overflow retrieved with other events");
gotOverflow = true;
} else {
}
}
throw new RuntimeException("Key is no longer valid");
}
// check that all expected events were received or there was an overflow
throw new RuntimeException("Insufficient events");
}
/**
* Tests that check that ENTRY_MODIFY events are queued efficiently
*/
throws IOException, InterruptedException
{
// this test uses a random number of files
for (int i=0; i<nfiles; i++) {
// "some" of the files exist, some do not.
entries[i].deleteIfExists();
if (rand.nextBoolean())
}
// do several rounds of noise and test
// make some noise!!!
for (int i=0; i<100; i++) {
switch (action) {
default: entry.modifyIfExists();
}
}
// process events and ensure that we don't get repeated modify
// events for the same file.
if (kind == ENTRY_MODIFY) {
if (!added) {
throw new RuntimeException(
"ENTRY_MODIFY events not queued efficiently");
}
} else {
}
}
throw new RuntimeException("Key is no longer valid");
}
}
}
}
static class DirectoryEntry {
}
}
}
}
}
}
}
}