Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Fixes basic daemon test, closes #185
Browse files Browse the repository at this point in the history
  • Loading branch information
binwiederhier committed Sep 2, 2014
1 parent bc9c641 commit 8d5dc84
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
Expand Up @@ -130,7 +130,7 @@ public void run() {
logger.log(Level.SEVERE, "ERROR while running watch at " + config.getLocalDir(), e);
}
}
}, "WatchOpT/" + config.getLocalDir().getName());
}, "WR/" + config.getLocalDir().getName());

watchThread.start();
}
Expand Down
Expand Up @@ -17,9 +17,7 @@
*/
package org.syncany.tests.daemon;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -196,21 +194,35 @@ public void testWatchServer() throws Exception {

// Create big file to trigger sync
clientA.createNewFile("bigfileforlongsync", 5000);
// Wait to allow sync to start
Thread.sleep(100);

eventBus.post(cliRequest);

response = waitForResponse(30);

// ^^ Now sync should start and we send 'status' requests
CliResponse cliResponse = null;
boolean syncRunningMessageReceived = false;

assertTrue(response instanceof CliResponse);
CliResponse cliResponse = (CliResponse) response;
for (i = 30; i < 50; i++) {
cliRequest.setId(i);
eventBus.post(cliRequest);

response = waitForResponse(i);

assertTrue(response instanceof CliResponse);
cliResponse = (CliResponse) response;

System.out.println(cliResponse.getOutput());

if ("Cannot run CLI commands while sync is running or requested.\n".equals(cliResponse.getOutput())) {
syncRunningMessageReceived = true;
break;
}

Thread.sleep(200);
}

assertEquals("Cannot run CLI commands while sync is running or requested.\n", cliResponse.getOutput());
assertTrue(syncRunningMessageReceived);

// Allow daemon to sync
Thread.sleep(10000);
for (i = 31; i < 50; i++) {
for (i = 50; i < 60; i++) {
cliRequest.setId(i);
eventBus.post(cliRequest);

Expand All @@ -224,6 +236,7 @@ public void testWatchServer() throws Exception {
Thread.sleep(1000);
}

assertNotNull(cliResponse);
assertEquals("No local changes.\n", cliResponse.getOutput());

// Restore file test
Expand Down
Expand Up @@ -235,7 +235,6 @@ private void runSync() throws Exception {
syncRequested.set(false);

logger.log(Level.INFO, "RUNNING SYNC ...");


try {
boolean notifyChanges = false;
Expand Down

0 comments on commit 8d5dc84

Please sign in to comment.