diff --git a/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java b/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java index 3363f62a6..1887b68e8 100644 --- a/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java +++ b/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshEditorTest.java @@ -57,7 +57,7 @@ import com.google.common.collect.ImmutableSet; @BoshLanguageServerTest public class BoshEditorTest { - @Autowired LanguageServerHarness harness; + @Autowired LanguageServerHarness harness; @Autowired BoshLanguageServerInitializer serverInitializer; @Autowired BoshCliConfig cliConfig; diff --git a/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshLanguageServerInitializerTest.java b/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshLanguageServerInitializerTest.java index 57110a7a5..dedb393e5 100644 --- a/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshLanguageServerInitializerTest.java +++ b/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/BoshLanguageServerInitializerTest.java @@ -46,7 +46,7 @@ public class BoshLanguageServerInitializerTest { @MockBean DynamicModelProvider releasesProvider; @Autowired - LanguageServerHarness harness; + LanguageServerHarness harness; @Test public void createAndInitializeServerWithWorkspace() throws Exception { diff --git a/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/bootiful/BoshLanguageServerTestConfiguration.java b/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/bootiful/BoshLanguageServerTestConfiguration.java index c06b18303..9bf8ff0a1 100644 --- a/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/bootiful/BoshLanguageServerTestConfiguration.java +++ b/headless-services/bosh-language-server/src/test/java/org/springframework/ide/vscode/bosh/bootiful/BoshLanguageServerTestConfiguration.java @@ -25,9 +25,9 @@ public class BoshLanguageServerTestConfiguration { return new MockCloudConfigProvider(cliConfig); } - @Bean public LanguageServerHarness harness(SimpleLanguageServer server) throws Exception { - LanguageServerHarness harness = new LanguageServerHarness<>( - ()-> server, + @Bean public LanguageServerHarness harness(SimpleLanguageServer server) throws Exception { + LanguageServerHarness harness = new LanguageServerHarness( + server, LanguageId.BOSH_DEPLOYMENT ); return harness; diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/composable/ComposableLanguageServer.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/composable/ComposableLanguageServer.java index 480c29e1b..b11cd9b10 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/composable/ComposableLanguageServer.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/composable/ComposableLanguageServer.java @@ -33,8 +33,8 @@ public class ComposableLanguageServer implem private VscodeCompletionEngineAdapter completionEngineAdapter; private HoverHandler hoverHandler; - public ComposableLanguageServer(String extensionId, LSFactory _components) { - this.server = new SimpleLanguageServer(extensionId); + public ComposableLanguageServer(SimpleLanguageServer server, LSFactory _components) { + this.server = server; this.components = _components.create(server); SimpleTextDocumentService documents = server.getTextDocumentService(); diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/config/LanguageServerInitializer.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/config/LanguageServerInitializer.java index 02e75f22d..c2fc48ee9 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/config/LanguageServerInitializer.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/config/LanguageServerInitializer.java @@ -17,8 +17,14 @@ import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguage * called meant to be called on a newly instantiated SimpleLanguageServer, right after it * was created (and prior to actually starting the language server). * + * Deprecated. Uses of this should just be converted on a 'InializingBean' which will make + * spring framework call them after server bean has been created and all its dependencies + * injected. This is simpler and gives more flexibility to deal with dependency cycles. + * For an example See BootLanguageServerIitializer. + * * @author Kris De Volder */ +@Deprecated public interface LanguageServerInitializer { void initialize(SimpleLanguageServer server) throws Exception; } diff --git a/headless-services/commons/language-server-starter/src/main/java/org/springframework/ide/vscode/languageserver/starter/LanguageServerAutoConf.java b/headless-services/commons/language-server-starter/src/main/java/org/springframework/ide/vscode/languageserver/starter/LanguageServerAutoConf.java index c64f015a0..8afb9b453 100644 --- a/headless-services/commons/language-server-starter/src/main/java/org/springframework/ide/vscode/languageserver/starter/LanguageServerAutoConf.java +++ b/headless-services/commons/language-server-starter/src/main/java/org/springframework/ide/vscode/languageserver/starter/LanguageServerAutoConf.java @@ -12,6 +12,8 @@ package org.springframework.ide.vscode.languageserver.starter; import java.util.Optional; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -28,13 +30,20 @@ public class LanguageServerAutoConf { @ConditionalOnMissingBean @Bean public SimpleLanguageServer languageServer( LanguageServerProperties props, - LanguageServerInitializer initializer, Optional severities ) throws Exception { SimpleLanguageServer server = new SimpleLanguageServer(props.getExtensionId()); severities.ifPresent(server::setDiagnosticSeverityProvider); - initializer.initialize(server); return server; } + + @ConditionalOnBean({LanguageServerInitializer.class, SimpleLanguageServer.class}) + @Bean + InitializingBean initializer(SimpleLanguageServer server, LanguageServerInitializer serverInit) { + return () -> { + serverInit.initialize(server); + }; + } + } diff --git a/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java b/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java index 764c81837..1a171bcd6 100644 --- a/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java +++ b/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java @@ -127,7 +127,7 @@ public class Editor { } }; - private LanguageServerHarness harness; + private LanguageServerHarness harness; private TextDocumentInfo doc; private int selectionEnd; diff --git a/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/LanguageServerHarness.java b/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/LanguageServerHarness.java index c47d91509..f26b4a84d 100644 --- a/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/LanguageServerHarness.java +++ b/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/LanguageServerHarness.java @@ -8,7 +8,6 @@ * Contributors: * Pivotal, Inc. - initial API and implementation *******************************************************************************/ - package org.springframework.ide.vscode.languageserver.testharness; import static org.junit.Assert.assertEquals; @@ -121,16 +120,15 @@ import com.google.gson.JsonArray; import reactor.core.publisher.Mono; -public class LanguageServerHarness { +public class LanguageServerHarness { //Warning this 'harness' is incomplete. Growing it as needed. private Random random = new Random(); - private Callable factory; - private LanguageId defaultLanguageId; + private final LanguageId defaultLanguageId; - private S server; + private final SimpleLanguageServer server; private InitializeResult initResult; @@ -141,25 +139,25 @@ public class LanguageServerHarness { private Gson gson = new Gson(); - public LanguageServerHarness(Callable factory, LanguageId defaultLanguageId) { - this.factory = factory; + public LanguageServerHarness(SimpleLanguageServer server, LanguageId defaultLanguageId) { this.defaultLanguageId = defaultLanguageId; + this.server = server; } public static final Duration HIGHLIGHTS_TIMEOUT = Duration.ofMillis(15000000000L); //Why so long? - public static LanguageServerHarness create(String extensionId, LanguageServerInitializer initializer) throws Exception { - Callable factory = () -> { - SimpleLanguageServer s = new SimpleLanguageServer(extensionId); - initializer.initialize(s); - return s; - }; - return new LanguageServerHarness<>(factory); - } +// public static LanguageServerHarness create(String extensionId, LanguageServerInitializer initializer) throws Exception { +// Callable factory = () -> { +// SimpleLanguageServer s = new SimpleLanguageServer(extensionId); +// initializer.initialize(s); +// return s; +// }; +// return new LanguageServerHarness<>(factory); +// } - public LanguageServerHarness(Callable factory) throws Exception { - this(factory, LanguageId.PLAINTEXT); - } +// public LanguageServerHarness(Callable factory) throws Exception { +// this(factory, LanguageId.PLAINTEXT); +// } public synchronized TextDocumentInfo getOrReadFile(File file, String languageId) throws Exception { String uri = file.toURI().toString(); @@ -224,7 +222,6 @@ public class LanguageServerHarness { } public InitializeResult intialize(File workspaceRoot) throws Exception { - server = factory.call(); int parentPid = random.nextInt(40000)+1000; InitializeParams initParams = new InitializeParams(); if (workspaceRoot!=null) { @@ -799,9 +796,4 @@ public class LanguageServerHarness { public SimpleLanguageServer getServer() { return server==null ? null : server.getServer(); } - - public S getServerWrapper() { - return server; - } - } diff --git a/headless-services/commons/language-server-test-harness/src/test/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEditsTest.java b/headless-services/commons/language-server-test-harness/src/test/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEditsTest.java index 70d8f17ba..59bf6dcd5 100644 --- a/headless-services/commons/language-server-test-harness/src/test/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEditsTest.java +++ b/headless-services/commons/language-server-test-harness/src/test/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEditsTest.java @@ -15,8 +15,10 @@ import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; +import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; import org.springframework.ide.vscode.commons.util.text.IDocument; import org.springframework.ide.vscode.commons.util.text.IRegion; +import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.commons.util.text.TextDocument; import org.springframework.ide.vscode.languageserver.testharness.Editor; import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; @@ -34,7 +36,8 @@ public class DocumentEditsTest { @Before public void setup() throws Exception { - harness = new LanguageServerHarness(null); + SimpleLanguageServer server = new SimpleLanguageServer("dont-care"); + harness = new LanguageServerHarness(server, LanguageId.PLAINTEXT); } class TestSubject { diff --git a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java index 189d84b48..791328ccc 100644 --- a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java +++ b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java @@ -60,7 +60,7 @@ public class ConcourseEditorTest { ConcourseLanguageServerInitializer serverInitializer; @Autowired - LanguageServerHarness harness; + LanguageServerHarness harness; @MockBean private GithubInfoProvider github; diff --git a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseLanguageServerInitializerTest.java b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseLanguageServerInitializerTest.java index b22e25c9f..c2683599f 100644 --- a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseLanguageServerInitializerTest.java +++ b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseLanguageServerInitializerTest.java @@ -23,12 +23,12 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; import org.springframework.ide.vscode.concourse.bootiful.ConcourseLanguageServerTest; import org.springframework.ide.vscode.concourse.github.GithubInfoProvider; -import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; + @RunWith(SpringRunner.class) @ConcourseLanguageServerTest public class ConcourseLanguageServerInitializerTest { @@ -37,7 +37,7 @@ public class ConcourseLanguageServerInitializerTest { return Paths.get(ConcourseLanguageServerInitializerTest.class.getResource(name).toURI()).toFile(); } - @Autowired LanguageServerHarness harness; + @Autowired LanguageServerHarness harness; @MockBean GithubInfoProvider github; @Test diff --git a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/bootiful/ConcourseLanguageServerTestConfiguration.java b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/bootiful/ConcourseLanguageServerTestConfiguration.java index b4e962c52..ce00a633d 100644 --- a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/bootiful/ConcourseLanguageServerTestConfiguration.java +++ b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/bootiful/ConcourseLanguageServerTestConfiguration.java @@ -19,9 +19,9 @@ import org.springframework.ide.vscode.languageserver.testharness.LanguageServerH @Configuration public class ConcourseLanguageServerTestConfiguration { - @Bean public LanguageServerHarness harness(SimpleLanguageServer server) throws Exception { - LanguageServerHarness harness = new LanguageServerHarness<>( - ()-> server, + @Bean public LanguageServerHarness harness(SimpleLanguageServer server) throws Exception { + LanguageServerHarness harness = new LanguageServerHarness( + server, LanguageId.CONCOURSE_PIPELINE ); return harness; diff --git a/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java b/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java index 0311ede6c..dec1eb4cb 100644 --- a/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java +++ b/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java @@ -53,7 +53,7 @@ public class ManifestYamlEditorTest { MockCloudfoundry cloudfoundry; @Autowired - LanguageServerHarness harness; + LanguageServerHarness harness; @Before public void initHarness() throws Exception { diff --git a/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServerInitializerTest.java b/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServerInitializerTest.java index fae57c098..f23e81e1d 100644 --- a/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServerInitializerTest.java +++ b/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServerInitializerTest.java @@ -46,7 +46,7 @@ public class ManifestYamlLanguageServerInitializerTest { return Paths.get(ManifestYamlLanguageServerInitializerTest.class.getResource(name).toURI()).toFile(); } - @Autowired LanguageServerHarness harness; + @Autowired LanguageServerHarness harness; @Autowired ManifestYamlLanguageServerInitializer serverInitializer; @Autowired SimpleLanguageServer server; diff --git a/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/bootiful/ManifestYamlLanguageServerTestConfiguration.java b/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/bootiful/ManifestYamlLanguageServerTestConfiguration.java index 437901c64..fe3a7c283 100644 --- a/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/bootiful/ManifestYamlLanguageServerTestConfiguration.java +++ b/headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/bootiful/ManifestYamlLanguageServerTestConfiguration.java @@ -34,9 +34,9 @@ public class ManifestYamlLanguageServerTestConfiguration { return cf.defaultParamsProvider; } - @Bean public LanguageServerHarness harness(SimpleLanguageServer server) throws Exception { - LanguageServerHarness harness = new LanguageServerHarness<>( - ()-> server, + @Bean public LanguageServerHarness harness(SimpleLanguageServer server) throws Exception { + LanguageServerHarness harness = new LanguageServerHarness( + server, LanguageId.CF_MANIFEST ); return harness; diff --git a/headless-services/spring-boot-language-server/pom.xml b/headless-services/spring-boot-language-server/pom.xml index ccf806f33..c105f0693 100644 --- a/headless-services/spring-boot-language-server/pom.xml +++ b/headless-services/spring-boot-language-server/pom.xml @@ -80,6 +80,11 @@ + + org.springframework.boot + spring-boot-starter-test + test + org.springframework.ide.vscode language-server-test-harness diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/BootLanguagServerBootApp.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguagServerBootApp.java similarity index 76% rename from headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/BootLanguagServerBootApp.java rename to headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguagServerBootApp.java index 52285deb6..c5e756bb4 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/BootLanguagServerBootApp.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguagServerBootApp.java @@ -8,10 +8,11 @@ * Contributors: * Pivotal, Inc. - initial API and implementation *******************************************************************************/ -package org.springframework.ide.vscode.boot; +package org.springframework.ide.vscode.boot.app; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; import org.springframework.context.annotation.Bean; import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; import org.springframework.ide.vscode.commons.util.LogRedirect; @@ -29,8 +30,8 @@ public class BootLanguagServerBootApp { return SERVER_NAME; } - @Bean SimpleLanguageServer languageServer() { - return BootLanguageServer.create(BootLanguageServerParams.createDefault()).getServer(); + @ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness") + @Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) { + return BootLanguageServerParams.createDefault().create(server); } - } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/BootLanguageServer.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerInitializer.java similarity index 53% rename from headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/BootLanguageServer.java rename to headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerInitializer.java index 04dea0566..d69842a22 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/BootLanguageServer.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerInitializer.java @@ -8,23 +8,35 @@ * Contributors: * Pivotal, Inc. - initial API and implementation *******************************************************************************/ -package org.springframework.ide.vscode.boot; +package org.springframework.ide.vscode.boot.app; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents; import org.springframework.ide.vscode.boot.properties.BootPropertiesLanguageServerComponents; import org.springframework.ide.vscode.commons.languageserver.composable.ComposableLanguageServer; import org.springframework.ide.vscode.commons.languageserver.composable.CompositeLanguageServerComponents; -import org.springframework.ide.vscode.commons.languageserver.composable.LanguageServerComponents; import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver; import org.springframework.ide.vscode.commons.languageserver.util.LSFactory; import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; import org.springframework.ide.vscode.commons.util.text.TextDocument; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; -public class BootLanguageServer extends ComposableLanguageServer { +@Component +public class BootLanguageServerInitializer implements InitializingBean { - private static final Logger log = LoggerFactory.getLogger(BootLanguageServer.class); + @Autowired SimpleLanguageServer server; + + @Autowired BootLanguageServerParams params; + + private CompositeLanguageServerComponents components; + + private ComposableLanguageServer composableLs; + + private static final Logger log = LoggerFactory.getLogger(BootLanguageServerInitializer.class); private static ProjectObserver.Listener reconcileOpenDocuments(SimpleLanguageServer s, CompositeLanguageServerComponents c) { return ProjectObserver.onAny(project -> { @@ -37,12 +49,8 @@ public class BootLanguageServer extends Comp }); } - private BootLanguageServer(String extensionId, LSFactory _components) { - super(extensionId, _components); - } - - public static ComposableLanguageServer create(LSFactory _params) { - return new ComposableLanguageServer<>("vscode-boot", s -> { + public static ComposableLanguageServer create(SimpleLanguageServer server, LSFactory _params) { + return new ComposableLanguageServer<>(server, s -> { BootLanguageServerParams params = _params.create(s); CompositeLanguageServerComponents.Builder builder = new CompositeLanguageServerComponents.Builder(); builder.add(new BootPropertiesLanguageServerComponents(s, (ignore) -> params)); @@ -53,12 +61,35 @@ public class BootLanguageServer extends Comp }); } - public static ComposableLanguageServer createProperties(LSFactory params) { - return new ComposableLanguageServer<>("vscode-boot-properties", s -> new BootPropertiesLanguageServerComponents(s, params)); + public static ComposableLanguageServer createProperties(SimpleLanguageServer server, LSFactory params) { + return new ComposableLanguageServer<>(server, s -> new BootPropertiesLanguageServerComponents(s, params)); } - public static ComposableLanguageServer createJava(LSFactory params) { - return new ComposableLanguageServer<>("vscode-boot-java", s -> new BootJavaLanguageServerComponents(s, params)); + public static ComposableLanguageServer createJava(SimpleLanguageServer server, LSFactory params) { + return new ComposableLanguageServer<>(server, s -> new BootJavaLanguageServerComponents(s, params)); + } + + @Override + public void afterPropertiesSet() throws Exception { + //TODO: ComposableLanguageServer object instance serves no purpose anymore. The constructor really just contains + // some server intialization code. Migrate that code and get rid of the ComposableLanguageServer class + this.composableLs = new ComposableLanguageServer<>(server, s -> { + CompositeLanguageServerComponents.Builder builder = new CompositeLanguageServerComponents.Builder(); + builder.add(new BootPropertiesLanguageServerComponents(s, (ignore) -> params)); + builder.add(new BootJavaLanguageServerComponents(s, (ignore) -> params)); + components = builder.build(s); + params.projectObserver.addListener(reconcileOpenDocuments(s, components)); + return components; + }); + } + + public CompositeLanguageServerComponents getComponents() { + Assert.notNull(components, "Not yet initialized, can't get components yet."); + return components; + } + + public void setMaxCompletions(int maxCompletions) { + composableLs.setMaxCompletionsNumber(maxCompletions); } } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/BootLanguageServerParams.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerParams.java similarity index 99% rename from headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/BootLanguageServerParams.java rename to headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerParams.java index 9c7db4040..3b58aa4fb 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/BootLanguageServerParams.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerParams.java @@ -8,7 +8,7 @@ * Contributors: * Pivotal, Inc. - initial API and implementation *******************************************************************************/ -package org.springframework.ide.vscode.boot; +package org.springframework.ide.vscode.boot.app; import java.nio.file.Paths; import java.time.Duration; @@ -90,6 +90,7 @@ public class BootLanguageServerParams { } public static LSFactory createDefault() { + //TODO: Get rid of LSFactory return (SimpleLanguageServer server) -> { // Initialize project finders, project caches and project observers JavaProjectsService jdtProjectCache = new JavaProjectsServiceWithFallback( diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/BootJavaLanguageServerComponents.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/BootJavaLanguageServerComponents.java index 135ce6020..3d29d38c4 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/BootJavaLanguageServerComponents.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/BootJavaLanguageServerComponents.java @@ -20,7 +20,7 @@ import org.eclipse.lsp4j.CompletionItemKind; import org.eclipse.lsp4j.InitializeParams; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ide.vscode.boot.BootLanguageServerParams; +import org.springframework.ide.vscode.boot.app.BootLanguageServerParams; import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup; import org.springframework.ide.vscode.boot.java.autowired.AutowiredHoverProvider; import org.springframework.ide.vscode.boot.java.beans.BeansSymbolProvider; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexer.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexer.java index 3e7ebf83a..fa0f35964 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexer.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexer.java @@ -52,7 +52,7 @@ import org.eclipse.lsp4j.SymbolInformation; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ide.vscode.boot.BootLanguageServerParams; +import org.springframework.ide.vscode.boot.app.BootLanguageServerParams; import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchies; import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup; import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/BootPropertiesLanguageServerComponents.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/BootPropertiesLanguageServerComponents.java index f881673ce..fc18f1943 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/BootPropertiesLanguageServerComponents.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/BootPropertiesLanguageServerComponents.java @@ -13,7 +13,7 @@ package org.springframework.ide.vscode.boot.properties; import java.util.Optional; import java.util.Set; -import org.springframework.ide.vscode.boot.BootLanguageServerParams; +import org.springframework.ide.vscode.boot.app.BootLanguageServerParams; import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory; import org.springframework.ide.vscode.boot.common.RelaxedNameConfig; import org.springframework.ide.vscode.boot.metadata.PropertyInfo; diff --git a/headless-services/spring-boot-language-server/src/main/resources/application.yml b/headless-services/spring-boot-language-server/src/main/resources/application.yml new file mode 100644 index 000000000..6c3ea8a07 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/main/resources/application.yml @@ -0,0 +1,2 @@ +languageserver: + extension-id: vscode-spring-boot \ No newline at end of file diff --git a/headless-services/spring-boot-language-server/src/main/resources/simplelogger.properties b/headless-services/spring-boot-language-server/src/main/resources/simplelogger.properties deleted file mode 100644 index 149c0e459..000000000 --- a/headless-services/spring-boot-language-server/src/main/resources/simplelogger.properties +++ /dev/null @@ -1,36 +0,0 @@ -# SLF4J's SimpleLogger configuration file -# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. - -# Default logging detail level for all instances of SimpleLogger. -# Must be one of ("trace", "debug", "info", "warn", or "error"). -# If not specified, defaults to "info". -#org.slf4j.simpleLogger.defaultLogLevel=info - -# Logging detail level for a SimpleLogger instance named "xxxxx". -# Must be one of ("trace", "debug", "info", "warn", or "error"). -# If not specified, the default logging detail level is used. -#org.slf4j.simpleLogger.log.xxxxx= - -# Set to true if you want the current date and time to be included in output messages. -# Default is false, and will output the number of milliseconds elapsed since startup. -#org.slf4j.simpleLogger.showDateTime=false - -# The date and time format to be used in the output messages. -# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. -# If the format is not specified or is invalid, the default format is used. -# The default format is yyyy-MM-dd HH:mm:ss:SSS Z. -#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z - -# Set to true if you want to output the current thread name. -# Defaults to true. -#org.slf4j.simpleLogger.showThreadName=true - -# Set to true if you want the Logger instance name to be included in output messages. -# Defaults to true. -#org.slf4j.simpleLogger.showLogName=true - -# Set to true if you want the last component of the name to be included in output messages. -# Defaults to false. -#org.slf4j.simpleLogger.showShortLogName=false - -org.slf4j.simpleLogger.log.org.springframework.ide.vscode.boot.java.handlers.RemoteRunningAppsProvider=debug diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/BootLanguageServerTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/BootLanguageServerTest.java new file mode 100644 index 000000000..97e01d924 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/BootLanguageServerTest.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2018 Pivotal, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.vscode.boot.bootiful; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.junit.runner.RunWith; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.ide.vscode.boot.app.BootLanguagServerBootApp; +import org.springframework.ide.vscode.languageserver.starter.LanguageServerAutoConf; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.junit4.SpringRunner; + +@Retention(RUNTIME) +@Target(TYPE) +@OverrideAutoConfiguration(enabled=false) +@ImportAutoConfiguration(classes=LanguageServerAutoConf.class) +@SpringBootTest(classes={ + BootLanguagServerBootApp.class, +}) +@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD) +public @interface BootLanguageServerTest { +} diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/HoverTestConf.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/HoverTestConf.java new file mode 100644 index 000000000..d67645e38 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/HoverTestConf.java @@ -0,0 +1,50 @@ +package org.springframework.ide.vscode.boot.bootiful; + +import java.time.Duration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.ide.vscode.boot.app.BootLanguageServerParams; +import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; +import org.springframework.ide.vscode.commons.util.text.LanguageId; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.MockRunningAppProvider; + +@Configuration +public class HoverTestConf { + + @Bean PropertyIndexHarness indexHarness() { + return new PropertyIndexHarness(); + } + + @Bean MockRunningAppProvider mockAppsHarness() { + return new MockRunningAppProvider(); + } + + @Bean BootLanguageServerHarness harness(SimpleLanguageServer server, BootLanguageServerParams serverParams, PropertyIndexHarness indexHarness, JavaProjectFinder projectFinder) throws Exception { + return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java"); + } + + @Bean Duration watchDogInterval() { + return Duration.ofMillis(100); + } + + @Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) { + BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault().create(server); + return new BootLanguageServerParams( + indexHarness().getProjectFinder(), + testDefaults.projectObserver, + indexHarness().getIndexProvider(), + indexHarness().getAdHocIndexProvider(), + testDefaults.typeUtilProvider, + mockAppsHarness().provider, + watchDogInterval() + ); + } + + @Bean JavaProjectFinder projectFinder(BootLanguageServerParams serverParams) { + return serverParams.projectFinder; + } +} \ No newline at end of file diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/PropertyEditorTestConf.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/PropertyEditorTestConf.java new file mode 100644 index 000000000..4df6a2b00 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/PropertyEditorTestConf.java @@ -0,0 +1,59 @@ +package org.springframework.ide.vscode.boot.bootiful; + +import org.eclipse.lsp4j.TextDocumentIdentifier; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.ide.vscode.boot.app.BootLanguageServerParams; +import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness; +import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog; +import org.springframework.ide.vscode.boot.metadata.types.TypeUtil; +import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver; +import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; +import org.springframework.ide.vscode.commons.util.text.IDocument; +import org.springframework.ide.vscode.commons.util.text.LanguageId; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.MockRunningAppProvider; + +@Configuration public class PropertyEditorTestConf { + + @Bean PropertyIndexHarness indexHarness() { + return new PropertyIndexHarness(); + } + + @Bean MockRunningAppProvider mockAppsHarness() { + return new MockRunningAppProvider(); + } + + @Bean BootLanguageServerHarness harness( + SimpleLanguageServer server, + BootLanguageServerParams serverParams, + PropertyIndexHarness indexHarness, + JavaProjectFinder projectFinder, + LanguageId defaultLanguageId, + @Qualifier("defaultFileExtension") String defaultFileExtension + ) throws Exception { + return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, defaultLanguageId, defaultFileExtension); + } + + @Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) { + JavaProjectFinder projectFinder = indexHarness().getProjectFinder(); + TypeUtilProvider typeUtilProvider = (IDocument doc) -> new TypeUtil(projectFinder.find(new TextDocumentIdentifier(doc.getUri()))); + + return new BootLanguageServerParams( + projectFinder, + ProjectObserver.NULL, + indexHarness().getIndexProvider(), + indexHarness().getAdHocIndexProvider(), + typeUtilProvider, + mockAppsHarness().provider, + SpringLiveHoverWatchdog.DEFAULT_INTERVAL + ); + } + + @Bean JavaProjectFinder projectFinder(BootLanguageServerParams serverParams) { + return serverParams.projectFinder; + } +} \ No newline at end of file diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/SymbolProviderTestConf.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/SymbolProviderTestConf.java new file mode 100644 index 000000000..c9b0f542f --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/bootiful/SymbolProviderTestConf.java @@ -0,0 +1,41 @@ +package org.springframework.ide.vscode.boot.bootiful; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.ide.vscode.boot.app.BootLanguageServerInitializer; +import org.springframework.ide.vscode.boot.app.BootLanguageServerParams; +import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness; +import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents; +import org.springframework.ide.vscode.boot.java.utils.SpringIndexer; +import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; +import org.springframework.ide.vscode.commons.util.text.LanguageId; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; + +@Configuration public class SymbolProviderTestConf { + + @Bean PropertyIndexHarness indexHarness() { + return new PropertyIndexHarness(); + } + + @Bean JavaProjectFinder projectFinder(BootLanguageServerParams serverParams) { + return serverParams.projectFinder; + } + + @Bean BootLanguageServerHarness harness(SimpleLanguageServer server, BootLanguageServerParams serverParams, PropertyIndexHarness indexHarness, JavaProjectFinder projectFinder) throws Exception { + return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java"); + } + + @Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) { + return BootLanguageServerParams.createTestDefault().create(server); + } + + @Bean SpringIndexer springIndexer(BootLanguageServerInitializer serverInit) { + return serverInit.getComponents().get(BootJavaLanguageServerComponents.class).getSpringIndexer(); + } + + @Bean DefaultSpringPropertyIndexProvider indexProvider(BootLanguageServerParams serverParams) { + return (DefaultSpringPropertyIndexProvider) serverParams.indexProvider; + } +} \ No newline at end of file diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/AbstractPropsEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/AbstractPropsEditorTest.java index 025690cbe..d94eac8f4 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/AbstractPropsEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/AbstractPropsEditorTest.java @@ -24,16 +24,14 @@ import java.util.Set; import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.junit.Before; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ide.vscode.boot.app.BootLanguageServerInitializer; import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness.ItemConfigurer; import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider; -import org.springframework.ide.vscode.boot.metadata.types.TypeUtil; -import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider; import org.springframework.ide.vscode.commons.java.IJavaProject; import org.springframework.ide.vscode.commons.languageserver.java.CompositeJavaProjectFinder; import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; -import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject; -import org.springframework.ide.vscode.commons.util.text.IDocument; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; @@ -47,7 +45,15 @@ public abstract class AbstractPropsEditorTest { protected ProjectsHarness projects = ProjectsHarness.INSTANCE; - protected PropertyIndexHarness md; + @Autowired protected PropertyIndexHarness md; + @Autowired protected LanguageServerHarness harness; + @Autowired BootLanguageServerInitializer serverInit; + + @Before public void setup() throws Exception { + serverInit.setMaxCompletions(-1); + harness.intialize(null); + } + protected final CompositeJavaProjectFinder javaProjectFinder = new CompositeJavaProjectFinder(Arrays.asList(new JavaProjectFinder() { @Override public Optional find(TextDocumentIdentifier doc) { @@ -55,37 +61,12 @@ public abstract class AbstractPropsEditorTest { } })); - protected LanguageServerHarness harness; - private IJavaProject testProject; - private TypeUtil typeUtil; - protected TypeUtilProvider typeUtilProvider = (IDocument doc) -> { - if (typeUtil==null) { - typeUtil = new TypeUtil(testProject); - } - return typeUtil; - }; abstract public Editor newEditor(String contents) throws Exception; private IJavaProject getTestProject() { - return testProject; - } - - @Before - public void setup() throws Exception { - md = new PropertyIndexHarness(); - harness = new LanguageServerHarness(this::newLanguageServer) { - @Override - protected LanguageId getDefaultLanguageId() { - return AbstractPropsEditorTest.this.getLanguageId(); - } - @Override - protected String getFileExtension() { - return AbstractPropsEditorTest.this.getFileExtension(); - } - }; - harness.intialize(null); + return md.getTestProject(); } protected abstract LanguageId getLanguageId(); @@ -97,8 +78,6 @@ public abstract class AbstractPropsEditorTest { */ protected abstract String getFileExtension(); - protected abstract SimpleLanguageServer newLanguageServer(); - public ItemConfigurer data(String id, String type, Object deflt, String description, String... sources) { return md.data(id, type, deflt, description, sources); } @@ -113,8 +92,6 @@ public abstract class AbstractPropsEditorTest { public void useProject(IJavaProject p) throws Exception { md.useProject(p); - this.testProject = p; - this.typeUtil = null; } /** diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/PropertyIndexHarness.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/PropertyIndexHarness.java index f758db046..4d0a604b8 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/PropertyIndexHarness.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/PropertyIndexHarness.java @@ -13,6 +13,7 @@ package org.springframework.ide.vscode.boot.editor.harness; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty; import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation; @@ -24,6 +25,7 @@ import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider; import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry; import org.springframework.ide.vscode.commons.java.IClasspath; import org.springframework.ide.vscode.commons.java.IJavaProject; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; import org.springframework.ide.vscode.commons.util.FuzzyMap; import org.springframework.ide.vscode.commons.util.text.IDocument; @@ -35,6 +37,12 @@ public class PropertyIndexHarness { private Map datas = new LinkedHashMap<>(); private ValueProviderRegistry valueProviders = ValueProviderRegistry.getDefault(); private SpringPropertyIndex index = null; + private FuzzyMap adHocProperties = new FuzzyMap() { + @Override + protected String getKey(PropertyInfo entry) { + return entry.getId(); + } + }; private IJavaProject testProject = null; protected final SpringPropertyIndexProvider indexProvider = new SpringPropertyIndexProvider() { @@ -52,7 +60,9 @@ public class PropertyIndexHarness { } } }; - + + protected final SpringPropertyIndexProvider adHocIndexProvider = doc -> adHocProperties; + public synchronized void useProject(IJavaProject p) throws Exception { index = null; this.testProject = p; @@ -562,4 +572,20 @@ public class PropertyIndexHarness { return indexProvider; } + public SpringPropertyIndexProvider getAdHocIndexProvider() { + return adHocIndexProvider; + } + + public JavaProjectFinder getProjectFinder() { + return (doc) -> Optional.ofNullable(testProject); + } + + public void adHoc(String adHocPropertyId) { + adHocProperties.add(new PropertyInfo(adHocPropertyId, null, null, null, null, null, null, null, null, null, null)); + } + + public IJavaProject getTestProject() { + return testProject; + } + } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/autowired/test/AutowiredHoverProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/autowired/test/AutowiredHoverProviderTest.java index 55ed85d3a..559e969f5 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/autowired/test/AutowiredHoverProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/autowired/test/AutowiredHoverProviderTest.java @@ -19,20 +19,31 @@ import java.util.stream.Stream; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.HoverTestConf; import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBean; import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel; +import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServerWrapper; import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.MockRunningAppProvider; import org.springframework.ide.vscode.project.harness.ProjectsHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness.CustomizableProjectContent; import org.springframework.ide.vscode.project.harness.ProjectsHarness.ProjectCustomizer; +import org.springframework.test.context.junit4.SpringRunner; /** * @author Martin Lippert */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(HoverTestConf.class) public class AutowiredHoverProviderTest { private static final String FOO_IMPL_CONTENTS = "package com.example;\n" + @@ -124,20 +135,15 @@ public class AutowiredHoverProviderTest { p.createType("com.example.FooImplementation", FOO_IMPL_CONTENTS); }; - private BootJavaLanguageServerHarness harness; + @Autowired + private BootLanguageServerHarness harness; private ProjectsHarness projects = ProjectsHarness.INSTANCE; + @Autowired private MockRunningAppProvider mockAppProvider; @Before public void setup() throws Exception { - mockAppProvider = new MockRunningAppProvider(); - harness = BootJavaLanguageServerHarness.builder() - .mockDefaults() - .runningAppProvider(mockAppProvider.provider) - .watchDogInterval(Duration.ofMillis(100)) - .build(); - MavenJavaProject jp = projects.mavenProject("empty-boot-15-web-app", FOO_INTERFACE); assertTrue(jp.findType("com.example.Foo").exists()); harness.useProject(jp); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/beans/test/SpringIndexerBeansTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/beans/test/SpringIndexerBeansTest.java index ac82da864..0ba7c7c18 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/beans/test/SpringIndexerBeansTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/beans/test/SpringIndexerBeansTest.java @@ -17,41 +17,44 @@ import java.util.concurrent.TimeUnit; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.junit.Before; import org.junit.Test; -import org.springframework.ide.vscode.boot.java.Annotations; -import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup; -import org.springframework.ide.vscode.boot.java.beans.BeansSymbolProvider; -import org.springframework.ide.vscode.boot.java.beans.ComponentSymbolProvider; -import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.app.BootLanguageServerInitializer; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf; +import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents; import org.springframework.ide.vscode.boot.java.utils.SpringIndexer; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * @author Martin Lippert */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(SymbolProviderTestConf.class) public class SpringIndexerBeansTest { - private AnnotationHierarchyAwareLookup symbolProviders; - private BootJavaLanguageServerHarness harness; + @Autowired private BootLanguageServerHarness harness; + @Autowired private BootLanguageServerInitializer serverInit; + @Autowired private JavaProjectFinder projectFinder; + private File directory; - private SpringIndexer indexer; + @Autowired private SpringIndexer indexer; @Before public void setup() throws Exception { - symbolProviders = new AnnotationHierarchyAwareLookup<>(); - symbolProviders.put(Annotations.BEAN, new BeansSymbolProvider()); - symbolProviders.put(Annotations.COMPONENT, new ComponentSymbolProvider()); - - harness = BootJavaLanguageServerHarness.builder().build(); harness.intialize(null); - indexer = harness.getServerWrapper().getComponents().getSpringIndexer(); directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-beans/").toURI()); String projectDir = directory.toURI().toString(); // trigger project creation - harness.getServerWrapper().getComponents().getProjectFinder().find(new TextDocumentIdentifier(projectDir)).get(); + projectFinder.find(new TextDocumentIdentifier(projectDir)).get(); CompletableFuture initProject = indexer.waitOperation(); initProject.get(5, TimeUnit.SECONDS); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/beans/test/SpringIndexerFunctionBeansTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/beans/test/SpringIndexerFunctionBeansTest.java index fcc22690c..6d0e3f1da 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/beans/test/SpringIndexerFunctionBeansTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/beans/test/SpringIndexerFunctionBeansTest.java @@ -17,41 +17,41 @@ import java.util.concurrent.TimeUnit; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.junit.Before; import org.junit.Test; -import org.springframework.ide.vscode.boot.java.Annotations; -import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyAwareLookup; -import org.springframework.ide.vscode.boot.java.beans.BeansSymbolProvider; -import org.springframework.ide.vscode.boot.java.beans.ComponentSymbolProvider; -import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf; import org.springframework.ide.vscode.boot.java.utils.SpringIndexer; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * @author Martin Lippert */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(SymbolProviderTestConf.class) public class SpringIndexerFunctionBeansTest { - private AnnotationHierarchyAwareLookup symbolProviders; - private BootJavaLanguageServerHarness harness; - private SpringIndexer indexer; + @Autowired private BootLanguageServerHarness harness; + @Autowired private SpringIndexer indexer; + @Autowired private JavaProjectFinder projectFinder; + private File directory; @Before public void setup() throws Exception { - symbolProviders = new AnnotationHierarchyAwareLookup<>(); - symbolProviders.put(Annotations.BEAN, new BeansSymbolProvider()); - symbolProviders.put(Annotations.COMPONENT, new ComponentSymbolProvider()); - - harness = BootJavaLanguageServerHarness.builder().build(); harness.intialize(null); - - indexer = harness.getServerWrapper().getComponents().getSpringIndexer(); + directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-beans/").toURI()); String projectDir = directory.toURI().toString(); // trigger project creation - harness.getServerWrapper().getComponents().getProjectFinder().find(new TextDocumentIdentifier(projectDir)).get(); + projectFinder.find(new TextDocumentIdentifier(projectDir)).get(); CompletableFuture initProject = indexer.waitOperation(); initProject.get(5, TimeUnit.SECONDS); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/conditionals/test/ConditionalsLiveHoverTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/conditionals/test/ConditionalsLiveHoverTest.java index 215d4f407..9f35cb992 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/conditionals/test/ConditionalsLiveHoverTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/conditionals/test/ConditionalsLiveHoverTest.java @@ -14,33 +14,37 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.File; -import java.time.Duration; import org.eclipse.lsp4j.Hover; import org.junit.Before; import org.junit.Test; -import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents; -import org.springframework.ide.vscode.commons.languageserver.composable.ComposableLanguageServer; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.HoverTestConf; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.MockRunningAppProvider; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(HoverTestConf.class) public class ConditionalsLiveHoverTest { - private LanguageServerHarness> harness; + @Autowired + private BootLanguageServerHarness harness; + + @Autowired private MockRunningAppProvider mockAppProvider; @Before public void setup() throws Exception { - - mockAppProvider = new MockRunningAppProvider(); - harness = BootJavaLanguageServerHarness.builder() - .runningAppProvider(mockAppProvider.provider) - .watchDogInterval(Duration.ofMillis(100)) - .build(); + harness.useProject(ProjectsHarness.INSTANCE.mavenProject("test-conditionals-live-hover")); } @Test diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/data/test/DataRepositorySymbolProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/data/test/DataRepositorySymbolProviderTest.java index 1274aea64..f79d04f30 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/data/test/DataRepositorySymbolProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/data/test/DataRepositorySymbolProviderTest.java @@ -23,31 +23,40 @@ import org.eclipse.lsp4j.SymbolInformation; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf; import org.springframework.ide.vscode.boot.java.utils.SpringIndexer; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * @author Martin Lippert */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(SymbolProviderTestConf.class) public class DataRepositorySymbolProviderTest { - private BootJavaLanguageServerHarness harness; - private SpringIndexer indexer; + @Autowired private BootLanguageServerHarness harness; + @Autowired private JavaProjectFinder projectFinder; + @Autowired private SpringIndexer indexer; + private File directory; @Before public void setup() throws Exception { - harness = BootJavaLanguageServerHarness.builder().build(); - harness.intialize(null); - indexer = harness.getServerWrapper().getComponents().getSpringIndexer(); - + directory = new File(ProjectsHarness.class.getResource("/test-projects/test-spring-data-symbols/").toURI()); String projectDir = directory.toURI().toString(); - + // trigger project creation - harness.getServerWrapper().getComponents().getProjectFinder().find(new TextDocumentIdentifier(projectDir)).get(); + projectFinder.find(new TextDocumentIdentifier(projectDir)).get(); CompletableFuture initProject = indexer.waitOperation(); initProject.get(5, TimeUnit.SECONDS); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ActiveProfilesHoverTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ActiveProfilesHoverTest.java index b3c612214..e0ed72cea 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ActiveProfilesHoverTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ActiveProfilesHoverTest.java @@ -10,31 +10,35 @@ *******************************************************************************/ package org.springframework.ide.vscode.boot.java.livehover.test; -import java.time.Duration; - import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.MockRunningAppProvider; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.ide.vscode.boot.bootiful.HoverTestConf; +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(HoverTestConf.class) public class ActiveProfilesHoverTest { - private BootJavaLanguageServerHarness harness; private ProjectsHarness projects = ProjectsHarness.INSTANCE; + @Autowired + private BootLanguageServerHarness harness; + + @Autowired private MockRunningAppProvider mockAppProvider; @Before public void setup() throws Exception { - mockAppProvider = new MockRunningAppProvider(); - harness = BootJavaLanguageServerHarness.builder() - .mockDefaults() - .runningAppProvider(mockAppProvider.provider) - .watchDogInterval(Duration.ofMillis(100)) - .build(); harness.useProject(projects.mavenProject("empty-boot-15-web-app")); harness.intialize(null); } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ActuatorWarningHoverTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ActuatorWarningHoverTest.java index 8a7018132..98093e6ce 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ActuatorWarningHoverTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ActuatorWarningHoverTest.java @@ -10,35 +10,31 @@ *******************************************************************************/ package org.springframework.ide.vscode.boot.java.livehover.test; -import java.time.Duration; - -import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.HoverTestConf; import org.springframework.ide.vscode.commons.java.IJavaProject; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.MockRunningAppProvider; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(HoverTestConf.class) public class ActuatorWarningHoverTest { private static final String ACTUATOR_PROJECT = "empty-boot-15-web-app"; private static final String NO_ACTUATOR_PROJECT = "no-actuator-boot-15-web-app"; - - private BootJavaLanguageServerHarness harness; private ProjectsHarness projects = ProjectsHarness.INSTANCE; - private MockRunningAppProvider mockAppProvider; - @Before - public void setup() throws Exception { - mockAppProvider = new MockRunningAppProvider(); - harness = BootJavaLanguageServerHarness.builder() - .mockDefaults() - .runningAppProvider(mockAppProvider.provider) - .watchDogInterval(Duration.ofMillis(100)) - .build(); - } + @Autowired private BootLanguageServerHarness harness; + @Autowired private MockRunningAppProvider mockAppProvider; @Test public void showWarningIf_NoActuator_and_RunningApp() throws Exception { //Has running app: diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/BeanInjectedIntoHoverProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/BeanInjectedIntoHoverProviderTest.java index 2299a4a79..60da3571c 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/BeanInjectedIntoHoverProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/BeanInjectedIntoHoverProviderTest.java @@ -14,21 +14,29 @@ import static org.junit.Assert.assertTrue; import java.nio.file.Path; import java.nio.file.Paths; -import java.time.Duration; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.HoverTestConf; import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBean; import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel; import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.MockRunningAppProvider; import org.springframework.ide.vscode.project.harness.ProjectsHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness.CustomizableProjectContent; import org.springframework.ide.vscode.project.harness.ProjectsHarness.ProjectCustomizer; +import org.springframework.test.context.junit4.SpringRunner; +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(HoverTestConf.class) public class BeanInjectedIntoHoverProviderTest { private static final ProjectCustomizer FOO_INTERFACE = (CustomizableProjectContent p) -> { @@ -63,20 +71,16 @@ public class BeanInjectedIntoHoverProviderTest { }; - private BootJavaLanguageServerHarness harness; private ProjectsHarness projects = ProjectsHarness.INSTANCE; + @Autowired + private BootLanguageServerHarness harness; + + @Autowired private MockRunningAppProvider mockAppProvider; @Before public void setup() throws Exception { - mockAppProvider = new MockRunningAppProvider(); - harness = BootJavaLanguageServerHarness.builder() - .mockDefaults() - .runningAppProvider(mockAppProvider.provider) - .watchDogInterval(Duration.ofMillis(100)) - .build(); - MavenJavaProject jp = projects.mavenProject("empty-boot-15-web-app", FOO_INTERFACE); assertTrue(jp.findType("hello.Foo").exists()); harness.useProject(jp); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/BeansByTypeHoverProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/BeansByTypeHoverProviderTest.java index c19db79f2..345a0dc66 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/BeansByTypeHoverProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/BeansByTypeHoverProviderTest.java @@ -10,35 +10,34 @@ *******************************************************************************/ package org.springframework.ide.vscode.boot.java.livehover.test; -import java.time.Duration; - import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.HoverTestConf; import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBean; import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel; import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.MockRunningAppProvider; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(HoverTestConf.class) public class BeansByTypeHoverProviderTest { - private BootJavaLanguageServerHarness harness; private ProjectsHarness projects = ProjectsHarness.INSTANCE; - - private MockRunningAppProvider mockAppProvider; + @Autowired private BootLanguageServerHarness harness; + @Autowired private MockRunningAppProvider mockAppProvider; @Before public void setup() throws Exception { - mockAppProvider = new MockRunningAppProvider(); - harness = BootJavaLanguageServerHarness.builder() - .mockDefaults() - .runningAppProvider(mockAppProvider.provider) - .watchDogInterval(Duration.ofMillis(100)) - .build(); - MavenJavaProject jp = projects.mavenProject("empty-boot-15-web-app"); harness.useProject(jp); harness.intialize(null); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ComponentInjectionsHoverProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ComponentInjectionsHoverProviderTest.java index e46ff9986..8243defbb 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ComponentInjectionsHoverProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/livehover/test/ComponentInjectionsHoverProviderTest.java @@ -12,21 +12,28 @@ package org.springframework.ide.vscode.boot.java.livehover.test; import static org.junit.Assert.assertTrue; -import java.time.Duration; - import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.HoverTestConf; import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBean; import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel; import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.MockRunningAppProvider; import org.springframework.ide.vscode.project.harness.ProjectsHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness.CustomizableProjectContent; import org.springframework.ide.vscode.project.harness.ProjectsHarness.ProjectCustomizer; +import org.springframework.test.context.junit4.SpringRunner; +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(HoverTestConf.class) public class ComponentInjectionsHoverProviderTest { private static final ProjectCustomizer EXTRA_TYPES = (CustomizableProjectContent p) -> { @@ -54,20 +61,12 @@ public class ComponentInjectionsHoverProviderTest { }; - private BootJavaLanguageServerHarness harness; private ProjectsHarness projects = ProjectsHarness.INSTANCE; - - private MockRunningAppProvider mockAppProvider; + @Autowired private BootLanguageServerHarness harness; + @Autowired private MockRunningAppProvider mockAppProvider; @Before public void setup() throws Exception { - mockAppProvider = new MockRunningAppProvider(); - harness = BootJavaLanguageServerHarness.builder() - .mockDefaults() - .runningAppProvider(mockAppProvider.provider) - .watchDogInterval(Duration.ofMillis(100)) - .build(); - MavenJavaProject jp = projects.mavenProject("empty-boot-15-web-app", EXTRA_TYPES); assertTrue(jp.findType("com.example.Foo").exists()); harness.useProject(jp); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTest.java index 6a1698d3d..f28f7cc06 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTest.java @@ -13,35 +13,35 @@ package org.springframework.ide.vscode.boot.java.requestmapping.test; import static org.junit.Assert.assertTrue; import java.io.File; -import java.time.Duration; import org.junit.Before; import org.junit.Test; -import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents; -import org.springframework.ide.vscode.commons.languageserver.composable.ComposableLanguageServer; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.HoverTestConf; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; -import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.MockRequestMapping; import org.springframework.ide.vscode.project.harness.MockRunningAppProvider; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; import com.google.common.collect.ImmutableList; +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(HoverTestConf.class) public class RequestMappingLiveHoverTest { - private LanguageServerHarness> harness; - private MockRunningAppProvider mockAppProvider; + @Autowired BootLanguageServerHarness harness; + @Autowired MockRunningAppProvider mockAppProvider; @Before public void setup() throws Exception { - - mockAppProvider = new MockRunningAppProvider(); - harness = BootJavaLanguageServerHarness.builder() - .runningAppProvider(mockAppProvider.provider) - .watchDogInterval(Duration.ofMillis(100)) - .build(); + harness.useProject(ProjectsHarness.INSTANCE.mavenProject("test-request-mapping-live-hover")); } @Test diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingSymbolProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingSymbolProviderTest.java index 2dc2557f8..1092d3405 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingSymbolProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingSymbolProviderTest.java @@ -23,31 +23,40 @@ import org.eclipse.lsp4j.SymbolInformation; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf; import org.springframework.ide.vscode.boot.java.utils.SpringIndexer; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * @author Martin Lippert */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(SymbolProviderTestConf.class) public class RequestMappingSymbolProviderTest { - private BootJavaLanguageServerHarness harness; - private SpringIndexer indexer; + @Autowired private BootLanguageServerHarness harness; + @Autowired private JavaProjectFinder projectFinder; + @Autowired private SpringIndexer indexer; + private File directory; @Before public void setup() throws Exception { - harness = BootJavaLanguageServerHarness.builder().build(); - harness.intialize(null); - indexer = harness.getServerWrapper().getComponents().getSpringIndexer(); - + directory = new File(ProjectsHarness.class.getResource("/test-projects/test-request-mapping-symbols/").toURI()); String projectDir = directory.toURI().toString(); - + // trigger project creation - harness.getServerWrapper().getComponents().getProjectFinder().find(new TextDocumentIdentifier(projectDir)).get(); + projectFinder.find(new TextDocumentIdentifier(projectDir)).get(); CompletableFuture initProject = indexer.waitOperation(); initProject.get(5, TimeUnit.SECONDS); @@ -134,7 +143,7 @@ public class RequestMappingSymbolProviderTest { List symbols = indexer.getSymbols(docUri); assertTrue(containsSymbol(symbols, "@/postAndPutHello -- POST,PUT", docUri, 36, 1, 36, 76)); } - + @Test public void testMediaTypes() throws Exception { String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMappingMediaTypes.java").toUri().toString(); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxCodeLensProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxCodeLensProviderTest.java index d9dfba835..59c37bee1 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxCodeLensProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxCodeLensProviderTest.java @@ -25,34 +25,41 @@ import org.eclipse.lsp4j.Range; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf; import org.springframework.ide.vscode.boot.java.utils.SpringIndexer; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.TextDocumentInfo; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * @author Martin Lippert */ @SuppressWarnings("deprecation") +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(SymbolProviderTestConf.class) public class WebFluxCodeLensProviderTest { - private BootJavaLanguageServerHarness harness; - private SpringIndexer indexer; + @Autowired private BootLanguageServerHarness harness; + @Autowired private JavaProjectFinder projectFinder; + @Autowired private SpringIndexer indexer; private File directory; @Before public void setup() throws Exception { - harness = BootJavaLanguageServerHarness.builder().build(); - harness.intialize(null); - indexer = harness.getServerWrapper().getComponents().getSpringIndexer(); - directory = new File(ProjectsHarness.class.getResource("/test-projects/test-webflux-project/").toURI()); String projectDir = directory.toURI().toString(); // trigger project creation - harness.getServerWrapper().getComponents().getProjectFinder().find(new TextDocumentIdentifier(projectDir)).get(); + projectFinder.find(new TextDocumentIdentifier(projectDir)).get(); CompletableFuture initProject = indexer.waitOperation(); initProject.get(5, TimeUnit.SECONDS); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxMappingSymbolProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxMappingSymbolProviderTest.java index df31ff283..68bdec668 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxMappingSymbolProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxMappingSymbolProviderTest.java @@ -25,34 +25,47 @@ import org.eclipse.lsp4j.SymbolInformation; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf; import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation; import org.springframework.ide.vscode.boot.java.requestmapping.WebfluxHandlerInformation; import org.springframework.ide.vscode.boot.java.utils.SpringIndexer; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; import org.springframework.ide.vscode.commons.util.Assert; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * @author Martin Lippert */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(SymbolProviderTestConf.class) public class WebFluxMappingSymbolProviderTest { - private BootJavaLanguageServerHarness harness; + @Autowired + private BootLanguageServerHarness harness; + + @Autowired private SpringIndexer indexer; + + @Autowired + JavaProjectFinder projectFinder; + private File directory; @Before public void setup() throws Exception { - harness = BootJavaLanguageServerHarness.builder().build(); - harness.intialize(null); - indexer = harness.getServerWrapper().getComponents().getSpringIndexer(); - directory = new File(ProjectsHarness.class.getResource("/test-projects/test-webflux-project/").toURI()); String projectDir = directory.toURI().toString(); // trigger project creation - harness.getServerWrapper().getComponents().getProjectFinder().find(new TextDocumentIdentifier(projectDir)).get(); + projectFinder.find(new TextDocumentIdentifier(projectDir)).get(); CompletableFuture initProject = indexer.waitOperation(); initProject.get(5, TimeUnit.SECONDS); @@ -65,7 +78,7 @@ public class WebFluxMappingSymbolProviderTest { assertEquals(4, symbols.size()); assertTrue(containsSymbol(symbols, "@/users - Content-Type: application/json", docUri, 13, 1, 13, 74)); assertTrue(containsSymbol(symbols, "@/users/{username} - Content-Type: application/json", docUri, 18, 1, 18, 85)); - + List addons = indexer.getAdditonalInformation(docUri); Assert.noElements(addons); } @@ -79,10 +92,10 @@ public class WebFluxMappingSymbolProviderTest { assertTrue(containsSymbol(symbols, "@/echo -- POST - Accept: text/plain - Content-Type: text/plain", docUri, 23, 5, 23, 101)); assertTrue(containsSymbol(symbols, "@/quotes -- GET - Accept: application/json", docUri, 24, 5, 24, 86)); assertTrue(containsSymbol(symbols, "@/quotes -- GET - Accept: application/stream+json", docUri, 25, 5, 25, 94)); - + List addons = indexer.getAdditonalInformation(docUri); assertEquals(8, addons.size()); - + WebfluxHandlerInformation handlerInfo1 = getWebfluxHandler(addons, "/hello", "GET").get(0); assertEquals("/hello", handlerInfo1.getPath()); assertEquals("[GET]", Arrays.toString(handlerInfo1.getHttpMethods())); @@ -90,7 +103,7 @@ public class WebFluxMappingSymbolProviderTest { assertEquals("[TEXT_PLAIN]", Arrays.toString(handlerInfo1.getAcceptTypes())); assertEquals("org.test.QuoteHandler", handlerInfo1.getHandlerClass()); assertEquals("public Mono hello(org.springframework.web.reactive.function.server.ServerRequest)", handlerInfo1.getHandlerMethod()); - + WebfluxHandlerInformation handlerInfo2 = getWebfluxHandler(addons, "/echo", "POST").get(0); assertEquals("/echo", handlerInfo2.getPath()); assertEquals("[POST]", Arrays.toString(handlerInfo2.getHttpMethods())); @@ -127,7 +140,7 @@ public class WebFluxMappingSymbolProviderTest { List addons = indexer.getAdditonalInformation(docUri); assertEquals(6, addons.size()); - + WebfluxHandlerInformation handlerInfo1 = getWebfluxHandler(addons, "/person/{id}", "GET").get(0); assertEquals("/person/{id}", handlerInfo1.getPath()); assertEquals("[GET]", Arrays.toString(handlerInfo1.getHttpMethods())); @@ -135,7 +148,7 @@ public class WebFluxMappingSymbolProviderTest { assertEquals("[APPLICATION_JSON]", Arrays.toString(handlerInfo1.getAcceptTypes())); assertEquals("org.test.PersonHandler1", handlerInfo1.getHandlerClass()); assertEquals("public Mono getPerson(org.springframework.web.reactive.function.server.ServerRequest)", handlerInfo1.getHandlerMethod()); - + WebfluxHandlerInformation handlerInfo2 = getWebfluxHandler(addons, "/person/", "POST").get(0); assertEquals("/person/", handlerInfo2.getPath()); assertEquals("[POST]", Arrays.toString(handlerInfo2.getHttpMethods())); @@ -164,7 +177,7 @@ public class WebFluxMappingSymbolProviderTest { List addons = indexer.getAdditonalInformation(docUri); assertEquals(6, addons.size()); - + WebfluxHandlerInformation handlerInfo1 = getWebfluxHandler(addons, "/person/{id}", "GET").get(0); assertEquals("/person/{id}", handlerInfo1.getPath()); assertEquals("[GET]", Arrays.toString(handlerInfo1.getHttpMethods())); @@ -172,7 +185,7 @@ public class WebFluxMappingSymbolProviderTest { assertEquals("[APPLICATION_JSON]", Arrays.toString(handlerInfo1.getAcceptTypes())); assertEquals("org.test.PersonHandler2", handlerInfo1.getHandlerClass()); assertEquals("public Mono getPerson(org.springframework.web.reactive.function.server.ServerRequest)", handlerInfo1.getHandlerMethod()); - + WebfluxHandlerInformation handlerInfo2 = getWebfluxHandler(addons, "/", "POST").get(0); assertEquals("/", handlerInfo2.getPath()); assertEquals("[POST]", Arrays.toString(handlerInfo2.getHttpMethods())); @@ -195,7 +208,7 @@ public class WebFluxMappingSymbolProviderTest { String docUri = directory.toPath().resolve("src/main/java/org/test/NestedRouter3.java").toUri().toString(); List symbols = indexer.getSymbols(docUri); assertEquals(8, symbols.size()); - + assertTrue(containsSymbol(symbols, "@/person/sub1/sub2/{id} -- GET - Accept: application/json", docUri, 29, 7, 29, 46)); assertTrue(containsSymbol(symbols, "@/person/sub1/sub2 -- GET - Accept: application/json", docUri, 30, 8, 30, 61)); assertTrue(containsSymbol(symbols, "@/person/sub1/sub2/nestedGet -- GET", docUri, 31, 9, 31, 56)); @@ -205,7 +218,7 @@ public class WebFluxMappingSymbolProviderTest { List addons = indexer.getAdditonalInformation(docUri); assertEquals(12, addons.size()); - + WebfluxHandlerInformation handlerInfo1 = getWebfluxHandler(addons, "/person/sub1/sub2/{id}", "GET").get(0); assertEquals("/person/sub1/sub2/{id}", handlerInfo1.getPath()); assertEquals("[GET]", Arrays.toString(handlerInfo1.getHttpMethods())); @@ -213,7 +226,7 @@ public class WebFluxMappingSymbolProviderTest { assertEquals("[APPLICATION_JSON]", Arrays.toString(handlerInfo1.getAcceptTypes())); assertEquals("org.test.PersonHandler3", handlerInfo1.getHandlerClass()); assertEquals("public Mono getPerson(org.springframework.web.reactive.function.server.ServerRequest)", handlerInfo1.getHandlerMethod()); - + WebfluxHandlerInformation handlerInfo2 = getWebfluxHandler(addons, "/person/sub1/sub2", "GET").get(0); assertEquals("/person/sub1/sub2", handlerInfo2.getPath()); assertEquals("[GET]", Arrays.toString(handlerInfo2.getHttpMethods())); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/scope/test/ScopeCompletionTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/scope/test/ScopeCompletionTest.java index 3811c84e3..beb9273cd 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/scope/test/ScopeCompletionTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/scope/test/ScopeCompletionTest.java @@ -19,25 +19,33 @@ import org.apache.commons.io.IOUtils; import org.eclipse.lsp4j.CompletionItem; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.HoverTestConf; import org.springframework.ide.vscode.commons.java.IJavaProject; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; import org.springframework.ide.vscode.languageserver.testharness.TestAsserts; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * @author Martin Lippert */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(HoverTestConf.class) public class ScopeCompletionTest { - private BootJavaLanguageServerHarness harness; + @Autowired private BootLanguageServerHarness harness; private Editor editor; @Before public void setup() throws Exception { IJavaProject testProject = ProjectsHarness.INSTANCE.mavenProject("test-annotations"); - harness = BootJavaLanguageServerHarness.builder().mockDefaults().build(); harness.useProject(testProject); harness.intialize(null); } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/CompilationUnitCacheTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/CompilationUnitCacheTest.java index d106fb0e3..c55943174 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/CompilationUnitCacheTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/CompilationUnitCacheTest.java @@ -22,17 +22,25 @@ import java.nio.file.Path; import java.nio.file.Paths; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.junit.Before; import org.junit.Test; -import org.springframework.ide.vscode.commons.java.DelegatingCachedClasspath; -import org.springframework.ide.vscode.commons.java.IClasspath; -import org.springframework.ide.vscode.commons.java.IJavaProject; -import org.springframework.ide.vscode.commons.java.JavaProject; -import org.springframework.ide.vscode.commons.maven.MavenCore; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.ide.vscode.boot.app.BootLanguageServerInitializer; +import org.springframework.ide.vscode.boot.app.BootLanguageServerParams; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness; +import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents; +import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; +import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.commons.util.text.TextDocument; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * CU Cache tests @@ -40,21 +48,57 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness; * @author Alex Boyko * */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest public class CompilationUnitCacheTest { - private BootJavaLanguageServerHarness harness; + ProjectsHarness projects = ProjectsHarness.INSTANCE; + + @Autowired + private BootLanguageServerHarness harness; + + @Autowired + private BootLanguageServerInitializer serverInit; + + @Autowired + private MockProjectObserver projectObserver; + + @Configuration static class TestConf { + + @Bean PropertyIndexHarness indexHarness() { + return new PropertyIndexHarness(); + } + + @Bean JavaProjectFinder projectFinder(BootLanguageServerParams serverParams) { + return serverParams.projectFinder; + } + + @Bean MockProjectObserver projectObserver() { + return new MockProjectObserver(); + } + + @Bean BootLanguageServerHarness harness(SimpleLanguageServer server, BootLanguageServerParams serverParams, PropertyIndexHarness indexHarness, JavaProjectFinder projectFinder) throws Exception { + return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java"); + } + + @Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, MockProjectObserver projectObserver) { + BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault().create(server); + return new BootLanguageServerParams( + indexHarness().getProjectFinder(), + projectObserver, + indexHarness().getIndexProvider(), + indexHarness().getAdHocIndexProvider(), + testDefaults.typeUtilProvider, + RunningAppProvider.NULL, + null + ); + } - @Before - public void setup() throws Exception { - harness = BootJavaLanguageServerHarness.builder().build(); } @Test public void cu_cached() throws Exception { - harness = BootJavaLanguageServerHarness.builder() - .mockDefaults().build(); harness.useProject(ProjectsHarness.dummyProject()); - harness.intialize(null); TextDocument doc = new TextDocument(harness.createTempUri(), LanguageId.JAVA, 0, "package my.package\n" + @@ -83,14 +127,12 @@ public class CompilationUnitCacheTest { } private CompilationUnit getCompilationUnit(TextDocument doc) { - harness.getServerWrapper().getServer().getAsync().waitForAll(); - return harness.getServerWrapper().getComponents().getCompilationUnitCache().withCompilationUnit(doc, cu -> cu); + harness.getServer().getAsync().waitForAll(); + return serverInit.getComponents().get(BootJavaLanguageServerComponents.class).getCompilationUnitCache().withCompilationUnit(doc, cu -> cu); } @Test public void cu_cache_invalidated_by_doc_change() throws Exception { - harness = BootJavaLanguageServerHarness.builder() - .mockDefaults().build(); harness.useProject(ProjectsHarness.dummyProject()); harness.intialize(null); @@ -115,8 +157,6 @@ public class CompilationUnitCacheTest { @Test public void cu_cache_invalidated_by_doc_close() throws Exception { - harness = BootJavaLanguageServerHarness.builder() - .mockDefaults().build(); harness.useProject(ProjectsHarness.dummyProject()); harness.intialize(null); @@ -144,7 +184,8 @@ public class CompilationUnitCacheTest { File directory = new File( ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI()); String docUri = directory.toPath().resolve("src/main/java/example/HelloWorldController.java").toUri().toString(); - + MavenJavaProject project = projects.mavenProject("test-request-mapping-live-hover"); + harness.useProject(project); harness.intialize(directory); URI fileUri = new URI(docUri); @@ -158,7 +199,7 @@ public class CompilationUnitCacheTest { CompilationUnit cuAnother = getCompilationUnit(document); assertTrue(cu == cuAnother); - harness.changeFile(directory.toPath().resolve(MavenCore.POM_XML).toUri().toString()); + projectObserver.doWithListeners(l -> l.changed(project)); cuAnother = getCompilationUnit(document); assertNotNull(cuAnother); assertFalse(cu == cuAnother); @@ -169,7 +210,8 @@ public class CompilationUnitCacheTest { File directory = new File( ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI()); String docUri = directory.toPath().resolve("src/main/java/example/HelloWorldController.java").toUri().toString(); - + MavenJavaProject project = projects.mavenProject("test-request-mapping-live-hover"); + harness.useProject(project); harness.intialize(directory); URI fileUri = new URI(docUri); @@ -183,7 +225,7 @@ public class CompilationUnitCacheTest { CompilationUnit cuAnother = getCompilationUnit(document); assertTrue(cu == cuAnother); - harness.deleteFile(directory.toPath().resolve(MavenCore.POM_XML).toUri().toString()); + projectObserver.doWithListeners(l -> l.deleted(project)); cuAnother = getCompilationUnit(document); assertNotNull(cuAnother); assertFalse(cu == cuAnother); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/MockProjectObserver.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/MockProjectObserver.java new file mode 100644 index 000000000..32fe67ee2 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/MockProjectObserver.java @@ -0,0 +1,29 @@ +package org.springframework.ide.vscode.boot.java.utils.test; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver; +import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener; + +public class MockProjectObserver implements ProjectObserver { + + List listeners = new ArrayList<>(); + + @Override + synchronized public void addListener(Listener l) { + listeners.add(l); + } + + @Override + synchronized public void removeListener(Listener l) { + listeners.remove(l); + } + + public synchronized void doWithListeners(Consumer action) { + for (Listener l : listeners) { + action.accept(l); + } + } +} \ No newline at end of file diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/SpringIndexerTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/SpringIndexerTest.java index e0b289444..bcec899dd 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/SpringIndexerTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/SpringIndexerTest.java @@ -27,35 +27,44 @@ import org.eclipse.lsp4j.SymbolInformation; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf; import org.springframework.ide.vscode.boot.java.utils.SpringIndexer; import org.springframework.ide.vscode.commons.java.IJavaProject; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; import org.springframework.ide.vscode.commons.util.Assert; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * @author Martin Lippert */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(SymbolProviderTestConf.class) public class SpringIndexerTest { - private BootJavaLanguageServerHarness harness; + @Autowired private BootLanguageServerHarness harness; + @Autowired private SpringIndexer indexer; + @Autowired private JavaProjectFinder projectFinder; + private File directory; - private SpringIndexer indexer; private String projectDir; private IJavaProject project; @Before public void setup() throws Exception { - harness = BootJavaLanguageServerHarness.builder().build(); - harness.intialize(null); - indexer = harness.getServerWrapper().getComponents().getSpringIndexer(); directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-parent/test-annotation-indexing/").toURI()); projectDir = directory.toURI().toString(); // trigger project creation - project = harness.getServerWrapper().getComponents().getProjectFinder().find(new TextDocumentIdentifier(projectDir)).get(); + project = projectFinder.find(new TextDocumentIdentifier(projectDir)).get(); CompletableFuture initProject = indexer.waitOperation(); initProject.get(5, TimeUnit.SECONDS); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/SpringPropertyIndexTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/SpringPropertyIndexTest.java index cb099ceac..8467d3535 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/SpringPropertyIndexTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/SpringPropertyIndexTest.java @@ -20,6 +20,11 @@ import java.io.File; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf; import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents; import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider; import org.springframework.ide.vscode.commons.languageserver.ProgressService; @@ -28,8 +33,9 @@ import org.springframework.ide.vscode.commons.maven.MavenCore; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.commons.util.text.TextDocument; import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * Tests for Spring properties index in Boot Java server @@ -37,21 +43,20 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness; * @author Alex Boyko * */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(SymbolProviderTestConf.class) public class SpringPropertyIndexTest { - private LanguageServerHarness> harness; + @Autowired + private LanguageServerHarness harness; + @Autowired private DefaultSpringPropertyIndexProvider propertyIndexProvider; - @Before - public void setup() throws Exception { - harness = BootJavaLanguageServerHarness.builder().build(); - } - @Test public void testPropertiesIndexRefreshOnProjectChange() throws Exception { harness.intialize(new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-parent/test-annotation-indexing/").toURI())); - propertyIndexProvider = (DefaultSpringPropertyIndexProvider) harness.getServerWrapper().getComponents().getSpringPropertyIndexProvider(); File directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-parent/test-annotation-indexing/").toURI()); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/value/test/ValueCompletionTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/value/test/ValueCompletionTest.java index 4a3004a55..2af35ef3c 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/value/test/ValueCompletionTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/value/test/ValueCompletionTest.java @@ -21,38 +21,79 @@ import org.apache.commons.io.IOUtils; import org.eclipse.lsp4j.CompletionItem; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.ide.vscode.boot.app.BootLanguageServerParams; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness; +import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider; import org.springframework.ide.vscode.boot.java.value.ValueCompletionProcessor; import org.springframework.ide.vscode.commons.java.IJavaProject; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver; +import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; +import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; -import org.springframework.ide.vscode.project.harness.BootJavaLanguageServerHarness; +import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; -import org.springframework.ide.vscode.project.harness.PropertyIndexHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * @author Martin Lippert */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest public class ValueCompletionTest { - private BootJavaLanguageServerHarness harness; - private IJavaProject testProject; + @Autowired private BootLanguageServerHarness harness; + @Autowired private IJavaProject testProject; private Editor editor; - private PropertyIndexHarness indexHarness; + @Autowired private PropertyIndexHarness indexHarness; + + @Configuration static class TestConf { + + //Somewhat strange test setup, test provides a specific test project. + //The project finder finds this test project, + //But it is not used in the indexProvider/harness. + //this is a bit odd... but we preserved the strangeness how it was. + + @Bean MavenJavaProject testProject() throws Exception { + return ProjectsHarness.INSTANCE.mavenProject("test-annotations"); + } + + @Bean PropertyIndexHarness indexHarness() { + return new PropertyIndexHarness(); + } + + @Bean JavaProjectFinder projectFinder(MavenJavaProject testProject) { + return (doc) -> Optional.of(testProject); + } + + @Bean BootLanguageServerHarness harness(SimpleLanguageServer server, BootLanguageServerParams serverParams, PropertyIndexHarness indexHarness, JavaProjectFinder projectFinder) throws Exception { + return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java"); + } + + @Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, JavaProjectFinder projectFinder) { + BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault().create(server); + return new BootLanguageServerParams( + projectFinder, + ProjectObserver.NULL, + indexHarness().getIndexProvider(), + indexHarness().getAdHocIndexProvider(), + testDefaults.typeUtilProvider, + RunningAppProvider.NULL, + null + ); + } + } @Before public void setup() throws Exception { - //Somewhat strange test setup, test provides a specific test project. - // The context finder finds this test project, - // But it is not used in the indexProvider. - //This is a bit odd... but we preserved the strangeness how it was. - testProject = ProjectsHarness.INSTANCE.mavenProject("test-annotations"); - harness = BootJavaLanguageServerHarness.builder() - .mockDefaults() - .projectFinder(d -> Optional.ofNullable(getTestProject())) - .build(); - indexHarness = harness.getPropertyIndexHarness(); harness.intialize(null); } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java index c56194ef0..56414a443 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java @@ -23,26 +23,28 @@ import java.util.List; import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.Diagnostic; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.springframework.ide.vscode.boot.BootLanguageServer; -import org.springframework.ide.vscode.boot.BootLanguageServerParams; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.app.BootLanguageServerInitializer; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.PropertyEditorTestConf; import org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest; import org.springframework.ide.vscode.boot.editor.harness.StyledStringMatcher; -import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider; -import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog; import org.springframework.ide.vscode.boot.metadata.CachingValueProvider; import org.springframework.ide.vscode.boot.metadata.PropertiesLoader; -import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndex; import org.springframework.ide.vscode.commons.java.IJavaProject; import org.springframework.ide.vscode.commons.java.IType; -import org.springframework.ide.vscode.commons.languageserver.composable.ComposableLanguageServer; -import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver; -import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; import org.springframework.ide.vscode.project.harness.ProjectsHarness.ProjectCustomizer; +import org.springframework.test.context.junit4.SpringRunner; import com.google.common.collect.ImmutableList; import com.google.common.io.Files; @@ -52,8 +54,20 @@ import com.google.common.io.Files; * * @author Alex Boyko */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(PropertyEditorTestConf.class) public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { + @Configuration static class TestConf { + @Bean LanguageId defaultLanguageId() { + return LanguageId.BOOT_PROPERTIES; + } + @Bean String defaultFileExtension() { + return ".properties"; + } + } + private static final ProjectCustomizer WITH_EMPTY_APPLICATION_YML = projectContents -> { projectContents.createFile("src/main/resources/application.yml", ""); }; @@ -78,7 +92,6 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { editor.assertProblems("problem|extraneous input", "another|mismatched input"); } - @Test public void bug_158348104() throws Exception { //See: https://www.pivotaltracker.com/story/show/158348104 data("spring.activemq.close-timeout", "java.time.Duration", null, null); @@ -1653,23 +1666,6 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { ////////////// harness code below ///////////////////////// - @Override - protected SimpleLanguageServer newLanguageServer() { - ComposableLanguageServer server = BootLanguageServer.create( - s -> new BootLanguageServerParams( - javaProjectFinder, - ProjectObserver.NULL, - md.getIndexProvider(), - (doc) -> SpringPropertyIndex.EMPTY_INDEX, - typeUtilProvider, - RunningAppProvider.NULL, - SpringLiveHoverWatchdog.DEFAULT_INTERVAL - ) - ); - server.setMaxCompletionsNumber(-1); - return server.getServer(); - } - /** * Like 'assertCompletionsBasic' but places the 'textBefore' in a context * with other text around it... trying several different variations of diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java index e45d57fce..6fbc106f3 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java @@ -20,25 +20,25 @@ import java.util.Optional; import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.Diagnostic; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.springframework.ide.vscode.boot.BootLanguageServer; -import org.springframework.ide.vscode.boot.BootLanguageServerParams; +import org.junit.runner.RunWith; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.PropertyEditorTestConf; import org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest; import org.springframework.ide.vscode.boot.editor.harness.StyledStringMatcher; -import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider; -import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog; import org.springframework.ide.vscode.boot.metadata.CachingValueProvider; import org.springframework.ide.vscode.boot.metadata.PropertyInfo; -import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndex; import org.springframework.ide.vscode.commons.java.IJavaProject; -import org.springframework.ide.vscode.commons.languageserver.composable.ComposableLanguageServer; -import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver; -import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; import org.springframework.ide.vscode.commons.util.RunnableWithException; import org.springframework.ide.vscode.commons.util.StringUtil; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.languageserver.testharness.Editor; +import org.springframework.test.context.junit4.SpringRunner; /** * This class is a placeholder where we will attempt to copy and port @@ -47,8 +47,20 @@ import org.springframework.ide.vscode.languageserver.testharness.Editor; * * @author Kris De Volder */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(PropertyEditorTestConf.class) public class ApplicationYamlEditorTest extends AbstractPropsEditorTest { + @Configuration static class TestConf { + @Bean LanguageId defaultLanguageId() { + return LanguageId.BOOT_PROPERTIES_YAML; + } + @Bean String defaultFileExtension() { + return ".yml"; + } + } + //////////////////////////////////////////////////////////////////////////////////////// @Test public void bug_158348104() throws Exception { @@ -3895,23 +3907,6 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest { return string; } - @Override - protected SimpleLanguageServer newLanguageServer() { - ComposableLanguageServer server = BootLanguageServer.create( - s -> new BootLanguageServerParams( - javaProjectFinder, - ProjectObserver.NULL, - md.getIndexProvider(), - (doc) -> SpringPropertyIndex.EMPTY_INDEX, - typeUtilProvider, - RunningAppProvider.NULL, - SpringLiveHoverWatchdog.DEFAULT_INTERVAL - ) - ); - server.setMaxCompletionsNumber(-1); - return server.getServer(); - } - @Override protected String getFileExtension() { return ".yml"; diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/SpringPropertiesIndexTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/SpringPropertiesIndexTest.java index a6a21b236..7c6bf14e7 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/SpringPropertiesIndexTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/SpringPropertiesIndexTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.springframework.ide.vscode.boot.test; -import static org.mockito.Matchers.anyObject; +import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -18,20 +18,20 @@ import static org.mockito.Mockito.verify; import java.io.File; -import org.junit.Before; import org.junit.Test; -import org.springframework.ide.vscode.boot.BootLanguageServer; -import org.springframework.ide.vscode.boot.BootLanguageServerParams; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; +import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf; import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider; -import org.springframework.ide.vscode.boot.properties.BootPropertiesLanguageServerComponents; import org.springframework.ide.vscode.commons.languageserver.ProgressService; -import org.springframework.ide.vscode.commons.languageserver.composable.ComposableLanguageServer; -import org.springframework.ide.vscode.commons.languageserver.composable.CompositeLanguageServerComponents; import org.springframework.ide.vscode.commons.maven.MavenCore; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.commons.util.text.TextDocument; import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; import org.springframework.ide.vscode.project.harness.ProjectsHarness; +import org.springframework.test.context.junit4.SpringRunner; /** * Tests for Boot properties index @@ -39,23 +39,20 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness; * @author Alex Boyko * */ +@RunWith(SpringRunner.class) +@BootLanguageServerTest +@Import(SymbolProviderTestConf.class) public class SpringPropertiesIndexTest { - private LanguageServerHarness> harness; + @Autowired + private LanguageServerHarness harness; + @Autowired private DefaultSpringPropertyIndexProvider propertyIndexProvider; - @Before - public void setup() throws Exception { - harness = new LanguageServerHarness<>(() -> BootLanguageServer.create(BootLanguageServerParams.createTestDefault())); - } - @Test public void testPropertiesIndexRefreshOnProjectChange() throws Exception { harness.intialize(new File(ProjectsHarness.class.getResource("/test-projects/boot-1.2.0-properties-live-metadta/").toURI())); - propertyIndexProvider = (DefaultSpringPropertyIndexProvider) harness.getServerWrapper() - .getComponents().get(BootPropertiesLanguageServerComponents.class) - .getPropertiesIndexProvider(); File directory = new File(ProjectsHarness.class.getResource("/test-projects/boot-1.2.0-properties-live-metadta/").toURI()); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/BootJavaLanguageServerHarness.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/BootJavaLanguageServerHarness.java deleted file mode 100644 index 6c7b565c6..000000000 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/BootJavaLanguageServerHarness.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.project.harness; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.time.Duration; - -import org.junit.Assert; -import org.springframework.ide.vscode.boot.BootLanguageServer; -import org.springframework.ide.vscode.boot.BootLanguageServerParams; -import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents; -import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider; -import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider; -import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider; -import org.springframework.ide.vscode.commons.java.IClasspath; -import org.springframework.ide.vscode.commons.java.IJavaProject; -import org.springframework.ide.vscode.commons.languageserver.composable.ComposableLanguageServer; -import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; -import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver; -import org.springframework.ide.vscode.commons.languageserver.jdt.ls.Classpath; -import org.springframework.ide.vscode.commons.languageserver.jdt.ls.Classpath.CPE; -import org.springframework.ide.vscode.commons.languageserver.util.LSFactory; -import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; - -public class BootJavaLanguageServerHarness extends LanguageServerHarness> { - - private PropertyIndexHarness indexHarness; - private final JavaProjectFinder projectFinder = (doc) -> getServerWrapper().getComponents().getProjectFinder().find(doc); - - /** - * Creates a builder and initializes it so that it sets up a test harness with - * the 'real stuff'. I.e project finder and other injected components are like - * they would be in 'production' environment. - *

- * Builder methods can still be called to replace some of the components with - * mocks selectively. - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - LSFactory defaultsFactory = BootLanguageServerParams.createTestDefault(); - private JavaProjectFinder projectFinder = null; - private ProjectObserver projectObserver = null; - private SpringPropertyIndexProvider indexProvider = null; - private SpringPropertyIndexProvider adHocIndexProvider = null; - private RunningAppProvider runningAppProvider = null; - private PropertyIndexHarness indexHarness = null; - private Duration watchDogInterval = null; - private TypeUtilProvider typeUtilProvider = null; - - public BootJavaLanguageServerHarness build() throws Exception { - BootJavaLanguageServerHarness harness = new BootJavaLanguageServerHarness(this); - return harness; - } - - public Builder mockDefaults() { - indexHarness = new PropertyIndexHarness(); - projectFinder = indexHarness.getProjectFinder(); - indexProvider = indexHarness.getIndexProvider(); - adHocIndexProvider = indexHarness.adHocIndexProvider; - projectObserver = ProjectObserver.NULL; - runningAppProvider = RunningAppProvider.NULL; - return this; - } - - public Builder runningAppProvider(RunningAppProvider provider) { - this.runningAppProvider = () -> provider.getAllRunningSpringApps(); - return this; - } - - public Builder projectFinder(JavaProjectFinder projectFinder) { - this.projectFinder = projectFinder; - return this; - } - - public Builder propertyIndexProvider(SpringPropertyIndexProvider propertyIndexProvider) { - this.indexProvider = propertyIndexProvider; - return this; - } - - public Builder watchDogInterval(Duration watchDogInterval) { - this.watchDogInterval = watchDogInterval; - return this; - } - } - - /** - * This constructor is private. Use the builder api instead. - */ - private BootJavaLanguageServerHarness(Builder builder) throws Exception { - super(() -> { - LSFactory params = (server) -> { - BootLanguageServerParams defaults = BootLanguageServerParams.createTestDefault().create(server); - return new BootLanguageServerParams( - builder.projectFinder==null?defaults.projectFinder:builder.projectFinder, - builder.projectObserver==null?defaults.projectObserver:builder.projectObserver, - builder.indexProvider==null?defaults.indexProvider:builder.indexProvider, - builder.adHocIndexProvider==null?defaults.adHocIndexProvider:builder.adHocIndexProvider, - builder.typeUtilProvider==null?defaults.typeUtilProvider:builder.typeUtilProvider, - builder.runningAppProvider==null?defaults.runningAppProvider:builder.runningAppProvider, - builder.watchDogInterval==null?defaults.watchDogInterval:builder.watchDogInterval - ); - }; - return BootLanguageServer.createJava(params); - }); - this.indexHarness = builder.indexHarness; - } - - public BootLanguageServerParams getServerParams() { - return getServerWrapper().getComponents().getServerParams(); - } - - - - @Override - protected String getFileExtension() { - return ".java"; - } - - public JavaProjectFinder getProjectFinder() { - return projectFinder; - } - - public PropertyIndexHarness getPropertyIndexHarness() { - Assert.assertNotNull(indexHarness); //only supported in some types of instantations of the harness (i.e. when indexer is controlled by indexer harness. - return indexHarness; - } - - public void useProject(IJavaProject p) throws Exception { - indexHarness.useProject(p); - } - - public Path getOutputFolder() throws Exception { - IClasspath classpath = getProjectFinder().find(null).get().getClasspath(); - for (CPE cpe : classpath.getClasspathEntries()) { - if (Classpath.isSource(cpe)) { - if (cpe.getPath().endsWith("main/java")) { - return Paths.get(cpe.getOutputFolder()); - } - } - } - return null; - } - -} diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/BootLanguageServerHarness.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/BootLanguageServerHarness.java new file mode 100644 index 000000000..ca0386965 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/BootLanguageServerHarness.java @@ -0,0 +1,148 @@ +/******************************************************************************* + * Copyright (c) 2017 Pivotal, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.vscode.project.harness; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.Assert; +import org.springframework.ide.vscode.boot.app.BootLanguageServerParams; +import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness; +import org.springframework.ide.vscode.commons.java.IClasspath; +import org.springframework.ide.vscode.commons.java.IJavaProject; +import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; +import org.springframework.ide.vscode.commons.languageserver.jdt.ls.Classpath; +import org.springframework.ide.vscode.commons.languageserver.jdt.ls.Classpath.CPE; +import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; +import org.springframework.ide.vscode.commons.util.text.LanguageId; +import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; + +public class BootLanguageServerHarness extends LanguageServerHarness { + + private final PropertyIndexHarness indexHarness; + private final JavaProjectFinder projectFinder; + private final BootLanguageServerParams serverParams; + private final String defaultFileExtension; + +// /** +// * Creates a builder and initializes it so that it sets up a test harness with +// * the 'real stuff'. I.e project finder and other injected components are like +// * they would be in 'production' environment. +// *

+// * Builder methods can still be called to replace some of the components with +// * mocks selectively. +// */ +// public static Builder builder() { +// return new Builder(); +// } +// +// public static class Builder { +// +// LSFactory defaultsFactory = BootLanguageServerParams.createTestDefault(); +// private JavaProjectFinder projectFinder = null; +// private ProjectObserver projectObserver = null; +// private SpringPropertyIndexProvider indexProvider = null; +// private SpringPropertyIndexProvider adHocIndexProvider = null; +// private RunningAppProvider runningAppProvider = null; +// private PropertyIndexHarness indexHarness = null; +// private Duration watchDogInterval = null; +// private TypeUtilProvider typeUtilProvider = null; +// +// public BootJavaLanguageServerHarness build() throws Exception { +// BootJavaLanguageServerHarness harness = new BootJavaLanguageServerHarness(this); +// return harness; +// } +// +// public Builder mockDefaults() { +// indexHarness = new PropertyIndexHarness(); +// projectFinder = indexHarness.getProjectFinder(); +// indexProvider = indexHarness.getIndexProvider(); +// adHocIndexProvider = indexHarness.adHocIndexProvider; +// projectObserver = ProjectObserver.NULL; +// runningAppProvider = RunningAppProvider.NULL; +// return this; +// } +// +// public Builder runningAppProvider(RunningAppProvider provider) { +// this.runningAppProvider = () -> provider.getAllRunningSpringApps(); +// return this; +// } +// +// public Builder projectFinder(JavaProjectFinder projectFinder) { +// this.projectFinder = projectFinder; +// return this; +// } +// +// public Builder propertyIndexProvider(SpringPropertyIndexProvider propertyIndexProvider) { +// this.indexProvider = propertyIndexProvider; +// return this; +// } +// +// public Builder watchDogInterval(Duration watchDogInterval) { +// this.watchDogInterval = watchDogInterval; +// return this; +// } +// } + + /** + * This constructor is private. Use the builder api instead. + * @param projectFinder + */ + public BootLanguageServerHarness( + SimpleLanguageServer server, + BootLanguageServerParams serverParams, + PropertyIndexHarness indexHarness, + JavaProjectFinder projectFinder, + LanguageId defaultLanguageId, + String defaultFileExtension + ) throws Exception { + super(server, defaultLanguageId); + this.serverParams = serverParams; + this.indexHarness = indexHarness; + this.projectFinder = projectFinder; + this.defaultFileExtension = defaultFileExtension; + } + + public BootLanguageServerParams getServerParams() { + return serverParams; + } + + @Override + protected String getFileExtension() { + return defaultFileExtension; + } + + public JavaProjectFinder getProjectFinder() { + return projectFinder; + } + + public PropertyIndexHarness getPropertyIndexHarness() { + Assert.assertNotNull(indexHarness); //only supported in some types of instantations of the harness (i.e. when indexer is controlled by indexer harness. + return indexHarness; + } + + public void useProject(IJavaProject p) throws Exception { + indexHarness.useProject(p); + } + + public Path getOutputFolder() throws Exception { + IClasspath classpath = getProjectFinder().find(null).get().getClasspath(); + for (CPE cpe : classpath.getClasspathEntries()) { + if (Classpath.isSource(cpe)) { + if (cpe.getPath().endsWith("main/java")) { + return Paths.get(cpe.getOutputFolder()); + } + } + } + return null; + } + +} diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/PropertyIndexHarness.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/PropertyIndexHarness.java deleted file mode 100644 index 62bfb1641..000000000 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/project/harness/PropertyIndexHarness.java +++ /dev/null @@ -1,586 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.project.harness; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty; -import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation; -import org.springframework.ide.vscode.boot.configurationmetadata.ValueHint; -import org.springframework.ide.vscode.boot.configurationmetadata.ValueProvider; -import org.springframework.ide.vscode.boot.metadata.PropertyInfo; -import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndex; -import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider; -import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry; -import org.springframework.ide.vscode.commons.java.IClasspath; -import org.springframework.ide.vscode.commons.java.IJavaProject; -import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; -import org.springframework.ide.vscode.commons.util.FuzzyMap; -import org.springframework.ide.vscode.commons.util.text.IDocument; - -/** - * Provides some convenience apis for test code to create / use test data for a SpringPropertyIndex. - */ -public class PropertyIndexHarness { - - private Map datas = new LinkedHashMap<>(); - private SpringPropertyIndex index = null; - private FuzzyMap adHocProperties = new FuzzyMap() { - @Override - protected String getKey(PropertyInfo entry) { - return entry.getId(); - } - }; - private IJavaProject testProject = null; - - protected final SpringPropertyIndexProvider indexProvider = new SpringPropertyIndexProvider() { - @Override - public FuzzyMap getIndex(IDocument doc) { - synchronized (PropertyIndexHarness.this) { - if (index==null) { - IClasspath classpath = testProject == null ? null : testProject.getClasspath(); - index = new SpringPropertyIndex(ValueProviderRegistry.getDefault(), classpath); - for (ConfigurationMetadataProperty propertyInfo : datas.values()) { - index.add(propertyInfo); - } - } - return index; - } - } - }; - - protected final SpringPropertyIndexProvider adHocIndexProvider = doc -> adHocProperties; - - public synchronized void useProject(IJavaProject p) throws Exception { - index = null; - this.testProject = p; - } - - public class ItemConfigurer { - - private ConfigurationMetadataProperty item; - - public ItemConfigurer(ConfigurationMetadataProperty item) { - this.item = item; - } - - /** - * Add a provider with a single parameter. - * @return - */ - public ItemConfigurer provider(String name, String paramName, Object paramValue) { - ValueProvider provider = new ValueProvider(); - provider.setName(name); - provider.getParameters().put(paramName, paramValue); - item.getHints().getValueProviders().add(provider); - return this; - } - - /** - * Add a value hint. If description contains a '.' the dot is used - * to break description into a short and long description. - * @return - */ - public ItemConfigurer valueHint(Object value, String description) { - ValueHint hint = new ValueHint(); - hint.setValue(value); - if (description!=null) { - int dotPos = description.indexOf('.'); - if (dotPos>=0) { - hint.setShortDescription( description.substring(0, dotPos)); - } - hint.setDescription(description); - } - item.getHints().getValueHints().add(hint); - return this; - } - } - - - public synchronized ItemConfigurer data(String id, String type, Object deflt, String description, - String... source - ) { - ConfigurationMetadataProperty item = new ConfigurationMetadataProperty(); - item.setId(id); - item.setDescription(description); - item.setType(type); - item.setDefaultValue(deflt); - index = null; - datas.put(item.getId(), item); - return new ItemConfigurer(item); - } - - public synchronized void keyHints(String id, String... hintValues) { - index = null; - List hints = datas.get(id).getHints().getKeyHints(); - for (String value : hintValues) { - ValueHint hint = new ValueHint(); - hint.setValue(value); - hints.add(hint); - } - } - - public synchronized void valueHints(String id, String... hintValues) { - index = null; - List hints = datas.get(id).getHints().getValueHints(); - for (String value : hintValues) { - ValueHint hint = new ValueHint(); - hint.setValue(value); - hints.add(hint); - } - } - - public synchronized void deprecate(String key, String replacedBy, String reason) { - index = null; - ConfigurationMetadataProperty info = datas.get(key); - Deprecation d = new Deprecation(); - d.setReplacement(replacedBy); - d.setReason(reason); - info.setDeprecation(d); - } - - /** - * Call this method to add some default test data to the Completion engine's index. - * Note that this data is not added automatically, some test may want to use smaller - * test data sets. - */ - public void defaultTestData() { - data("banner.charset", "java.nio.charset.Charset", "UTF-8", "Banner file encoding."); - data("banner.location", "java.lang.String", "classpath:banner.txt", "Banner file location."); - data("debug", "java.lang.Boolean", "false", "Enable debug logs."); - data("flyway.check-location", "java.lang.Boolean", "false", "Check that migration scripts location exists."); - data("flyway.clean-on-validation-error", "java.lang.Boolean", null, null); - data("flyway.enabled", "java.lang.Boolean", "true", "Enable flyway."); - data("flyway.encoding", "java.lang.String", null, null); - data("flyway.ignore-failed-future-migration", "java.lang.Boolean", null, null); - data("flyway.init-description", "java.lang.String", null, null); - data("flyway.init-on-migrate", "java.lang.Boolean", null, null); - data("flyway.init-sqls", "java.util.List", null, "SQL statements to execute to initialize a connection immediately after obtaining\n it."); - data("flyway.init-version", "org.flywaydb.core.api.MigrationVersion", null, null); - data("flyway.locations", "java.util.List", null, "Locations of migrations scripts."); - data("flyway.out-of-order", "java.lang.Boolean", null, null); - data("flyway.password", "java.lang.String", null, "Login password of the database to migrate."); - data("flyway.placeholder-prefix", "java.lang.String", null, null); - data("flyway.placeholders", "java.util.Map", null, null); - data("flyway.placeholder-suffix", "java.lang.String", null, null); - data("flyway.schemas", "java.lang.String[]", null, null); - data("flyway.sql-migration-prefix", "java.lang.String", null, null); - data("flyway.sql-migration-separator", "java.lang.String", null, null); - data("flyway.sql-migration-suffix", "java.lang.String", null, null); - data("flyway.table", "java.lang.String", null, null); - data("flyway.target", "org.flywaydb.core.api.MigrationVersion", null, null); - data("flyway.url", "java.lang.String", null, "JDBC url of the database to migrate. If not set, the primary configured data source\n is used."); - data("flyway.user", "java.lang.String", null, "Login user of the database to migrate."); - data("flyway.validate-on-migrate", "java.lang.Boolean", null, null); - data("http.mappers.json-pretty-print", "java.lang.Boolean", null, "Enable json pretty print."); - data("http.mappers.json-sort-keys", "java.lang.Boolean", null, "Enable key sorting."); - data("liquibase.change-log", "java.lang.String", "classpath:/db/changelog/db.changelog-master.yaml", "Change log configuration path."); - data("liquibase.check-change-log-location", "java.lang.Boolean", "true", "Check the change log location exists."); - data("liquibase.contexts", "java.lang.String", null, "Comma-separated list of runtime contexts to use."); - data("liquibase.default-schema", "java.lang.String", null, "Default database schema."); - data("liquibase.drop-first", "java.lang.Boolean", "false", "Drop the database schema first."); - data("liquibase.enabled", "java.lang.Boolean", "true", "Enable liquibase support."); - data("liquibase.password", "java.lang.String", null, "Login password of the database to migrate."); - data("liquibase.url", "java.lang.String", null, "JDBC url of the database to migrate. If not set, the primary configured data source\n is used."); - data("liquibase.user", "java.lang.String", null, "Login user of the database to migrate."); - data("logging.config", "java.lang.String", null, "Location of the logging configuration file."); - data("logging.file", "java.lang.String", null, "Log file name."); - data("logging.level", "java.util.Map", null, "Log levels severity mapping. Use 'root' for the root logger."); - data("logging.path", "java.lang.String", null, "Location of the log file."); - data("multipart.file-size-threshold", "java.lang.String", "0", "Threshold after which files will be written to disk. Values can use the suffixed\n \"MB\" or \"KB\" to indicate a Megabyte or Kilobyte size."); - data("multipart.location", "java.lang.String", null, "Intermediate location of uploaded files."); - data("multipart.max-file-size", "java.lang.String", "1Mb", "Max file size. Values can use the suffixed \"MB\" or \"KB\" to indicate a Megabyte or\n Kilobyte size."); - data("multipart.max-request-size", "java.lang.String", "10Mb", "Max request size. Values can use the suffixed \"MB\" or \"KB\" to indicate a Megabyte\n or Kilobyte size."); - data("security.basic.enabled", "java.lang.Boolean", "true", "Enable basic authentication."); - data("security.basic.path", "java.lang.String[]", "[Ljava.lang.Object;@7abd0056", "Comma-separated list of paths to secure."); - data("security.basic.realm", "java.lang.String", "Spring", "HTTP basic realm name."); - data("security.enable-csrf", "java.lang.Boolean", "false", "Enable Cross Site Request Forgery support."); - data("security.filter-order", "java.lang.Integer", "0", "Security filter chain order."); - data("security.headers.cache", "java.lang.Boolean", "false", "Enable cache control HTTP headers."); - data("security.headers.content-type", "java.lang.Boolean", "false", "Enable \"X-Content-Type-Options\" header."); - data("security.headers.frame", "java.lang.Boolean", "false", "Enable \"X-Frame-Options\" header."); - data("security.headers.hsts", "org.springframework.boot.autoconfigure.security.SecurityProperties$Headers$HSTS", null, "HTTP Strict Transport Security (HSTS) mode (none, domain, all)."); - data("security.headers.xss", "java.lang.Boolean", "false", "Enable cross site scripting (XSS) protection."); - data("security.ignored", "java.util.List", null, "Comma-separated list of paths to exclude from the default secured paths."); - data("security.require-ssl", "java.lang.Boolean", "false", "Enable secure channel for all requests."); - data("security.sessions", "org.springframework.security.config.http.SessionCreationPolicy", null, "Session creation policy (always, never, if_required, stateless)."); - data("security.user.name", "java.lang.String", "user", "Default user name."); - data("security.user.password", "java.lang.String", null, "Password for the default user name."); - data("security.user.role", "java.util.List", null, "Granted roles for the default user name."); - data("server.address", "java.net.InetAddress", null, "Network address to which the server should bind to."); - data("server.context-parameters", "java.util.Map", null, "ServletContext parameters."); - data("server.context-path", "java.lang.String", null, "Context path of the application."); - data("server.port", "java.lang.Integer", null, "Server HTTP port."); - data("server.servlet-path", "java.lang.String", "/", "Path of the main dispatcher servlet."); - data("server.session-timeout", "java.lang.Integer", null, "Session timeout in seconds."); - data("server.ssl.ciphers", "java.lang.String[]", null, null); - data("server.ssl.client-auth", "org.springframework.boot.context.embedded.Ssl$ClientAuth", null, null); - data("server.ssl.key-alias", "java.lang.String", null, null); - data("server.ssl.key-password", "java.lang.String", null, null); - data("server.ssl.key-store", "java.lang.String", null, null); - data("server.ssl.key-store-password", "java.lang.String", null, null); - data("server.ssl.key-store-provider", "java.lang.String", null, null); - data("server.ssl.key-store-type", "java.lang.String", null, null); - data("server.ssl.protocol", "java.lang.String", null, null); - data("server.ssl.trust-store", "java.lang.String", null, null); - data("server.ssl.trust-store-password", "java.lang.String", null, null); - data("server.ssl.trust-store-provider", "java.lang.String", null, null); - data("server.ssl.trust-store-type", "java.lang.String", null, null); - data("server.tomcat.access-log-enabled", "java.lang.Boolean", "false", "Enable access log."); - data("server.tomcat.access-log-pattern", "java.lang.String", null, "Format pattern for access logs."); - data("server.tomcat.background-processor-delay", "java.lang.Integer", "30", "Delay in seconds between the invocation of backgroundProcess methods."); - data("server.tomcat.basedir", "java.io.File", null, "Tomcat base directory. If not specified a temporary directory will be used."); - data("server.tomcat.internal-proxies", "java.lang.String", "10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|192\\.168\\.\\d{1,3}\\.\\d{1,3}|169\\.254\\.\\d{1,3}\\.\\d{1,3}|127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}", "Regular expression that matches proxies that are to be trusted."); - data("server.tomcat.max-http-header-size", "java.lang.Integer", "0", "Maximum size in bytes of the HTTP message header."); - data("server.tomcat.max-threads", "java.lang.Integer", "0", "Maximum amount of worker threads."); - data("server.tomcat.port-header", "java.lang.String", null, "Name of the HTTP header used to override the original port value."); - data("server.tomcat.protocol-header", "java.lang.String", null, "Header that holds the incoming protocol, usually named \"X-Forwarded-Proto\".\n Configured as a RemoteIpValve only if remoteIpHeader is also set."); - data("server.tomcat.remote-ip-header", "java.lang.String", null, "Name of the http header from which the remote ip is extracted. Configured as a\n RemoteIpValve only if remoteIpHeader is also set."); - data("server.tomcat.uri-encoding", "java.lang.String", null, "Character encoding to use to decode the URI."); - data("server.undertow.buffer-size", "java.lang.Integer", null, "Size of each buffer in bytes."); - data("server.undertow.buffers-per-region", "java.lang.Integer", null, "Number of buffer per region."); - data("server.undertow.direct-buffers", "java.lang.Boolean", null, null); - data("server.undertow.io-threads", "java.lang.Integer", null, "Number of I/O threads to create for the worker."); - data("server.undertow.worker-threads", "java.lang.Integer", null, "Number of worker threads."); - data("spring.activemq.broker-url", "java.lang.String", null, "URL of the ActiveMQ broker. Auto-generated by default."); - data("spring.activemq.in-memory", "java.lang.Boolean", "true", "Specify if the default broker URL should be in memory. Ignored if an explicit\n broker has been specified."); - data("spring.activemq.password", "java.lang.String", null, "Login password of the broker."); - data("spring.activemq.pooled", "java.lang.Boolean", "false", "Specify if a PooledConnectionFactory should be created instead of a regular\n ConnectionFactory."); - data("spring.activemq.user", "java.lang.String", null, "Login user of the broker."); - data("spring.aop.auto", "java.lang.Boolean", "true", "Add @EnableAspectJAutoProxy."); - data("spring.aop.proxy-target-class", "java.lang.Boolean", "false", "Whether subclass-based (CGLIB) proxies are to be created (true) as opposed to standard Java interface-based proxies (false)."); - data("spring.application.index", "java.lang.Integer", null, "Application index."); - data("spring.application.name", "java.lang.String", null, "Application name."); - data("spring.batch.initializer.enabled", "java.lang.Boolean", "true", "Create the required batch tables on startup if necessary."); - data("spring.batch.job.enabled", "java.lang.Boolean", "true", "Execute all Spring Batch jobs in the context on startup."); - data("spring.batch.job.names", "java.lang.String", "", "Comma-separated list of job names to execute on startup. By default, all Jobs\n found in the context are executed."); - data("spring.batch.schema", "java.lang.String", "classpath:org/springframework/batch/core/schema-@@platform@@.sql", "Path to the SQL file to use to initialize the database schema."); - data("spring.config.location", "java.lang.String", null, "Config file locations."); - data("spring.config.name", "java.lang.String", "application", "Config file name."); - data("spring.dao.exceptiontranslation.enabled", "java.lang.Boolean", "true", "Enable the PersistenceExceptionTranslationPostProcessor."); - data("spring.data.elasticsearch.cluster-name", "java.lang.String", "elasticsearch", "Elasticsearch cluster name."); - data("spring.data.elasticsearch.cluster-nodes", "java.lang.String", null, "Comma-separated list of cluster node addresses. If not specified, starts a client\n node."); - data("spring.data.elasticsearch.repositories.enabled", "java.lang.Boolean", "true", "Enable Elasticsearch repositories."); - data("spring.data.jpa.repositories.enabled", "java.lang.Boolean", "true", "Enable JPA repositories."); - data("spring.data.mongodb.authentication-database", "java.lang.String", null, "Authentication database name."); - data("spring.data.mongodb.database", "java.lang.String", null, "Database name."); - data("spring.data.mongodb.grid-fs-database", "java.lang.String", null, "GridFS database name."); - data("spring.data.mongodb.host", "java.lang.String", null, "Mongo server host."); - data("spring.data.mongodb.password", "char[]", null, "Login password of the mongo server."); - data("spring.data.mongodb.port", "java.lang.Integer", null, "Mongo server port."); - data("spring.data.mongodb.repositories.enabled", "java.lang.Boolean", "true", "Enable Mongo repositories."); - data("spring.data.mongodb.uri", "java.lang.String", "mongodb://localhost/test", "Mmongo database URI. When set, host and port are ignored."); - data("spring.data.mongodb.username", "java.lang.String", null, "Login user of the mongo server."); - data("spring.data.rest.base-uri", "java.net.URI", null, null); - data("spring.data.rest.default-page-size", "java.lang.Integer", null, null); - data("spring.data.rest.limit-param-name", "java.lang.String", null, null); - data("spring.data.rest.max-page-size", "java.lang.Integer", null, null); - data("spring.data.rest.page-param-name", "java.lang.String", null, null); - data("spring.data.rest.return-body-on-create", "java.lang.Boolean", null, null); - data("spring.data.rest.return-body-on-update", "java.lang.Boolean", null, null); - data("spring.data.rest.sort-param-name", "java.lang.String", null, null); - data("spring.data.solr.host", "java.lang.String", "http://127.0.0.1:8983/solr", "Solr host. Ignored if \"zk-host\" is set."); - data("spring.data.solr.repositories.enabled", "java.lang.Boolean", "true", "Enable Solr repositories."); - data("spring.data.solr.zk-host", "java.lang.String", null, "ZooKeeper host address in the form HOST:PORT."); - data("spring.datasource.abandon-when-percentage-full", "java.lang.Integer", null, null); - data("spring.datasource.access-to-underlying-connection-allowed", "java.lang.Boolean", null, null); - data("spring.datasource.alternate-username-allowed", "java.lang.Boolean", null, null); - data("spring.datasource.auto-commit", "java.lang.Boolean", null, null); - data("spring.datasource.catalog", "java.lang.String", null, null); - data("spring.datasource.commit-on-return", "java.lang.Boolean", null, null); - data("spring.datasource.connection-customizer-class-name", "java.lang.String", null, null); - data("spring.datasource.connection-init-sql", "java.lang.String", null, null); - data("spring.datasource.connection-init-sqls", "java.util.Collection", null, null); - data("spring.datasource.connection-properties", "java.lang.String", null, null); - data("spring.datasource.connection-test-query", "java.lang.String", null, null); - data("spring.datasource.connection-timeout", "java.lang.Long", null, null); - data("spring.datasource.continue-on-error", "java.lang.Boolean", "false", "Do not stop if an error occurs while initializing the database."); - data("spring.datasource.data", "java.lang.String", null, "Data (DML) script resource reference."); - data("spring.datasource.data-source-class-name", "java.lang.String", null, null); - data("spring.datasource.data-source", "java.lang.Object", null, null); - data("spring.datasource.data-source-j-n-d-i", "java.lang.String", null, null); - data("spring.datasource.data-source-properties", "java.util.Properties", null, null); - data("spring.datasource.db-properties", "java.util.Properties", null, null); - data("spring.datasource.default-auto-commit", "java.lang.Boolean", null, null); - data("spring.datasource.default-catalog", "java.lang.String", null, null); - data("spring.datasource.default-read-only", "java.lang.Boolean", null, null); - data("spring.datasource.default-transaction-isolation", "java.lang.Integer", null, null); - data("spring.datasource.driver-class-name", "java.lang.String", null, "Fully qualified name of the JDBC driver. Auto-detected based on the URL by default."); - data("spring.datasource.fair-queue", "java.lang.Boolean", null, null); - data("spring.datasource.idle-timeout", "java.lang.Long", null, null); - data("spring.datasource.ignore-exception-on-pre-load", "java.lang.Boolean", null, null); - data("spring.datasource.initialization-fail-fast", "java.lang.Boolean", null, null); - data("spring.datasource.initialize", "java.lang.Boolean", "true", "Populate the database using 'data.sql'."); - data("spring.datasource.initial-size", "java.lang.Integer", null, null); - data("spring.datasource.init-s-q-l", "java.lang.String", null, null); - data("spring.datasource.isolate-internal-queries", "java.lang.Boolean", null, null); - data("spring.datasource.jdbc4-connection-test", "java.lang.Boolean", null, null); - data("spring.datasource.jdbc-interceptors", "java.lang.String", null, null); - data("spring.datasource.jdbc-url", "java.lang.String", null, null); - data("spring.datasource.jmx-enabled", "java.lang.Boolean", "false", "Enable JMX support (if provided by the underlying pool)."); - data("spring.datasource.jndi-name", "java.lang.String", null, "JNDI location of the datasource. Class, url, username & password are ignored when\n set."); - data("spring.datasource.leak-detection-threshold", "java.lang.Long", null, null); - data("spring.datasource.log-abandoned", "java.lang.Boolean", null, null); - data("spring.datasource.login-timeout", "java.lang.Integer", null, null); - data("spring.datasource.log-validation-errors", "java.lang.Boolean", null, null); - data("spring.datasource.max-active", "java.lang.Integer", null, null); - data("spring.datasource.max-age", "java.lang.Long", null, null); - data("spring.datasource.max-idle", "java.lang.Integer", null, null); - data("spring.datasource.maximum-pool-size", "java.lang.Integer", null, null); - data("spring.datasource.max-lifetime", "java.lang.Long", null, null); - data("spring.datasource.max-open-prepared-statements", "java.lang.Integer", null, null); - data("spring.datasource.max-wait", "java.lang.Integer", null, null); - data("spring.datasource.metric-registry", "java.lang.Object", null, null); - data("spring.datasource.min-evictable-idle-time-millis", "java.lang.Integer", null, null); - data("spring.datasource.min-idle", "java.lang.Integer", null, null); - data("spring.datasource.minimum-idle", "java.lang.Integer", null, null); - data("spring.datasource.name", "java.lang.String", null, null); - data("spring.datasource.num-tests-per-eviction-run", "java.lang.Integer", null, null); - data("spring.datasource.password", "java.lang.String", null, "Login password of the database."); - data("spring.datasource.platform", "java.lang.String", "all", "Platform to use in the schema resource (schema-${platform}.sql)."); - data("spring.datasource.pool-name", "java.lang.String", null, null); - data("spring.datasource.pool-prepared-statements", "java.lang.Boolean", null, null); - data("spring.datasource.propagate-interrupt-state", "java.lang.Boolean", null, null); - data("spring.datasource.read-only", "java.lang.Boolean", null, null); - data("spring.datasource.register-mbeans", "java.lang.Boolean", null, null); - data("spring.datasource.remove-abandoned", "java.lang.Boolean", null, null); - data("spring.datasource.remove-abandoned-timeout", "java.lang.Integer", null, null); - data("spring.datasource.rollback-on-return", "java.lang.Boolean", null, null); - data("spring.datasource.schema", "java.lang.String", null, "Schema (DDL) script resource reference."); - data("spring.datasource.separator", "java.lang.String", ";", "Statement separator in SQL initialization scripts."); - data("spring.datasource.sql-script-encoding", "java.lang.String", null, "SQL scripts encoding."); - data("spring.datasource.suspect-timeout", "java.lang.Integer", null, null); - data("spring.datasource.test-on-borrow", "java.lang.Boolean", null, null); - data("spring.datasource.test-on-connect", "java.lang.Boolean", null, null); - data("spring.datasource.test-on-return", "java.lang.Boolean", null, null); - data("spring.datasource.test-while-idle", "java.lang.Boolean", null, null); - data("spring.datasource.time-between-eviction-runs-millis", "java.lang.Integer", null, null); - data("spring.datasource.transaction-isolation", "java.lang.String", null, null); - data("spring.datasource.url", "java.lang.String", null, "JDBC url of the database."); - data("spring.datasource.use-disposable-connection-facade", "java.lang.Boolean", null, null); - data("spring.datasource.use-equals", "java.lang.Boolean", null, null); - data("spring.datasource.use-lock", "java.lang.Boolean", null, null); - data("spring.datasource.username", "java.lang.String", null, "Login user of the database."); - data("spring.datasource.validation-interval", "java.lang.Long", null, null); - data("spring.datasource.validation-query", "java.lang.String", null, null); - data("spring.datasource.validation-query-timeout", "java.lang.Integer", null, null); - data("spring.datasource.validator-class-name", "java.lang.String", null, null); - data("spring.datasource.xa.data-source-class-name", "java.lang.String", null, "XA datasource fully qualified name."); - data("spring.datasource.xa.properties", "java.util.Map", null, "Properties to pass to the XA data source."); - data("spring.freemarker.allow-request-override", "java.lang.Boolean", null, "Set whether HttpServletRequest attributes are allowed to override (hide) controller\n generated model attributes of the same name."); - data("spring.freemarker.cache", "java.lang.Boolean", null, "Enable template caching."); - data("spring.freemarker.char-set", "java.lang.String", null, null); - data("spring.freemarker.charset", "java.lang.String", null, "Template encoding."); - data("spring.freemarker.check-template-location", "java.lang.Boolean", null, "Check that the templates location exists."); - data("spring.freemarker.content-type", "java.lang.String", null, "Content-Type value."); - data("spring.freemarker.enabled", "java.lang.Boolean", null, "Enable MVC view resolution for this technology."); - data("spring.freemarker.expose-request-attributes", "java.lang.Boolean", null, "Set whether all request attributes should be added to the model prior to merging\n with the template."); - data("spring.freemarker.expose-session-attributes", "java.lang.Boolean", null, "Set whether all HttpSession attributes should be added to the model prior to\n merging with the template."); - data("spring.freemarker.expose-spring-macro-helpers", "java.lang.Boolean", null, "Set whether to expose a RequestContext for use by Spring's macro library, under the\n name \"springMacroRequestContext\"."); - data("spring.freemarker.prefix", "java.lang.String", null, "Prefix that gets prepended to view names when building a URL."); - data("spring.freemarker.request-context-attribute", "java.lang.String", null, "Name of the RequestContext attribute for all views."); - data("spring.freemarker.settings", "java.util.Map", null, "Well-known FreeMarker keys which will be passed to FreeMarker's Configuration."); - data("spring.freemarker.suffix", "java.lang.String", null, "Suffix that gets appended to view names when building a URL."); - data("spring.freemarker.template-loader-path", "java.lang.String[]", new String[] {"snuzzle" ,"buggles"}, "Comma-separated list of template paths."); - data("spring.freemarker.view-names", "java.lang.String[]", null, "White list of view names that can be resolved."); - data("spring.groovy.template.cache", "java.lang.Boolean", null, "Enable template caching."); - data("spring.groovy.template.char-set", "java.lang.String", null, null); - data("spring.groovy.template.charset", "java.lang.String", null, "Template encoding."); - data("spring.groovy.template.check-template-location", "java.lang.Boolean", null, "Check that the templates location exists."); - data("spring.groovy.template.configuration.auto-escape", "java.lang.Boolean", null, null); - data("spring.groovy.template.configuration.auto-indent", "java.lang.Boolean", null, null); - data("spring.groovy.template.configuration.auto-indent-string", "java.lang.String", null, null); - data("spring.groovy.template.configuration.auto-new-line", "java.lang.Boolean", null, null); - data("spring.groovy.template.configuration.base-template-class", "java.lang.Class", null, null); - data("spring.groovy.template.configuration.cache-templates", "java.lang.Boolean", null, null); - data("spring.groovy.template.configuration.declaration-encoding", "java.lang.String", null, null); - data("spring.groovy.template.configuration.expand-empty-elements", "java.lang.Boolean", null, null); - data("spring.groovy.template.configuration", "java.util.Map", null, "Configuration to pass to TemplateConfiguration."); - data("spring.groovy.template.configuration.locale", "java.util.Locale", null, null); - data("spring.groovy.template.configuration.new-line-string", "java.lang.String", null, null); - data("spring.groovy.template.configuration.resource-loader-path", "java.lang.String", null, null); - data("spring.groovy.template.configuration.use-double-quotes", "java.lang.Boolean", null, null); - data("spring.groovy.template.content-type", "java.lang.String", null, "Content-Type value."); - data("spring.groovy.template.enabled", "java.lang.Boolean", null, "Enable MVC view resolution for this technology."); - data("spring.groovy.template.prefix", "java.lang.String", "classpath:/templates/", "Prefix that gets prepended to view names when building a URL."); - data("spring.groovy.template.suffix", "java.lang.String", ".tpl", "Suffix that gets appended to view names when building a URL."); - data("spring.groovy.template.view-names", "java.lang.String[]", null, "White list of view names that can be resolved."); - data("spring.hornetq.embedded.cluster-password", "java.lang.String", null, "Cluster password. Randomly generated on startup by default"); - data("spring.hornetq.embedded.data-directory", "java.lang.String", null, "Journal file directory. Not necessary if persistence is turned off."); - data("spring.hornetq.embedded.enabled", "java.lang.Boolean", "true", "Enable embedded mode if the HornetQ server APIs are available."); - data("spring.hornetq.embedded.persistent", "java.lang.Boolean", "false", "Enable persistent store."); - data("spring.hornetq.embedded.queues", "java.lang.String[]", "[Ljava.lang.Object;@2f5ce114", "Comma-separate list of queues to create on startup."); - data("spring.hornetq.embedded.server-id", "java.lang.Integer", "0", "Server id. By default, an auto-incremented counter is used."); - data("spring.hornetq.embedded.topics", "java.lang.String[]", "[Ljava.lang.Object;@6272137a", "Comma-separate list of topics to create on startup."); - data("spring.hornetq.host", "java.lang.String", "localhost", "HornetQ broker host."); - data("spring.hornetq.mode", "org.springframework.boot.autoconfigure.jms.hornetq.HornetQMode", null, "HornetQ deployment mode, auto-detected by default. Can be explicitly set to\n \"native\" or \"embedded\"."); - data("spring.hornetq.port", "java.lang.Integer", "5445", "HornetQ broker port."); - data("spring.http.encoding.charset", "java.nio.charset.Charset", null, "Charset of HTTP requests and responses. Added to the \"Content-Type\" header if not\n set explicitly."); - data("spring.http.encoding.enabled", "java.lang.Boolean", "true", "Enable http encoding support."); - data("spring.http.encoding.force", "java.lang.Boolean", "true", "Force the encoding to the configured charset on HTTP requests and responses."); - data("spring.jackson.date-format", "java.lang.String", null, "Date format string (yyyy-MM-dd HH:mm:ss), or a fully-qualified date format class\n name."); - data("spring.jackson.deserialization", "java.util.Map", null, "Jackson on/off features that affect the way Java objects are deserialized."); - data("spring.jackson.generator", "java.util.Map", null, "Jackson on/off features for generators."); - data("spring.jackson.mapper", "java.util.Map", null, "Jackson general purpose on/off features."); - data("spring.jackson.parser", "java.util.Map", null, "Jackson on/off features for parsers."); - data("spring.jackson.property-naming-strategy", "java.lang.String", null, "One of the constants on Jackson's PropertyNamingStrategy\n (CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES). Can also be a fully-qualified class\n name of a PropertyNamingStrategy subclass."); - data("spring.jackson.serialization", "java.util.Map", null, "Jackson on/off features that affect the way Java objects are serialized."); - data("spring.jersey.filter.order", "java.lang.Integer", "0", "Jersey filter chain order."); - data("spring.jersey.init", "java.util.Map", null, "Init parameters to pass to Jersey."); - data("spring.jersey.type", "org.springframework.boot.autoconfigure.jersey.JerseyProperties$Type", null, "Jersey integration type. Can be either \"servlet\" or \"filter\"."); - data("spring.jms.jndi-name", "java.lang.String", null, "Connection factory JNDI name. When set, takes precedence to others connection\n factory auto-configurations."); - data("spring.jms.pub-sub-domain", "java.lang.Boolean", "false", "Specify if the default destination type is topic."); - data("spring.jmx.enabled", "java.lang.Boolean", "true", "Expose management beans to the JMX domain."); - data("spring.jpa.database", "org.springframework.orm.jpa.vendor.Database", null, "Target database to operate on, auto-detected by default. Can be alternatively set\n using the \"databasePlatform\" property."); - data("spring.jpa.database-platform", "java.lang.String", null, "Name of the target database to operate on, auto-detected by default. Can be\n alternatively set using the \"Database\" enum."); - data("spring.jpa.generate-ddl", "java.lang.Boolean", "false", "Initialize the schema on startup."); - data("spring.jpa.hibernate.ddl-auto", "java.lang.String", null, "DDL mode (\"none\", \"validate\", \"update\", \"create\", \"create-drop\"). This is\n actually a shortcut for the \"hibernate.hbm2ddl.auto\" property. Default to\n \"create-drop\" when using an embedded database, \"none\" otherwise."); - data("spring.jpa.hibernate.naming-strategy", "java.lang.Class", null, "Naming strategy fully qualified name."); - data("spring.jpa.open-in-view", "java.lang.Boolean", "true", "Register OpenEntityManagerInViewInterceptor. Binds a JPA EntityManager to the thread for the entire processing of the request."); - data("spring.jpa.properties", "java.util.Map", null, "Additional native properties to set on the JPA provider."); - data("spring.jpa.show-sql", "java.lang.Boolean", "false", "Enable logging of SQL statements."); - data("spring.jta.allow-multiple-lrc", "java.lang.Boolean", null, null); - data("spring.jta.asynchronous2-pc", "java.lang.Boolean", null, null); - data("spring.jta.background-recovery-interval", "java.lang.Integer", null, null); - data("spring.jta.background-recovery-interval-seconds", "java.lang.Integer", null, null); - data("spring.jta.current-node-only-recovery", "java.lang.Boolean", null, null); - data("spring.jta.debug-zero-resource-transaction", "java.lang.Boolean", null, null); - data("spring.jta.default-transaction-timeout", "java.lang.Integer", null, null); - data("spring.jta.disable-jmx", "java.lang.Boolean", null, null); - data("spring.jta.enabled", "java.lang.Boolean", "true", "Enable JTA support."); - data("spring.jta.exception-analyzer", "java.lang.String", null, null); - data("spring.jta.filter-log-status", "java.lang.Boolean", null, null); - data("spring.jta.force-batching-enabled", "java.lang.Boolean", null, null); - data("spring.jta.forced-write-enabled", "java.lang.Boolean", null, null); - data("spring.jta.graceful-shutdown-interval", "java.lang.Integer", null, null); - data("spring.jta.jndi-transaction-synchronization-registry-name", "java.lang.String", null, null); - data("spring.jta.jndi-user-transaction-name", "java.lang.String", null, null); - data("spring.jta.journal", "java.lang.String", null, null); - data("spring.jta.log-dir", "java.lang.String", null, "Transaction logs directory."); - data("spring.jta.log-part1-filename", "java.lang.String", null, null); - data("spring.jta.log-part2-filename", "java.lang.String", null, null); - data("spring.jta.max-log-size-in-mb", "java.lang.Integer", null, null); - data("spring.jta.resource-configuration-filename", "java.lang.String", null, null); - data("spring.jta.server-id", "java.lang.String", null, null); - data("spring.jta.skip-corrupted-logs", "java.lang.Boolean", null, null); - data("spring.jta.transaction-manager-id", "java.lang.String", null, "Transaction manager unique identifier."); - data("spring.jta.warn-about-zero-resource-transaction", "java.lang.Boolean", null, null); - data("spring.mail.default-encoding", "java.lang.String", "UTF-8", "Default MimeMessage encoding."); - data("spring.mail.host", "java.lang.String", null, "SMTP server host."); - data("spring.mail.password", "java.lang.String", null, "Login password of the SMTP server."); - data("spring.mail.port", "java.lang.Integer", null, "SMTP server port."); - data("spring.mail.properties", "java.util.Map", null, "Additional JavaMail session properties."); - data("spring.mail.username", "java.lang.String", null, "Login user of the SMTP server."); - data("spring.main.show-banner", "java.lang.Boolean", "true", "Display the banner when the application runs."); - data("spring.main.sources", "java.util.Set", null, "Sources (class name, package name or XML resource location) used to create the ApplicationContext."); - data("spring.main.web-environment", "java.lang.Boolean", null, "Run the application in a web environment (auto-detected by default)."); - data("spring.mandatory-file-encoding", "java.lang.String", null, "Expected character encoding the application must use."); - data("spring.messages.basename", "java.lang.String", "messages", "Comma-separated list of basenames, each following the ResourceBundle convention.\n Essentially a fully-qualified classpath location. If it doesn't contain a package\n qualifier (such as \"org.mypackage\"), it will be resolved from the classpath root."); - data("spring.messages.cache-seconds", "java.lang.Integer", "-1", "Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles\n are cached forever."); - data("spring.messages.encoding", "java.lang.String", "utf-8", "Message bundles encoding."); - data("spring.mobile.devicedelegatingviewresolver.enabled", "java.lang.Boolean", "false", "Enable device view resolver."); - data("spring.mobile.devicedelegatingviewresolver.mobile-prefix", "java.lang.String", "mobile/", "Prefix that gets prepended to view names for mobile devices."); - data("spring.mobile.devicedelegatingviewresolver.mobile-suffix", "java.lang.String", "", "Suffix that gets appended to view names for mobile devices."); - data("spring.mobile.devicedelegatingviewresolver.normal-prefix", "java.lang.String", "", "Prefix that gets prepended to view names for normal devices."); - data("spring.mobile.devicedelegatingviewresolver.normal-suffix", "java.lang.String", "", "Suffix that gets appended to view names for normal devices."); - data("spring.mobile.devicedelegatingviewresolver.tablet-prefix", "java.lang.String", "tablet/", "Prefix that gets prepended to view names for tablet devices."); - data("spring.mobile.devicedelegatingviewresolver.tablet-suffix", "java.lang.String", "", "Suffix that gets appended to view names for tablet devices."); - data("spring.mobile.sitepreference.enabled", "java.lang.Boolean", "true", "Enable SitePreferenceHandler."); - data("spring.mvc.date-format", "java.lang.String", null, "Date format to use (e.g. dd/MM/yyyy)"); - data("spring.mvc.ignore-default-model-on-redirect", "java.lang.Boolean", "true", "If the the content of the \"default\" model should be ignored during redirect\n scenarios."); - data("spring.mvc.locale", "java.lang.String", null, "Locale to use."); - data("spring.mvc.message-codes-resolver-format", "org.springframework.validation.DefaultMessageCodesResolver$Format", null, "Formatting strategy for message codes (PREFIX_ERROR_CODE, POSTFIX_ERROR_CODE)."); - data("spring.profiles.active", "java.lang.String", null, "Comma-separated list of active profiles. Can be overridden by a command line switch."); - data("spring.profiles.include", "java.lang.String", null, "Unconditionally activate the specified comma separated profiles."); - data("spring.rabbitmq.addresses", "java.lang.String", null, "Comma-separated list of addresses to which the client should connect to."); - data("spring.rabbitmq.dynamic", "java.lang.Boolean", "true", "Create an AmqpAdmin bean."); - data("spring.rabbitmq.host", "java.lang.String", "localhost", "RabbitMQ host."); - data("spring.rabbitmq.password", "java.lang.String", null, "Login to authenticate against the broker."); - data("spring.rabbitmq.port", "java.lang.Integer", "5672", "RabbitMQ port."); - data("spring.rabbitmq.username", "java.lang.String", null, "Login user to authenticate to the broker."); - data("spring.rabbitmq.virtual-host", "java.lang.String", null, "Virtual host to use when connecting to the broker."); - data("spring.redis.database", "java.lang.Integer", "0", "Database index used by the connection factory."); - data("spring.redis.host", "java.lang.String", "localhost", "Redis server host."); - data("spring.redis.password", "java.lang.String", null, "Login password of the redis server."); - data("spring.redis.pool.max-active", "java.lang.Integer", "8", "Max number of connections that can be allocated by the pool at a given time.\n Use a negative value for no limit."); - data("spring.redis.pool.max-idle", "java.lang.Integer", "8", "Max number of \"idle\" connections in the pool. Use a negative value to indicate\n an unlimited number of idle connections."); - data("spring.redis.pool.max-wait", "java.lang.Integer", "-1", "Maximum amount of time (in milliseconds) a connection allocation should block\n before throwing an exception when the pool is exhausted. Use a negative value\n to block indefinitely."); - data("spring.redis.pool.min-idle", "java.lang.Integer", "0", "Target for the minimum number of idle connections to maintain in the pool. This\n setting only has an effect if it is positive."); - data("spring.redis.port", "java.lang.Integer", "6379", "Redis server port."); - data("spring.redis.sentinel.master", "java.lang.String", null, "Name of Redis server."); - data("spring.redis.sentinel.nodes", "java.lang.String", null, "Comma-separated list of host:port pairs."); - data("spring.resources.add-mappings", "java.lang.Boolean", "true", "Enable default resource handling."); - data("spring.resources.cache-period", "java.lang.Integer", null, "Cache period for the resources served by the resource handler, in seconds."); - data("spring.social.auto-connection-views", "java.lang.Boolean", "false", "Enable the connection status view for supported providers."); - data("spring.social.facebook.app-id", "java.lang.String", null, "Application id."); - data("spring.social.facebook.app-secret", "java.lang.String", null, "Application secret."); - data("spring.social.linkedin.app-id", "java.lang.String", null, "Application id."); - data("spring.social.linkedin.app-secret", "java.lang.String", null, "Application secret."); - data("spring.social.twitter.app-id", "java.lang.String", null, "Application id."); - data("spring.social.twitter.app-secret", "java.lang.String", null, "Application secret."); - data("spring.thymeleaf.cache", "java.lang.Boolean", "true", "Enable template caching."); - data("spring.thymeleaf.check-template-location", "java.lang.Boolean", "true", "Check that the templates location exists."); - data("spring.thymeleaf.content-type", "java.lang.String", "text/html", "Content-Type value."); - data("spring.thymeleaf.enabled", "java.lang.Boolean", "true", "Enable MVC Thymeleaf view resolution."); - data("spring.thymeleaf.encoding", "java.lang.String", "UTF-8", "Template encoding."); - data("spring.thymeleaf.excluded-view-names", "java.lang.String[]", null, "Comma-separated list of view names that should be excluded from resolution."); - data("spring.thymeleaf.mode", "java.lang.String", "HTML5", "Template mode to be applied to templates. See also StandardTemplateModeHandlers."); - data("spring.thymeleaf.prefix", "java.lang.String", "classpath:/templates/", "Prefix that gets prepended to view names when building a URL."); - data("spring.thymeleaf.suffix", "java.lang.String", ".html", "Suffix that gets appended to view names when building a URL."); - data("spring.thymeleaf.view-names", "java.lang.String[]", null, "Comma-separated list of view names that can be resolved."); - data("spring.velocity.allow-request-override", "java.lang.Boolean", null, "Set whether HttpServletRequest attributes are allowed to override (hide) controller\n generated model attributes of the same name."); - data("spring.velocity.cache", "java.lang.Boolean", null, "Enable template caching."); - data("spring.velocity.char-set", "java.lang.String", null, null); - data("spring.velocity.charset", "java.lang.String", null, "Template encoding."); - data("spring.velocity.check-template-location", "java.lang.Boolean", null, "Check that the templates location exists."); - data("spring.velocity.content-type", "java.lang.String", null, "Content-Type value."); - data("spring.velocity.date-tool-attribute", "java.lang.String", null, "Name of the DateTool helper object to expose in the Velocity context of the view."); - data("spring.velocity.enabled", "java.lang.Boolean", null, "Enable MVC view resolution for this technology."); - data("spring.velocity.expose-request-attributes", "java.lang.Boolean", null, "Set whether all request attributes should be added to the model prior to merging\n with the template."); - data("spring.velocity.expose-session-attributes", "java.lang.Boolean", null, "Set whether all HttpSession attributes should be added to the model prior to\n merging with the template."); - data("spring.velocity.expose-spring-macro-helpers", "java.lang.Boolean", null, "Set whether to expose a RequestContext for use by Spring's macro library, under the\n name \"springMacroRequestContext\"."); - data("spring.velocity.number-tool-attribute", "java.lang.String", null, "Name of the NumberTool helper object to expose in the Velocity context of the view."); - data("spring.velocity.prefer-file-system-access", "java.lang.Boolean", "true", "Prefer file system access for template loading. File system access enables hot\n detection of template changes."); - data("spring.velocity.prefix", "java.lang.String", null, "Prefix that gets prepended to view names when building a URL."); - data("spring.velocity.properties", "java.util.Map", null, "Additional velocity properties."); - data("spring.velocity.request-context-attribute", "java.lang.String", null, "Name of the RequestContext attribute for all views."); - data("spring.velocity.resource-loader-path", "java.lang.String", "classpath:/templates/", "Template path."); - data("spring.velocity.suffix", "java.lang.String", null, "Suffix that gets appended to view names when building a URL."); - data("spring.velocity.toolbox-config-location", "java.lang.String", null, "Velocity Toolbox config location, for example \"/WEB-INF/toolbox.xml\". Automatically\n loads a Velocity Tools toolbox definition file and expose all defined tools in the\n specified scopes."); - data("spring.velocity.view-names", "java.lang.String[]", null, "White list of view names that can be resolved."); - data("spring.view.prefix", "java.lang.String", null, "Spring MVC view prefix."); - data("spring.view.suffix", "java.lang.String", null, "Spring MVC view suffix."); - } - - public boolean isEmpty() { - return datas == null || datas.isEmpty(); - } - - public SpringPropertyIndexProvider getIndexProvider() { - return indexProvider; - } - - public SpringPropertyIndexProvider getAdHocIndexProvider() { - return adHocIndexProvider; - } - - public JavaProjectFinder getProjectFinder() { - return (doc) -> Optional.ofNullable(testProject); - } - - public void adHoc(String adHocPropertyId) { - adHocProperties.add(new PropertyInfo(adHocPropertyId, null, null, null, null, null, null, null, null, null, null)); - } - -}