Search in sources :

Example 1 with WatchDog

use of jetbrains.communicator.util.WatchDog in project intellij-plugins by JetBrains.

the class LocalMessageDispatcherTest method testPerformance.

public void testPerformance() throws Exception {
    Logger logger = Logger.getLogger("jetbrains.communicator");
    Level oldLevel = logger.getLevel();
    try {
        logger.setLevel(Level.WARN);
        for (int i = 0; i < 1000; i++) {
            Date date = new Date(System.currentTimeMillis() + i * 1000L * 3600L);
            myDispatcher.sendNow(myUser, new MockMessage(date));
        }
        Thread.sleep(SAVE_WAIT_TIMEOUT * 2);
        WatchDog watchDog = new WatchDog("Load history");
        LocalMessageDispatcherImpl localMessageDispatcher = createLocalMessageDispatcher();
        LocalMessage[] messages = localMessageDispatcher.getHistory(myUser, yesterday());
        assertEquals(1000, messages.length);
        long diff = watchDog.diff();
        watchDog.watchAndReset("done");
        assertTrue("Too long getting history:" + diff, diff < 1500);
        messages = localMessageDispatcher.getHistory(myUser, null);
        assertEquals(1000, messages.length);
        diff = watchDog.diff();
        watchDog.watchAndReset("again done");
        assertTrue("Too long getting history second time:" + diff, diff < 100);
    } finally {
        logger.setLevel(oldLevel);
    }
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) WatchDog(jetbrains.communicator.util.WatchDog) MockMessage(jetbrains.communicator.mock.MockMessage) Level(org.apache.log4j.Level) Logger(org.apache.log4j.Logger) Date(java.util.Date)

Example 2 with WatchDog

use of jetbrains.communicator.util.WatchDog in project intellij-plugins by JetBrains.

the class AbstractTransportTestCase method testGetFileContent_BigFile.

public void testGetFileContent_BigFile() throws Exception {
    VFile vFile = VFile.create("a path");
    myUserModel.addUser(mySelf);
    mySelf.setCanAccessMyFiles(true, myUserModel);
    char[] buf = new char[100000];
    Arrays.fill(buf, 'd');
    myIdeFacade.setReturnedFileText(vFile, new String(buf));
    WatchDog s = new WatchDog("get 100000 bytes file");
    mySelf.getVFile(vFile, myIdeFacade);
    s.stop();
    assertEquals("Should successfully return file text", new String(buf), vFile.getContents());
}
Also used : WatchDog(jetbrains.communicator.util.WatchDog) VFile(jetbrains.communicator.core.vfs.VFile)

Aggregations

WatchDog (jetbrains.communicator.util.WatchDog)2 Date (java.util.Date)1 LocalMessage (jetbrains.communicator.core.dispatcher.LocalMessage)1 VFile (jetbrains.communicator.core.vfs.VFile)1 MockMessage (jetbrains.communicator.mock.MockMessage)1 Level (org.apache.log4j.Level)1 Logger (org.apache.log4j.Logger)1