@Test
public void testOutgoingExtensionExceptionCallback() throws Exception
{
defineClass(Latch.class);
evaluateScript("var latch = new Latch(1);");
Latch latch = (Latch)get("latch");
evaluateScript("var connectLatch = new Latch(1);");
Latch connectLatch = get("connectLatch");
evaluateScript("" +
"cometd.configure({url: '" + cometdURL + "', logLevel: '" + getLogLevel() + "'});" +
"cometd.addListener('/meta/connect', function(message) { connectLatch.countDown(); });" +
"cometd.registerExtension('testext', {" +
" outgoing: function(message) { throw 'test'; }" +
"});" +
"" +
"cometd.onExtensionException = function(exception, extensionName, outgoing, message) " +
"{" +
" if (exception === 'test' && extensionName === 'testext' && outgoing === true)" +
" {" +
" this.unregisterExtension(extensionName);" +
" latch.countDown();" +
" }" +
"};" +
"" +
"cometd.handshake();");
Assert.assertTrue(latch.await(5000));
Assert.assertTrue(connectLatch.await(5000));
evaluateScript("cometd.disconnect(true);");
}