Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
Poytr1 committed Jun 10, 2019
1 parent d386ef8 commit ef73e15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ public InitializeResult initialize(InitializeParams param) {

public static void cancelInitJobFromURI(String uri) {
IPath rootName = ResourceUtils.canonicalFilePathFromURI(uri);
Job[] jobs = Job.getJobManager().find(rootName);
Job[] jobs = Job.getJobManager().find(rootName);
for (Job job: jobs) {
JavaLanguageServerPlugin.logInfo("Cancel init job: " + job.toString());
JavaLanguageServerPlugin.logInfo("Cancel init job: " + job.toString());
job.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.elastic.jdt.ls.core.internal;

import static org.elastic.jdt.ls.core.internal.ElasticJavaLanguageServerPlugin.logInfo;

import org.junit.Assert;
import org.junit.Test;

Expand All @@ -23,15 +21,13 @@ public void testCancelInitJob() throws Exception {
String rootURI = file.toURI().toString();
params.setRootUri(rootURI);
handler.initialize(params);
Job[] initJobs = Job.getJobManager().find(ExtendedInitHandler.JAVA_LS_INITIALIZATION_JOBS);
Assert.assertSame(1, initJobs.length);
Job initJob = initJobs[0];
Assert.assertSame(Job.RUNNING, initJob.getState());
Job[] initJobs = Job.getJobManager().find(ExtendedInitHandler.JAVA_LS_INITIALIZATION_JOBS);
Assert.assertSame(1, initJobs.length);
Job initJob = initJobs[0];
Assert.assertSame(Job.RUNNING, initJob.getState());
ExtendedInitHandler.cancelInitJobFromURI(rootURI);
// Wait for cancelling for initialize job
// Wait for cancelling for initialize job
TimeUnit.MILLISECONDS.sleep(100);
logInfo(initJobs[1].toString());
logInfo("state: "+initJobs[1].getState());
Assert.assertSame(Job.NONE, initJob.getState());
}

Expand Down

0 comments on commit ef73e15

Please sign in to comment.