Merge branch 'master' into spring-data-content-assist
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*******************************************************************************
|
||||
* 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 org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AdHocPropertyHarness;
|
||||
import org.springframework.ide.vscode.boot.metadata.ProjectBasedPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
|
||||
@Configuration
|
||||
public class AdHocPropertyHarnessTestConf {
|
||||
@Bean AdHocPropertyHarness adHocPropertyHarness() {
|
||||
return new AdHocPropertyHarness();
|
||||
}
|
||||
|
||||
@Bean ProjectBasedPropertyIndexProvider adHocProperties(AdHocPropertyHarness adHocProperties) {
|
||||
return adHocProperties.getIndexProvider();
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
@OverrideAutoConfiguration(enabled=false)
|
||||
@ImportAutoConfiguration(classes=LanguageServerAutoConf.class)
|
||||
@SpringBootTest(classes={
|
||||
BootLanguagServerBootApp.class,
|
||||
BootLanguagServerBootApp.class
|
||||
})
|
||||
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public @interface BootLanguageServerTest {
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* 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 java.time.Duration;
|
||||
|
||||
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.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
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;
|
||||
@@ -15,10 +27,11 @@ import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
|
||||
@Configuration
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
public class HoverTestConf {
|
||||
|
||||
@Bean PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness();
|
||||
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean MockRunningAppProvider mockAppsHarness() {
|
||||
@@ -33,13 +46,12 @@ public class HoverTestConf {
|
||||
return Duration.ofMillis(100);
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server);
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, ValueProviderRegistry valueProviders, PropertyIndexHarness indexHarness) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server, valueProviders);
|
||||
return new BootLanguageServerParams(
|
||||
indexHarness().getProjectFinder(),
|
||||
indexHarness.getProjectFinder(),
|
||||
testDefaults.projectObserver,
|
||||
indexHarness().getIndexProvider(),
|
||||
indexHarness().getAdHocIndexProvider(),
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
mockAppsHarness().provider,
|
||||
watchDogInterval()
|
||||
@@ -53,5 +65,4 @@ public class HoverTestConf {
|
||||
@Bean SourceLinks sourceLinks() {
|
||||
return SourceLinkFactory.NO_SOURCE_LINKS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ 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.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaDocumentUriProvider;
|
||||
@@ -21,6 +22,7 @@ import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider;
|
||||
import org.springframework.ide.vscode.boot.test.DefinitionLinkAsserts;
|
||||
@@ -32,10 +34,12 @@ 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 {
|
||||
@Configuration
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
public class PropertyEditorTestConf {
|
||||
|
||||
@Bean PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness();
|
||||
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean MockRunningAppProvider mockAppsHarness() {
|
||||
@@ -53,15 +57,14 @@ import org.springframework.ide.vscode.project.harness.MockRunningAppProvider;
|
||||
return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, defaultLanguageId, defaultFileExtension);
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) {
|
||||
JavaProjectFinder projectFinder = indexHarness().getProjectFinder();
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, PropertyIndexHarness indexHarness) {
|
||||
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(),
|
||||
indexHarness.getIndexProvider(),
|
||||
typeUtilProvider,
|
||||
mockAppsHarness().provider,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
|
||||
@@ -1,24 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* 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 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.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AdHocPropertyHarness;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexer;
|
||||
import org.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
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 {
|
||||
@Configuration
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
public class SymbolProviderTestConf {
|
||||
|
||||
@Bean PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness();
|
||||
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean JavaProjectFinder projectFinder(BootLanguageServerParams serverParams) {
|
||||
@@ -29,8 +45,8 @@ import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java");
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server) {
|
||||
return BootLanguageServerParams.createTestDefault(server);
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, ValueProviderRegistry valueProviders) {
|
||||
return BootLanguageServerParams.createTestDefault(server, valueProviders);
|
||||
}
|
||||
|
||||
@Bean SpringIndexer springIndexer(BootLanguageServerInitializer serverInit) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@@ -149,15 +150,22 @@ public abstract class AbstractPropsEditorTest {
|
||||
|
||||
private CompletionItem assertCompletionWithLabel(String expectLabel, List<CompletionItem> completions) {
|
||||
StringBuilder found = new StringBuilder();
|
||||
List<CompletionItem> matching = new ArrayList<CompletionItem>();
|
||||
for (CompletionItem c : completions) {
|
||||
String actualLabel = c.getLabel();
|
||||
found.append(actualLabel+"\n");
|
||||
if (actualLabel.equals(expectLabel)) {
|
||||
return c;
|
||||
matching.add(c);
|
||||
}
|
||||
}
|
||||
fail("No completion found with label '"+expectLabel+"' in:\n"+found);
|
||||
return null; //unreachable, but compiler doesn't know that.
|
||||
if (matching.isEmpty()) {
|
||||
fail("No completion found with label '"+expectLabel+"' in:\n"+found);
|
||||
} else if (matching.size() > 1) {
|
||||
fail("Multiple completion found with identical label '"+expectLabel+"' in:\n"+found);
|
||||
} else {
|
||||
return matching.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void assertCompletionCount(int expected, String editorText) throws Exception {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*******************************************************************************
|
||||
* 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.editor.harness;
|
||||
|
||||
import org.springframework.ide.vscode.boot.metadata.ProjectBasedPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
|
||||
public class AdHocPropertyHarness {
|
||||
|
||||
private FuzzyMap<PropertyInfo> adHocProperties = new FuzzyMap<PropertyInfo>() {
|
||||
@Override
|
||||
protected String getKey(PropertyInfo entry) {
|
||||
return entry.getId();
|
||||
}
|
||||
};
|
||||
|
||||
protected final ProjectBasedPropertyIndexProvider adHocIndexProvider = project -> adHocProperties;
|
||||
|
||||
public ProjectBasedPropertyIndexProvider getIndexProvider() {
|
||||
return adHocIndexProvider;
|
||||
}
|
||||
|
||||
public void add(String adHocPropertyId) {
|
||||
adHocProperties.add(new PropertyInfo(adHocPropertyId, null, null, null, null, null, null, null, null, null, null));
|
||||
}
|
||||
}
|
||||
@@ -34,15 +34,9 @@ import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
*/
|
||||
public class PropertyIndexHarness {
|
||||
|
||||
private final ValueProviderRegistry valueProviders;
|
||||
private Map<String, ConfigurationMetadataProperty> datas = new LinkedHashMap<>();
|
||||
private ValueProviderRegistry valueProviders = ValueProviderRegistry.getDefault();
|
||||
private SpringPropertyIndex index = null;
|
||||
private FuzzyMap<PropertyInfo> adHocProperties = new FuzzyMap<PropertyInfo>() {
|
||||
@Override
|
||||
protected String getKey(PropertyInfo entry) {
|
||||
return entry.getId();
|
||||
}
|
||||
};
|
||||
private IJavaProject testProject = null;
|
||||
|
||||
protected final SpringPropertyIndexProvider indexProvider = new SpringPropertyIndexProvider() {
|
||||
@@ -60,9 +54,11 @@ public class PropertyIndexHarness {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected final SpringPropertyIndexProvider adHocIndexProvider = doc -> adHocProperties;
|
||||
|
||||
|
||||
public PropertyIndexHarness(ValueProviderRegistry valueProviders) {
|
||||
this.valueProviders = valueProviders;
|
||||
}
|
||||
|
||||
public synchronized void useProject(IJavaProject p) throws Exception {
|
||||
index = null;
|
||||
this.testProject = p;
|
||||
@@ -572,18 +568,10 @@ 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;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -40,14 +40,16 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActuatorEnvOrderedPropertySourceCamelCase() throws Exception {
|
||||
// Tests an actuator env json that contains camel case context path in command line arg and application config.
|
||||
public void testBoot1xActualActuatorEnvProp() throws Exception {
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "1.x";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
@@ -59,7 +61,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson("2.x", AcuatorEnvTestConstants.BOOT_2x_ENV_CONTEXT_PATH_CAMEL_CASE)
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_1x_ENV)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
@@ -67,23 +69,23 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
// test that the command line arg context path appears
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/pathfromcommandlineargs/hello-world](http://cfapps.io:1111/pathfromcommandlineargs/hello-world) \n" +
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/fromEnv/hello-world](http://cfapps.io:1111/fromEnv/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActuatorEnvOrderedPropertySourceKebabCase() throws Exception {
|
||||
public void testBoot1xActualActuatorCommandArgCamel() throws Exception {
|
||||
|
||||
// Tests an actuator env json that contains kebab case context path in command line arg and application config.
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "1.x";
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
@@ -95,7 +97,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson("2.x", AcuatorEnvTestConstants.BOOT_2x_ENV_CONTEXT_PATH_KEBAB_CASE)
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_1x_COMMAND_LINE_ARG_CAMEL_CASE)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
@@ -103,13 +105,346 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
// test that the command line arg context path appears
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/pathfromcommandlineargs/hello-world](http://cfapps.io:1111/pathfromcommandlineargs/hello-world) \n" +
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/fromlaunchconfig/hello-world](http://cfapps.io:1111/fromlaunchconfig/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoot1xActualActuatorCommandArgKebab() throws Exception {
|
||||
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "1.x";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_1x_COMMAND_LINE_ARG_KEBAB_CASE)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/fromlaunchconfig/hello-world](http://cfapps.io:1111/fromlaunchconfig/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoot1xActualActuatorAppConfigFileKebab() throws Exception {
|
||||
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "1.x";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_1x_APP_CONFIG_FILE_KEBAB_CASE)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/frompropsfile/hello-world](http://cfapps.io:1111/frompropsfile/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoot1xActualActuatorAppConfigFileCamel() throws Exception {
|
||||
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "1.x";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_1x_APP_CONFIG_FILE_CAMEL_CASE)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/frompropsfile/hello-world](http://cfapps.io:1111/frompropsfile/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoot2xActualActuatorEnvProp() throws Exception {
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "2.x";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_2x_ENV)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/fromenvironment/hello-world](http://cfapps.io:1111/fromenvironment/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoot2xActualActuatorCommandArgCamel() throws Exception {
|
||||
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "2.x";
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_2x_COMMAND_LINE_ARG_CAMEL_CASE)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/fromlaunchconfig/hello-world](http://cfapps.io:1111/fromlaunchconfig/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoot2xActualActuatorCommandArgKebab() throws Exception {
|
||||
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "2.x";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_2x_COMMAND_LINE_ARG_KEBAB_CASE)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/fromlaunchconfig/hello-world](http://cfapps.io:1111/fromlaunchconfig/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoot2xActualActuatorAppConfigFileKebab() throws Exception {
|
||||
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "2.x";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_2x_APP_CONFIG_FILE_KEBAB_CASE)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/frompropsfile/hello-world](http://cfapps.io:1111/frompropsfile/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoot2xActualActuatorAppConfigFileCamel() throws Exception {
|
||||
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "2.x";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_2x_APP_CONFIG_FILE_CAMEL_CASE)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/frompropsfile/hello-world](http://cfapps.io:1111/frompropsfile/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoot2xActualActuatorPropertySourcePriority() throws Exception {
|
||||
|
||||
// Test that for Boot 2.x, if context path property appears in three different sources:
|
||||
// env var, command line arg, and app config file, that the highest priority source is read, in this case command line arg
|
||||
|
||||
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();
|
||||
|
||||
String bootVersion = "2.x";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.requestMappingsJson(
|
||||
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
|
||||
.contextPathEnvJson(bootVersion, AcuatorEnvTestConstants.BOOT_2x_PROPERTY_SOURCE_PRIORITY)
|
||||
.build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/fromlaunchconfig/hello-world](http://cfapps.io:1111/fromlaunchconfig/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithMockedContextPath() throws Exception {
|
||||
@@ -125,7 +460,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.contextPath("/adifferentpath")
|
||||
.contextPath("/mockedpath")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -137,7 +472,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
|
||||
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
|
||||
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/adifferentpath/hello-world](http://cfapps.io:1111/adifferentpath/hello-world) \n" +
|
||||
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/mockedpath/hello-world](http://cfapps.io:1111/mockedpath/hello-world) \n" +
|
||||
"\n" +
|
||||
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
@@ -158,7 +493,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.contextPath("/differentPaath")
|
||||
.contextPath("/mockedpath")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -185,8 +520,8 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(value={\"/greetings\", \"/hello\"}, method=GET)", "[http://cfapps.io:999/differentPaath/greetings](http://cfapps.io:999/differentPaath/greetings) \n" +
|
||||
"[http://cfapps.io:999/differentPaath/hello](http://cfapps.io:999/differentPaath/hello) \n" +
|
||||
editor.assertHoverContains("@RequestMapping(value={\"/greetings\", \"/hello\"}, method=GET)", "[http://cfapps.io:999/mockedpath/greetings](http://cfapps.io:999/mockedpath/greetings) \n" +
|
||||
"[http://cfapps.io:999/mockedpath/hello](http://cfapps.io:999/mockedpath/hello) \n" +
|
||||
"\n" +
|
||||
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
|
||||
|
||||
|
||||
@@ -27,8 +27,10 @@ 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.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.bootiful.AdHocPropertyHarnessTestConf;
|
||||
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;
|
||||
@@ -36,6 +38,7 @@ import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
@@ -67,10 +70,11 @@ public class CompilationUnitCacheTest {
|
||||
@Autowired
|
||||
private MockProjectObserver projectObserver;
|
||||
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
@Configuration static class TestConf {
|
||||
|
||||
@Bean PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness();
|
||||
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean JavaProjectFinder projectFinder(BootLanguageServerParams serverParams) {
|
||||
@@ -85,13 +89,12 @@ public class CompilationUnitCacheTest {
|
||||
return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java");
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, MockProjectObserver projectObserver) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server);
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, MockProjectObserver projectObserver, ValueProviderRegistry valueProviders, PropertyIndexHarness indexHarness) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server, valueProviders);
|
||||
return new BootLanguageServerParams(
|
||||
indexHarness().getProjectFinder(),
|
||||
indexHarness.getProjectFinder(),
|
||||
projectObserver,
|
||||
indexHarness().getIndexProvider(),
|
||||
indexHarness().getAdHocIndexProvider(),
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
null
|
||||
|
||||
@@ -12,10 +12,14 @@ package org.springframework.ide.vscode.boot.java.value.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.boot.java.value.test.MockProjects.MockProject;
|
||||
import org.springframework.ide.vscode.boot.metadata.AdHocSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.TextDocumentSaveChange;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
@@ -23,6 +27,7 @@ import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
public class AdHocSpringPropertyIndexProviderTest {
|
||||
|
||||
private MockProjects projects = new MockProjects();
|
||||
private MockDocumentEvents documents = new MockDocumentEvents();
|
||||
|
||||
@Test
|
||||
public void parseProperties() throws Exception {
|
||||
@@ -31,29 +36,45 @@ public class AdHocSpringPropertyIndexProviderTest {
|
||||
"some-adhoc-foo=somefoo\n" +
|
||||
"some-adhoc-bar=somebar\n"
|
||||
);
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, null);
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, null, documents);
|
||||
|
||||
TextDocument doc = new TextDocument(project.uri("src/main/java/SomeClass.java"), LanguageId.JAVA);
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
//alphabetic order
|
||||
"some-adhoc-bar",
|
||||
"some-adhoc-foo"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseYamlWithList() throws Exception {
|
||||
//Note: the LoggerNameProvider implementation relies on this behavior
|
||||
MockProject project = projects.create("test-project");
|
||||
project.ensureFile("src/main/resources/application.yml",
|
||||
"from-yaml:\n" +
|
||||
" adhoc:\n" +
|
||||
" - one\n" +
|
||||
" - two\n"
|
||||
);
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, null, documents);
|
||||
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-yaml.adhoc"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseYaml() throws Exception {
|
||||
MockProject project = projects.create("test-project");
|
||||
project.ensureFile("src/main/resources/application.yml",
|
||||
"from-yaml:\n" +
|
||||
" adhoc:\n" +
|
||||
" foo: somefoo\n" +
|
||||
" bar: somebar\n"
|
||||
" adhoc:\n" +
|
||||
" foo: somefoo\n" +
|
||||
" bar: somebar\n"
|
||||
);
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, null);
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, null, documents);
|
||||
|
||||
TextDocument doc = new TextDocument(project.uri("src/main/java/SomeClass.java"), LanguageId.JAVA);
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
//alphabetic order
|
||||
"from-yaml.adhoc.bar",
|
||||
"from-yaml.adhoc.foo"
|
||||
@@ -67,20 +88,19 @@ public class AdHocSpringPropertyIndexProviderTest {
|
||||
"initial-property=somefoo\n"
|
||||
);
|
||||
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, null);
|
||||
TextDocument doc = new TextDocument(project.uri("src/main/java/SomeClass.java"), LanguageId.JAVA);
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, null, documents);
|
||||
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property"
|
||||
);
|
||||
|
||||
project.ensureFile("new-sourcefolder/application.properties", "new-property=whatever");
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property"
|
||||
);
|
||||
|
||||
project.createSourceFolder("new-sourcefolder");
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property",
|
||||
"new-property"
|
||||
);
|
||||
@@ -93,20 +113,52 @@ public class AdHocSpringPropertyIndexProviderTest {
|
||||
"initial-property=somefoo\n"
|
||||
);
|
||||
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, projects.fileObserver);
|
||||
TextDocument doc = new TextDocument(project.uri("src/main/java/SomeClass.java"), LanguageId.JAVA);
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, projects.fileObserver, documents);
|
||||
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property"
|
||||
);
|
||||
|
||||
project.ensureFile("src/main/resources/application.properties", "from-properties=whatever");
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-properties"
|
||||
);
|
||||
|
||||
project.ensureFile("src/main/resources/application.yml", "from-yaml: whatever");
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-properties",
|
||||
"from-yaml"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void respondsToDocumentSave() throws Exception {
|
||||
MockProject project = projects.create("test-project");
|
||||
project.ensureFile("src/main/resources/application.properties",
|
||||
"initial-property=somefoo\n"
|
||||
);
|
||||
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, projects.fileObserver, documents);
|
||||
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property"
|
||||
);
|
||||
|
||||
File propsFile = project.ensureFileNoEvents("src/main/resources/application.properties", "from-properties=whatever");
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property" //not changed yet because didn't fire change events.
|
||||
);
|
||||
documents.fire(new TextDocumentSaveChange(new TextDocument(propsFile.toURI().toString(), LanguageId.BOOT_PROPERTIES)));
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-properties"
|
||||
);
|
||||
|
||||
project.ensureFileNoEvents("src/main/resources/application.yml", "from-yaml: whatever");
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-properties"
|
||||
);
|
||||
documents.fire(new TextDocumentSaveChange(new TextDocument(propsFile.toURI().toString(), LanguageId.BOOT_PROPERTIES_YAML)));
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-properties",
|
||||
"from-yaml"
|
||||
);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.springframework.ide.vscode.boot.java.value.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.DocumentEventListenerManager;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.TextDocumentSaveChange;
|
||||
|
||||
public class MockDocumentEvents implements DocumentEventListenerManager {
|
||||
|
||||
List<Consumer<TextDocumentSaveChange>> saveHandlers = new ArrayList<Consumer<TextDocumentSaveChange>>();
|
||||
|
||||
@Override
|
||||
public void onDidSave(Consumer<TextDocumentSaveChange> h) {
|
||||
saveHandlers.add(h);
|
||||
}
|
||||
|
||||
public void fire(TextDocumentSaveChange e) {
|
||||
saveHandlers.forEach(h -> {
|
||||
h.accept(e);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -153,15 +153,26 @@ public class MockProjects {
|
||||
return root.isDirectory();
|
||||
}
|
||||
|
||||
public void ensureFile(String projectRelativePath, String contents) throws Exception {
|
||||
public File ensureFileNoEvents(String projectRelativePath, String contents) throws Exception {
|
||||
return ensureFile(false, projectRelativePath, contents);
|
||||
}
|
||||
|
||||
private File ensureFile(boolean fireEvents, String projectRelativePath, String contents) throws Exception {
|
||||
File target = new File(root, projectRelativePath);
|
||||
boolean existed = target.exists();
|
||||
IOUtil.pipe(new ByteArrayInputStream(contents.getBytes("UTF8")), target);
|
||||
if (existed) {
|
||||
fileObserver.fileChanged(target);
|
||||
} else {
|
||||
fileObserver.fileCreated(target);
|
||||
if (fireEvents) {
|
||||
if (existed) {
|
||||
fileObserver.fileChanged(target);
|
||||
} else {
|
||||
fileObserver.fileCreated(target);
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
public void ensureFile(String projectRelativePath, String contents) throws Exception {
|
||||
ensureFile(true, projectRelativePath, contents);
|
||||
}
|
||||
|
||||
public String uri(String projectRelativePath) {
|
||||
|
||||
@@ -19,20 +19,27 @@ import java.util.Optional;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.lsp4j.CompletionItem;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
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.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.bootiful.AdHocPropertyHarnessTestConf;
|
||||
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AdHocPropertyHarness;
|
||||
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.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.java.value.ValueCompletionProcessor;
|
||||
import org.springframework.ide.vscode.boot.metadata.AdHocSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
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;
|
||||
@@ -54,12 +61,16 @@ public class ValueCompletionTest {
|
||||
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private IJavaProject testProject;
|
||||
@Autowired private JavaProjectFinder projectFinder;
|
||||
|
||||
private Editor editor;
|
||||
|
||||
@Autowired private PropertyIndexHarness indexHarness;
|
||||
@Autowired private AdHocPropertyHarness adHocProperties;
|
||||
|
||||
@Configuration static class TestConf {
|
||||
@Configuration
|
||||
@Import(AdHocPropertyHarnessTestConf.class)
|
||||
static class TestConf {
|
||||
|
||||
//Somewhat strange test setup, test provides a specific test project.
|
||||
//The project finder finds this test project,
|
||||
@@ -70,8 +81,8 @@ public class ValueCompletionTest {
|
||||
return ProjectsHarness.INSTANCE.mavenProject("test-annotations");
|
||||
}
|
||||
|
||||
@Bean PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness();
|
||||
@Bean PropertyIndexHarness indexHarness(ValueProviderRegistry valueProviders) {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean JavaProjectFinder projectFinder(MavenJavaProject testProject) {
|
||||
@@ -82,13 +93,12 @@ public class ValueCompletionTest {
|
||||
return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java");
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, JavaProjectFinder projectFinder) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server);
|
||||
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, JavaProjectFinder projectFinder, ValueProviderRegistry valueProviders, PropertyIndexHarness indexHarness) {
|
||||
BootLanguageServerParams testDefaults = BootLanguageServerParams.createTestDefault(server, valueProviders);
|
||||
return new BootLanguageServerParams(
|
||||
projectFinder,
|
||||
ProjectObserver.NULL,
|
||||
indexHarness().getIndexProvider(),
|
||||
indexHarness().getAdHocIndexProvider(),
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
null
|
||||
@@ -112,7 +122,7 @@ public class ValueCompletionTest {
|
||||
|
||||
@Test
|
||||
public void testPrefixIdentification() {
|
||||
ValueCompletionProcessor processor = new ValueCompletionProcessor(null, null);
|
||||
ValueCompletionProcessor processor = new ValueCompletionProcessor(projectFinder, null, null);
|
||||
|
||||
assertEquals("pre", processor.identifyPropertyPrefix("pre", 3));
|
||||
assertEquals("pre", processor.identifyPropertyPrefix("prefix", 3));
|
||||
@@ -336,9 +346,9 @@ public class ValueCompletionTest {
|
||||
"${spring.prop1}<*>"
|
||||
);
|
||||
|
||||
indexHarness.adHoc("spring.ad-hoc.thingy");
|
||||
indexHarness.adHoc("spring.ad-hoc.other-thingy");
|
||||
indexHarness.adHoc("spring.prop1"); //should not suggest this twice!
|
||||
adHocProperties.add("spring.ad-hoc.thingy");
|
||||
adHocProperties.add("spring.ad-hoc.other-thingy");
|
||||
adHocProperties.add("spring.prop1"); //should not suggest this twice!
|
||||
editor.assertContextualCompletions(
|
||||
"<*>"
|
||||
, //==>
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
|
||||
/**
|
||||
* Index Navigation tests.
|
||||
*
|
||||
*
|
||||
* @author Kris De Volder
|
||||
* @author Alex Boyko
|
||||
*
|
||||
@@ -27,7 +27,7 @@ public class IndexNavigatorTest {
|
||||
|
||||
@Test
|
||||
public void testSimple() throws Exception {
|
||||
PropertyIndexHarness harness = new PropertyIndexHarness();
|
||||
PropertyIndexHarness harness = indexHarness();
|
||||
harness.defaultTestData();
|
||||
|
||||
start(harness);
|
||||
@@ -43,9 +43,13 @@ public class IndexNavigatorTest {
|
||||
assertEmpty();
|
||||
}
|
||||
|
||||
private PropertyIndexHarness indexHarness() {
|
||||
return new PropertyIndexHarness(new ValueProviderRegistry());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartialName() throws Exception {
|
||||
PropertyIndexHarness harness = new PropertyIndexHarness();
|
||||
PropertyIndexHarness harness = indexHarness();
|
||||
harness.defaultTestData();
|
||||
|
||||
start(harness);
|
||||
@@ -60,7 +64,7 @@ public class IndexNavigatorTest {
|
||||
|
||||
@Test
|
||||
public void testAmbiguous() throws Exception {
|
||||
PropertyIndexHarness harness = new PropertyIndexHarness();
|
||||
PropertyIndexHarness harness = indexHarness();
|
||||
harness.defaultTestData();
|
||||
|
||||
harness.data("foo.bar", "java.lang.String", null, "Foo dot bar");
|
||||
@@ -130,7 +134,7 @@ public class IndexNavigatorTest {
|
||||
public void navigate(String propName) {
|
||||
navigator = navigator.selectSubProperty(propName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class LoggerNameProviderTest {
|
||||
"org.springframework.instrument.classloading.jboss.JBossMCTranslatorAdapter", //11
|
||||
"org.springframework.instrument.classloading.jboss.JBossModulesAdapter" //12
|
||||
};
|
||||
|
||||
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
private MavenJavaProject project;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class LoggerNameProviderTest {
|
||||
|
||||
@Test
|
||||
public void directResults() throws Exception {
|
||||
LoggerNameProvider p = new LoggerNameProvider();
|
||||
LoggerNameProvider p = new LoggerNameProvider(null);
|
||||
String query = "jboss";
|
||||
List<String> directQueryResults = getResults(p, query);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class LoggerNameProviderTest {
|
||||
|
||||
@Test
|
||||
public void cachedResults() throws Exception {
|
||||
LoggerNameProvider p = new LoggerNameProvider();
|
||||
LoggerNameProvider p = new LoggerNameProvider(null);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
String query = "jboss";
|
||||
@@ -105,7 +105,7 @@ public class LoggerNameProviderTest {
|
||||
public void incrementalResults() throws Exception {
|
||||
String fullQuery = "jboss";
|
||||
|
||||
CachingValueProvider p = new LoggerNameProvider();
|
||||
CachingValueProvider p = new LoggerNameProvider(null);
|
||||
for (int i = 0; i <= fullQuery.length(); i++) {
|
||||
String query = fullQuery.substring(0, i);
|
||||
List<String> results = getResults(p, query);
|
||||
|
||||
@@ -22,21 +22,21 @@ import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
/**
|
||||
* Sanity test the boot properties index
|
||||
*
|
||||
*
|
||||
* @author Alex Boyko
|
||||
*
|
||||
*/
|
||||
public class PropertiesIndexTest {
|
||||
|
||||
private static final String CUSTOM_PROPERTIES_PROJECT = "custom-properties-boot-project";
|
||||
|
||||
|
||||
private ProjectsHarness projects = ProjectsHarness.INSTANCE;
|
||||
private ProgressService progressService = (id, msg) -> { /*ignore*/ };
|
||||
|
||||
|
||||
@Test
|
||||
public void springStandardPropertyPresent_Maven() throws Exception {
|
||||
SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager(
|
||||
ValueProviderRegistry.getDefault(), null);
|
||||
new ValueProviderRegistry(), null);
|
||||
IJavaProject mavenProject = projects.mavenProject(CUSTOM_PROPERTIES_PROJECT);
|
||||
FuzzyMap<PropertyInfo> index = indexManager.get(mavenProject, progressService);
|
||||
PropertyInfo propertyInfo = index.get("server.port");
|
||||
@@ -48,7 +48,7 @@ public class PropertiesIndexTest {
|
||||
@Test
|
||||
public void customPropertyPresent_Maven() throws Exception {
|
||||
SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager(
|
||||
ValueProviderRegistry.getDefault(), null);
|
||||
new ValueProviderRegistry(), null);
|
||||
IJavaProject mavenProject = projects.mavenProject(CUSTOM_PROPERTIES_PROJECT);
|
||||
FuzzyMap<PropertyInfo> index = indexManager.get(mavenProject, progressService);
|
||||
PropertyInfo propertyInfo = index.get("demo.settings.user");
|
||||
@@ -60,7 +60,7 @@ public class PropertiesIndexTest {
|
||||
@Test
|
||||
public void propertyNotPresent_Maven() throws Exception {
|
||||
SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager(
|
||||
ValueProviderRegistry.getDefault(), null);
|
||||
new ValueProviderRegistry(), null);
|
||||
IJavaProject mavenProject = projects.mavenProject(CUSTOM_PROPERTIES_PROJECT);
|
||||
FuzzyMap<PropertyInfo> index = indexManager.get(mavenProject, progressService);
|
||||
PropertyInfo propertyInfo = index.get("my.server.port");
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.ide.vscode.boot.properties.reconcile.ApplicationPropertiesProblemType.PROP_DUPLICATE_KEY;
|
||||
@@ -35,6 +36,7 @@ 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.AdHocPropertyHarness;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.StyledStringMatcher;
|
||||
import org.springframework.ide.vscode.boot.metadata.CachingValueProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertiesLoader;
|
||||
@@ -59,8 +61,9 @@ import com.google.common.io.Files;
|
||||
@Import(PropertyEditorTestConf.class)
|
||||
public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
|
||||
@Autowired
|
||||
private DefinitionLinkAsserts definitionLinkAsserts;
|
||||
@Autowired DefinitionLinkAsserts definitionLinkAsserts;
|
||||
@Autowired AdHocPropertyHarness adHocProperties;
|
||||
|
||||
|
||||
@Configuration static class TestConf {
|
||||
@Bean LanguageId defaultLanguageId() {
|
||||
@@ -1148,6 +1151,68 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void userDefinedLoggingGroups() throws Exception {
|
||||
useProject(createPredefinedMavenProject("empty-boot-2.1.0-app"));
|
||||
|
||||
adHocProperties.add("logging.group.foobar");
|
||||
adHocProperties.add("logging.group.user-defined");
|
||||
adHocProperties.add("logging.group.indexed[0]");
|
||||
adHocProperties.add("logging.group.indexed[0]");
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging.level.<*>"
|
||||
, //==============
|
||||
"user-defined",
|
||||
//=>
|
||||
"logging.level.user-defined=<*>"
|
||||
);
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging.level.<*>"
|
||||
, //==============
|
||||
"foobar",
|
||||
//=>
|
||||
"logging.level.foobar=<*>"
|
||||
);
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging.level.<*>"
|
||||
, //==============
|
||||
"indexed",
|
||||
//=>
|
||||
"logging.level.indexed=<*>"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test public void userDefinedLoggingGroupsValueCompletions() throws Exception {
|
||||
useProject(createPredefinedMavenProject("empty-boot-2.1.0-app"));
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging.group.whatever=demo<*>"
|
||||
, //==============
|
||||
"com.example.demo",
|
||||
//=>
|
||||
"logging.group.whatever=com.example.demo<*>"
|
||||
);
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging.group.whatever=stuff,demo<*>"
|
||||
, //==============
|
||||
"com.example.demo",
|
||||
//=>
|
||||
"logging.group.whatever=stuff,com.example.demo<*>"
|
||||
);
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging.group.whatever[0]=demo<*>"
|
||||
, //==============
|
||||
"com.example.demo",
|
||||
//=>
|
||||
"logging.group.whatever[0]=com.example.demo<*>"
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void testPropertyMapKeyCompletions() throws Exception {
|
||||
useProject(createPredefinedMavenProject("empty-boot-2.1.0-app"));
|
||||
assertCompletionWithLabel(
|
||||
|
||||
@@ -256,6 +256,48 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void userDefinedLoggingGroupsValueCompletions() throws Exception {
|
||||
useProject(createPredefinedMavenProject("empty-boot-2.1.0-app"));
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging:\n" +
|
||||
" group:\n"+
|
||||
" whatever:\n" +
|
||||
" - demo<*>"
|
||||
, //==============
|
||||
"com.example.demo",
|
||||
//=>
|
||||
"logging:\n" +
|
||||
" group:\n"+
|
||||
" whatever:\n" +
|
||||
" - com.example.demo<*>"
|
||||
);
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging:\n" +
|
||||
" group:\n"+
|
||||
" whatever: demo<*>"
|
||||
, //==============
|
||||
"com.example.demo",
|
||||
//=>
|
||||
"logging:\n" +
|
||||
" group:\n"+
|
||||
" whatever: com.example.demo<*>"
|
||||
);
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging:\n" +
|
||||
" group:\n"+
|
||||
" whatever: stuff,demo<*>"
|
||||
, //==============
|
||||
"com.example.demo",
|
||||
//=>
|
||||
"logging:\n" +
|
||||
" group:\n"+
|
||||
" whatever: stuff,com.example.demo<*>"
|
||||
);
|
||||
}
|
||||
|
||||
///////////////////// ported tests from old STS code base ////////////////////////////////////////////////
|
||||
|
||||
@Test public void testHovers() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user