<commit_before>package org.cometd.javascript.jquery.extension;

import java.net.URL;

import org.cometd.Bayeux;
import org.cometd.javascript.jquery.AbstractCometdJQueryTest;
import org.cometd.server.ext.TimesyncExtension;
import org.testng.annotations.Test;

/**
 * @version $Revision$ $Date$
 */
public class CometdTimeSyncExtensionTest extends AbstractCometdJQueryTest
{
    protected void customizeBayeux(Bayeux bayeux)
    {
        bayeux.addExtension(new TimesyncExtension());
    }

    @Test
    public void testTimeSync() throws Exception
    {
        URL timesyncExtensionURL = new URL(contextURL + "/org/cometd/TimeSyncExtension.js");
        evaluateURL(timesyncExtensionURL);

        evaluateScript("$.cometd.configure({url: '" + cometURL + "', logLevel: 'debug'});");
        evaluateScript("$.cometd.registerExtension('timesync', new org.cometd.TimeSyncExtension());");

        evaluateScript("var inTimeSync = undefined;");
        evaluateScript("var outTimeSync = undefined;");
        evaluateScript("$.cometd.registerExtension('test', {" +
                "incoming: function(message)" +
                "{" +
                "    var channel = message.channel;" +
                "    if (channel && channel.indexOf('/meta/') == 0)" +
                "    {" +
                "        inTimeSync = message.ext && message.ext.timesync;" +
                "    }" +
                "   return message;" +
                "}," +
                "outgoing: function(message)" +
                "{" +
                "    var channel = message.channel;" +
                "    if (channel && channel.indexOf('/meta/') == 0)" +
                "    {" +<commit_msg>Using jquery binding for timesync extension.<commit_after>package org.cometd.javascript.jquery.extension;

import java.net.URL;

import org.cometd.Bayeux;
import org.cometd.javascript.jquery.AbstractCometdJQueryTest;
import org.cometd.server.ext.TimesyncExtension;
import org.testng.annotations.Test;

/**
 * @version $Revision$ $Date$
 */
public class CometdTimeSyncExtensionTest extends AbstractCometdJQueryTest
{
    protected void customizeBayeux(Bayeux bayeux)
    {
        bayeux.addExtension(new TimesyncExtension());
    }

    @Test
    public void testTimeSync() throws Exception
    {
        URL timesyncExtensionURL = new URL(contextURL + "/org/cometd/TimeSyncExtension.js");
        evaluateURL(timesyncExtensionURL);
        URL jqueryTimesyncExtensionURL = new URL(contextURL + "/jquery/jquery.cometd-timesync.js");
        evaluateURL(jqueryTimesyncExtensionURL);

        evaluateScript("$.cometd.configure({url: '" + cometURL + "', logLevel: 'debug'});");

        evaluateScript("var inTimeSync = undefined;");
        evaluateScript("var outTimeSync = undefined;");
        evaluateScript("$.cometd.registerExtension('test', {" +
                "incoming: function(message)" +
                "{" +
                "    var channel = message.channel;" +
                "    if (channel && channel.indexOf('/meta/') == 0)" +
                "    {" +
                "        inTimeSync = message.ext && message.ext.timesync;" +
                "    }" +
                "   return message;" +
                "}," +
                "outgoing: function(message)" +
                "{" +
                "    var channel = message.channel;" +
                "    if (channel && channel.indexOf('/meta/') == 0)" +
                "    {" +
{'fraction_non_alphanumeric': 0.13352685050798258, 'fraction_numerical': 0.0011611030478955006, 'mean_word_length': 2.2296157450796628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5665747', 'n_tokens_mistral': 989, 'n_tokens_neox': 938, 'n_words': 158}