From eeddb9d07aa1167338aea368bd1162d293c1980d Mon Sep 17 00:00:00 2001 From: Amiram Wingarten Date: Sun, 10 Dec 2017 12:05:10 +0200 Subject: [PATCH] update tests dependencies and stabilize tests --- .../com/sap/lsp/cf/ws/WSSynchronization.java | 6 +++--- src/test/javascript/package.json | 10 +++++----- .../test/SyncIntegrationFullTest.js | 4 ++-- src/test/javascript/test/SyncNoWebsocket.js | 20 ++++++++++--------- src/test/javascript/test/util/Util.js | 12 +++++------ 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/sap/lsp/cf/ws/WSSynchronization.java b/src/main/java/com/sap/lsp/cf/ws/WSSynchronization.java index 479f59e..84a04bf 100644 --- a/src/main/java/com/sap/lsp/cf/ws/WSSynchronization.java +++ b/src/main/java/com/sap/lsp/cf/ws/WSSynchronization.java @@ -281,7 +281,7 @@ private void syncWorkspace(InputStream workspaceZipStream, File destination) thr // Create sync label file long timestamp = System.currentTimeMillis(); File syncFile = new File(destination, SYNC_FILE); - new FileOutputStream(syncFile).close(); + syncFile.createNewFile(); syncFile.setLastModified(timestamp); } @@ -383,8 +383,8 @@ private void handleLSPDest(boolean bReg, BufferedReader reader) { private boolean checkSync() { String workspaceSaveDir = this.saveDir; - File fSyncts = new File(new File(workspaceSaveDir),SYNC_FILE); - return fSyncts.exists(); + File fSync = new File(new File(workspaceSaveDir), SYNC_FILE); + return fSync.exists(); } diff --git a/src/test/javascript/package.json b/src/test/javascript/package.json index aaf1f5f..da69d13 100644 --- a/src/test/javascript/package.json +++ b/src/test/javascript/package.json @@ -3,14 +3,14 @@ "test": "mocha --timeout 20000" }, "devDependencies": { - "chai": "4.1.1", - "mocha": "3.5.0", + "chai": "4.1.2", + "mocha": "4.0.1", "promise": "8.0.1", "sleep": "5.1.1", "promise-timeout": "1.1.1", - "request": "2.81.0", - "request-promise": "4.2.1", - "ws": "3.1.0" + "request": "2.83.0", + "request-promise": "4.2.2", + "ws": "3.3.2" }, "dependencies": { "assert": "1.4.1" diff --git a/src/test/javascript/test/SyncIntegrationFullTest.js b/src/test/javascript/test/SyncIntegrationFullTest.js index fc2e776..b30a5c1 100644 --- a/src/test/javascript/test/SyncIntegrationFullTest.js +++ b/src/test/javascript/test/SyncIntegrationFullTest.js @@ -154,8 +154,8 @@ describe('Sync Integration Full loop Test', function () { new Promise(function (resolve, reject) { aSubscribers.push({ method: "workspace/didChangeWatchedFiles", callback: function (oLspMsg) { - console.log("Test response delete single file - loopback received:\n" + JSON.stringify(oLspMsg)); - expect(oLspMsg, "Delete notification faillure").to.deep.equal(delete1Resp); + console.log("Test response delete single file - loop back received:\n" + JSON.stringify(oLspMsg)); + expect(oLspMsg, "Delete notification failure").to.deep.equal(delete1Resp); resolve(); } }) diff --git a/src/test/javascript/test/SyncNoWebsocket.js b/src/test/javascript/test/SyncNoWebsocket.js index f959fb3..c1fb008 100644 --- a/src/test/javascript/test/SyncNoWebsocket.js +++ b/src/test/javascript/test/SyncNoWebsocket.js @@ -73,16 +73,18 @@ describe('Sync Integration Test - no websocket', function () { form.append('file', fs.createReadStream(zipFilePath)); }).then(function () { // putting file that already exists should fail - return new Promise(function (resolve) { - let req = request.put(pathPrefix + modulePath + '/java/test.java', COMMON_OPTIONS, function (err, res) { - console.log("error: " + err); - console.log("res: " + res); - assert.ok(res); - assert.equal(res.statusCode, 403); - resolve(res); + setTimeout(function () { + return new Promise(function (resolve) { + let req = request.put(pathPrefix + modulePath + '/java/test.java', COMMON_OPTIONS, function (err, res) { + console.log("error: " + err); + console.log("res: " + res); + assert.ok(res); + assert.equal(res.statusCode, 403); + resolve(res); + }); + req.form().append('file', fs.createReadStream(zipFilePath)); }); - req.form().append('file', fs.createReadStream(zipFilePath)); - }); + }, 10); }).then(deletePath.bind(undefined, '/java/test.java', filePath)); }); diff --git a/src/test/javascript/test/util/Util.js b/src/test/javascript/test/util/Util.js index a380168..0cf0ecf 100644 --- a/src/test/javascript/test/util/Util.js +++ b/src/test/javascript/test/util/Util.js @@ -2,13 +2,13 @@ const fs = require('fs'); module.exports = { - deleteFolderRecursive: function (path) { - var that = this; + deleteFolderRecursive: function (path) { + let that = this; if (fs.existsSync(path)) { - fs.readdirSync(path).forEach(function(file,index){ - var curPath = path + "/" + file; + fs.readdirSync(path).forEach(function (file, index) { + let curPath = path + "/" + file; if (fs.lstatSync(curPath).isDirectory()) { // recurse - that.deleteFolderRecursive(curPath); + that.deleteFolderRecursive(curPath); } else { // delete file fs.unlinkSync(curPath); } @@ -17,4 +17,4 @@ module.exports = { } } -} \ No newline at end of file +}; \ No newline at end of file