/*
* 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 7654321
* @summary Tests the NotificationBuffer class.
* @author Eamonn McManus
* @run clean NotificationBufferTest
* @run build NotificationBufferTest NotificationSender NotificationSenderMBean
* @run main NotificationBufferTest
*/
public class NotificationBufferTest {
// System.setProperty("java.util.logging.config.file",
// "../../../../logging.properties");
try {
// java.util.logging.LogManager.getLogManager().readConfiguration();
if (ok) {
return;
} else {
}
} catch (Exception e) {
e.printStackTrace();
}
}
final NotificationBuffer nb =
// Get initial sequence number
if (nnotifs > 0) {
"got " + nnotifs);
return false;
}
return false;
}
NotificationSenderMBean.class,
false);
/* We test here that MBeans already present when the
NotificationBuffer was created get a listener for the
buffer, as do MBeans created later. The
MBeanServerDelegate was already present, while the
NotificationSender was created later. */
// Check that the NotificationSender does indeed have a listener
/* Note we are dependent on the specifics of our JMX
implementation here. There is no guarantee that the MBean
creation listeners will have run to completion when
creation of the MBean returns. */
if (nlisteners != 1) {
"has " + nlisteners);
return false;
}
// Now we should see two creation notifications
return false;
}
{
return false;
}
return false;
}
// If we ask for max 1 notifs, we should only get one
return false;
}
// Now we should get the other one
0L, 1);
return false;
}
return false;
}
// Now we should get none (timeout is 0)
return false;
}
return false;
}
// Check that timeouts work
return false;
}
if (elapsed < 250L) {
elapsed);
return false;
}
// Check that notification filtering works
public boolean isNotificationEnabled(Notification n) {
if (!(n instanceof MBeanServerNotification))
return false;
}
};
return false;
}
return false;
}
// Now send 8 notifs to fill up our 10-element buffer
return false;
}
// Check that the 10 notifs are the ones we expected
for (int i = 0; i < 10; i++) {
return false;
}
}
// Check that ObjectName filtering works
return false;
}
// Send one more notif, which should cause the oldest one to drop
+ earliest);
return false;
}
// Check that the 10 notifs are the ones we expected
for (int i = 0; i < 10; i++) {
(i < 1) ? notifType
: (i < 9) ? "tiddly.pom" : "foo.bar";
return false;
}
}
// Apply a filter that only selects the first notif, with max notifs 1,
// then check that it skipped past the others even though it already
// had its 1 notif
return false;
}
0L, 1000);
return false;
}
// Create a second, larger buffer, which should share the same notifs
return false;
// Check that the capacity is now 20
if (nr.getEarliestSequenceNumber() !=
"that should have fit");
return false;
}
"that should have fit");
return false;
}
// Drop the second buffer and check that the capacity shrinks
return false;
}
return false;
}
return false;
}
// Final test: check that destroying the final shared buffer
// removes its listeners
if (nlisteners != 0) {
"but notification sender has " + nlisteners);
return false;
}
return true;
}
TargetedNotification[] tn2) {
return false;
}
return false;
}
return true;
}
final ObjectName pattern,
final NotificationFilter filter) {
return new NotificationBufferFilter() {
}
}
};
};
}