/*
* 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 6957378
* @summary Test that a listener can be removed remotely from an MBean that no longer exists.
* @author Eamonn McManus
*/
public class DeadListenerTest {
getServerNotifFwdM.setAccessible(true);
ServerNotifForwarder serverNotifForwarder = (ServerNotifForwarder) getServerNotifFwdM.invoke(connection);
listenerMapF.setAccessible(true);
@SuppressWarnings("unchecked")
Map<ObjectName, Set<?>> listenerMap = (Map<ObjectName, Set<?>>) listenerMapF.get(serverNotifForwarder);
assertTrue("Server listenerMap initially empty", mapWithoutKey(listenerMap, delegateName).isEmpty());
assertTrue("One entry in listenerMap for two listeners on same MBean", mapWithoutKey(listenerMap, delegateName).size() == 1);
// Make sure notifs are working normally.
}
// Make sure that removing a nonexistent listener from an existent MBean produces ListenerNotFoundException
try {
assertTrue("Remove of nonexistent listener succeeded but should not have", false);
} catch (ListenerNotFoundException e) {
// OK: expected
}
// Make sure that removing a nonexistent listener from a nonexistent MBean produces ListenerNotFoundException
try {
assertTrue("Remove of listener from nonexistent MBean succeeded but should not have", false);
} catch (ListenerNotFoundException e) {
// OK: expected
}
// Now unregister our MBean, and check that notifs it sends no longer go anywhere.
// wait for the listener cleanup to take place upon processing notifications
while (countdown-- > 0 &&
}
// listener has been removed or the wait has timed out
// Check that there is no trace of the listeners any more in ServerNotifForwarder.listenerMap.
// THIS DEPENDS ON JMX IMPLEMENTATION DETAILS.
// If the JMX implementation changes, the code here may have to change too.
}
return copy;
}
public static interface NoddyMBean {}
count = i;
}
public CountListener() {
this.count = new AtomicInteger();
}
int count() {
}
}
}
if (!cond) {
}
}
}
return conn;
}
}
}